Search in sources :

Example 26 with ResolveResult

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

the class AsTest method testReference.

public void testReference() {
    myFixture.configureByFiles("reference.ex", "suffix1.ex");
    PsiElement alias = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling().getFirstChild();
    assertInstanceOf(alias, ElixirAlias.class);
    PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) alias.getReference();
    assertNotNull(polyVariantReference);
    ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
    assertEquals(2, resolveResults.length);
    // alias
    assertEquals("alias Prefix.Suffix1, as: As", resolveResults[0].getElement().getParent().getParent().getParent().getParent().getParent().getText());
    // defmodule
    assertEquals("defmodule Prefix.Suffix1 do\nend", resolveResults[1].getElement().getText());
}
Also used : ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Example 27 with ResolveResult

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

the class MultipleAliasTest method testReference.

public void testReference() {
    myFixture.configureByFiles("reference.ex", "multiple_alias_aye.ex", "multiple_alias_bee.ex");
    PsiElement alias = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling().getFirstChild();
    assertInstanceOf(alias, ElixirAlias.class);
    PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) alias.getReference();
    assertNotNull(polyVariantReference);
    ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
    assertEquals(2, resolveResults.length);
    // alias
    assertEquals("alias Prefix.{MultipleAliasAye, MultipleAliasBee}", resolveResults[0].getElement().getParent().getParent().getParent().getParent().getParent().getText());
    // defmodule
    assertEquals("defmodule Prefix.MultipleAliasAye do\nend", resolveResults[1].getElement().getText());
}
Also used : ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Example 28 with ResolveResult

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

the class SuffixTest method testReference.

public void testReference() {
    myFixture.configureByFiles("reference.ex", "suffix.ex");
    PsiElement alias = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling().getFirstChild();
    assertInstanceOf(alias, ElixirAlias.class);
    PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) alias.getReference();
    assertNotNull(polyVariantReference);
    ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
    assertEquals(resolveResults.length, 2);
    // alias
    assertEquals("alias Prefix.Suffix", resolveResults[0].getElement().getParent().getParent().getText());
    // defmodule
    assertEquals("defmodule Prefix.Suffix do\nend", resolveResults[1].getElement().getText());
}
Also used : ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Example 29 with ResolveResult

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

the class NestedTest method testReference.

public void testReference() {
    myFixture.configureByFiles("reference.ex", "multiple_alias_aye.ex", "multiple_alias_bee.ex", "nested.ex");
    PsiElement alias = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling();
    assertInstanceOf(alias, QualifiedAlias.class);
    PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) alias.getReference();
    assertNotNull(polyVariantReference);
    ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
    assertEquals(2, resolveResults.length);
    // alias
    assertEquals("alias Prefix.{MultipleAliasAye, MultipleAliasBee}", resolveResults[0].getElement().getParent().getParent().getParent().getParent().getParent().getText());
    // defmodule
    assertEquals("defmodule Prefix.MultipleAliasAye.Nested do\nend", resolveResults[1].getElement().getText());
}
Also used : ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Example 30 with ResolveResult

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

the class NestedTest method testReference.

public void testReference() {
    myFixture.configureByFiles("reference.ex", "suffix.ex", "nested.ex");
    PsiElement alias = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling();
    assertInstanceOf(alias, QualifiedAlias.class);
    PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) alias.getReference();
    assertNotNull(polyVariantReference);
    ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
    assertEquals(2, resolveResults.length);
    // alias
    assertEquals("alias Prefix.Suffix", resolveResults[0].getElement().getParent().getParent().getText());
    // defmodule
    assertEquals("defmodule Prefix.Suffix.Nested do\nend", resolveResults[1].getElement().getText());
}
Also used : ResolveResult(com.intellij.psi.ResolveResult) PsiElement(com.intellij.psi.PsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Aggregations

ResolveResult (com.intellij.psi.ResolveResult)30 PsiElement (com.intellij.psi.PsiElement)25 PsiPolyVariantReference (com.intellij.psi.PsiPolyVariantReference)10 NotNull (org.jetbrains.annotations.NotNull)8 PsiReference (com.intellij.psi.PsiReference)5 PsiElementResolveResult (com.intellij.psi.PsiElementResolveResult)4 PsiFile (com.intellij.psi.PsiFile)4 ImportedResolveResult (com.jetbrains.python.psi.resolve.ImportedResolveResult)3 Call (org.elixir_lang.psi.call.Call)3 JSReferenceExpression (com.intellij.lang.javascript.psi.JSReferenceExpression)2 JSE4XNamespaceReference (com.intellij.lang.javascript.psi.e4x.JSE4XNamespaceReference)2 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Nullable (org.jetbrains.annotations.Nullable)2 GoReference (com.goide.psi.impl.GoReference)1 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)1 ProblemHighlightType (com.intellij.codeInspection.ProblemHighlightType)1 ASTNode (com.intellij.lang.ASTNode)1 InjectedLanguageManager (com.intellij.lang.injection.InjectedLanguageManager)1