Search in sources :

Example 1 with PerlNamespaceReference

use of com.perl5.lang.perl.psi.references.PerlNamespaceReference in project Perl5-IDEA by Camelcade.

the class PerlNamespaceElementImpl method getNamespaceDefinitions.

@Override
public List<PerlNamespaceDefinitionElement> getNamespaceDefinitions() {
    List<PerlNamespaceDefinitionElement> namespaceDefinitions = new ArrayList<>();
    PsiReference[] references = getReferences();
    for (PsiReference reference : references) {
        if (reference instanceof PerlNamespaceReference) {
            ResolveResult[] results = ((PerlNamespaceReference) reference).multiResolve(false);
            for (ResolveResult result : results) {
                PsiElement targetElement = result.getElement();
                assert targetElement != null;
                assert targetElement instanceof PerlNamespaceDefinitionElement;
                namespaceDefinitions.add((PerlNamespaceDefinitionElement) targetElement);
            }
        }
    }
    return namespaceDefinitions;
}
Also used : PerlNamespaceReference(com.perl5.lang.perl.psi.references.PerlNamespaceReference) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PerlNamespaceReference

use of com.perl5.lang.perl.psi.references.PerlNamespaceReference in project Perl5-IDEA by Camelcade.

the class PerlStringContentElementImpl method computeReferences.

@Override
public PsiReference[] computeReferences() {
    List<PsiReference> result = new ArrayList<>();
    if (looksLikePackage()) {
        result.add(new PerlNamespaceReference(PerlStringContentElementImpl.this));
    } else {
        @SuppressWarnings("unchecked") PerlReferencesProvider referencesProvider = PsiTreeUtil.getParentOfType(PerlStringContentElementImpl.this, PerlReferencesProvider.class, true, PsiPerlStatement.class);
        if (referencesProvider != null) {
            PsiReference[] references = referencesProvider.getReferences(PerlStringContentElementImpl.this);
            if (references != null) {
                result.addAll(Arrays.asList(references));
            }
        }
    }
    result.addAll(Arrays.asList(ReferenceProvidersRegistry.getReferencesFromProviders(PerlStringContentElementImpl.this)));
    return result.toArray(new PsiReference[result.size()]);
}
Also used : PerlNamespaceReference(com.perl5.lang.perl.psi.references.PerlNamespaceReference) ArrayList(java.util.ArrayList) PsiReference(com.intellij.psi.PsiReference) PerlReferencesProvider(com.perl5.lang.perl.extensions.parser.PerlReferencesProvider)

Aggregations

PsiReference (com.intellij.psi.PsiReference)2 PerlNamespaceReference (com.perl5.lang.perl.psi.references.PerlNamespaceReference)2 ArrayList (java.util.ArrayList)2 PsiElement (com.intellij.psi.PsiElement)1 ResolveResult (com.intellij.psi.ResolveResult)1 PerlReferencesProvider (com.perl5.lang.perl.extensions.parser.PerlReferencesProvider)1