Search in sources :

Example 1 with PerlResolveUtil

use of com.perl5.lang.perl.psi.utils.PerlResolveUtil in project Perl5-IDEA by Camelcade.

the class PerlVariableMixin method getGlobalDeclarations.

// fixme this need to be moved to PerlResolveUtil or Resolver
@Override
public List<PerlVariableDeclarationElement> getGlobalDeclarations() {
    List<PerlVariableDeclarationElement> result = new ArrayList<>();
    PerlVariableType myType = getActualType();
    // wrapper if any
    PsiElement parent = getParent();
    if (myType == PerlVariableType.SCALAR) {
        for (PerlVariableDeclarationElement variable : PerlScalarUtil.getGlobalScalarDefinitions(getProject(), getCanonicalName())) {
            if (!variable.equals(parent)) {
                result.add(variable);
            }
        }
    } else if (myType == PerlVariableType.ARRAY) {
        for (PerlVariableDeclarationElement variable : PerlArrayUtil.getGlobalArrayDefinitions(getProject(), getCanonicalName())) {
            if (!variable.equals(parent)) {
                result.add(variable);
            }
        }
    } else if (myType == PerlVariableType.HASH) {
        for (PerlVariableDeclarationElement variable : PerlHashUtil.getGlobalHashDefinitions(getProject(), getCanonicalName())) {
            if (!variable.equals(parent)) {
                result.add(variable);
            }
        }
    }
    return result;
}
Also used : PerlVariableType(com.perl5.lang.perl.psi.utils.PerlVariableType) ArrayList(java.util.ArrayList) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement)

Aggregations

LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 PerlVariableType (com.perl5.lang.perl.psi.utils.PerlVariableType)1 ArrayList (java.util.ArrayList)1