Search in sources :

Example 6 with LineResult

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

Aggregations

LineResult (org.erlide.cover.views.model.LineResult)6 IEditorPart (org.eclipse.ui.IEditorPart)3 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)3 ModuleStats (org.erlide.cover.views.model.ModuleStats)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 Annotation (org.eclipse.jface.text.source.Annotation)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1