Search in sources :

Example 1 with LineResult

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

the class CoverEventHandler method prepLineResults.

private void prepLineResults(final OtpErlangList lineList, final ModuleStats stats) {
    for (OtpErlangObject aLineList : lineList) {
        final OtpErlangTuple res = (OtpErlangTuple) aLineList;
        final int num = Integer.parseInt(res.elementAt(1).toString());
        final int calls = Integer.parseInt(res.elementAt(2).toString());
        final LineResult lineRes = new LineResult(num, calls);
        stats.addLine(lineRes);
    }
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) LineResult(org.erlide.cover.views.model.LineResult) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 2 with LineResult

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

the class EditorTracker method removeAnnotationsFragment.

/**
 * Removes coverage annotations from a fragment of file
 *
 * @param fileName
 * @param start
 * @param end
 */
public void removeAnnotationsFragment(final String fileName, final int start, final int end) {
    final IEditorPart currentEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (currentEditor.getTitle().equals(fileName) && currentEditor instanceof ITextEditor) {
        final ITextEditor editor = (ITextEditor) currentEditor;
        final IAnnotationModel annMod = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
        final Set<LineResult> list = coverage.getLineSet(editor.getTitle());
        for (final LineResult lr : list) {
            if (lr.getLineNum() < start || end != -1 && lr.getLineNum() > end) {
                continue;
            }
            log.info(lr.getLineNum());
            if (coverage.containsAnnotation(editor.getTitle(), lr)) {
                final Annotation ann = coverage.getAnnotation(editor.getTitle(), lr);
                annMod.removeAnnotation(ann);
                coverage.removeAnnotation(editor.getTitle(), lr);
            }
        }
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) LineResult(org.erlide.cover.views.model.LineResult) IEditorPart(org.eclipse.ui.IEditorPart) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) Annotation(org.eclipse.jface.text.source.Annotation)

Example 3 with LineResult

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

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

the class EditorTracker method annotateEditor.

public void annotateEditor(final IWorkbenchPart part) {
    if (!(part instanceof ITextEditor)) {
        return;
    }
    final ITextEditor editor = (ITextEditor) part;
    log.info(editor.getTitle());
    if (!coverage.containsFile(editor.getTitle())) {
        return;
    }
    log.info(coverage);
    final Set<LineResult> list = coverage.getLineSet(editor.getTitle());
    for (final LineResult lr : list) {
        if (lr.getLineNum() == 0) {
            continue;
        }
        markLine(editor, lr);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) LineResult(org.erlide.cover.views.model.LineResult)

Example 5 with LineResult

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

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