Search in sources :

Example 1 with OtpErlangList

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

the class ModuleDefinition method name.

public String name() {
    OtpErlangTuple quotedDefmodule = (OtpErlangTuple) defmodule.quote();
    OtpErlangList callArguments = Macro.callArguments(quotedDefmodule);
    // Alias + block
    assert callArguments.arity() == 2;
    OtpErlangObject quotedName = callArguments.elementAt(0);
    // TODO handle other forms for module names
    assert Macro.isAliases(quotedName);
    return Macro.toString(quotedName);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 2 with OtpErlangList

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

the class BreakpointReachedEvent method getTraceElement.

@Nullable
private static ElixirTraceElement getTraceElement(@Nullable OtpErlangTuple moduleFunctionArgsTuple, @Nullable OtpErlangList bindingsList, String file, Integer line) {
    String moduleName = getAtomText(elementAt(moduleFunctionArgsTuple, 0));
    String functionName = getAtomText(elementAt(moduleFunctionArgsTuple, 1));
    OtpErlangList args = getListValue(elementAt(moduleFunctionArgsTuple, 2));
    Collection<ElixirVariableBinding> bindings = getBindings(bindingsList);
    // bindings are not necessarily present
    if (moduleName == null || functionName == null || args == null)
        return null;
    return new ElixirTraceElement(moduleName, functionName, args, bindings, file, line);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with OtpErlangList

use of com.ericsson.otp.erlang.OtpErlangList 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)

Aggregations

OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 Nullable (org.jetbrains.annotations.Nullable)2 ArrayList (java.util.ArrayList)1