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;
}
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);
}
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);
}
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;
}
Aggregations