use of org.erlide.backend.api.BackendException in project erlide_eclipse by erlang.
the class DialyzerUtils method doDialyze.
public static void doDialyze(final IProgressMonitor monitor, final Set<IErlModule> modules, final Set<IErlProject> projects, final IBackend backend) throws InvocationTargetException, DialyzerErrorException {
if (backend == null) {
ErlLogger.warn("Trying to dialyze with null backend");
return;
}
try {
for (final IErlModule module : modules) {
DialyzerMarkerUtils.removeDialyzerMarkersFor(module.getResource());
}
// TODO handle preferences from multiple projects
final DialyzerPreferences prefs = DialyzerPreferences.get(null);
final Collection<String> pltPaths = prefs.getPltPaths();
// prefs.getFromSource();
final boolean fromSource = false;
// prefs.getNoCheckPLT();
final boolean noCheckPLT = true;
final List<String> files = Lists.newArrayList();
final List<IPath> includeDirs = Lists.newArrayList();
final List<String> names = Lists.newArrayList();
DialyzerUtils.collectFilesAndIncludeDirs(modules, projects, files, names, includeDirs, fromSource);
if (names.isEmpty()) {
return;
}
final String fileNames = names.size() + " modules [" + DialyzerUtils.getFileNames(names) + "]";
monitor.subTask(fileNames);
ErlLogger.trace("dialyzer", "run %s", fileNames);
final IOtpRpc b = backend.getOtpRpc();
final RpcFuture future = ErlideDialyze.dialyze(b, files, pltPaths, includeDirs, fromSource, noCheckPLT);
while (!future.isDone()) {
// check cancellation
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
// check backend down
if (!backend.isRunning()) {
throw new BackendException("Dialyzer: backend " + backend.getName() + " is down");
}
OtpErlangObject r = null;
try {
r = future.checkedGet(500, TimeUnit.MILLISECONDS);
} catch (final TimeoutException e) {
} catch (final RpcTimeoutException e) {
}
if (r != null) {
DialyzerUtils.processResult(b, r);
}
}
} catch (final RpcException e) {
throw new InvocationTargetException(e);
} catch (final BackendException e) {
throw new InvocationTargetException(e);
}
}
use of org.erlide.backend.api.BackendException in project erlide_eclipse by erlang.
the class AsyncCaller method run.
@Override
public void run() {
final T context = prepare();
try {
final RpcFuture result = call();
if (result == null) {
return;
}
final Job job = new UIJob("async call updater") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
try {
if (result.checkedGet(1, TimeUnit.MILLISECONDS) == null) {
schedule(interval);
}
} catch (final RpcException e) {
ErlLogger.error(e);
} catch (final TimeoutException e) {
ErlLogger.error(e);
}
handleResult(context, result);
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
return new Status(IStatus.OK, ErlideUIPlugin.PLUGIN_ID, "done");
}
};
job.schedule(interval);
} catch (final BackendException e) {
ErlLogger.error(e);
}
}
use of org.erlide.backend.api.BackendException 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));
}
Aggregations