Search in sources :

Example 1 with GrTypeDefinitionStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub in project intellij-community by JetBrains.

the class GrTypeDefinitionImpl method getQualifiedName.

@Nullable
@Override
public String getQualifiedName() {
    final GrTypeDefinitionStub stub = getStub();
    if (stub != null) {
        return stub.getQualifiedName();
    }
    PsiElement parent = getParent();
    if (parent instanceof GroovyFile) {
        String packageName = ((GroovyFile) parent).getPackageName();
        return !packageName.isEmpty() ? packageName + "." + getName() : getName();
    }
    final PsiClass containingClass = getContainingClass();
    if (containingClass != null && containingClass.getQualifiedName() != null) {
        return containingClass.getQualifiedName() + "." + getName();
    }
    return null;
}
Also used : GrTypeDefinitionStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GrTypeDefinitionStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub in project intellij-community by JetBrains.

the class GrTypeDefinitionImpl method getScope.

@Nullable
@Override
public PsiElement getScope() {
    final GrTypeDefinitionStub stub = getStub();
    if (stub != null) {
        return stub.getParentStub().getPsi();
    }
    ASTNode treeElement = getNode();
    ASTNode parent = treeElement.getTreeParent();
    while (parent != null) {
        if (parent.getElementType() instanceof IStubElementType && !(parent.getElementType() == GroovyElementTypes.CLASS_BODY)) {
            return parent.getPsi();
        }
        parent = parent.getTreeParent();
    }
    return getContainingFile();
}
Also used : GrTypeDefinitionStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub) ASTNode(com.intellij.lang.ASTNode) IStubElementType(com.intellij.psi.stubs.IStubElementType) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)2 GrTypeDefinitionStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub)2 ASTNode (com.intellij.lang.ASTNode)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 IStubElementType (com.intellij.psi.stubs.IStubElementType)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1