Search in sources :

Example 6 with IOtpRpc

use of org.erlide.runtime.rpc.IOtpRpc 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 7 with IOtpRpc

use of org.erlide.runtime.rpc.IOtpRpc 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 8 with IOtpRpc

use of org.erlide.runtime.rpc.IOtpRpc 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 9 with IOtpRpc

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

the class ErlExternalReferenceEntry method buildStructure.

@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
    if (prebuilt) {
        // already done
        return true;
    }
    final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
    final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
    if (backend != null) {
        final List<String> files = ErlangEngine.getInstance().getOpenService().getLibFiles(path.toPortableString());
        final List<IErlModule> children = Lists.newArrayListWithCapacity(files.size());
        for (final String file : files) {
            if (CommonUtils.isErlangFileContentFileName(getName(file))) {
                children.add(new ErlModule(this, getName(file), file, null, null));
            }
        }
        setChildren(children);
        return true;
    }
    return false;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule) IErlModule(org.erlide.engine.model.root.IErlModule) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 10 with IOtpRpc

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

the class ErlExternalReferenceEntryList method buildStructure.

@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
    // TODO some code duplication within this function
    // ErlLogger.debug("ErlExternalReferenceEntryList.buildStructure %s",
    // getName());
    final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(this);
    final ErlModelCache cache = ErlModelCache.getDefault();
    List<ExternalTreeEntry> externalModuleTree = cache.getExternalTree(externalModules);
    List<ExternalTreeEntry> externalIncludeTree = cache.getExternalTree(externalIncludes);
    if (externalModuleTree == null || externalIncludeTree == null) {
        final OtpErlangList pathVars = ErlangEngine.getInstance().getModel().getPathVars();
        final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(project);
        if (externalModuleTree == null && !externalModules.isEmpty()) {
            if (pm != null) {
                pm.worked(1);
            }
            externalModuleTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalModules, pathVars);
        }
        if (externalIncludeTree == null && !externalIncludes.isEmpty()) {
            if (pm != null) {
                pm.worked(1);
            }
            externalIncludeTree = ErlangEngine.getInstance().getOpenService().getExternalModuleTree(backend, externalIncludes, pathVars);
        }
    }
    setChildren(null);
    final IErlModel model = ErlangEngine.getInstance().getModel();
    if (externalModuleTree != null && !externalModuleTree.isEmpty()) {
        addExternalEntries(pm, externalModuleTree, model, "modules", null, false);
        cache.putExternalTree(externalModules, project, externalModuleTree);
    }
    if (externalIncludeTree != null && !externalIncludeTree.isEmpty() || !projectIncludes.isEmpty()) {
        addExternalEntries(pm, externalIncludeTree, model, "includes", projectIncludes, true);
        if (externalIncludeTree != null) {
            cache.putExternalTree(externalIncludes, project, externalIncludeTree);
        }
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) ErlModelCache(org.erlide.engine.internal.model.cache.ErlModelCache) ExternalTreeEntry(org.erlide.engine.services.search.ExternalTreeEntry) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Aggregations

IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)16 IErlProject (org.erlide.engine.model.root.IErlProject)6 RpcException (org.erlide.runtime.rpc.RpcException)6 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)4 Test (org.junit.Test)4 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)3 IErlModule (org.erlide.engine.model.root.IErlModule)3 DebugException (org.eclipse.debug.core.DebugException)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 IErlModel (org.erlide.engine.model.root.IErlModel)2 OpenResult (org.erlide.engine.services.search.OpenResult)2 AbstractErlangEditor (org.erlide.ui.editors.erl.AbstractErlangEditor)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 Function (com.google.common.base.Function)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 TimeoutException (java.util.concurrent.TimeoutException)1 IProject (org.eclipse.core.resources.IProject)1