Search in sources :

Example 1 with Parameter

use of org.elixir_lang.annonator.Parameter in project intellij-elixir by KronicDeth.

the class ElementDescriptionProvider method getElementDescription.

/*
     * Private Instance Methods
     */
@Nullable
private String getElementDescription(@NotNull ElixirIdentifier identifier, @NotNull ElementDescriptionLocation location) {
    String elementDescription = null;
    Parameter parameter = new Parameter(identifier);
    Parameter.Type type = Parameter.putParameterized(parameter).type;
    if (type == Parameter.Type.FUNCTION_NAME) {
        if (location == UsageViewShortNameLocation.INSTANCE) {
            elementDescription = identifier.getText();
        } else if (location == UsageViewTypeLocation.INSTANCE) {
            elementDescription = "function";
        }
    } else if (type == Parameter.Type.MACRO_NAME) {
        if (location == UsageViewShortNameLocation.INSTANCE) {
            elementDescription = identifier.getText();
        } else if (location == UsageViewTypeLocation.INSTANCE) {
            elementDescription = "macro";
        }
    }
    return elementDescription;
}
Also used : Parameter(org.elixir_lang.annonator.Parameter) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Parameter

use of org.elixir_lang.annonator.Parameter in project intellij-elixir by KronicDeth.

the class Variable method icon.

@Contract(pure = true)
@Nullable
private Icon icon(@NotNull PsiElement element) {
    Icon icon = null;
    Parameter parameter = new Parameter(element);
    Parameter.Type parameterType = Parameter.putParameterized(parameter).type;
    if (parameterType != null) {
        icon = ElixirIcons.PARAMETER;
    } else {
        icon = ElixirIcons.VARIABLE;
    }
    return icon;
}
Also used : Parameter(org.elixir_lang.annonator.Parameter) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with Parameter

use of org.elixir_lang.annonator.Parameter in project intellij-elixir by KronicDeth.

the class Variants method lookupElementList.

/*
     * Static Methods
     */
@Nullable
public static List<LookupElement> lookupElementList(@NotNull PsiElement entrance) {
    Variants variants = new Variants();
    Parameter parameter = Parameter.putParameterized(new Parameter(entrance));
    Call entranceCallDefinitionClause = null;
    if (parameter.isCallDefinitionClauseName()) {
        entranceCallDefinitionClause = (Call) parameter.parameterized;
    }
    ResolveState resolveState = ResolveState.initial().put(ENTRANCE, entrance).put(ENTRANCE_CALL_DEFINITION_CLAUSE, entranceCallDefinitionClause);
    PsiTreeUtil.treeWalkUp(variants, entrance, entrance.getContainingFile(), resolveState);
    List<LookupElement> lookupElementList = new ArrayList<LookupElement>();
    lookupElementList.addAll(variants.getLookupElementCollection());
    return lookupElementList;
}
Also used : Call(org.elixir_lang.psi.call.Call) Parameter(org.elixir_lang.annonator.Parameter) LookupElement(com.intellij.codeInsight.lookup.LookupElement) ResolveState(com.intellij.psi.ResolveState) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Parameter

use of org.elixir_lang.annonator.Parameter in project intellij-elixir by KronicDeth.

the class ElixirPsiImplUtil method getPresentation.

@Contract(pure = true)
@Nullable
public static ItemPresentation getPresentation(@NotNull final ElixirIdentifier identifier) {
    Parameter parameter = new Parameter(identifier);
    Parameter parameterizedParameter = Parameter.putParameterized(parameter);
    ItemPresentation itemPresentation = null;
    if ((parameterizedParameter.type == Parameter.Type.FUNCTION_NAME || parameterizedParameter.type == Parameter.Type.MACRO_NAME) && parameterizedParameter.parameterized != null) {
        final NavigatablePsiElement parameterized = parameterizedParameter.parameterized;
        if (parameterized instanceof Call) {
            CallDefinitionClause callDefinitionClause = CallDefinitionClause.fromCall((Call) parameterized);
            if (callDefinitionClause != null) {
                itemPresentation = callDefinitionClause.getPresentation();
            }
        }
    }
    return itemPresentation;
}
Also used : Call(org.elixir_lang.psi.call.Call) CallDefinitionClause.enclosingModularMacroCall(org.elixir_lang.structure_view.element.CallDefinitionClause.enclosingModularMacroCall) ItemPresentation(com.intellij.navigation.ItemPresentation) Parameter(org.elixir_lang.annonator.Parameter) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Parameter

use of org.elixir_lang.annonator.Parameter in project intellij-elixir by KronicDeth.

the class Variable method color.

/*
     * Private Instance Methods
     */
@Contract(pure = true)
@NotNull
private Color color(@NotNull final PsiElement element) {
    Color color = JBColor.foreground();
    if (isIgnored(element)) {
        color = ElixirSyntaxHighlighter.IGNORED_VARIABLE.getDefaultAttributes().getForegroundColor();
    } else {
        Parameter parameter = new Parameter(element);
        Parameter.Type parameterType = Parameter.putParameterized(parameter).type;
        if (parameterType != null) {
            if (parameterType == Parameter.Type.VARIABLE) {
                color = ElixirSyntaxHighlighter.PARAMETER.getDefaultAttributes().getForegroundColor();
            }
        } else if (isParameterWithDefault(element)) {
            color = ElixirSyntaxHighlighter.PARAMETER.getDefaultAttributes().getForegroundColor();
        } else if (isVariable(element)) {
            color = ElixirSyntaxHighlighter.VARIABLE.getDefaultAttributes().getForegroundColor();
        }
    }
    return color;
}
Also used : JBColor(com.intellij.ui.JBColor) Parameter(org.elixir_lang.annonator.Parameter) Contract(org.jetbrains.annotations.Contract) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Parameter (org.elixir_lang.annonator.Parameter)5 Nullable (org.jetbrains.annotations.Nullable)4 Contract (org.jetbrains.annotations.Contract)3 Call (org.elixir_lang.psi.call.Call)2 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 ItemPresentation (com.intellij.navigation.ItemPresentation)1 ResolveState (com.intellij.psi.ResolveState)1 JBColor (com.intellij.ui.JBColor)1 CallDefinitionClause.enclosingModularMacroCall (org.elixir_lang.structure_view.element.CallDefinitionClause.enclosingModularMacroCall)1 NotNull (org.jetbrains.annotations.NotNull)1