Search in sources :

Example 1 with ErlangAtom

use of org.intellij.erlang.psi.ErlangAtom 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");
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TextRange(com.intellij.openapi.util.TextRange) ErlangAtom(org.intellij.erlang.psi.ErlangAtom) NamedElement(org.elixir_lang.psi.NamedElement) Annotation(com.intellij.lang.annotation.Annotation)

Aggregations

Annotation (com.intellij.lang.annotation.Annotation)1 Project (com.intellij.openapi.project.Project)1 TextRange (com.intellij.openapi.util.TextRange)1 NamedElement (org.elixir_lang.psi.NamedElement)1 ErlangAtom (org.intellij.erlang.psi.ErlangAtom)1