use of org.elixir_lang.psi.call.StubBased in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method canonicalName.
@Nullable
public static String canonicalName(@NotNull StubBased stubBased) {
String canonicalName;
if (isModular(stubBased)) {
String canonicalNameSuffix = null;
if (Implementation.is(stubBased)) {
String protocolName = Implementation.protocolName(stubBased);
PsiElement forNameElement = Implementation.forNameElement(stubBased);
String forName = null;
if (forNameElement != null) {
forName = forNameElement.getText();
}
canonicalNameSuffix = StringUtil.notNullize(protocolName, "?") + "." + StringUtil.notNullize(forName, "?");
} else if (Module.is(stubBased) || Protocol.is(stubBased)) {
canonicalNameSuffix = org.elixir_lang.navigation.item_presentation.modular.Module.presentableText(stubBased);
}
Call enclosing = enclosingModularMacroCall(stubBased);
if (enclosing instanceof StubBased) {
StubBased enclosingStubBased = (StubBased) enclosing;
String canonicalNamePrefix = enclosingStubBased.canonicalName();
canonicalName = StringUtil.notNullize(canonicalNamePrefix, "?") + "." + StringUtil.notNullize(canonicalNameSuffix, "?");
} else {
canonicalName = StringUtil.notNullize(canonicalNameSuffix, "?");
}
} else {
canonicalName = stubBased.getName();
}
return canonicalName;
}
use of org.elixir_lang.psi.call.StubBased in project intellij-elixir by KronicDeth.
the class Stub method hasCanonicalNames.
/*
* Private Instance Methods
*/
private boolean hasCanonicalNames(Call call) {
boolean hasCanonicalNames = false;
if (call instanceof StubBased) {
StubBased stubBased = (StubBased) call;
hasCanonicalNames = stubBased.canonicalNameSet().size() > 0;
}
return hasCanonicalNames;
}
use of org.elixir_lang.psi.call.StubBased in project intellij-elixir by KronicDeth.
the class TestFinder method corresponding.
@NotNull
private static Collection<PsiElement> corresponding(@NotNull PsiElement element, @NotNull Function<String, String> correspondingName, @NotNull Condition<Call> correspondingCallCondition) {
Call sourceElement = sourceElement(element);
Collection<PsiElement> correspondingCollection = new ArrayList<PsiElement>();
if (sourceElement != null && sourceElement instanceof StubBased) {
StubBased sourceStubBased = (StubBased) sourceElement;
@SuppressWarnings("unchecked") Set<String> canonicalNameSet = sourceStubBased.canonicalNameSet();
if (!canonicalNameSet.isEmpty()) {
Project project = element.getProject();
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
for (String canonicalName : canonicalNameSet) {
String correspondingCanonicalName = correspondingName.fun(canonicalName);
if (correspondingCanonicalName != null) {
Collection<NamedElement> correspondingElements = StubIndex.getElements(AllName.KEY, correspondingCanonicalName, project, scope, NamedElement.class);
for (NamedElement correspondingElement : correspondingElements) {
if (correspondingElement instanceof Call) {
Call correspondingCall = (Call) correspondingElement;
if (correspondingCallCondition.value(correspondingCall)) {
correspondingCollection.add(correspondingCall);
}
}
}
}
}
}
}
return correspondingCollection;
}
Aggregations