use of org.elixir_lang.psi.NamedElement in project intellij-elixir by KronicDeth.
the class MultiResolve method indexedNamedElements.
/*
* Private Static Methods
*/
@NotNull
private static Collection<NamedElement> indexedNamedElements(@NotNull PsiNamedElement match, @NotNull String unaliasedName) {
Project project = match.getProject();
Collection<NamedElement> indexNamedElementCollection;
if (DumbService.isDumb(project)) {
indexNamedElementCollection = Collections.emptyList();
} else {
indexNamedElementCollection = StubIndex.getElements(AllName.KEY, unaliasedName, project, GlobalSearchScope.allScope(project), NamedElement.class);
}
return indexNamedElementCollection;
}
use of org.elixir_lang.psi.NamedElement in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsByName.
/*
* Instance Methods
*/
/**
* Returns the list of navigation items matching the specified name.
*
* @param name the name selected from the list.
* @param pattern the original pattern entered in the dialog
* @param project the project in which the navigation is performed.
* @param includeNonProjectItems if true, the navigation items for non-project items (for example,
* library classes) should be included in the returned array.
* @return the array of navigation items.
*/
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = globalSearchScope(project, includeNonProjectItems);
Collection<NamedElement> result = StubIndex.getElements(AllName.KEY, name, project, scope, NamedElement.class);
List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size());
EnclosingModularByCall enclosingModularByCall = new EnclosingModularByCall();
Map<CallDefinition.Tuple, CallDefinition> callDefinitionByTuple = new HashMap<CallDefinition.Tuple, CallDefinition>();
for (final NamedElement element : result) {
// Use navigation element so that source element is used for compiled elements
PsiElement sourceElement = element.getNavigationElement();
if (sourceElement instanceof Call) {
getItemsByNameFromCall(name, items, enclosingModularByCall, callDefinitionByTuple, (Call) sourceElement);
}
}
return items.toArray(new NavigationItem[items.size()]);
}
use of org.elixir_lang.psi.NamedElement in project intellij-elixir by KronicDeth.
the class Module method annotate.
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull com.intellij.lang.annotation.AnnotationHolder annotationHolder) {
if (psiElement instanceof ErlangAtom) {
ErlangAtom erlangAtom = (ErlangAtom) psiElement;
String name = erlangAtom.getName();
if (name.startsWith(ELIXIR_ALIAS_PREFIX)) {
Project project = psiElement.getProject();
Collection<NamedElement> namedElementCollection = StubIndex.getElements(AllName.KEY, name, project, GlobalSearchScope.allScope(project), NamedElement.class);
if (namedElementCollection.size() > 0) {
TextRange textRange = psiElement.getTextRange();
String unprefixedName = name.substring(ELIXIR_ALIAS_PREFIX.length(), name.length());
Annotation annotation = annotationHolder.createInfoAnnotation(textRange, "Resolves to Elixir Module " + unprefixedName);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
} else {
TextRange textRange = psiElement.getTextRange();
annotationHolder.createErrorAnnotation(textRange, "Unresolved Elixir Module");
}
}
}
}
use of org.elixir_lang.psi.NamedElement in project intellij-elixir by KronicDeth.
the class Element method getName.
/**
* The name of the {@link #navigationItem}.
*
* @return the {@link NamedElement#getName()} if {@link #navigationItem} is a {@link NamedElement}; otherwise,
* {@code null}.
*/
@Nullable
@Override
public String getName() {
String name = null;
if (navigationItem instanceof NamedElement) {
NamedElement namedElement = (NamedElement) navigationItem;
name = namedElement.getName();
}
return name;
}
use of org.elixir_lang.psi.NamedElement 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