Search in sources :

Example 31 with RpcException

use of org.erlide.runtime.rpc.RpcException 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();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) Stopwatch(com.google.common.base.Stopwatch) ExternalTreeEntry(org.erlide.engine.services.search.ExternalTreeEntry) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 32 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class ErlideOpen method getOtpLibStructure.

@Override
public OtpErlangList getOtpLibStructure(final IOtpRpc backend) {
    try {
        final OtpErlangObject res = backend.call(ErlideOpen.ERLIDE_OPEN, "get_otp_lib_structure", "s", stateDir);
        if (Util.isOk(res)) {
            final OtpErlangTuple tres = (OtpErlangTuple) res;
            final OtpErlangList lot = (OtpErlangList) tres.elementAt(1);
            return lot;
        }
        ErlLogger.error(res.toString());
    } catch (final RpcException 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) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 33 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class ErlideOpen method getIncludesInDir.

@Override
public Collection<String> getIncludesInDir(final String directory) {
    try {
        final OtpErlangObject res = ideBackend.call(ErlideOpen.ERLIDE_OPEN, "get_includes_in_dir", "s", directory);
        if (Util.isOk(res)) {
            final OtpErlangTuple t = (OtpErlangTuple) res;
            final OtpErlangList l = (OtpErlangList) t.elementAt(1);
            final List<String> result = Lists.newArrayListWithCapacity(l.arity());
            for (final OtpErlangObject object : l) {
                result.add(Util.stringValue(object));
            }
            return result;
        }
    } catch (final RpcException 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) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 34 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class TraceBackend method loadFile.

/**
 * Loads information about given file.
 *
 * @param path
 *            path
 */
public void loadFile(final String path) {
    if (!tracing && !loading) {
        synchronized (this) {
            if (!tracing && !loading) {
                try {
                    loading = true;
                    loadingFileInfo = true;
                    handler = new TraceEventHandler();
                    getBackend(true);
                    tracerBackend.getRuntime().registerEventListener(handler);
                    tracerBackend.getOtpRpc().call(Constants.ERLANG_HELPER_MODULE, TraceBackend.FUN_FILE_INFO, "s", new OtpErlangString(path));
                } catch (final RpcException e) {
                    ErlLogger.error(e);
                    errorObject = e;
                    finishLoading(TracingStatus.EXCEPTION_THROWN);
                }
            }
        }
    }
}
Also used : RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 35 with RpcException

use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.

the class OtpNodeProxyTest method shutdownIsDetected.

@Test
public void shutdownIsDetected() {
    final IOtpRpc site = runtime.getOtpRpc();
    try {
        site.cast("erlang", "halt", "i", 0);
    } catch (final RpcException e1) {
    }
    expect(runtime, process, 0, State.TERMINATED);
}
Also used : RpcException(org.erlide.runtime.rpc.RpcException) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) Test(org.junit.Test)

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