Search in sources :

Example 1 with StatsTreeModel

use of org.erlide.cover.views.model.StatsTreeModel 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)

Aggregations

OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 ArrayList (java.util.ArrayList)1 CoverException (org.erlide.cover.api.CoverException)1 StatsTreeModel (org.erlide.cover.views.model.StatsTreeModel)1 RpcException (org.erlide.runtime.rpc.RpcException)1