Search in sources :

Example 1 with PsiElementResolveResult

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

the class PyTargetReference method multiResolve.

@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    final ResolveResult[] results = super.multiResolve(incompleteCode);
    boolean shadowed = false;
    for (ResolveResult result : results) {
        final PsiElement element = result.getElement();
        if (element != null && (element.getContainingFile() != myElement.getContainingFile() || element instanceof PyFunction || element instanceof PyClass)) {
            shadowed = true;
            break;
        }
    }
    if (results.length > 0 && !shadowed) {
        return results;
    }
    // resolve to self if no other target found
    return new ResolveResult[] { new PsiElementResolveResult(myElement) };
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyFunction(com.jetbrains.python.psi.PyFunction) 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 2 with PsiElementResolveResult

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

the class For method execute.

/*
     * Private Instance Methods
     */
private boolean execute(@NotNull Call call, @NotNull @SuppressWarnings("unused") ResolveState state) {
    boolean keepProcessing = true;
    if (org.elixir_lang.structure_view.element.modular.Implementation.is(call)) {
        PsiElement element = org.elixir_lang.structure_view.element.modular.Implementation.forNameElement(call);
        boolean validResult;
        if (element != null) {
            validResult = this.validResult;
        } else {
            Call enclosingModularMacroCall = enclosingModularMacroCall(call);
            if (enclosingModularMacroCall != null) {
                if (enclosingModularMacroCall.isCalling(KERNEL, DEFMODULE)) {
                    element = Module.nameIdentifier(enclosingModularMacroCall);
                    validResult = this.validResult;
                } else {
                    element = enclosingModularMacroCall;
                    validResult = false;
                }
            } else {
                element = call;
                validResult = false;
            }
        }
        resolveResultList = Collections.<ResolveResult>singletonList(new PsiElementResolveResult(element, validResult));
        keepProcessing = false;
    }
    return keepProcessing;
}
Also used : Call(org.elixir_lang.psi.call.Call) CallDefinitionClause.enclosingModularMacroCall(org.elixir_lang.structure_view.element.CallDefinitionClause.enclosingModularMacroCall) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElement(com.intellij.psi.PsiElement)

Example 3 with PsiElementResolveResult

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

the class Protocol method execute.

/*
     * Private Instance Methods
     */
private boolean execute(@NotNull Call call, @NotNull @SuppressWarnings("unused") ResolveState state) {
    boolean keepProcessing = true;
    if (org.elixir_lang.structure_view.element.modular.Implementation.is(call)) {
        QualifiableAlias protocolNameElement = org.elixir_lang.structure_view.element.modular.Implementation.protocolNameElement(call);
        PsiElement element;
        boolean validResult;
        if (protocolNameElement != null) {
            element = protocolNameElement;
            validResult = this.validResult;
        } else {
            element = call;
            validResult = false;
        }
        resolveResultList = Collections.<ResolveResult>singletonList(new PsiElementResolveResult(element, validResult));
        keepProcessing = false;
    }
    return keepProcessing;
}
Also used : QualifiableAlias(org.elixir_lang.psi.QualifiableAlias) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElement(com.intellij.psi.PsiElement)

Example 4 with PsiElementResolveResult

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

the class CfmlArgumentNameReference method resolveInner.

@NotNull
@Override
protected ResolveResult[] resolveInner() {
    PsiElement nextSibling = getNextSibling();
    while (nextSibling instanceof PsiWhiteSpace) {
        nextSibling = nextSibling.getNextSibling();
    }
    if (nextSibling != null && nextSibling.getNode().getElementType() != CfmlTokenTypes.ASSIGN) {
        return super.resolveInner();
    }
    CfmlParameter[] functionParameters = getFunctionParameters();
    if (functionParameters != null) {
        Collection<ResolveResult> result = new LinkedList<>();
        String referenceName = getReferenceName();
        for (CfmlParameter param : functionParameters) {
            if (referenceName.equals(param.getName())) {
                result.add(new PsiElementResolveResult(param));
            }
        }
        return result.toArray(ResolveResult.EMPTY_ARRAY);
    }
    return ResolveResult.EMPTY_ARRAY;
}
Also used : PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) LinkedList(java.util.LinkedList) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PsiElementResolveResult

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

the class PodLinkToFileReference method resolveInner.

@NotNull
@Override
protected ResolveResult[] resolveInner(boolean incompleteCode) {
    PodFormatterL podLink = getElement();
    PodLinkDescriptor descriptor = podLink.getLinkDescriptor();
    if (descriptor != null && !descriptor.isUrl() && descriptor.getFileId() != null) {
        PsiFile targetFile = PodFileUtil.getPodOrPackagePsiByDescriptor(podLink.getProject(), descriptor);
        if (targetFile != null) {
            return new ResolveResult[] { new PsiElementResolveResult(targetFile) };
        }
    }
    return ResolveResult.EMPTY_ARRAY;
}
Also used : PsiFile(com.intellij.psi.PsiFile) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) PodFormatterL(com.perl5.lang.pod.parser.psi.PodFormatterL) PodLinkDescriptor(com.perl5.lang.pod.parser.psi.PodLinkDescriptor) PsiElementResolveResult(com.intellij.psi.PsiElementResolveResult) ResolveResult(com.intellij.psi.ResolveResult) NotNull(org.jetbrains.annotations.NotNull)

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