Search in sources :

Example 1 with InMatch

use of org.elixir_lang.psi.operation.InMatch in project intellij-elixir by KronicDeth.

the class Variable method enclosingMatch.

@Contract(pure = true)
@NotNull
private PsiElement enclosingMatch(@NotNull final PsiElement ancestor) {
    PsiElement enclosingMatch = ancestor;
    PsiElement parent = ancestor.getParent();
    if (parent instanceof InMatch || parent instanceof Match) {
        enclosingMatch = parent;
    } else {
        assert ancestor != null;
    }
    return enclosingMatch;
}
Also used : InMatch(org.elixir_lang.psi.operation.InMatch) PsiElement(com.intellij.psi.PsiElement) Match(org.elixir_lang.psi.operation.Match) InMatch(org.elixir_lang.psi.operation.InMatch) Contract(org.jetbrains.annotations.Contract) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with InMatch

use of org.elixir_lang.psi.operation.InMatch 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;
}
Also used : InMatch(org.elixir_lang.psi.operation.InMatch) PsiFile(com.intellij.psi.PsiFile) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement) PsiElement(com.intellij.psi.PsiElement) Call(org.elixir_lang.psi.call.Call) When(org.elixir_lang.psi.operation.When) Contract(org.jetbrains.annotations.Contract) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 InMatch (org.elixir_lang.psi.operation.InMatch)2 Contract (org.jetbrains.annotations.Contract)2 NotNull (org.jetbrains.annotations.NotNull)2 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 Call (org.elixir_lang.psi.call.Call)1 Match (org.elixir_lang.psi.operation.Match)1 When (org.elixir_lang.psi.operation.When)1