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();
}
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);
}
}
}
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;
}
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());
}
}
}
Aggregations