Search in sources :

Example 1 with PsiClassInitializerStub

use of com.intellij.psi.impl.java.stubs.PsiClassInitializerStub in project intellij-community by JetBrains.

the class PsiClassImpl method getContextStub.

@Nullable
private StubElement getContextStub() {
    PsiClassStub<?> stub = getStub();
    if (stub == null)
        return null;
    // if AST is not loaded, then we only can need context to resolve supertype references
    // this can be done by stubs unless there are local/anonymous classes referencing other local classes
    StubElement parent = stub.getParentStub();
    if (parent instanceof PsiClassInitializerStub || parent instanceof PsiMethodStub) {
        if (parent.getChildrenByType(JavaStubElementTypes.CLASS, PsiElement.ARRAY_FACTORY).length <= 1) {
            parent = parent.getParentStub();
        }
    }
    return parent instanceof PsiClassStub ? parent : null;
}
Also used : PsiClassInitializerStub(com.intellij.psi.impl.java.stubs.PsiClassInitializerStub) PsiMethodStub(com.intellij.psi.impl.java.stubs.PsiMethodStub) StubElement(com.intellij.psi.stubs.StubElement) PsiClassStub(com.intellij.psi.impl.java.stubs.PsiClassStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiClassInitializerStub (com.intellij.psi.impl.java.stubs.PsiClassInitializerStub)1 PsiClassStub (com.intellij.psi.impl.java.stubs.PsiClassStub)1 PsiMethodStub (com.intellij.psi.impl.java.stubs.PsiMethodStub)1 StubElement (com.intellij.psi.stubs.StubElement)1 Nullable (org.jetbrains.annotations.Nullable)1