[java-highlighting] Don't suggest moving 'this' to the beginning of the list if there is already a receiver there

GitOrigin-RevId: d474d72a0fa00912a65f7ed32a85f2c2deec5e44
This commit is contained in:
Andrey.Cherkasov
2021-05-11 17:47:33 +03:00
committed by intellij-monorepo-bot
parent eeb345a0d7
commit 02e34802cf
3 changed files with 12 additions and 1 deletions

View File

@@ -763,7 +763,10 @@ public final class AnnotationsHighlightUtil {
String text = JavaErrorBundle.message("receiver.wrong.position");
HighlightInfo info =
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create();
QuickFixAction.registerQuickFixAction(info, new MakeReceiverParameterFirstFix(parameter));
PsiReceiverParameter firstReceiverParameter = PsiTreeUtil.getChildOfType(method.getParameterList(), PsiReceiverParameter.class);
if (!PsiUtil.isJavaToken(PsiTreeUtil.skipWhitespacesAndCommentsBackward(firstReceiverParameter), JavaTokenType.LPARENTH)) {
QuickFixAction.registerQuickFixAction(info, new MakeReceiverParameterFirstFix(parameter));
}
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(parameter));
return info;
}

View File

@@ -0,0 +1,4 @@
// "Move 'this' to the beginning of the list" "false"
class X {
void foo(X this, int i, X this<caret>) {}
}

View File

@@ -0,0 +1,4 @@
// "Move 'this' to the beginning of the list" "false"
class X {
void foo(X this, X this<caret>) {}
}