Search in sources :

Example 16 with PsiPolyVariantReference

use of com.intellij.psi.PsiPolyVariantReference 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 17 with PsiPolyVariantReference

use of com.intellij.psi.PsiPolyVariantReference 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 18 with PsiPolyVariantReference

use of com.intellij.psi.PsiPolyVariantReference 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 19 with PsiPolyVariantReference

use of com.intellij.psi.PsiPolyVariantReference 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 20 with PsiPolyVariantReference

use of com.intellij.psi.PsiPolyVariantReference 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

PsiPolyVariantReference (com.intellij.psi.PsiPolyVariantReference)20 PsiElement (com.intellij.psi.PsiElement)17 ResolveResult (com.intellij.psi.ResolveResult)10 PsiReference (com.intellij.psi.PsiReference)7 Call (org.elixir_lang.psi.call.Call)3 PyResolveContext (com.jetbrains.python.psi.resolve.PyResolveContext)2 ASTNode (com.intellij.lang.ASTNode)1 JSFile (com.intellij.lang.javascript.psi.JSFile)1 JSReferenceExpression (com.intellij.lang.javascript.psi.JSReferenceExpression)1 Document (com.intellij.openapi.editor.Document)1 TextRange (com.intellij.openapi.util.TextRange)1 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)1 XmlTag (com.intellij.psi.xml.XmlTag)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1