Search in sources :

Example 21 with RpcException

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

the class OtpNodeProxyTest method nonManagedRuntimeWorks.

@Test
public void nonManagedRuntimeWorks() {
    final RuntimeData data = new RuntimeData(info, "run");
    data.setNodeName(runtime.getNodeName());
    data.setLongName(false);
    data.setCookie("c");
    data.setManaged(false);
    final OtpNodeProxy runtime2 = new OtpNodeProxy(data);
    runtime2.ensureRunning();
    final Process process2 = runtime2.getProcess();
    assertThat(runtime2.isRunning()).isEqualTo(true);
    assertThat(process2).isNull();
    final IOtpRpc site = runtime2.getOtpRpc();
    OtpErlangObject r;
    try {
        r = site.call("erlang", "now", "");
    } catch (final RpcException e) {
        r = null;
    }
    assertThat(r).isNotNull();
    try {
        runtime2.dispose();
    } catch (final Throwable t) {
        ErlLogger.error(t);
    }
    try {
        Thread.sleep(100);
    } catch (final InterruptedException e) {
    }
    expect(runtime2, process2, -1, State.TERMINATED);
    assertThat(runtime.state()).isEqualTo(State.RUNNING);
}
Also used : RuntimeData(org.erlide.runtime.api.RuntimeData) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpNodeProxy(org.erlide.runtime.internal.OtpNodeProxy) RpcException(org.erlide.runtime.rpc.RpcException) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) Test(org.junit.Test)

Example 22 with RpcException

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

the class OtpNodeProxyTest method exitCodeIsDetected.

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

Example 23 with RpcException

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

the class OtpNodeProxyTest method runtimeProcessStartsAndIsAvailableForRpc.

@Test
public void runtimeProcessStartsAndIsAvailableForRpc() {
    int val;
    try {
        val = process.exitValue();
    } catch (final IllegalThreadStateException e) {
        val = -1;
    }
    assertThat(val).isEqualTo(-1);
    assertThat(runtime.isRunning()).isEqualTo(true);
    final IOtpRpc site = runtime.getOtpRpc();
    OtpErlangObject r;
    try {
        r = site.call("erlang", "now", "");
    } catch (final RpcException e) {
        r = null;
    }
    assertThat(r).isNotNull();
    try {
        site.cast("erlang", "halt", "i", 0);
    } catch (final RpcException e1) {
    }
    expect(runtime, process, 0, State.TERMINATED);
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcException(org.erlide.runtime.rpc.RpcException) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) Test(org.junit.Test)

Example 24 with RpcException

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

the class ErlangSearchPage method tryErlangTextSelection.

public SearchPatternData tryErlangTextSelection(final SearchPatternData initData0, final IEditorPart activePart) throws ErlModelException {
    final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) activePart;
    final IErlModule module = erlangEditor.getModule();
    SearchPatternData initData = initData0;
    if (module != null) {
        final ISelection ssel = erlangEditor.getSite().getSelectionProvider().getSelection();
        final ITextSelection textSel = (ITextSelection) ssel;
        final int offset = textSel.getOffset();
        OpenResult res;
        try {
            res = ErlangEngine.getInstance().getOpenService().open(module.getScannerName(), offset, ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module), "", ErlangEngine.getInstance().getModel().getPathVars());
        } catch (final RpcException e) {
            res = null;
        }
        ErlLogger.debug("searchPage(open) " + res);
        initData = determineInitValuesFrom(module, offset, res);
    }
    return initData;
}
Also used : OpenResult(org.erlide.engine.services.search.OpenResult) RpcException(org.erlide.runtime.rpc.RpcException) IErlModule(org.erlide.engine.model.root.IErlModule) ISelection(org.eclipse.jface.viewers.ISelection) ITextSelection(org.eclipse.jface.text.ITextSelection) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 25 with RpcException

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

the class CoveragePerformer method analyse.

/**
 * Perform coverage analysis
 */
@Override
public synchronized void analyse() throws CoverException {
    final List<OtpErlangObject> modules = new ArrayList<>(config.getModules().size());
    for (final IErlModule module : config.getModules()) {
        log.info(module.getModuleName());
        modules.add(new OtpErlangList(module.getModuleName()));
    }
    try {
        CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_ANALYSE, "x", modules);
    } catch (final RpcException e) {
        ErlLogger.error(e);
        throw new CoverException(e.getMessage());
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule)

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