Search in sources :

Example 1 with GrImportStatementStub

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

the class GrImportStatementImpl method getImportedName.

@Override
@Nullable
public String getImportedName() {
    if (isOnDemand())
        return null;
    GrImportStatementStub stub = getStub();
    if (stub != null) {
        String name = stub.getAliasName();
        if (name != null) {
            return name;
        }
        String referenceText = stub.getReferenceText();
        if (referenceText == null)
            return null;
        return StringUtil.getShortName(referenceText);
    }
    PsiElement aliasNameElement = getAliasNameElement();
    if (aliasNameElement != null) {
        return aliasNameElement.getText();
    }
    GrCodeReferenceElement ref = getImportReference();
    return ref == null ? null : ref.getReferenceName();
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GrImportStatementStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrImportStatementStub) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GrImportStatementStub

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

the class GrImportStatementImpl method getAliasNameElement.

@Nullable
@Override
public PsiElement getAliasNameElement() {
    GrImportStatementStub stub = getStub();
    if (stub != null) {
        String alias = stub.getAliasName();
        if (alias == null)
            return null;
        GrImportStatement imp = GroovyPsiElementFactory.getInstance(getProject()).createImportStatementFromText("import A as " + alias);
        return imp.getAliasNameElement();
    }
    return findChildByType(GroovyTokenTypes.mIDENT);
}
Also used : GrImportStatement(org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement) GrImportStatementStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrImportStatementStub) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)2 GrImportStatementStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrImportStatementStub)2 GrImportStatement (org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1