use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ProcessHelper method getProcsOnTracedNodes.
/**
* Returns list of processes on all traced nodes.
*
* @return list of processes
*/
public static TracedProcess[] getProcsOnTracedNodes() {
try {
final IOtpRpc backend = TraceBackend.getInstance().getBackend(true).getOtpRpc();
final List<OtpErlangAtom> nodeAtoms = new ArrayList<>();
for (final Object o : TraceBackend.getInstance().getTracedNodesArray()) {
final TracedNode tracedNode = (TracedNode) o;
if (tracedNode.isEnabled()) {
nodeAtoms.add(new OtpErlangAtom(tracedNode.getNodeName()));
}
}
final OtpErlangList nodesList = new OtpErlangList(nodeAtoms.toArray(new OtpErlangAtom[nodeAtoms.size()]));
final OtpErlangList procList = (OtpErlangList) backend.call(ProcessHelper.MODULE_NAME, ProcessHelper.FUNCTION_NAME, "x", nodesList);
final TracedProcess[] processes = new TracedProcess[procList.arity()];
for (int i = 0; i < procList.arity(); i++) {
final OtpErlangTuple tuple = (OtpErlangTuple) procList.elementAt(i);
processes[i] = new TracedProcess(tuple);
}
return processes;
} catch (final RpcException e) {
ErlLogger.error(e);
}
return null;
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class TestResultsView method handleEvent.
private void handleEvent(final OtpErlangObject msg) throws OtpParserException, OtpErlangException {
final OtpErlangTuple tuple = (OtpErlangTuple) msg;
final String tag = ((OtpErlangAtom) tuple.elementAt(0)).atomValue();
final OtpErlangObject value = tuple.elementAt(1);
TestCaseData test;
if ("init".equals(tag)) {
// value = {Dir, Suite, Case}
label.setText("Started: " + formatTitle(value) + ". Compiling files, please wait...");
treeViewer.getTree().setCursor(treeViewer.getTree().getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
} else if ("start_failed".equals(tag)) {
// value = ?
} else if ("log_started".equals(tag)) {
// value = Dir
treeViewer.getTree().setCursor(treeViewer.getTree().getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
} else if ("start".equals(tag)) {
// value = {Module, Function}
final OtpBindings bindings = OtpErlang.match("{M:a,F:a}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
test = findCase(mod, fun);
test.setRunning();
} else if ("result".equals(tag)) {
// value = {Module, Function, Result}
final OtpBindings bindings = OtpErlang.match("{M:a,F:a,R}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final OtpErlangObject result = bindings.get("R");
test = findCase(mod, fun);
if (result instanceof OtpErlangAtom) {
test.setSuccesful();
// } else {
// final BindingsImpl bindings =
// OtpErlang.match("{failure,{M:a,F:a},L,R}", result);
// final OtpErlangObject locations = bindings.get("L");
// final OtpErlangObject reason = bindings.get("R");
// test.setFailed(reason, locations);
}
} else if ("fail".equals(tag)) {
// value = {{Module, Function}, [Locations], Reason
final OtpBindings bindings = OtpErlang.match("{{M:a,F:a},L,R}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final Collection<OtpErlangObject> locations = bindings.getList("L");
final OtpErlangObject reason = bindings.get("R");
test = findCase(mod, fun);
test.setFailed(reason, locations);
} else if ("skip".equals(tag)) {
// value = {Module, Function, Comment
final OtpBindings bindings = OtpErlang.match("{M:a,F:a,C}", value);
final String mod = bindings.getAtom("M");
final String fun = bindings.getAtom("F");
final OtpErlangObject reason = bindings.get("C");
test = findCase(mod, fun);
test.setSkipped(reason);
} else if ("done".equals(tag)) {
// value = Module, Log, {Successful,Failed,Skipped}, [Results]}
final OtpBindings bindings = OtpErlang.match("{M,L,{S:i,F:i,K:i},R}", value);
final int successful = bindings.getInt("S");
final int failed = bindings.getInt("F");
final int skipped = bindings.getInt("K");
label.setText(label.getText() + " -- Done! Successful: " + successful + ", Failed: " + failed + ", Skipped: " + skipped);
}
control.redraw();
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ModelUtilsTest method getImportsAsListTest.
@Test
public void getImportsAsListTest() throws Exception {
// given
// an Erlang module with imports
final IErlModule moduleA = ErlideTestUtils.createModule(ModelUtilsTest.projects[0], "ax.erl", "-module(ax).\n-import(lists, [reverse/1, foldl/3].\n");
moduleA.open(null);
// when
// fetching imports as list of OtpErlangTuple
final Collection<IErlElement> children = moduleA.getChildren();
final Collection<IErlImport> imports2 = moduleA.getImports();
final List<OtpErlangObject> imports = modelUtilService.getImportsAsList(moduleA);
// then
// they should be returned
assertEquals(2, children.size());
assertEquals(1, imports2.size());
assertEquals(1, imports.size());
final OtpErlangAtom listAtom = new OtpErlangAtom("lists");
assertEquals(new OtpErlangTuple(new OtpErlangObject[] { listAtom, new OtpErlangList(new OtpErlangObject[] { makeTuple2("reverse", 1), makeTuple2("foldl", 3) }) }), imports.get(0));
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_sig_a.
@Test
public void testMatch_sig_a() throws Exception {
final OtpBindings r = OtpErlang.match("W:a", "zzz");
Assert.assertEquals(r.get("W"), new OtpErlangAtom("zzz"));
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class PatternMatchTest method testMatch_same.
@Test
public void testMatch_same() throws Exception {
final OtpBindings r = OtpErlang.match("[W, {V}]", "[a, {a}]");
Assert.assertEquals(r.get("W"), new OtpErlangAtom("a"));
}
Aggregations