use of org.erlide.cover.api.CoverException 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.cover.api.CoverException 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.cover.api.CoverException 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());
}
}
}
use of org.erlide.cover.api.CoverException in project erlide_eclipse by erlang.
the class CoverLaunchConfigurationDelegate method launch.
@Override
public void launch(final ILaunchConfiguration config, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
try {
super.launch(config, mode, launch, monitor);
CoverLaunchData coverData;
coverData = new CoverLaunchData(config);
final CoverBackend coverBackend = CoverBackend.getInstance();
coverBackend.setBackend(backend);
coverBackend.initialize(coverData);
coverBackend.runCoverageAnalysis(new CoverRunner());
} catch (final CoreException e) {
ErlLogger.error(e);
} catch (final CoverException e) {
if (CoverBackend.getInstance().getListeners().isEmpty()) {
throw new RuntimeException(e.getMessage());
}
CoverBackend.getInstance().handleError(e.getMessage());
}
}
use of org.erlide.cover.api.CoverException in project erlide_eclipse by erlang.
the class CoveragePerformer method analyse.
/**
* Perform coverage analysis
*/
@Override
public synchronized void analyse() throws CoverException {
final List<OtpErlangObject> modules = new ArrayList<>(config.getModules().size());
for (final IErlModule module : config.getModules()) {
log.info(module.getModuleName());
modules.add(new OtpErlangList(module.getModuleName()));
}
try {
CoverBackend.getInstance().getBackend().getOtpRpc().call(CoverConstants.COVER_ERL_BACKEND, CoverConstants.FUN_ANALYSE, "x", modules);
} catch (final RpcException e) {
ErlLogger.error(e);
throw new CoverException(e.getMessage());
}
}
Aggregations