mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
check that new expression reference resolves to class (IDEA-36082; IDEA-72934)
This commit is contained in:
@@ -951,6 +951,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
highlightReferencedMethodOrClassName(ref, resolved);
|
||||
}
|
||||
|
||||
if (parent instanceof PsiNewExpression && !(resolved instanceof PsiClass) && resolved instanceof PsiNamedElement && ((PsiNewExpression)parent).getClassOrAnonymousClassReference() == ref) {
|
||||
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref)
|
||||
.descriptionAndTooltip("Cannot find symbol " + ((PsiNamedElement)resolved).getName()).create());
|
||||
}
|
||||
if (!myHolder.hasErrorResults() && resolved instanceof PsiClass) {
|
||||
final PsiClass aClass = ((PsiClass)resolved).getContainingClass();
|
||||
if (aClass != null) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
void foo(Object obj) {
|
||||
new <error descr="Cannot find symbol obj">obj</error>();
|
||||
new <error descr="Cannot find symbol java">java</error>();
|
||||
new java.lang.Object();
|
||||
new Object();
|
||||
}
|
||||
}
|
||||
@@ -375,6 +375,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testInnerClassConstantReference() { doTest(false, false); }
|
||||
public void testIDEA60875() { doTest(false, false); }
|
||||
public void testIDEA71645() { doTest(false, false); }
|
||||
public void testNewExpressionClass() { doTest(false, false); }
|
||||
|
||||
public void testNoEnclosingInstanceWhenStaticNestedInheritsFromContainingClass() throws Exception {
|
||||
doTest(false, false);
|
||||
|
||||
Reference in New Issue
Block a user