use of org.erlide.runtime.rpc.RpcException 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.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class BuilderHelper method compileErl.
public void compileErl(@NonNull final IProject project, final BuildResource resource, final String outputDir, final IOtpRpc b, final OtpErlangList compilerOptions) {
final RpcFuture res = startCompileErl(project, resource, outputDir, b, compilerOptions, true);
if (res == null) {
ErlLogger.warn("error compiling erl file: " + resource.getResource().getProjectRelativePath());
return;
}
try {
final OtpErlangObject result = res.checkedGet();
completeCompile(project, resource.getResource(), result, b, compilerOptions);
} catch (final RpcException e) {
ErlLogger.warn(e);
}
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class CoveragePerformer method setCoverageConfiguration.
/**
* Set coverage configuration
*/
@Override
public synchronized void setCoverageConfiguration(final IConfiguration conf) throws CoverException {
config = conf;
StatsTreeModel.getInstance().setRootLabel(config.getProject().getName());
final IPath ppath = config.getProject().getWorkspaceProject().getLocation();
// set include files
final List<OtpErlangObject> includes = new ArrayList<>(config.getModules().size());
for (final IPath include : config.getIncludeDirs()) {
log.info(ppath.append(include));
includes.add(new OtpErlangList(ppath.append(include).toString()));
}
try {
CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_SET_INCLUDES, "x", includes);
} catch (final RpcException e1) {
e1.printStackTrace();
throw new CoverException(e1);
}
recompileModules();
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class CoveragePerformer method recompileModules.
// cover compilation of chosen modules
private void recompileModules() throws CoverException {
final List<OtpErlangObject> paths = new ArrayList<>(config.getModules().size());
for (final IErlModule module : config.getModules()) {
if (module == null) {
final String msg = "No such module at given project. Check your configuration";
CoverBackend.getInstance().handleError(msg);
throw new CoverException(msg);
}
log.info(module.getFilePath());
paths.add(new OtpErlangList(module.getFilePath()));
}
try {
CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_PREP, "x", paths);
} catch (final RpcException e) {
ErlLogger.error(e);
throw new CoverException(e.getMessage());
}
}
use of org.erlide.runtime.rpc.RpcException in project erlide_eclipse by erlang.
the class CoveragePerformer method startCover.
/**
* Start cover
*/
@Override
public synchronized void startCover(final Collection<String> nodes) throws CoverException {
final StatsTreeModel model = StatsTreeModel.getInstance();
model.clear();
if (CoverBackend.getInstance().getAnnotationMaker() != null) {
CoverBackend.getInstance().getAnnotationMaker().clearAllAnnotations();
}
for (final ICoverObserver obs : CoverBackend.getInstance().getListeners()) {
obs.eventOccured(new CoverEvent(CoverStatus.UPDATE));
}
boolean different = false;
for (final String node : nodes) {
if (!coverNodes.contains(node)) {
different = true;
break;
}
}
if (coverNodes.isEmpty() || different) {
coverNodes = nodes;
log.info(CoverBackend.getInstance().getBackend().getName());
coverNodes.add(CoverBackend.getInstance().getBackend().getName());
// TODO restarting
final List<OtpErlangObject> names = new ArrayList<>(coverNodes.size());
for (final String name : coverNodes) {
names.add(new OtpErlangAtom(name));
}
final OtpErlangList nodesList = new OtpErlangList(names.toArray(new OtpErlangObject[0]));
try {
CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_START, "x", nodesList);
} catch (final RpcException e) {
ErlLogger.error(e);
throw new CoverException(e.getMessage());
}
}
}
Aggregations