Search in sources :

Example 1 with CoverException

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();
}
Also used : IPath(org.eclipse.core.runtime.IPath) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList)

Example 2 with CoverException

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());
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 3 with CoverException

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());
        }
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) StatsTreeModel(org.erlide.cover.views.model.StatsTreeModel)

Example 4 with CoverException

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());
    }
}
Also used : CoverBackend(org.erlide.cover.core.CoverBackend) CoreException(org.eclipse.core.runtime.CoreException) CoverException(org.erlide.cover.api.CoverException) CoverRunner(org.erlide.cover.core.CoverRunner)

Example 5 with CoverException

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());
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) CoverException(org.erlide.cover.api.CoverException) RpcException(org.erlide.runtime.rpc.RpcException) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

CoverException (org.erlide.cover.api.CoverException)5 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)4 ArrayList (java.util.ArrayList)4 RpcException (org.erlide.runtime.rpc.RpcException)4 IErlModule (org.erlide.engine.model.root.IErlModule)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 CoverBackend (org.erlide.cover.core.CoverBackend)1 CoverRunner (org.erlide.cover.core.CoverRunner)1 StatsTreeModel (org.erlide.cover.views.model.StatsTreeModel)1