Search in sources :

Example 1 with Quotable

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

the class Normalized method operand.

@Contract(pure = true)
@Nullable
private static Quotable operand(@NotNull PsiElement[] children, int operatorIndex) {
    int operandCount = children.length - 1 - operatorIndex;
    Quotable operand = null;
    // ensure operand is there and there isn't more than one
    if (operandCount == 1) {
        PsiElement child = children[operatorIndex + 1];
        if (child instanceof Quotable) {
            operand = (Quotable) child;
        }
    }
    return operand;
}
Also used : Quotable(org.elixir_lang.psi.Quotable) PsiElement(com.intellij.psi.PsiElement) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Quotable

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

the class Normalized method leftOperand.

@Contract(pure = true)
@Nullable
public static Quotable leftOperand(@NotNull PsiElement[] children, int operatorIndex) {
    Quotable leftOperand = null;
    int leftOperandCount = operatorIndex;
    // ensures that {@code partialLeft PsiErrorElement} returns {@code null}
    if (leftOperandCount == 1) {
        PsiElement child = children[operatorIndex - 1];
        // prevents PsiErrorElement from being leftOperand
        if (child instanceof Quotable) {
            leftOperand = (Quotable) child;
        }
    }
    return leftOperand;
}
Also used : Quotable(org.elixir_lang.psi.Quotable) PsiElement(com.intellij.psi.PsiElement) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with Quotable

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

the class Overridable method getChildren.

/**
     * Returns the list of children of the tree element.
     *
     * @return the list of children.
     */
@NotNull
@Override
public TreeElement[] getChildren() {
    QuotableKeywordList keywordArguments = ElixirPsiImplUtil.keywordArguments(navigationItem);
    TreeElement[] children;
    if (keywordArguments != null) {
        List<QuotableKeywordPair> quotableKeywordPairList = keywordArguments.quotableKeywordPairList();
        List<TreeElement> treeElementList = new ArrayList<TreeElement>(quotableKeywordPairList.size());
        for (QuotableKeywordPair quotableKeywordPair : quotableKeywordPairList) {
            Quotable keywordKey = quotableKeywordPair.getKeywordKey();
            OtpErlangObject quotedKeywordKey = keywordKey.quote();
            String name;
            if (quotedKeywordKey instanceof OtpErlangAtom) {
                OtpErlangAtom keywordKeyAtom = (OtpErlangAtom) quotedKeywordKey;
                name = keywordKeyAtom.atomValue();
            } else {
                name = keywordKey.getText();
            }
            Quotable keywordValue = quotableKeywordPair.getKeywordValue();
            OtpErlangObject quotedKeywordValue = keywordValue.quote();
            Integer arity = null;
            if (quotedKeywordValue instanceof OtpErlangLong) {
                OtpErlangLong keywordValueErlangLong = (OtpErlangLong) quotedKeywordValue;
                try {
                    arity = keywordValueErlangLong.intValue();
                } catch (OtpErlangRangeException e) {
                    arity = null;
                }
            }
            boolean overridable = true;
            //noinspection ConstantConditions
            treeElementList.add(new CallReference(modular, quotableKeywordPair, Timed.Time.RUN, overridable, name, arity));
        }
        children = treeElementList.toArray(new TreeElement[treeElementList.size()]);
    } else {
        children = new TreeElement[0];
    }
    return children;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) ArrayList(java.util.ArrayList) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) Quotable(org.elixir_lang.psi.Quotable) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) QuotableKeywordList(org.elixir_lang.psi.QuotableKeywordList) QuotableKeywordPair(org.elixir_lang.psi.QuotableKeywordPair) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with Quotable

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

the class Normalized method rightOperand.

@Contract(pure = true)
@Nullable
public static Quotable rightOperand(@NotNull PsiElement[] children, int operatorIndex) {
    int rightOperandCount = children.length - 1 - operatorIndex;
    Quotable rightOperand = null;
    // ensure right operand is there and there isn't more than one
    if (rightOperandCount == 1) {
        PsiElement child = children[operatorIndex + 1];
        if (child instanceof Quotable) {
            rightOperand = (Quotable) child;
        }
    }
    return rightOperand;
}
Also used : Quotable(org.elixir_lang.psi.Quotable) PsiElement(com.intellij.psi.PsiElement) Contract(org.jetbrains.annotations.Contract) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Quotable (org.elixir_lang.psi.Quotable)4 PsiElement (com.intellij.psi.PsiElement)3 Contract (org.jetbrains.annotations.Contract)3 Nullable (org.jetbrains.annotations.Nullable)3 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 ArrayList (java.util.ArrayList)1 QuotableKeywordList (org.elixir_lang.psi.QuotableKeywordList)1 QuotableKeywordPair (org.elixir_lang.psi.QuotableKeywordPair)1 NotNull (org.jetbrains.annotations.NotNull)1