mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
highlight this inside interface inner classes (IDEA-97032)
This commit is contained in:
+11
-8
@@ -1307,16 +1307,19 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
return HighlightClassUtil.reportIllegalEnclosingUsage(expr, null, aClass, expr);
|
||||
}
|
||||
|
||||
if (expr instanceof PsiThisExpression && PsiTreeUtil.getParentOfType(expr, PsiMethod.class) == null) {
|
||||
if (aClass.isInterface()) {
|
||||
return thisNotFoundInInterfaceInfo(expr);
|
||||
}
|
||||
|
||||
if (aClass instanceof PsiAnonymousClass && PsiTreeUtil.isAncestor(((PsiAnonymousClass)aClass).getArgumentList(), expr, true)) {
|
||||
final PsiClass parentClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
|
||||
if (parentClass != null && parentClass.isInterface()) {
|
||||
if (expr instanceof PsiThisExpression) {
|
||||
final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(expr, PsiMethod.class);
|
||||
if (psiMethod == null || psiMethod.getContainingClass() != aClass) {
|
||||
if (aClass.isInterface()) {
|
||||
return thisNotFoundInInterfaceInfo(expr);
|
||||
}
|
||||
|
||||
if (aClass instanceof PsiAnonymousClass && PsiTreeUtil.isAncestor(((PsiAnonymousClass)aClass).getArgumentList(), expr, true)) {
|
||||
final PsiClass parentClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
|
||||
if (parentClass != null && parentClass.isInterface()) {
|
||||
return thisNotFoundInInterfaceInfo(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+16
@@ -5,4 +5,20 @@ class C implements A {
|
||||
interface A {
|
||||
A a = new C(<error descr="Cannot find symbol variable this">this</error>);
|
||||
A a1 = new C(<error descr="Cannot find symbol variable this">this</error>){};
|
||||
|
||||
class B {
|
||||
A foo() {
|
||||
return <error descr="Cannot find symbol variable this">A.this</error>;
|
||||
}
|
||||
|
||||
B foo1() {
|
||||
return B.this;
|
||||
}
|
||||
|
||||
class D {
|
||||
B f() {
|
||||
return B.this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user