Search in sources :

Example 6 with OtpErlangObject

use of com.ericsson.otp.erlang.OtpErlangObject in project intellij-elixir by KronicDeth.

the class BreakpointReachedEvent method getStack.

@Nullable
private static List<ElixirTraceElement> getStack(@Nullable OtpErlangList traceElementsList) {
    if (traceElementsList == null)
        return null;
    List<ElixirTraceElement> stack = new ArrayList<>(traceElementsList.arity());
    for (OtpErlangObject traceElementObject : traceElementsList) {
        OtpErlangTuple traceElementTuple = getTupleValue(traceElementObject);
        // ignoring SP at 0
        OtpErlangTuple moduleFunctionArgsTuple = getTupleValue(elementAt(traceElementTuple, 1));
        OtpErlangList bindingsList = getListValue(elementAt(traceElementTuple, 2));
        OtpErlangTuple fileLineTuple = getTupleValue(elementAt(traceElementTuple, 3));
        String file = getStringText(elementAt(fileLineTuple, 0));
        Integer line = getIntegerValue(elementAt(fileLineTuple, 1));
        ElixirTraceElement traceElement = getTraceElement(moduleFunctionArgsTuple, bindingsList, file, line);
        if (traceElement == null)
            return null;
        stack.add(traceElement);
    }
    return stack;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with OtpErlangObject

use of com.ericsson.otp.erlang.OtpErlangObject in project intellij-elixir by KronicDeth.

the class Import method keywordValueToArity.

@Nullable
private static Integer keywordValueToArity(@NotNull final Quotable keywordValue) {
    OtpErlangObject quotedKeywordValue = keywordValue.quote();
    Integer arity = null;
    if (quotedKeywordValue instanceof OtpErlangLong) {
        OtpErlangLong quotedKeywordValueLong = (OtpErlangLong) quotedKeywordValue;
        try {
            arity = quotedKeywordValueLong.intValue();
        } catch (OtpErlangRangeException e) {
            Logger.error(Import.class, "Arity in OtpErlangLong could not be downcast to an int", keywordValue);
        }
    }
    return arity;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

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