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);
}
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());
}
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());
}
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 == "));
}
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);
}
Aggregations