Search in sources :

Example 11 with IOtpRpc

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;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 12 with IOtpRpc

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()));
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) IErlModule(org.erlide.engine.model.root.IErlModule) CompilerOptions(org.erlide.core.builder.CompilerOptions) ErlEditorActionBarContributor(org.erlide.ui.editors.erl.ErlEditorActionBarContributor) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) BuildResource(org.erlide.core.builder.BuildResource) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 13 with IOtpRpc

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);
    }
}
Also used : ErlTemplateCompletionProcessor(org.erlide.ui.templates.ErlTemplateCompletionProcessor) ErlModelException(org.erlide.engine.model.ErlModelException) BadLocationException(org.eclipse.jface.text.BadLocationException) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) IErlElement(org.erlide.engine.model.IErlElement) CompletionData(org.erlide.engine.services.codeassist.CompletionData) FunctionCompletionData(org.erlide.engine.services.codeassist.FunctionCompletionData) Function(com.google.common.base.Function) CompletionService(org.erlide.engine.services.codeassist.CompletionService) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) ISourceReference(org.erlide.engine.model.erlang.ISourceReference) IDocument(org.eclipse.jface.text.IDocument) ISourceRange(org.erlide.engine.model.erlang.ISourceRange)

Example 14 with IOtpRpc

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);
}
Also used : ErlideContextAssist(org.erlide.engine.internal.services.codeassist.ErlideContextAssist) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) BeforeClass(org.junit.BeforeClass)

Example 15 with IOtpRpc

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);
}
Also used : RpcException(org.erlide.runtime.rpc.RpcException) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc) Test(org.junit.Test)

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