mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-378781 Quick fixes for typos in keywords
- add examples for some keywords GitOrigin-RevId: b25b8ccd451eee251b466d22d7a5cb8d8bc1b502
This commit is contained in:
committed by
intellij-monorepo-bot
parent
db7064d868
commit
f62c5ebc02
+5
@@ -110,6 +110,7 @@ public final class HighlightFixTypoUtil {
|
||||
}
|
||||
|
||||
private static @Nullable ModCommandAction createThrowsTypoFix(@NotNull PsiErrorElement psiErrorElement) {
|
||||
// class A throw<caret> SomeException
|
||||
PsiElement prevVisibleLeaf = PsiTreeUtil.prevVisibleLeaf(psiErrorElement);
|
||||
if (!(prevVisibleLeaf instanceof PsiJavaToken token && token.getTokenType() == JavaTokenType.RPARENTH)) return null;
|
||||
if (!(token.getParent() instanceof PsiParameterList parameterList && parameterList.getParent() instanceof PsiMethod)) {
|
||||
@@ -130,6 +131,7 @@ public final class HighlightFixTypoUtil {
|
||||
|
||||
@Nullable
|
||||
private static CommonIntentionAction createSynchronizedSwitchTypoFix(@NotNull PsiMethodCallExpression methodCallExpression) {
|
||||
// switc<caret>()
|
||||
PsiExpressionList argumentList = methodCallExpression.getArgumentList();
|
||||
PsiExpression[] expressions = argumentList.getExpressions();
|
||||
if (expressions.length != 0 && expressions.length != 1) return null;
|
||||
@@ -395,6 +397,7 @@ public final class HighlightFixTypoUtil {
|
||||
|
||||
@Nullable
|
||||
private static CommonIntentionAction createBreakContinueTypoFix(@NotNull PsiJavaCodeReferenceElement ref) {
|
||||
// contine<caret>;
|
||||
if (ref.getParent() instanceof PsiExpressionStatement expressionStatement) {
|
||||
PsiElement[] children = expressionStatement.getChildren();
|
||||
if (children.length == 2 &&
|
||||
@@ -418,6 +421,7 @@ public final class HighlightFixTypoUtil {
|
||||
|
||||
private static CommonIntentionAction createBooleanNullTypoFix(@NotNull PsiJavaCodeReferenceElement ref) {
|
||||
if (ref instanceof PsiReferenceExpression expression) {
|
||||
//call(tru<caret>)
|
||||
Set<String> targetKeywords = new HashSet<>();
|
||||
PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, false);
|
||||
if (expectedType != null) {
|
||||
@@ -461,6 +465,7 @@ public final class HighlightFixTypoUtil {
|
||||
return QuickFixFactory.getInstance().createChangeToSimilarKeyword(typeElement, targetKeywords);
|
||||
}
|
||||
if (ref.getParent() instanceof PsiExpressionStatement expressionStatement) {
|
||||
// val<caret> something = something();
|
||||
PsiElement[] children = expressionStatement.getChildren();
|
||||
if (children.length == 2 && children[0] == ref && children[1] instanceof PsiErrorElement) {
|
||||
Set<String> targetKeywords = new HashSet<>(PsiTypes.primitiveTypeNames());
|
||||
|
||||
Reference in New Issue
Block a user