use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class ErlOtpExternalReferenceEntryList method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IErlProject erlProject = ErlangEngine.getInstance().getModelUtilService().getProject(this);
final IOtpRpc backend = OtpRpcFactory.getOtpRpcForProject(erlProject);
if (backend != null) {
addExternalEntries(pm, backend);
}
return true;
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class CompileAction method run.
@Override
public void run() {
final AbstractErlangEditor editor = (AbstractErlangEditor) getSite().getPage().getActiveEditor();
final IErlModule module = editor.getModule();
if (module == null) {
return;
}
final IResource resource = module.getResource();
final IProject project = resource.getProject();
if (project == null) {
return;
}
final IErlProject eproject = ErlangEngine.getInstance().getModelUtilService().getProject(module);
if (eproject == null) {
return;
}
final IOtpRpc b = BackendCore.getBuildBackend(eproject);
final BuildResource bres = new BuildResource(resource);
final CompilerOptions prefs = new CompilerOptions(project);
prefs.load();
final OtpErlangList compilerOptions = prefs.export();
final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
if ("erl".equals(resource.getFileExtension())) {
helper.compileErl(project, bres, erlProject.getProperties().getOutputDir().toString(), b, compilerOptions);
}
if ("yrl".equals(resource.getFileExtension())) {
helper.compileYrl(project, bres, b, compilerOptions);
}
final ErlEditorActionBarContributor status = (ErlEditorActionBarContributor) editor.getEditorSite().getActionBarContributor();
status.displayMessage(String.format("File '%s' was compiled.", resource.getName()));
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class AbstractErlContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
final String id = Integer.toHexString(viewer.hashCode()) + "@" + offset;
try {
ErlideEventTracer.getInstance().traceOperationStart("completion", id);
try {
final IDocument doc = viewer.getDocument();
final String before = getBefore(viewer, doc, offset);
String elementBefore;
final IErlElement el = getElementAt(offset);
if (el instanceof ISourceReference) {
final ISourceRange r = ((ISourceReference) el).getSourceRange();
final int o = r.getOffset();
elementBefore = doc.get(o, offset - o);
} else {
elementBefore = null;
}
if (restarted && offset > 0) {
final char last = doc.get(offset - 1, 1).charAt(0);
if (last == ',' || last == '.' || last == ';' || last == ')' || last == '(') {
return null;
}
}
if (Objects.equal(oldDoc, doc) && oldBefore != null && before.startsWith(oldBefore) && oldSuggestions == 0) {
return getNoCompletion(offset);
}
oldDoc = doc;
oldBefore = before;
final CompletionService completionService = ErlangEngine.getInstance().getCompletionService();
List<ICompletionProposal> result = Lists.newArrayList();
if (project != null) {
final IOtpRpc backend = BackendCore.getBuildBackend(project);
final List<CompletionData> resultData = completionService.computeCompletions(backend, project, module, elementBefore, offset, before, isInString());
result = Lists.transform(resultData, new Function<CompletionData, ICompletionProposal>() {
@Override
public ICompletionProposal apply(final CompletionData data) {
return toProposal(data);
}
});
}
final ErlTemplateCompletionProcessor t = new ErlTemplateCompletionProcessor(doc, offset - before.length(), before.length());
result.addAll(Arrays.asList(t.computeCompletionProposals(viewer, offset)));
oldSuggestions = result.size();
if (result.isEmpty()) {
ErlLogger.debug("no results");
return getNoCompletion(offset);
}
// ErlLogger.debug("%d results", result.size());
return result.toArray(new ICompletionProposal[result.size()]);
} catch (final Exception e) {
ErlLogger.warn(e);
return null;
}
} finally {
ErlideEventTracer.getInstance().traceOperationEnd("completion", id);
}
}
use of org.erlide.runtime.rpc.IOtpRpc in project erlide_eclipse by erlang.
the class CodeAssistTest method before.
@BeforeClass
public static void before() {
final IOtpRpc backend = OtpRpcFactory.getOtpRpc();
CodeAssistTest.assist = new ErlideContextAssist(backend);
}
use of org.erlide.runtime.rpc.IOtpRpc 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);
}
Aggregations