Search in sources :

Example 6 with ModuleStats

use of org.erlide.cover.views.model.ModuleStats in project erlide_eclipse by erlang.

the class EditorTracker method addAnnotationsFragment.

/**
 * Makrs coverage of fragment of a file, e.g. of a single function.
 *
 * @param fileName
 * @param start
 * @param end
 */
public void addAnnotationsFragment(final String fileName, final int start, final int end) {
    final IEditorPart currentEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (currentEditor.getTitle().equals(fileName) && currentEditor instanceof ITextEditor && !currentEditor.isDirty()) {
        final ModuleStats module = ModuleSet.get(fileName.replace(".erl", ""));
        if (module == null || !module.couldBeMarked) {
            return;
        }
        final List<LineResult> list = module.getLineResults();
        final ITextEditor editor = (ITextEditor) currentEditor;
        log.info(fileName);
        for (final LineResult lr : list) {
            if (lr.getLineNum() < start || end != -1 && lr.getLineNum() > end) {
                continue;
            }
            if (!coverage.containsAnnotation(fileName, lr)) {
                coverage.addAnnotation(fileName, lr, null);
            }
            markLine(editor, lr);
        }
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) LineResult(org.erlide.cover.views.model.LineResult) IEditorPart(org.eclipse.ui.IEditorPart) ModuleStats(org.erlide.cover.views.model.ModuleStats)

Example 7 with ModuleStats

use of org.erlide.cover.views.model.ModuleStats in project erlide_eclipse by erlang.

the class CoverEventHandler method gotResults.

/**
 * When coverage results came
 *
 * @param msg
 * @return
 */
private boolean gotResults(final OtpErlangObject msg) {
    if (msg instanceof OtpErlangTuple) {
        final OtpErlangTuple resTuple = (OtpErlangTuple) msg;
        if (resTuple.elementAt(0) instanceof OtpErlangAtom && ((OtpErlangAtom) resTuple.elementAt(0)).atomValue().equals(CoverEventHandler.COVER_RES)) {
            final String moduleName = resTuple.elementAt(1).toString();
            String htmlPath = resTuple.elementAt(2).toString();
            htmlPath = htmlPath.substring(1, htmlPath.length() - 1);
            final int allLines = Integer.parseInt(resTuple.elementAt(3).toString());
            final int coveredLines = Integer.parseInt(resTuple.elementAt(4).toString());
            final double percent = Double.parseDouble(resTuple.elementAt(5).toString());
            log.info(String.format("Module %s %s %d %d %f", moduleName, htmlPath, allLines, coveredLines, percent));
            final ModuleStats moduleStats = new ModuleStats();
            moduleStats.setLabel(moduleName);
            moduleStats.setHtmlPath(htmlPath);
            moduleStats.setLiniesCount(allLines);
            moduleStats.setCoverCount(coveredLines);
            try {
                final File file = new File(ErlangEngine.getInstance().getModel().findModule(moduleName).getFilePath());
                moduleStats.setMd5(MD5Checksum.getMD5(file));
            } catch (final Exception e) {
                ErlLogger.error(e);
            }
            // 
            prepLineResults((OtpErlangList) resTuple.elementAt(6), moduleStats);
            prepFuncResults((OtpErlangList) resTuple.elementAt(7), moduleStats);
            addModuleToTree(moduleStats);
            ModuleSet.add(moduleStats);
            return true;
        }
        return false;
    }
    return false;
}
Also used : OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) ModuleStats(org.erlide.cover.views.model.ModuleStats) File(java.io.File)

Aggregations

ModuleStats (org.erlide.cover.views.model.ModuleStats)7 FunctionStats (org.erlide.cover.views.model.FunctionStats)3 LineResult (org.erlide.cover.views.model.LineResult)3 File (java.io.File)2 IEditorPart (org.eclipse.ui.IEditorPart)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1 BrowserDialog (org.erlide.cover.ui.views.util.BrowserDialog)1 ICoverageObject (org.erlide.cover.views.model.ICoverageObject)1 StatsTreeObject (org.erlide.cover.views.model.StatsTreeObject)1