use of org.elixir_lang.psi.call.StubBased 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.StubBased 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.StubBased in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method fullyQualifiedName.
@Contract(pure = true)
@Nullable
public static String fullyQualifiedName(@NotNull final QualifiableAlias qualifiableAlias) {
String fullyQualifiedName = null;
PsiElement[] children = qualifiableAlias.getChildren();
int operatorIndex = Normalized.operatorIndex(children);
Quotable qualifier = org.elixir_lang.psi.operation.infix.Normalized.leftOperand(children, operatorIndex);
String qualifierName = null;
if (qualifier instanceof Call) {
Call qualifierCall = (Call) qualifier;
if (qualifierCall.isCalling(KERNEL, __MODULE__, 0)) {
Call enclosingCall = enclosingModularMacroCall(qualifierCall);
if (enclosingCall != null && enclosingCall instanceof StubBased) {
StubBased enclosingStubBasedCall = (StubBased) enclosingCall;
qualifierName = enclosingStubBasedCall.canonicalName();
}
}
} else if (qualifier instanceof QualifiableAlias) {
QualifiableAlias qualifiableQualifier = (QualifiableAlias) qualifier;
qualifierName = qualifiableQualifier.fullyQualifiedName();
} else if (qualifier instanceof ElixirAccessExpression) {
PsiElement qualifierChild = stripAccessExpression(qualifier);
if (qualifierChild instanceof ElixirAlias) {
ElixirAlias childAlias = (ElixirAlias) qualifierChild;
qualifierName = childAlias.getName();
}
}
if (qualifierName != null) {
Quotable rightOperand = org.elixir_lang.psi.operation.infix.Normalized.rightOperand(children, operatorIndex);
if (rightOperand instanceof ElixirAlias) {
ElixirAlias relativeAlias = (ElixirAlias) rightOperand;
fullyQualifiedName = qualifierName + "." + relativeAlias.getName();
}
}
return fullyQualifiedName;
}
use of org.elixir_lang.psi.call.StubBased in project intellij-elixir by KronicDeth.
the class ElixirFile method modulars.
/**
* @return modulars owned (declared) by this element.
*/
@NotNull
@Override
public StubBased[] modulars() {
StubBased[] stubBaseds = PsiTreeUtil.getChildrenOfType(this, StubBased.class);
List<StubBased> modularList = new ArrayList<StubBased>();
if (stubBaseds != null) {
for (StubBased stubBased : stubBaseds) {
if (Implementation.is(stubBased) || Module.is(stubBased) || Protocol.is(stubBased)) {
modularList.add(stubBased);
}
}
}
return modularList.toArray(new StubBased[modularList.size()]);
}
use of org.elixir_lang.psi.call.StubBased in project intellij-elixir by KronicDeth.
the class TestFinder method isTestElement.
/**
* Check if the given element is a test or not.
*/
public static boolean isTestElement(@NotNull PsiElement element) {
Call sourceElement = sourceElement(element);
boolean isTest = false;
if (sourceElement instanceof StubBased) {
@SuppressWarnings("rawtypes") StubBased sourceStubBased = (StubBased) sourceElement;
Set<String> canonicalNameSet = sourceStubBased.canonicalNameSet();
if (!canonicalNameSet.isEmpty()) {
for (String canonicalName : canonicalNameSet) {
if (canonicalName.endsWith("Test")) {
isTest = true;
break;
}
}
}
}
return isTest;
}
Aggregations