Search in sources :

Example 1 with PsiClassStub

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

the class PsiClassImpl method getQualifiedName.

@Override
public String getQualifiedName() {
    final PsiClassStub stub = getGreenStub();
    if (stub != null) {
        return stub.getQualifiedName();
    }
    PsiElement parent = getParent();
    if (parent instanceof PsiJavaFile) {
        return StringUtil.getQualifiedName(((PsiJavaFile) parent).getPackageName(), getName());
    }
    if (parent instanceof PsiClass) {
        String parentQName = ((PsiClass) parent).getQualifiedName();
        if (parentQName == null)
            return null;
        return StringUtil.getQualifiedName(parentQName, getName());
    }
    return null;
}
Also used : PsiClassStub(com.intellij.psi.impl.java.stubs.PsiClassStub)

Example 2 with PsiClassStub

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

the class PsiClassImpl method getName.

@Override
public String getName() {
    String name = myCachedName;
    if (name != null)
        return name;
    final PsiClassStub stub = getGreenStub();
    if (stub == null) {
        PsiIdentifier identifier = getNameIdentifier();
        name = identifier == null ? null : identifier.getText();
    } else {
        name = stub.getName();
    }
    myCachedName = name;
    return name;
}
Also used : PsiClassStub(com.intellij.psi.impl.java.stubs.PsiClassStub)

Example 3 with PsiClassStub

use of com.intellij.psi.impl.java.stubs.PsiClassStub 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)

Example 4 with PsiClassStub

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

the class PsiClassImpl method isInterface.

@Override
public boolean isInterface() {
    final PsiClassStub stub = getGreenStub();
    if (stub != null) {
        return stub.isInterface();
    }
    ASTNode keyword = getNode().findChildByRole(ChildRole.CLASS_OR_INTERFACE_KEYWORD);
    return keyword != null && keyword.getElementType() == JavaTokenType.INTERFACE_KEYWORD;
}
Also used : ASTNode(com.intellij.lang.ASTNode) PsiClassStub(com.intellij.psi.impl.java.stubs.PsiClassStub)

Example 5 with PsiClassStub

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

the class PsiClassImpl method isEnum.

@Override
public boolean isEnum() {
    final PsiClassStub stub = getGreenStub();
    if (stub != null) {
        return stub.isEnum();
    }
    final ASTNode keyword = getNode().findChildByRole(ChildRole.CLASS_OR_INTERFACE_KEYWORD);
    return keyword != null && keyword.getElementType() == JavaTokenType.ENUM_KEYWORD;
}
Also used : ASTNode(com.intellij.lang.ASTNode) PsiClassStub(com.intellij.psi.impl.java.stubs.PsiClassStub)

Aggregations

PsiClassStub (com.intellij.psi.impl.java.stubs.PsiClassStub)12 StubElement (com.intellij.psi.stubs.StubElement)4 ASTNode (com.intellij.lang.ASTNode)3 Nullable (org.jetbrains.annotations.Nullable)3 StubBasedPsiElementBase (com.intellij.extapi.psi.StubBasedPsiElementBase)1 PsiClass (com.intellij.psi.PsiClass)1 PsiClassInitializerStub (com.intellij.psi.impl.java.stubs.PsiClassInitializerStub)1 PsiMethodStub (com.intellij.psi.impl.java.stubs.PsiMethodStub)1 IStubElementType (com.intellij.psi.stubs.IStubElementType)1 PsiFileStub (com.intellij.psi.stubs.PsiFileStub)1 StubTree (com.intellij.psi.stubs.StubTree)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 NotNull (org.jetbrains.annotations.NotNull)1