mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java][highlight] IDEA-274531 errors shown incorrectly when a method name is the same as a nested class name
IDEA added a fix to remove the "new" keyword when a callsite looks like a call to a method or a field. It caused the mentioned regression, because sometimes the callsite might simply instantiate a class that has the same name as a method which was mistakenly highlighted as an error. This patch simply adds a check if the resolved element is of a PsiClass and if so then the mentioned highlighting doesn't get added to such callsites. GitOrigin-RevId: a34e6e1715d93ac21a2ba93cf5f57c54436bc11b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5657d92469
commit
383d5a0aab
+7
-1
@@ -2958,7 +2958,7 @@ public final class HighlightUtil {
|
||||
|
||||
PsiElement refParent = ref.getParent();
|
||||
|
||||
if (isCallToStaticMember(refParent)) {
|
||||
if (!(resolved instanceof PsiClass) && isCallToStaticMember(refParent)) {
|
||||
final String text = JavaErrorBundle.message("cannot.resolve.symbol", refName.getText());
|
||||
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(text).create();
|
||||
QuickFixAction.registerQuickFixAction(info, new RemoveNewKeywordFix(refParent));
|
||||
@@ -3000,6 +3000,12 @@ public final class HighlightUtil {
|
||||
}
|
||||
else {
|
||||
description = JavaErrorBundle.message("cannot.resolve.symbol", refName.getText());
|
||||
if (isCallToStaticMember(refParent)) {
|
||||
final String text = JavaErrorBundle.message("cannot.resolve.symbol", refName.getText());
|
||||
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(text).create();
|
||||
QuickFixAction.registerQuickFixAction(info, new RemoveNewKeywordFix(refParent));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
HighlightInfo info =
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Remove 'new'" "false"
|
||||
|
||||
class A {
|
||||
class B {}
|
||||
B B() {
|
||||
return new A.<caret>B();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user