use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class ErlangCode method isEmbedded.
public static boolean isEmbedded(final IOtpRpc backend) {
try {
final OtpErlangObject r = backend.call(ErlangCode.CODE, "ensure_loaded", "a", "funny_module_name_that_nobody_would_use");
final OtpBindings b = OtpErlang.match("{error, What}", r);
if ("embedded".equals(b.getAtom("What"))) {
return true;
}
} catch (final Exception e) {
// ignore errors
}
return false;
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class ErlangProcess method addStackTrace.
private void addStackTrace(final OtpErlangTuple savedStackTrace) {
try {
final OtpBindings bind = OtpErlang.match("{saved_stacktrace, _,STrace}", savedStackTrace);
if (bind != null) {
final Collection<OtpErlangObject> trace = bind.getList("STrace");
for (final OtpErlangObject oframe : trace) {
final OtpErlangTuple frame = (OtpErlangTuple) oframe;
final OtpErlangAtom m = (OtpErlangAtom) frame.elementAt(0);
final OtpErlangAtom f = (OtpErlangAtom) frame.elementAt(1);
final OtpErlangLong a = (OtpErlangLong) frame.elementAt(2);
try {
stackFrames.add(new ErlangUninterpretedStackFrame(m.atomValue(), new ErlangFunction(f.atomValue(), a.intValue()), this, getDebugTarget()));
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
}
}
}
} catch (final OtpParserException e1) {
// ignore
ErlLogger.error(e1);
} catch (final OtpErlangException e1) {
ErlLogger.error(e1);
}
}
use of org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class ErlangXref method functionUse.
@SuppressWarnings("boxing")
public FunctionRef[] functionUse(final String mod, final String fun, final int arity) {
try {
final OtpErlangObject r = backend.call(ErlangXref.ERLIDE_XREF, "function_use", "aai", mod.substring(0, mod.length() - 4), fun, arity);
final OtpBindings bind = OtpErlang.match("{ok, L}", r);
if (bind == null) {
return new FunctionRef[0];
}
final OtpErlangList l = (OtpErlangList) bind.get("L");
final List<FunctionRef> result = new ArrayList<>();
for (final OtpErlangObject e : l) {
result.add(new FunctionRef(e));
}
return result.toArray(new FunctionRef[result.size()]);
} catch (final Exception e) {
ErlLogger.debug(e);
}
return null;
}
use of org.erlide.util.erlang.OtpBindings 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 org.erlide.util.erlang.OtpBindings in project erlide_eclipse by erlang.
the class TestResultsView method formatTitle.
private String formatTitle(final OtpErlangObject value) {
try {
final OtpBindings b = OtpErlang.match("{D,S,C}", value);
final String suite = b.getAtom("S");
final String tcase = b.getAtom("C");
if (tcase.isEmpty()) {
return "suite " + suite;
}
return "suite " + suite + "; case " + tcase;
} catch (final OtpParserException e) {
} catch (final OtpErlangException e) {
}
return value.toString();
}
Aggregations