Search in sources :

Example 1 with GrPackageDefinitionStub

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

the class GroovyFileImpl method getPackageDefinition.

@Override
public GrPackageDefinition getPackageDefinition() {
    final StubElement<?> stub = getStub();
    if (stub != null) {
        for (StubElement element : stub.getChildrenStubs()) {
            if (element instanceof GrPackageDefinitionStub)
                return (GrPackageDefinition) element.getPsi();
        }
        return null;
    }
    ASTNode node = calcTreeElement().findChildByType(GroovyElementTypes.PACKAGE_DEFINITION);
    return node != null ? (GrPackageDefinition) node.getPsi() : null;
}
Also used : GrPackageDefinitionStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrPackageDefinitionStub) ASTNode(com.intellij.lang.ASTNode) StubElement(com.intellij.psi.stubs.StubElement)

Example 2 with GrPackageDefinitionStub

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

the class GrPackageDefinitionImpl method getPackageName.

@Override
public String getPackageName() {
    final GrPackageDefinitionStub stub = getStub();
    if (stub != null) {
        return stub.getPackageName();
    }
    GrCodeReferenceElement ref = getPackageReference();
    if (ref == null)
        return "";
    return PsiUtil.getQualifiedReferenceText(ref);
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GrPackageDefinitionStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrPackageDefinitionStub)

Aggregations

GrPackageDefinitionStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrPackageDefinitionStub)2 ASTNode (com.intellij.lang.ASTNode)1 StubElement (com.intellij.psi.stubs.StubElement)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1