Search in sources :

Example 1 with Named

use of org.elixir_lang.psi.call.Named in project intellij-elixir by KronicDeth.

the class Variants method addToLookupElementByPsiElement.

/*
     * Private Instance Methods
     */
private void addToLookupElementByPsiElement(@NotNull Call call) {
    if (call instanceof Named) {
        Named named = (Named) call;
        PsiElement nameIdentifier = named.getNameIdentifier();
        if (nameIdentifier != null) {
            if (lookupElementByPsiElement == null || !lookupElementByPsiElement.containsKey(nameIdentifier)) {
                if (lookupElementByPsiElement == null) {
                    lookupElementByPsiElement = new THashMap<PsiElement, LookupElement>();
                }
                String name = nameIdentifier.getText();
                lookupElementByPsiElement.put(nameIdentifier, LookupElementBuilder.createWithSmartPointer(name, nameIdentifier).withRenderer(new org.elixir_lang.code_insight.lookup.element_renderer.CallDefinitionClause(name)));
            }
        }
    }
}
Also used : Named(org.elixir_lang.psi.call.Named) CallDefinitionClause(org.elixir_lang.psi.scope.CallDefinitionClause) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PsiElement(com.intellij.psi.PsiElement)

Example 2 with Named

use of org.elixir_lang.psi.call.Named in project intellij-elixir by KronicDeth.

the class MultiResolve method addToResolveResultList.

/*
     * Private Instance Methods
     */
/*
     * Private Instance Methods
     */
private boolean addToResolveResultList(@NotNull Call call, boolean validResult, ResolveState state) {
    boolean keepProcessing = true;
    if (call instanceof Named) {
        Named named = (Named) call;
        PsiElement nameIdentifier = named.getNameIdentifier();
        if (nameIdentifier != null) {
            if (PsiTreeUtil.isAncestor(state.get(ENTRANCE), nameIdentifier, false)) {
                addNewToResolveResultList(nameIdentifier, validResult);
                keepProcessing = false;
            } else {
                /* Doesn't use a Map<PsiElement, ResolveSet> so that MultiResolve's helpers that require a
                   List<ResolveResult> can still work */
                addNewToResolveResultList(nameIdentifier, validResult);
                Call importCall = state.get(IMPORT_CALL);
                if (importCall != null) {
                    addNewToResolveResultList(importCall, validResult);
                }
            }
        }
    }
    return keepProcessing;
}
Also used : Named(org.elixir_lang.psi.call.Named) Call(org.elixir_lang.psi.call.Call) PsiElement(com.intellij.psi.PsiElement)

Example 3 with Named

use of org.elixir_lang.psi.call.Named in project intellij-elixir by KronicDeth.

the class Callable method calculateDefaultRangeInElement.

/*
     * Protected Instance Methods
     */
@Override
protected TextRange calculateDefaultRangeInElement() {
    TextRange defaultRangeInElement = null;
    TextRange myElementRangeInDocument = myElement.getTextRange();
    int myElementStartOffset = myElementRangeInDocument.getStartOffset();
    if (myElement instanceof Named) {
        Named named = (Named) myElement;
        PsiElement nameIdentifier = named.getNameIdentifier();
        if (nameIdentifier != null) {
            TextRange nameIdentifierRangeInDocument = nameIdentifier.getTextRange();
            defaultRangeInElement = new TextRange(nameIdentifierRangeInDocument.getStartOffset() - myElementStartOffset, nameIdentifierRangeInDocument.getEndOffset() - myElementStartOffset);
        }
    }
    if (defaultRangeInElement == null) {
        defaultRangeInElement = new TextRange(0, myElementRangeInDocument.getEndOffset() - myElementStartOffset);
    }
    return defaultRangeInElement;
}
Also used : Named(org.elixir_lang.psi.call.Named) TextRange(com.intellij.openapi.util.TextRange)

Aggregations

Named (org.elixir_lang.psi.call.Named)3 PsiElement (com.intellij.psi.PsiElement)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 TextRange (com.intellij.openapi.util.TextRange)1 Call (org.elixir_lang.psi.call.Call)1 CallDefinitionClause (org.elixir_lang.psi.scope.CallDefinitionClause)1