use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class Builder method isCollapsedByDefault.
/**
* Returns the default collapsed state for the folding region related to the specified node.
*
* @param node the node for which the collapsed state is requested.
* @return true if the region is collapsed by default, false otherwise.
*/
@Override
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
PsiElement element = node.getPsi();
boolean isCollapsedByDefault = false;
if (element instanceof AtNonNumericOperation) {
isCollapsedByDefault = ElixirFoldingSettings.getInstance().isReplaceModuleAttributesWithValues();
} else {
PsiElement[] children = element.getChildren();
for (PsiElement child : children) {
if (child instanceof Call) {
Call call = (Call) child;
for (String resolvedFunctionName : RESOLVED_FUNCTION_NAMES) {
if (call.isCalling(KERNEL, resolvedFunctionName)) {
isCollapsedByDefault = ElixirFoldingSettings.getInstance().isCollapseElixirModuleDirectiveGroups();
break;
}
}
}
}
}
return isCollapsedByDefault;
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class CallDefinitionClause method execute.
/*
* Private Instance Methods
*/
private boolean execute(@NotNull Call element, @NotNull final ResolveState state) {
boolean keepProcessing = true;
if (org.elixir_lang.structure_view.element.CallDefinitionClause.is(element)) {
keepProcessing = executeOnCallDefinitionClause(element, state);
} else if (Import.is(element)) {
final ResolveState importState = state.put(IMPORT_CALL, element);
try {
Import.callDefinitionClauseCallWhile(element, new Function<Call, Boolean>() {
@Override
public Boolean fun(Call callDefinitionClause) {
return executeOnCallDefinitionClause(callDefinitionClause, importState);
}
});
} catch (StackOverflowError stackOverflowError) {
Logger.error(CallDefinitionClause.class, "StackOverflowError while processing import", element);
}
} else if (Module.is(element)) {
Call[] childCalls = macroChildCalls(element);
if (childCalls != null) {
for (Call childCall : childCalls) {
if (!execute(childCall, state)) {
break;
}
}
}
// Only check MultiResolve.keepProcessing at the end of a Module to all multiple arities
keepProcessing = keepProcessing();
if (keepProcessing) {
// the implicit `import Kernel` and `import Kernel.SpecialForms`
keepProcessing = implicitImports(element, state);
}
}
return keepProcessing;
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class Issue480Test method assertResolvedNameArityRange.
private void assertResolvedNameArityRange(@NotNull PsiElement element, @NotNull String name, int arity) {
PsiReference reference = element.getReference();
assertNotNull(reference);
PsiElement resolved = reference.resolve();
assertNotNull(resolved);
assertInstanceOf(resolved, ElixirIdentifier.class);
PsiElement maybeDefMaybeCall = resolved.getParent().getParent().getParent();
assertInstanceOf(maybeDefMaybeCall, Call.class);
Call maybeDefCall = (Call) maybeDefMaybeCall;
assertTrue(CallDefinitionClause.is(maybeDefCall));
assertEquals(pair(name, new IntRange(arity)), nameArityRange(maybeDefCall));
}
use of org.elixir_lang.psi.call.Call 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 org.elixir_lang.psi.call.Call 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());
}
Aggregations