Search in sources :

Example 1 with ErlangFunctionCall

use of org.erlide.util.ErlangFunctionCall in project erlide_eclipse by erlang.

the class NewProcessEvent method execute.

@Override
public void execute(final ErlangDebugTarget debugTarget) {
    final OtpErlangTuple t = (OtpErlangTuple) cmds[1];
    final OtpErlangPid pid = (OtpErlangPid) t.elementAt(0);
    final ErlangProcess erlangProcess = debugTarget.getOrCreateErlangProcess(pid);
    final OtpErlangAtom statusA = (OtpErlangAtom) t.elementAt(2);
    final String status = statusA.atomValue();
    erlangProcess.setStatus(status);
    final OtpErlangTuple initialCall = (OtpErlangTuple) t.elementAt(1);
    erlangProcess.setInitialCall(new ErlangFunctionCall(initialCall));
    erlangProcess.fireCreationEvent();
}
Also used : OtpErlangPid(com.ericsson.otp.erlang.OtpErlangPid) ErlangFunctionCall(org.erlide.util.ErlangFunctionCall) ErlangProcess(org.erlide.backend.debug.model.ErlangProcess) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 2 with ErlangFunctionCall

use of org.erlide.util.ErlangFunctionCall in project erlide_eclipse by erlang.

the class HandleEdocLinksLocationListener method changing.

@Override
public void changing(final LocationEvent event) {
    ErlangBrowserInformationControlInput input = null;
    if (control != null) {
        input = control.getInput();
    } else if (edocView != null) {
        input = edocView.getInput();
    }
    if (input != null) {
        final AbstractErlangEditor editor = input.getEditor();
        String moduleName = "";
        final Object inputElement = input.getInputElement();
        if (inputElement instanceof OpenResult) {
            final OpenResult or = (OpenResult) inputElement;
            moduleName = or.getName();
        }
        final ErlangFunctionCall functionCall = HoverUtil.eventToErlangFunctionCall(moduleName, event);
        if (functionCall != null) {
            final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(editor.getModule());
            if (project == null) {
                return;
            }
            final IOtpRpc backend = BackendCore.getBuildBackend(project);
            final OtpErlangTuple otpDoc = (OtpErlangTuple) ErlangEngine.getInstance().getOtpDocService().getOtpDoc(backend, functionCall);
            if (Util.isOk(otpDoc)) {
                final String docStr = Util.stringValue(otpDoc.elementAt(1));
                final StringBuffer result = new StringBuffer(docStr);
                String docPath = "";
                String anchor = "";
                if (otpDoc.arity() > 4) {
                    docPath = Util.stringValue(otpDoc.elementAt(3));
                    anchor = Util.stringValue(otpDoc.elementAt(4));
                }
                if (result.length() > 0) {
                    final String html = HoverUtil.getHTML(result);
                    final Object element = new OpenResult(otpDoc.elementAt(2));
                    input = new ErlangBrowserInformationControlInput(input, editor, element, html, 20, HoverUtil.getDocumentationURL(docPath, anchor));
                }
            }
        }
    }
    if (input != null) {
        if (control != null) {
            if (control.hasDelayedInputChangeListener()) {
                control.notifyDelayedInputChange(input);
            } else {
                control.setInput(input);
            }
        } else if (edocView != null) {
            edocView.setInfo(input);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlangFunctionCall(org.erlide.util.ErlangFunctionCall) OpenResult(org.erlide.engine.services.search.OpenResult) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 3 with ErlangFunctionCall

use of org.erlide.util.ErlangFunctionCall in project erlide_eclipse by erlang.

the class HoverUtil method eventToErlangFunctionCall.

public static ErlangFunctionCall eventToErlangFunctionCall(final String moduleName0, final LocationEvent event) {
    String moduleName = moduleName0;
    final String location = event.location;
    final int hashPos = location.lastIndexOf('#');
    if (hashPos > 0) {
        String name = location.substring(hashPos + 1);
        final int colonPos = name.lastIndexOf(':');
        if (colonPos > 0) {
            name = name.substring(colonPos + 1);
        }
        final int slashPos = location.lastIndexOf('/');
        final int dotPos = location.lastIndexOf('.');
        if (slashPos > 0 && dotPos > 0) {
            moduleName = location.substring(slashPos + 1, dotPos);
        }
        final int quotePos = moduleName.lastIndexOf('\'');
        if (quotePos >= 0) {
            moduleName = moduleName.substring(quotePos + 1);
        }
        final int minusPos = name.lastIndexOf('-');
        if (minusPos > 0) {
            final String s = name.substring(minusPos + 1);
            name = name.substring(0, minusPos);
            try {
                final int i = Integer.parseInt(s);
                final ErlangFunctionCall erlangFunctionCall = new ErlangFunctionCall(moduleName, name, i);
                ErlLogger.debug("%s", erlangFunctionCall);
                return erlangFunctionCall;
            } catch (final NumberFormatException e) {
            }
        }
    }
    return null;
}
Also used : ErlangFunctionCall(org.erlide.util.ErlangFunctionCall)

Example 4 with ErlangFunctionCall

use of org.erlide.util.ErlangFunctionCall in project erlide_eclipse by erlang.

the class Backend method postLaunch.

protected void postLaunch() throws DebugException {
    final Collection<IProject> projects = Lists.newArrayList(data.getProjects());
    registerProjectsWithExecutionBackend(projects);
    if (data.isDebug()) {
        // add debugTarget
        final ILaunch launch = getData().getLaunch();
        if (!debuggerIsRunning()) {
            debugTarget = new ErlangDebugTarget(launch, this, projects);
            launch.addDebugTarget(debugTarget);
            registerStartupFunctionStarter(data);
            debugTarget.sendStarted();
        }
    } else if (data.isManaged()) {
        // don't run this if the node is already running
        final ErlangFunctionCall initCall = data.getInitialCall();
        if (initCall != null) {
            runInitial(initCall.getModule(), initCall.getName(), initCall.getParameters());
        }
    }
}
Also used : ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) ErlangFunctionCall(org.erlide.util.ErlangFunctionCall) ILaunch(org.eclipse.debug.core.ILaunch) IProject(org.eclipse.core.resources.IProject)

Aggregations

ErlangFunctionCall (org.erlide.util.ErlangFunctionCall)4 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)1 IProject (org.eclipse.core.resources.IProject)1 ILaunch (org.eclipse.debug.core.ILaunch)1 ErlangDebugTarget (org.erlide.backend.debug.model.ErlangDebugTarget)1 ErlangProcess (org.erlide.backend.debug.model.ErlangProcess)1 IErlProject (org.erlide.engine.model.root.IErlProject)1 OpenResult (org.erlide.engine.services.search.OpenResult)1 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)1 AbstractErlangEditor (org.erlide.ui.editors.erl.AbstractErlangEditor)1