Search in sources :

Example 1 with ModuleStats

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

the class HideCoverageAction method perform.

@Override
protected void perform(final StatsTreeObject selection) {
    if (selection instanceof ModuleStats) {
        final ModuleStats module = (ModuleStats) selection;
        final String name = module.getLabel() + ".erl";
        marker.removeAnnotationsFromFile(name);
    } else if (selection instanceof FunctionStats) {
        final FunctionStats fs = (FunctionStats) selection;
        final ModuleStats module = (ModuleStats) fs.getParent();
        final String name = module.getLabel() + ".erl";
        log.info(fs.getLineStart());
        log.info(fs.getLineEnd());
        marker.removeAnnotationsFragment(name, fs.getLineStart(), fs.getLineEnd());
    } else {
        marker.clearAllAnnotations();
    }
}
Also used : FunctionStats(org.erlide.cover.views.model.FunctionStats) ModuleStats(org.erlide.cover.views.model.ModuleStats)

Example 2 with ModuleStats

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

the class HtmlReportAction method run.

@Override
public void run() {
    log.info("html report!");
    if (StatsTreeModel.getInstance().getRoot().getHtmlPath() == null) {
        final IPath location = Activator.getDefault().getStateLocation().append(CoverConstants.REPORT_DIR);
        final File dir = location.toFile();
        if (!dir.exists() && !dir.mkdir()) {
            CoverageHelper.reportError("Can not save results!");
            return;
        }
        generateReportTree(StatsTreeModel.getInstance().getRoot(), dir.getAbsolutePath());
    }
    final ISelection selection = viewer.getSelection();
    log.info(selection.getClass().getName());
    if (!(selection instanceof ITreeSelection)) {
        final IStatus executionStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Internall error occured: bad sellection type", null);
        StatusManager.getManager().handle(executionStatus, StatusManager.SHOW);
        return;
    }
    final ITreeSelection treeSelection = (ITreeSelection) selection;
    log.info(treeSelection.getFirstElement());
    log.info(treeSelection.getFirstElement().getClass().getName());
    log.info(treeSelection.getPaths());
    final StatsTreeObject selObj = (StatsTreeObject) treeSelection.getFirstElement();
    final BrowserDialog browser = new BrowserDialog(shell);
    if (selObj instanceof FunctionStats) {
        final ModuleStats module = (ModuleStats) selObj.getParent();
        browser.setObject(module);
    } else {
        browser.setObject(selObj);
    }
    browser.open();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IPath(org.eclipse.core.runtime.IPath) ISelection(org.eclipse.jface.viewers.ISelection) FunctionStats(org.erlide.cover.views.model.FunctionStats) BrowserDialog(org.erlide.cover.ui.views.util.BrowserDialog) StatsTreeObject(org.erlide.cover.views.model.StatsTreeObject) ModuleStats(org.erlide.cover.views.model.ModuleStats) File(java.io.File)

Example 3 with ModuleStats

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

the class ShowCoverageAction method perform.

@Override
protected void perform(final StatsTreeObject selection) {
    if (selection instanceof ModuleStats) {
        final ModuleStats module = (ModuleStats) selection;
        final String name = module.getLabel() + ".erl";
        if (ifMarkAnnotations(module)) {
            module.couldBeMarked = true;
            marker.addAnnotationsToFile(name);
        }
    } else if (selection instanceof FunctionStats) {
        final FunctionStats fs = (FunctionStats) selection;
        final ModuleStats module = (ModuleStats) fs.getParent();
        final String name = module.getLabel() + ".erl";
        if (ifMarkAnnotations(module)) {
            log.info(fs.getLineStart());
            log.info(fs.getLineEnd());
            module.couldBeMarked = true;
            marker.addAnnotationsFragment(name, fs.getLineStart(), fs.getLineEnd());
        }
    } else if (selection.equals(StatsTreeModel.getInstance().getRoot())) {
        // TODO: check annotation tree, only if root mark all annotations
        final Collection<ICoverageObject> col = selection.getModules();
        for (final ICoverageObject module : col) {
            if (ifMarkAnnotations((ModuleStats) module)) {
                ((ModuleStats) module).couldBeMarked = true;
            } else {
                ((ModuleStats) module).couldBeMarked = false;
            }
        }
        marker.addAnnotations();
    } else {
        final Collection<ICoverageObject> col = selection.getModules();
        for (final ICoverageObject module : col) {
            if (ifMarkAnnotations((ModuleStats) module)) {
                final String name = module.getLabel() + ".erl";
                ((ModuleStats) module).couldBeMarked = true;
                marker.addAnnotationsToFile(name);
            }
        }
    }
}
Also used : ICoverageObject(org.erlide.cover.views.model.ICoverageObject) FunctionStats(org.erlide.cover.views.model.FunctionStats) ModuleStats(org.erlide.cover.views.model.ModuleStats)

Example 4 with ModuleStats

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

the class EditorTracker method addAnnotationsToFile.

/**
 * Marks coverage for a specified file.
 *
 * @param fileName
 */
public void addAnnotationsToFile(final String fileName) {
    final IEditorPart currentEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (currentEditor.getTitle().equals(fileName) && !currentEditor.isDirty()) {
        final ModuleStats module = ModuleSet.get(fileName.replace(".erl", ""));
        if (module == null || !module.couldBeMarked) {
            return;
        }
        final List<LineResult> list = module.getLineResults();
        for (final LineResult lr : list) {
            coverage.addAnnotation(fileName, lr, null);
        }
        annotateEditor(currentEditor);
    }
}
Also used : LineResult(org.erlide.cover.views.model.LineResult) IEditorPart(org.eclipse.ui.IEditorPart) ModuleStats(org.erlide.cover.views.model.ModuleStats)

Example 5 with ModuleStats

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

the class EditorTracker method createAnnotationMap.

private void createAnnotationMap() {
    final Iterator<ModuleStats> it = ModuleSet.iterator();
    while (it.hasNext()) {
        final ModuleStats module = it.next();
        if (!module.couldBeMarked) {
            continue;
        }
        final List<LineResult> list = module.getLineResults();
        final String modName = module.getLabel() + ".erl";
        for (final LineResult lr : list) {
            coverage.addAnnotation(modName, lr, null);
        }
    }
}
Also used : LineResult(org.erlide.cover.views.model.LineResult) ModuleStats(org.erlide.cover.views.model.ModuleStats)

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