use of org.elixir_lang.psi.operation.When in project intellij-elixir by KronicDeth.
the class ModuleAttribute method highlightTypesAndTypeParameterUsages.
private void highlightTypesAndTypeParameterUsages(@NotNull PsiElement psiElement, Set<String> typeParameterNameSet, AnnotationHolder annotationHolder, TextAttributesKey typeTextAttributesKey) {
if (psiElement instanceof Arguments) {
highlightTypesAndTypeParameterUsages((Arguments) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof AtUnqualifiedNoParenthesesCall) {
/* Occurs in the case of typing a {@code @type name ::} above a {@code @doc <HEREDOC>} and the
{@code @doc <HEREDOC>} is interpreted as the right-operand of {@code ::} */
} else if (psiElement instanceof ElixirAccessExpression || psiElement instanceof ElixirAssociationsBase || psiElement instanceof ElixirAssociations || psiElement instanceof ElixirContainerAssociationOperation || psiElement instanceof ElixirKeywordPair || psiElement instanceof ElixirKeywords || psiElement instanceof ElixirList || psiElement instanceof ElixirMapArguments || psiElement instanceof ElixirMapConstructionArguments || psiElement instanceof ElixirNoParenthesesArguments || psiElement instanceof ElixirParentheticalStab || psiElement instanceof ElixirStab || psiElement instanceof ElixirStabBody || psiElement instanceof ElixirStabNoParenthesesSignature || psiElement instanceof ElixirTuple) {
highlightTypesAndTypeParameterUsages(psiElement.getChildren(), typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof BracketOperation || psiElement instanceof ElixirAlias || psiElement instanceof ElixirAtom || psiElement instanceof ElixirAtomKeyword || psiElement instanceof ElixirBitString || psiElement instanceof ElixirCharToken || psiElement instanceof ElixirDecimalWholeNumber || psiElement instanceof ElixirKeywordKey || /* happens when :: is typed in `@spec` above function clause that uses `do:` */
psiElement instanceof ElixirNoParenthesesKeywords || psiElement instanceof ElixirStringLine || psiElement instanceof ElixirUnaryNumericOperation || psiElement instanceof ElixirVariable) {
// leave normal highlighting
} else if (psiElement instanceof ElixirMapOperation) {
highlightTypesAndTypeParameterUsages((ElixirMapOperation) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof ElixirMapUpdateArguments) {
highlightTypesAndTypeParameterUsages((ElixirMapUpdateArguments) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof ElixirRelativeIdentifier || psiElement instanceof UnqualifiedNoArgumentsCall) {
// highlight entire element
String name = psiElement.getText();
TextAttributesKey textAttributesKey;
if (typeParameterNameSet.contains(name)) {
textAttributesKey = ElixirSyntaxHighlighter.TYPE_PARAMETER;
} else {
textAttributesKey = typeTextAttributesKey;
}
highlight(psiElement.getTextRange(), annotationHolder, textAttributesKey);
} else if (psiElement instanceof ElixirStabParenthesesSignature) {
highlightTypesAndTypeParameterUsages((ElixirStabParenthesesSignature) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof ElixirStabOperation) {
highlightTypesAndTypeParameterUsages((ElixirStabOperation) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof ElixirStructOperation) {
highlightTypesAndTypeParameterUsages((ElixirStructOperation) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof InterpolatedString) {
highlightTypeError(psiElement, annotationHolder, "Strings aren't allowed in types");
} else if (psiElement instanceof When) {
/* NOTE: MUST be before `Infix` as `When` is a subinterface of
`Infix` */
highlightTypesAndTypeParameterUsages((When) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof Infix) {
highlightTypesAndTypeParameterUsages((Infix) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof QualifiedParenthesesCall) {
highlightTypesAndTypeParameterUsages((QualifiedParenthesesCall) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof QualifiedAlias) {
highlightTypesAndTypeParameterUsages((QualifiedAlias) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof QualifiedNoArgumentsCall) {
highlightTypesAndTypeParameterUsages((QualifiedNoArgumentsCall) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof QualifiedNoParenthesesCall) {
highlightTypesAndTypeParameterUsages((QualifiedNoParenthesesCall) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof UnqualifiedNoParenthesesCall) {
highlightTypesAndTypeParameterUsages((UnqualifiedNoParenthesesCall) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else if (psiElement instanceof UnqualifiedParenthesesCall) {
highlightTypesAndTypeParameterUsages((UnqualifiedParenthesesCall) psiElement, typeParameterNameSet, annotationHolder, typeTextAttributesKey);
} else {
cannotHighlightTypes(psiElement);
}
}
use of org.elixir_lang.psi.operation.When in project intellij-elixir by KronicDeth.
the class Parameter method putParameterized.
@Contract(pure = true)
@NotNull
private static Parameter putParameterized(@NotNull final Parameter parameter, @NotNull final PsiElement ancestor) {
Parameter parameterizedParameter;
PsiElement parent = ancestor.getParent();
/* MUST be before `Call` because `When` operations are `Call` implementations too in all cases even though
`When` is not a subinterface. */
if (parent instanceof When) {
parameterizedParameter = putParameterized(parameter, parent);
} else if (parent instanceof Call) {
parameterizedParameter = putParameterized(parameter, (Call) parent);
} else if (parent instanceof AtNonNumericOperation || parent instanceof ElixirAccessExpression || parent instanceof ElixirAssociations || parent instanceof ElixirAssociationsBase || parent instanceof ElixirBitString || parent instanceof ElixirBracketArguments || parent instanceof ElixirContainerAssociationOperation || parent instanceof ElixirKeywordPair || parent instanceof ElixirKeywords || parent instanceof ElixirList || parent instanceof ElixirMapArguments || parent instanceof ElixirMapConstructionArguments || parent instanceof ElixirMapOperation || parent instanceof ElixirMatchedParenthesesArguments || parent instanceof ElixirNoParenthesesArguments || parent instanceof ElixirNoParenthesesKeywordPair || parent instanceof ElixirNoParenthesesKeywords || /* ElixirNoParenthesesManyStrictNoParenthesesExpression indicates a syntax error where no parentheses
calls are nested, so it's invalid, but try to still resolve parameters to have highlighting */
parent instanceof ElixirNoParenthesesManyStrictNoParenthesesExpression || parent instanceof ElixirNoParenthesesOneArgument || /* handles `(conn, %{})` in `def (conn, %{})`, which can occur in def templates.
See https://github.com/KronicDeth/intellij-elixir/issues/367#issuecomment-244214975 */
parent instanceof ElixirNoParenthesesStrict || parent instanceof ElixirParenthesesArguments || parent instanceof ElixirParentheticalStab || parent instanceof ElixirStab || parent instanceof ElixirStabNoParenthesesSignature || parent instanceof ElixirStabBody || parent instanceof ElixirStabOperation || parent instanceof ElixirStabParenthesesSignature || parent instanceof ElixirStructOperation || parent instanceof ElixirTuple) {
parameterizedParameter = putParameterized(parameter, parent);
} else if (parent instanceof ElixirAnonymousFunction) {
parameterizedParameter = putParameterized(parameter, (ElixirAnonymousFunction) parent);
} else if (parent instanceof InMatch) {
parameterizedParameter = putParameterized(parameter, (InMatch) parent);
} else if (parent instanceof BracketOperation || parent instanceof ElixirBlockItem || parent instanceof ElixirDoBlock || parent instanceof ElixirInterpolation || parent instanceof ElixirMapUpdateArguments || parent instanceof ElixirMultipleAliases || parent instanceof ElixirQuoteStringBody || parent instanceof PsiFile || parent instanceof QualifiedAlias || parent instanceof QualifiedMultipleAliases) {
parameterizedParameter = new Parameter(parameter.entrance);
} else {
error("Don't know how to check if parameter", parent);
parameterizedParameter = new Parameter(parameter.entrance);
}
return parameterizedParameter;
}
use of org.elixir_lang.psi.operation.When in project intellij-elixir by KronicDeth.
the class Parameter method putParameterized.
@Contract(pure = true)
@NotNull
private static Parameter putParameterized(@NotNull final Parameter parameter, @NotNull final PsiElement ancestor) {
Parameter parameterizedParameter;
PsiElement parent = ancestor.getParent();
/* MUST be before `Call` because `When` operations are `Call` implementations too in all cases even though
`When` is not a subinterface. */
if (parent instanceof When) {
parameterizedParameter = putParameterized(parameter, parent);
} else if (parent instanceof Call) {
parameterizedParameter = putParameterized(parameter, (Call) parent);
} else if (parent instanceof AtOperation || parent instanceof ElixirAccessExpression || parent instanceof ElixirAssociations || parent instanceof ElixirAssociationsBase || parent instanceof ElixirEex || parent instanceof ElixirEexTag || parent instanceof ElixirBitString || parent instanceof ElixirBracketArguments || parent instanceof ElixirContainerAssociationOperation || parent instanceof ElixirKeywordPair || parent instanceof ElixirKeywords || parent instanceof ElixirList || parent instanceof ElixirMapArguments || parent instanceof ElixirMapConstructionArguments || parent instanceof ElixirMapOperation || parent instanceof ElixirMatchedParenthesesArguments || parent instanceof ElixirNoParenthesesArguments || parent instanceof ElixirNoParenthesesKeywordPair || parent instanceof ElixirNoParenthesesKeywords || /* ElixirNoParenthesesManyStrictNoParenthesesExpression indicates a syntax error where no parentheses
calls are nested, so it's invalid, but try to still resolve parameters to have highlighting */
parent instanceof ElixirNoParenthesesManyStrictNoParenthesesExpression || parent instanceof ElixirNoParenthesesOneArgument || /* handles `(conn, %{})` in `def (conn, %{})`, which can occur in def templates.
See https://github.com/KronicDeth/intellij-elixir/issues/367#issuecomment-244214975 */
parent instanceof ElixirNoParenthesesStrict || parent instanceof ElixirParenthesesArguments || parent instanceof ElixirParentheticalStab || parent instanceof ElixirStab || parent instanceof ElixirStabNoParenthesesSignature || parent instanceof ElixirStabBody || parent instanceof ElixirStabOperation || parent instanceof ElixirStabParenthesesSignature || parent instanceof ElixirStructOperation || parent instanceof ElixirTuple) {
parameterizedParameter = putParameterized(parameter, parent);
} else if (parent instanceof ElixirAnonymousFunction) {
parameterizedParameter = putParameterized(parameter, (ElixirAnonymousFunction) parent);
} else if (parent instanceof InMatch) {
parameterizedParameter = putParameterized(parameter, parent);
} else if (parent instanceof AtUnqualifiedBracketOperation || parent instanceof BracketOperation || parent instanceof ElixirBlockItem || parent instanceof ElixirDoBlock || parent instanceof ElixirInterpolation || parent instanceof ElixirMapUpdateArguments || parent instanceof ElixirMultipleAliases || parent instanceof ElixirHeredocLineBody || parent instanceof ElixirLineBody || parent instanceof PsiFile || parent instanceof QualifiedAlias || parent instanceof QualifiedMultipleAliases) {
parameterizedParameter = new Parameter(parameter.entrance);
} else {
error("Don't know how to check if parameter", parent);
parameterizedParameter = new Parameter(parameter.entrance);
}
return parameterizedParameter;
}
Aggregations