mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] use tree walk-up to find enclosing member is @CS check (IDEA-206662)
The bug appeared because anonymous classes don't have containing class.
This commit is contained in:
+4
-8
@@ -10,6 +10,7 @@ import com.intellij.openapi.util.RecursionManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -81,19 +82,14 @@ public class GroovyPsiManager {
|
||||
}
|
||||
|
||||
public boolean isCompileStatic(@NotNull PsiMember member) {
|
||||
Boolean aBoolean = myCompileStatic.get(member);
|
||||
if (aBoolean == null) {
|
||||
aBoolean = ConcurrencyUtil.cacheOrGet(myCompileStatic, member, isCompileStaticInner(member));
|
||||
}
|
||||
return aBoolean;
|
||||
return myCompileStatic.computeIfAbsent(member, this::isCompileStaticInner);
|
||||
}
|
||||
|
||||
private boolean isCompileStaticInner(@NotNull PsiMember member) {
|
||||
PsiAnnotation annotation = getCompileStaticAnnotation(member);
|
||||
if (annotation != null) return checkForPass(annotation);
|
||||
PsiClass aClass = member.getContainingClass();
|
||||
if (aClass != null) return isCompileStatic(aClass);
|
||||
return false;
|
||||
PsiMember enclosingMember = PsiTreeUtil.getParentOfType(member, PsiMember.class, true);
|
||||
return enclosingMember != null && isCompileStatic(enclosingMember);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
@@ -577,6 +577,11 @@ print <warning descr="Cannot resolve symbol 'abc'">abc</warning>
|
||||
@CompileStatic
|
||||
def bar() {
|
||||
print <error descr="Cannot resolve symbol 'abc'">abc</error>
|
||||
new Object() {
|
||||
def baz() {
|
||||
print(<error descr="Cannot resolve symbol 'unknown'">unknown</error>)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
''', true, false, false, GrUnresolvedAccessInspection)
|
||||
|
||||
Reference in New Issue
Block a user