use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class MultiResolve method addToResolveResultList.
private void addToResolveResultList(@NotNull PsiElement element, ResolveState state, boolean validResult) {
Boolean declaringScope = state.get(DECLARING_SCOPE);
if (declaringScope == null || declaringScope) {
PsiElement lastBinding = state.get(LAST_BINDING_KEY);
boolean added = false;
/* if LAST_BINDING_KEY is set, then we're checking if a right-hand match is bound higher up, so an effective
recursive call. If the recursive call got the same result, stop the recursion by not checking for
rebinding */
if (lastBinding == null || !element.isEquivalentTo(lastBinding)) {
if (!(element instanceof Call) || !isInDeclaringScope((Call) element, state) || /* if maybe a macro, then it could potentially not be a macro, in which case prefer the early
declaration */
Boolean.TRUE.equals(state.get(MAYBE_MACRO))) {
Match matchAncestor = PsiTreeUtil.getContextOfType(element, Match.class);
if (matchAncestor != null) {
PsiElement rightOperand = matchAncestor.rightOperand();
if (rightOperand != null) {
/* right-hand match can only be declarative if it is not already bound, so need to try to
resolve further up to try to find if {@code element} is already bound */
if (PsiTreeUtil.isAncestor(rightOperand, element, false)) {
// previous sibling or parent to search for earlier binding
PsiElement expression = previousExpression(matchAncestor);
if (expression != null) {
List<ResolveResult> preboundResolveResultList = resolveResultList(name, incompleteCode, expression, ResolveState.initial().put(ENTRANCE, matchAncestor).put(LAST_BINDING_KEY, element));
if (preboundResolveResultList != null && preboundResolveResultList.size() > 0) {
if (resolveResultList == null) {
resolveResultList = preboundResolveResultList;
} else {
resolveResultList.addAll(preboundResolveResultList);
}
added = true;
}
}
}
}
}
}
}
// either non-right match declaration or recursive call didn't find a rebinding
if (!added) {
addToResolveResultList(new PsiElementResolveResult(element, validResult));
}
}
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class ResolvableName method down.
/*
* Private Static Methods
*/
@Nullable
private static List<String> down(@NotNull Call qualifier) {
List<String> nameList = null;
if (qualifier.isCalling(KERNEL, __MODULE__, 0)) {
Call enclosingCall = enclosingModularMacroCall(qualifier);
if (enclosingCall != null && enclosingCall instanceof StubBased) {
StubBased enclosingStubBasedCall = (StubBased) enclosingCall;
String canonicalName = enclosingStubBasedCall.canonicalName();
if (canonicalName != null) {
nameList = new ArrayList<String>();
nameList.add(canonicalName);
}
}
}
return nameList;
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class Model method isSuitable.
@Override
protected boolean isSuitable(PsiElement element) {
boolean suitable = false;
// checks if the class is good
if (super.isSuitable(element)) {
// calls can be nested in calls, so need to check for sure
if (element instanceof Call) {
Call call = (Call) element;
suitable = isSuitable(call);
} else if (element instanceof ElixirAtom) {
ElixirAtom atom = (ElixirAtom) element;
suitable = Field.is(atom);
} else if (element instanceof QuotableKeywordPair) {
QuotableKeywordPair quotableKeywordPair = (QuotableKeywordPair) element;
suitable = FieldWithDefaultValue.is(quotableKeywordPair);
}
}
return suitable;
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class TestFinder method isTest.
@Override
public boolean isTest(@NotNull PsiElement element) {
Call sourceElement = findSourceElement(element);
boolean isTest = false;
if (sourceElement != null && sourceElement instanceof StubBased) {
StubBased sourceStubBased = (StubBased) sourceElement;
@SuppressWarnings("unchecked") Set<String> canonicalNameSet = sourceStubBased.canonicalNameSet();
if (!canonicalNameSet.isEmpty()) {
for (String canonicalName : canonicalNameSet) {
if (canonicalName.endsWith("Test")) {
isTest = true;
break;
}
}
}
}
return isTest;
}
use of org.elixir_lang.psi.call.Call in project intellij-elixir by KronicDeth.
the class TestFinder method parentCallSourceElement.
@Nullable
private static Call parentCallSourceElement(@NotNull PsiElement from) {
Call parentCall = PsiTreeUtil.getParentOfType(from, Call.class);
Call sourceElement = null;
if (parentCall != null) {
sourceElement = sourceElement(parentCall);
}
return sourceElement;
}
Aggregations