Search in sources :

Example 6 with IBackend

use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.

the class BackendManager method getBuildBackend.

@SuppressWarnings("null")
@Override
public IBackend getBuildBackend(@NonNull final IErlProject project) {
    final RuntimeInfo info = project.getRuntimeInfo();
    if (info == null) {
        ErlLogger.info("Project %s has no runtime info, using ide", project.getName());
        return getIdeBackend();
    }
    final String version = info.getVersion().asMajor().toString();
    IBackend b = buildBackends.get(version);
    if (b == null) {
        b = factory.createBuildBackend(info);
        buildBackends.put(version, b);
        addBackend(b);
        notifyBackendChange(b, BackendEvent.ADDED, null, null);
    }
    return b;
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) IBackend(org.erlide.backend.api.IBackend)

Example 7 with IBackend

use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.

the class InternalBuilder method fillAppFileDetails.

private void fillAppFileDetails(final IProject project, final String appSrc, final String destPath, final Collection<String> modules) {
    try {
        final IErlProject eproject = ErlangEngine.getInstance().getModel().findProject(project);
        if (eproject == null) {
            return;
        }
        final IBackend backend = BackendCore.getBackendManager().getBuildBackend(eproject);
        backend.getOtpRpc().call("erlide_builder", "compile_app_src", "ssla", appSrc, destPath, modules);
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackend(org.erlide.backend.api.IBackend) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) BackendException(org.erlide.backend.api.BackendException)

Example 8 with IBackend

use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.

the class BuilderHelper method loadModule.

public static void loadModule(@NonNull final IProject project, final String module) {
    try {
        final IBackendManager backendManager = BackendCore.getBackendManager();
        for (final IBackend b : backendManager.getExecutionBackends(project)) {
            ErlLogger.debug(":: loading %s in %s", module, b.getName());
            final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
            final IPath path = project.getLocation().append(erlProject.getProperties().getOutputDir()).append(module + ".beam");
            boolean ok = false;
            final OtpErlangBinary bin = BeamUtil.getBeamBinary(module, path);
            if (bin != null) {
                ok = BeamLoader.loadBeam(b.getOtpRpc(), module, bin);
            }
            if (!ok) {
                ErlLogger.error("Could not load %s", module);
            }
            backendManager.moduleLoaded(b, project, module);
        }
    } catch (final Exception e) {
        ErlLogger.debug(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackendManager(org.erlide.backend.api.IBackendManager) IPath(org.eclipse.core.runtime.IPath) IBackend(org.erlide.backend.api.IBackend) OtpErlangBinary(com.ericsson.otp.erlang.OtpErlangBinary) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) RpcException(org.erlide.runtime.rpc.RpcException)

Example 9 with IBackend

use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.

the class DialyzerBuilder method build.

public void build(final BuildNotifier notifier) throws CoreException {
    if (project == null) {
        return;
    }
    DialyzerPreferences prefs = null;
    prefs = DialyzerPreferences.get(project);
    if (prefs == null || !prefs.getDialyzeOnCompile()) {
        return;
    }
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final Set<IErlModule> modules = DialyzerUtils.collectModulesFromResource(model, project);
    final Set<IErlProject> projects = Sets.newHashSet();
    projects.add(model.findProject(project));
    DialyzerMarkerUtils.removeDialyzerMarkersFor(project);
    if (!modules.isEmpty()) {
        try {
            final IErlProject eproject = model.findProject(project);
            if (eproject == null) {
                return;
            }
            final IBackend backend = BackendCore.getBackendManager().getBuildBackend(eproject);
            DialyzerUtils.doDialyze(notifier.monitor, modules, projects, backend);
        } catch (final InvocationTargetException e) {
            ErlLogger.error(e);
        } catch (final DialyzerErrorException e) {
            ErlLogger.error(e);
            final String msg = NLS.bind(BuilderMessages.build_dialyzerProblem, e.getLocalizedMessage());
            DialyzerMarkerUtils.addProblemMarker(project, null, null, msg, 0, IMarker.SEVERITY_ERROR);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IBackend(org.erlide.backend.api.IBackend) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) DialyzerPreferences(org.erlide.dialyzer.builder.DialyzerPreferences) InvocationTargetException(java.lang.reflect.InvocationTargetException) DialyzerErrorException(org.erlide.dialyzer.builder.DialyzerUtils.DialyzerErrorException)

Example 10 with IBackend

use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.

the class SendToConsoleAction method getConsole.

private IErlangConsole getConsole(@NonNull final IProject aproject) {
    final IBackendManager backendManager = BackendCore.getBackendManager();
    final Set<IBackend> executionBackends = backendManager.getExecutionBackends(aproject);
    final ErlConsoleManager erlConsoleManager = ErlideUIPlugin.getDefault().getErlConsoleManager();
    IErlangConsole result = null;
    for (final IBackend backend : executionBackends) {
        result = erlConsoleManager.getConsole(backend);
        if (result != null) {
            break;
        }
    }
    return result;
}
Also used : IBackendManager(org.erlide.backend.api.IBackendManager) IBackend(org.erlide.backend.api.IBackend) IErlangConsole(org.erlide.ui.console.IErlangConsole) ErlConsoleManager(org.erlide.ui.console.ErlConsoleManager)

Aggregations

IBackend (org.erlide.backend.api.IBackend)25 IBackendManager (org.erlide.backend.api.IBackendManager)6 CoreException (org.eclipse.core.runtime.CoreException)4 IErlProject (org.erlide.engine.model.root.IErlProject)4 RuntimeInfo (org.erlide.runtime.runtimeinfo.RuntimeInfo)4 BackendData (org.erlide.backend.api.BackendData)3 ErlModelException (org.erlide.engine.model.ErlModelException)3 IErlModel (org.erlide.engine.model.root.IErlModel)3 HashSet (java.util.HashSet)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 ILaunch (org.eclipse.debug.core.ILaunch)2 BackendException (org.erlide.backend.api.BackendException)2 RpcException (org.erlide.runtime.rpc.RpcException)2 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1