Search in sources :

Example 96 with PsiElement

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

the class Issue480Test method assertUnresolvableReferenceNameArityRange.

/*
     * Private Instance Methods
     */
private void assertUnresolvableReferenceNameArityRange(@NotNull String name, int arity) {
    PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertNotNull(elementAtCaret);
    PsiElement grandParent = elementAtCaret.getParent().getParent();
    assertNotNull(grandParent);
    assertInstanceOf(grandParent, Call.class);
    Call grandParentCall = (Call) grandParent;
    assertEquals(name, grandParentCall.functionName());
    assertEquals(arity, grandParentCall.resolvedFinalArity());
    PsiReference reference = grandParent.getReference();
    assertNotNull(reference);
    PsiElement resolved = reference.resolve();
    assertNull(resolved);
}
Also used : Call(org.elixir_lang.psi.call.Call) PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement)

Example 97 with PsiElement

use of com.intellij.psi.PsiElement 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, as: As", resolveResults[0].getElement().getParent().getParent().getParent().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) LeafPsiElement(com.intellij.psi.impl.source.tree.LeafPsiElement) PsiPolyVariantReference(com.intellij.psi.PsiPolyVariantReference)

Example 98 with PsiElement

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

the class CallDefinitionHeadTest method assertIssue468CallDefinitionHeadClauseHead.

/*
     * Private Instance Methods
     */
private void assertIssue468CallDefinitionHeadClauseHead() {
    PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getParent();
    assertNotNull(element);
    assertInstanceOf(element, Call.class);
    Call call = (Call) element;
    assertTrue("Call at caret is not a call definition clause", CallDefinitionClause.is(call));
    PsiElement head = CallDefinitionClause.head(call);
    assertNotNull("Call definition has a null head", head);
    assertEquals("create(state = %__MODULE__{ecto_schema_module: ecto_schema_module, view: view}, params)", CallDefinitionHead.stripGuard(head).getText());
}
Also used : Call(org.elixir_lang.psi.call.Call) PsiElement(com.intellij.psi.PsiElement)

Example 99 with PsiElement

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

the class Issue429Test method testUseScope.

/*
     * Tests
     */
public void testUseScope() {
    myFixture.configureByFiles("get_use_scope.ex");
    PsiElement callable = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent().getPrevSibling().getLastChild().getLastChild().getLastChild();
    assertInstanceOf(callable, Call.class);
    SearchScope useScope = callable.getUseScope();
    assertInstanceOf(useScope, LocalSearchScope.class);
    LocalSearchScope localSearchScope = (LocalSearchScope) useScope;
    PsiElement[] scope = localSearchScope.getScope();
    assertEquals(1, scope.length);
    PsiElement singleScope = scope[0];
    assertTrue("Use Scope is not the surrounding if", singleScope.getText().startsWith("if auth == "));
}
Also used : LocalSearchScope(com.intellij.psi.search.LocalSearchScope) SearchScope(com.intellij.psi.search.SearchScope) LocalSearchScope(com.intellij.psi.search.LocalSearchScope) PsiElement(com.intellij.psi.PsiElement)

Example 100 with PsiElement

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

the class Issue463Test method testMapAccessQualifier.

public void testMapAccessQualifier() {
    myFixture.configureByFiles("map_access_qualifier.ex", "referenced.ex");
    PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertNotNull(elementAtCaret);
    PsiElement grandParent = elementAtCaret.getParent().getParent();
    assertNotNull(grandParent);
    assertInstanceOf(grandParent, Call.class);
    PsiReference reference = grandParent.getReference();
    assertNotNull(reference);
    PsiElement resolved = reference.resolve();
    assertNull(resolved);
}
Also used : PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)3163 Nullable (org.jetbrains.annotations.Nullable)493 PsiFile (com.intellij.psi.PsiFile)471 NotNull (org.jetbrains.annotations.NotNull)442 TextRange (com.intellij.openapi.util.TextRange)237 PsiReference (com.intellij.psi.PsiReference)226 Project (com.intellij.openapi.project.Project)222 VirtualFile (com.intellij.openapi.vfs.VirtualFile)206 ArrayList (java.util.ArrayList)192 ASTNode (com.intellij.lang.ASTNode)142 XmlTag (com.intellij.psi.xml.XmlTag)134 PsiClass (com.intellij.psi.PsiClass)115 Editor (com.intellij.openapi.editor.Editor)111 Document (com.intellij.openapi.editor.Document)109 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)85 PsiDirectory (com.intellij.psi.PsiDirectory)80 IElementType (com.intellij.psi.tree.IElementType)78 Module (com.intellij.openapi.module.Module)73 PsiMethod (com.intellij.psi.PsiMethod)73 UsageInfo (com.intellij.usageView.UsageInfo)70