Search in sources :

Example 1 with OtpErlangTuple

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

the class BreakpointReachedEvent method getBindings.

@NotNull
private static Collection<ElixirVariableBinding> getBindings(@Nullable OtpErlangList bindingsList) {
    if (bindingsList == null)
        return ContainerUtil.emptyList();
    Collection<ElixirVariableBinding> bindings = new ArrayList<>(bindingsList.arity());
    for (OtpErlangObject bindingObject : bindingsList) {
        OtpErlangTuple bindingTuple = getTupleValue(bindingObject);
        String variableName = getAtomText(elementAt(bindingTuple, 0));
        OtpErlangObject variableValue = elementAt(bindingTuple, 1);
        if (variableName == null || variableValue == null)
            return ContainerUtil.emptyList();
        bindings.add(new ElixirVariableBinding(variableName, variableValue));
    }
    return bindings;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with OtpErlangTuple

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

the class ErlangDebuggerEvent method create.

@Nullable
public static ErlangDebuggerEvent create(OtpErlangObject message) {
    if (!(message instanceof OtpErlangTuple))
        return null;
    OtpErlangTuple messageTuple = (OtpErlangTuple) message;
    String messageName = OtpErlangTermUtil.getAtomText(messageTuple.elementAt(0));
    if (messageName == null)
        return null;
    try {
        if (InterpretModulesResponseEvent.NAME.equals(messageName))
            return new InterpretModulesResponseEvent(messageTuple);
        if (SetBreakpointResponseEvent.NAME.equals(messageName))
            return new SetBreakpointResponseEvent(messageTuple);
        if (BreakpointReachedEvent.NAME.equals(messageName))
            return new BreakpointReachedEvent(messageTuple);
        if (DebugRemoteNodeResponseEvent.NAME.equals(messageName))
            return new DebugRemoteNodeResponseEvent(messageTuple);
    } catch (DebuggerEventFormatException e) {
        return new UnknownMessageEvent(messageTuple);
    }
    return new UnknownMessageEvent(messageTuple);
}
Also used : OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with OtpErlangTuple

use of com.ericsson.otp.erlang.OtpErlangTuple 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 4 with OtpErlangTuple

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

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