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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations