use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.
the class ConsoleTerminateAction method run.
@Override
public void run() {
try {
final IBackend backend = fConsole.getBackend();
final ILaunch launch = backend.getData().getLaunch();
if (launch != null) {
terminate(launch);
final Collection<IProject> projects = Lists.newArrayList(backend.getData().getProjects());
final IBackendManager backendManager = BackendCore.getBackendManager();
for (final IProject project : projects) {
backendManager.removeExecutionBackend(project, backend);
}
setEnabled(false);
fConsole.stop();
}
if (!backend.equals(BackendCore.getBackendManager().getIdeBackend())) {
backend.dispose();
}
} catch (final DebugException e) {
ErlLogger.error(e);
}
}
use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.
the class BackendLabelProvider method getText.
@Override
public String getText(final Object element) {
final IBackend b = (IBackend) element;
final BackendData data = b.getData();
final RuntimeInfo info = data.getRuntimeInfo();
final String s = info != null ? info.getName() : "<none>";
return s + ": " + data.getNodeName();
}
use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.
the class InternalBuilder method handleErlangFiles.
private void handleErlangFiles(final IErlProject erlProject, @NonNull final IProject project, final BuildKind kind, final IResourceDelta resourceDelta, final BuildNotifier notifier) throws CoreException, BackendException {
final OtpErlangList compilerOptions = CompilerOptions.get(project);
final Set<BuildResource> resourcesToBuild = getResourcesToBuild(kind, project, resourceDelta, notifier);
final int n = resourcesToBuild.size();
if (n == 0) {
return;
}
if (erlProject == null) {
return;
}
// if (BuilderHelper.isDebugging()) {
ErlLogger.debug("Will compile %d resource(s)", n);
// }
final IBackend backend = BackendCore.getBackendManager().getBuildBackend(erlProject);
if (backend == null) {
final String message = "No backend with the required " + "version could be found. Can't build.";
MarkerUtils.createProblemMarker(project, null, message, 0, IMarker.SEVERITY_ERROR);
throw new BackendException(message);
}
final IErlModel model = ErlangEngine.getInstance().getModel();
backend.addProjectPath(model.findProject(project));
notifier.setProgressPerCompilationUnit(1.0f / n);
final Map<RpcFuture, IResource> results = new HashMap<>();
for (final BuildResource bres : resourcesToBuild) {
notifier.checkCancel();
final IResource resource = bres.getResource();
MarkerUtils.deleteMarkers(resource);
notifier.aboutToCompile(resource);
if ("erl".equals(resource.getFileExtension())) {
final String outputDir = erlProject.getProperties().getOutputDir().toString();
final RpcFuture f = helper.startCompileErl(project, bres, outputDir, backend.getOtpRpc(), compilerOptions, kind == BuildKind.FULL);
if (f != null) {
results.put(f, resource);
}
} else if ("yrl".equals(resource.getFileExtension())) {
final RpcFuture f = helper.startCompileYrl(project, resource, backend.getOtpRpc(), compilerOptions);
if (f != null) {
results.put(f, resource);
}
} else {
ErlLogger.warn("Don't know how to compile: %s", resource.getName());
}
}
final List<Entry<RpcFuture, IResource>> done = Lists.newArrayList();
final List<Entry<RpcFuture, IResource>> waiting = Lists.newArrayList(results.entrySet());
// TODO should use some kind of notification!
while (!waiting.isEmpty()) {
for (final Entry<RpcFuture, IResource> result : waiting) {
notifier.checkCancel();
OtpErlangObject r;
try {
r = result.getKey().get(100, TimeUnit.MILLISECONDS);
} catch (final Exception e) {
r = null;
}
if (r != null) {
final IResource resource = result.getValue();
helper.completeCompile(project, resource, r, backend.getOtpRpc(), compilerOptions);
notifier.compiled(resource);
done.add(result);
}
}
waiting.removeAll(done);
done.clear();
}
helper.refreshOutputDir(project);
try {
helper.checkForClashes(backend.getOtpRpc(), project);
} catch (final Exception e) {
}
backend.removeProjectPath(model.findProject(project));
}
use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.
the class BackendFactory method createBuildBackend.
@Override
public synchronized IBackend createBuildBackend(final RuntimeInfo info) {
ErlLogger.debug("Create build backend " + info.getVersion().asMajor().toString());
final IBackend backend = createBackend(getBuildBackendData(info));
return backend;
}
use of org.erlide.backend.api.IBackend in project erlide_eclipse by erlang.
the class BackendManager method getByProject.
@Override
public IOtpRpc getByProject(final String projectName) {
final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
if (erlProject == null) {
return null;
}
final IBackend backend = getBuildBackend(erlProject);
if (backend == null) {
ErlLogger.warn("Could not find backend for project %s", project);
return null;
}
return backend.getOtpRpc();
}
Aggregations