use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class BackendUtils method isAccessibleDir.
public static boolean isAccessibleDir(final IOtpRpc backend, final String localDir) {
try {
final OtpErlangObject r = backend.call("file", "read_file_info", "s", localDir);
if (Util.isOk(r)) {
final OtpErlangTuple result = (OtpErlangTuple) r;
final OtpErlangTuple info = (OtpErlangTuple) result.elementAt(1);
final String access = info.elementAt(3).toString();
final int mode = ((OtpErlangLong) info.elementAt(7)).intValue();
return ("read".equals(access) || "read_write".equals(access)) && (mode & 4) == 4;
}
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
} catch (final RpcException e) {
ErlLogger.error(e);
}
return false;
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class ErlideDebug method startDebug.
@SuppressWarnings("boxing")
public static OtpErlangPid startDebug(final IOtpRpc backend, final int debugFlags, OtpErlangPid parentPid) throws DebugException {
OtpErlangObject res = null;
try {
res = backend.call(ErlideDebug.ERLIDE_DEBUG, "start_debug", "i", debugFlags);
} catch (final RpcException e) {
ErlLogger.warn(e);
}
if (res instanceof OtpErlangTuple) {
final OtpErlangTuple t = (OtpErlangTuple) res;
final OtpErlangObject o = t.elementAt(1);
final IStatus s = new Status(IStatus.ERROR, BackendActivator.PLUGIN_ID, DebugException.REQUEST_FAILED, o.toString(), null);
throw new DebugException(s);
}
final OtpErlangPid pid = (OtpErlangPid) res;
// TODO bake in this in start_debug
backend.send(pid, OtpErlang.mkTuple(ErlideDebug.PARENT_ATOM, parentPid));
return pid;
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class ErlideDebug method interpret.
@SuppressWarnings("boxing")
public static boolean interpret(final IOtpRpc backend, final String moduleName, final OtpErlangList options, final boolean distributed, final boolean interpret) {
try {
final OtpErlangObject res = backend.call(ErlideDebug.ERLIDE_DEBUG, "interpret", "alxoo", moduleName, options, distributed, interpret);
if (res instanceof OtpErlangTuple) {
final OtpErlangTuple t = (OtpErlangTuple) res;
final OtpErlangObject o = t.elementAt(0);
if (o instanceof OtpErlangAtom) {
final OtpErlangAtom moduleAtom = (OtpErlangAtom) o;
return "module".equals(moduleAtom.atomValue());
}
}
return Util.isOk(res);
} catch (final RpcException e) {
ErlLogger.warn(e);
}
return false;
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class ErlideDebug method attached.
/**
* Sent upon attach of process (should we move this to erlang, erlide_debug?
* maybe we should have an erlang process subscribing, and even filtering
* events to us)
*
* @param backend
* backend
* @param pid
* pid of attached process
* @param jpid
* java pseudo-pid
* @return pid of meta process
*/
public static OtpErlangPid attached(final IOtpRpc backend, final OtpErlangPid pid, final OtpErlangPid jpid) {
OtpErlangObject res = null;
try {
res = backend.call(ErlideDebug.ERLIDE_DEBUG, "attached", "xx", pid, jpid);
if (res instanceof OtpErlangTuple) {
final OtpErlangTuple t = (OtpErlangTuple) res;
final OtpErlangPid meta = (OtpErlangPid) t.elementAt(1);
return meta;
}
return null;
} catch (final RpcException e) {
ErlLogger.warn(e);
}
return null;
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class ErlideDebug method getAllModulesOnStack.
public static List<String> getAllModulesOnStack(final IOtpRpc backend, final OtpErlangPid meta) {
try {
final OtpErlangObject res = backend.call(ErlideDebug.ERLIDE_DEBUG, "all_modules_on_stack", "x", meta);
if (res instanceof OtpErlangList) {
final OtpErlangList modules = (OtpErlangList) res;
final List<String> result = new ArrayList<>(modules.arity());
for (final OtpErlangObject module : modules) {
final OtpErlangAtom moduleA = (OtpErlangAtom) module;
result.add(moduleA.atomValue());
}
return result;
}
} catch (final RpcException e) {
ErlLogger.warn(e);
ErlLogger.error(e);
}
return null;
}
Aggregations