use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class EventParser method isEventMessage.
public boolean isEventMessage(final OtpErlangObject msg) {
try {
final OtpErlangTuple tmsg = (OtpErlangTuple) msg;
final OtpErlangObject el0 = tmsg.elementAt(0);
return "event".equals(((OtpErlangAtom) el0).atomValue()) && tmsg.arity() == 4;
} catch (final Exception e) {
return false;
}
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class EventParser method getEventTopic.
private String getEventTopic(final OtpErlangObject msg) {
final OtpErlangTuple tmsg = (OtpErlangTuple) msg;
final Object el0 = tmsg.elementAt(1);
final OtpErlangAtom a = (OtpErlangAtom) el0;
return a.atomValue();
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ErlideOpen method getExternalModuleTree.
@Override
public List<ExternalTreeEntry> getExternalModuleTree(final IOtpRpc backend, final String externalModules, final OtpErlangList pathVars) {
ErlLogger.debug("open:external_module_tree -> " + externalModules);
final Stopwatch stopwatch = Stopwatch.createStarted();
try {
final OtpErlangObject res = backend.call(ErlideOpen.ERLIDE_OPEN, "get_external_module_tree", "x", mkContext(externalModules, null, pathVars, null, null));
if (Util.isOk(res)) {
OtpErlangTuple t = (OtpErlangTuple) res;
final OtpErlangList l = (OtpErlangList) t.elementAt(1);
final List<ExternalTreeEntry> result = Lists.newArrayListWithCapacity(l.arity());
for (final OtpErlangObject i : l) {
t = (OtpErlangTuple) i;
final String parentPath = Util.stringValue(t.elementAt(0));
final String path = Util.stringValue(t.elementAt(1));
final OtpErlangAtom isModuleA = (OtpErlangAtom) t.elementAt(2);
result.add(new ExternalTreeEntry(new Path(parentPath), new Path(path), "module".equals(isModuleA.atomValue())));
}
final String msg = "open:external_module_tree <- " + stopwatch;
if (stopwatch.elapsed(TimeUnit.SECONDS) > 5) {
ErlLogger.warn("WARNING " + msg);
} else {
ErlLogger.debug(msg);
}
return result;
}
} catch (final RpcException e) {
ErlLogger.warn("open:external_module_tree TIMEOUT <- " + stopwatch);
ErlLogger.warn(e);
}
return Lists.newArrayList();
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class ErlideOpen method mkContext.
@Override
public OtpErlangTuple mkContext(final String externalModules, final String externalIncludes, final OtpErlangList pathVars, final Collection<IPath> extraSourcePaths, final Collection<OtpErlangObject> imports) {
final OtpErlangAtom tag = new OtpErlangAtom("open_context");
final OtpErlangAtom UNDEFINED = new OtpErlangAtom("undefined");
final List<OtpErlangObject> result = Lists.newArrayList();
// order must match definition of #open_context !
// TODO use a proplist instead?
result.add(tag);
result.add(externalModules != null ? new OtpErlangString(externalModules) : UNDEFINED);
result.add(externalIncludes != null ? new OtpErlangString(externalIncludes) : UNDEFINED);
result.add(pathVars != null ? pathVars : UNDEFINED);
result.add(extraSourcePaths != null ? OtpErlang.mkStringList(extraSourcePaths) : UNDEFINED);
result.add(imports != null ? OtpErlang.mkList(imports) : UNDEFINED);
return new OtpErlangTuple(result.toArray(new OtpErlangObject[] {}));
}
use of com.ericsson.otp.erlang.OtpErlangAtom in project erlide_eclipse by erlang.
the class BeamLoader method loadBeam.
public static boolean loadBeam(final IOtpRpc backend, final String moduleName, final OtpErlangBinary bin) {
OtpErlangObject r = null;
try {
r = backend.call("code", "is_sticky", "a", moduleName);
// TODO handle sticky directories
if (!((OtpErlangAtom) r).booleanValue()) {
r = backend.call("code", "load_binary", "asb", moduleName, moduleName + ".erl", bin);
} else {
ErlLogger.warn("sticky:: %s", moduleName);
r = null;
}
} catch (final Exception e) {
ErlLogger.warn(e);
}
if (r instanceof OtpErlangTuple) {
final OtpErlangTuple t = (OtpErlangTuple) r;
if (((OtpErlangAtom) t.elementAt(0)).atomValue().compareTo("module") == 0) {
return true;
}
}
// binary couldn't be extracted
ErlLogger.error("Could not load " + moduleName + ": " + r);
return false;
}
Aggregations