Search in sources :

Example 6 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project Perl5-IDEA by Camelcade.

the class PerlMooseSuperReference method resolveInner.

@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
    // fixme not really dry with simpleresolver and superresolver. Need some generics magic
    List<ResolveResult> result = new ArrayList<>();
    PsiElement element = getElement();
    PerlMooseOverrideStatement overrideStatement = PsiTreeUtil.getParentOfType(element, PerlMooseOverrideStatement.class);
    if (overrideStatement != null) {
        String packageName = PerlPackageUtil.getContextPackageName(element);
        String subName = overrideStatement.getSubName();
        Project project = element.getProject();
        for (PsiElement targetElement : PerlMro.resolveSub(project, packageName, subName, true)) {
            result.add(new PsiElementResolveResult(targetElement));
        }
    }
    return result.toArray(new ResolveResult[result.size()]);
}
Also used : Project(com.intellij.openapi.project.Project) PerlMooseOverrideStatement(com.perl5.lang.perl.parser.moose.psi.impl.PerlMooseOverrideStatement) ArrayList(java.util.ArrayList) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project Perl5-IDEA by Camelcade.

the class PerlNamespaceFileReference method resolveInner.

@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
    PerlNamespaceElement myElement = getElement();
    PsiFile file = myElement.getContainingFile();
    PsiFile targetFile;
    targetFile = PerlPackageUtil.resolvePackageNameToPsi(file, getPackageName());
    return targetFile == null ? ResolveResult.EMPTY_ARRAY : new ResolveResult[] { new PsiElementResolveResult(targetFile) };
}
Also used : PerlNamespaceElement(com.perl5.lang.perl.psi.PerlNamespaceElement) PsiFile(com.intellij.psi.PsiFile) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project intellij-community by JetBrains.

the class TemplateReference method multiResolve.

@NotNull
public ResolveResult[] multiResolve(boolean incompleteCode) {
    final PsiElement element = resolve();
    if (element != null) {
        return new ResolveResult[] { new PsiElementResolveResult(element) };
    }
    final XmlFile xmlFile = (XmlFile) getElement().getContainingFile();
    if (xmlFile != null) {
        final List<PsiElementResolveResult> targets = new SmartList<>();
        XsltIncludeIndex.processBackwardDependencies(xmlFile, xmlFile1 -> {
            final PsiElement e = ResolveUtil.resolve(new NamedTemplateMatcher(xmlFile1.getDocument(), myName));
            if (e != null) {
                targets.add(new PsiElementResolveResult(e));
            }
            return true;
        });
        return targets.toArray(new ResolveResult[targets.size()]);
    } else {
        return ResolveResult.EMPTY_ARRAY;
    }
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) NamedTemplateMatcher(org.intellij.lang.xpath.xslt.util.NamedTemplateMatcher) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) SmartList(com.intellij.util.SmartList) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project oxy-template-support-plugin by mutant-industries.

the class MacroReferenceResolver method resolve.

@NotNull
@Override
public ResolveResult[] resolve(@NotNull PsiPolyVariantReference ref, @NotNull PsiFile containingFile, boolean incompleteCode) {
    String elementText = ref.getElement().getText();
    String macroName = elementText.substring(elementText.indexOf('\"') + 1, ref.getRangeInElement().getEndOffset());
    Project project = ref.getElement().getProject();
    String normalizedMacroName = MacroIndex.normalizeMacroName(macroName);
    List<PsiElement> references = new ArrayList<>();
    if (resolveJsMacros) {
        addJsMacroReferences(references, normalizedMacroName, ref.getElement(), project);
    }
    if (resolveJavaMacros) {
        addJavaMacroReferences(references, normalizedMacroName, project);
    }
    ResolveResult[] resolveResults = new ResolveResult[references.size()];
    for (int i = 0; i < references.size(); i++) {
        resolveResults[i] = new PsiElementResolveResult(references.get(i));
    }
    return resolveResults;
}
Also used : Project(com.intellij.openapi.project.Project) ArrayList(java.util.ArrayList) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with PsiElementResolveResult

use of com.intellij.psi.PsiElementResolveResult in project intellij-elixir by KronicDeth.

the class Exact method resolve.

@Override
public ResolveResult[] resolve(@NotNull Project project) {
    List<ResolveResult> resolveResultList = new ArrayList<>();
    forEachNavigationElement(project, name, navigationElement -> {
        resolveResultList.add(new PsiElementResolveResult(navigationElement));
        return true;
    });
    return resolveResultList.toArray(new ResolveResult[resolveResultList.size()]);
}
Also used : ArrayList(java.util.ArrayList) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult)

Aggregations

PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)17 PsiElement (com.intellij.psi.PsiElement)13 ResolveResult (com.intellij.psi.ResolveResult)13 NotNull (org.jetbrains.annotations.NotNull)12 ArrayList (java.util.ArrayList)8 Project (com.intellij.openapi.project.Project)5 PsiFile (com.intellij.psi.PsiFile)5 PerlGlobVariable (com.perl5.lang.perl.psi.PerlGlobVariable)2 PerlNamespaceDefinitionElement (com.perl5.lang.perl.psi.PerlNamespaceDefinitionElement)2 PerlSubDeclarationElement (com.perl5.lang.perl.psi.PerlSubDeclarationElement)2 PerlSubDefinitionElement (com.perl5.lang.perl.psi.PerlSubDefinitionElement)2 PerlSubElement (com.perl5.lang.perl.psi.PerlSubElement)2 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiFileSystemItem (com.intellij.psi.PsiFileSystemItem)1 PsiReference (com.intellij.psi.PsiReference)1 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)1 XmlFile (com.intellij.psi.xml.XmlFile)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1