Search in sources :

Example 6 with RpcException

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;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 7 with RpcException

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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) DebugException(org.eclipse.debug.core.DebugException)

Example 8 with RpcException

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;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 9 with RpcException

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;
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 10 with RpcException

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;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Aggregations

RpcException (org.erlide.runtime.rpc.RpcException)37 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)30 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)15 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)12 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)8 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)7 ArrayList (java.util.ArrayList)7 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)6 RpcFuture (org.erlide.runtime.rpc.RpcFuture)5 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)4 TimeoutException (java.util.concurrent.TimeoutException)4 CoverException (org.erlide.cover.api.CoverException)4 IErlModule (org.erlide.engine.model.root.IErlModule)4 RpcTimeoutException (org.erlide.runtime.rpc.RpcTimeoutException)4 Test (org.junit.Test)4 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)3 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)3 IPath (org.eclipse.core.runtime.IPath)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3