diff options
author | Roland Grunberg | 2014-04-14 20:22:32 +0000 |
---|---|---|
committer | Roland Grunberg | 2014-04-16 15:49:09 +0000 |
commit | 783a10a8a37dc832ade3f8a81d6a9385d17ab82a (patch) | |
tree | 23a10cd03e91cf79fd8d33100c5ff22e707a7168 /gcov | |
parent | e5d4c4761cc4084e2aefc45b16efd9ddd7218e0d (diff) | |
download | org.eclipse.linuxtools-783a10a8a37dc832ade3f8a81d6a9385d17ab82a.tar.gz org.eclipse.linuxtools-783a10a8a37dc832ade3f8a81d6a9385d17ab82a.tar.xz org.eclipse.linuxtools-783a10a8a37dc832ade3f8a81d6a9385d17ab82a.zip |
Add Gcov annotation specification for lines covered "many times".
Use the formula for an outlier (relative to upper quartile) to determine
whether a set of hit counts is large relative to each file, ignoring
lines not covered. Also show lines thoroughly covered in the overview
ruler.
Change-Id: I949c3f330b644482421441548020e91d51dd2ab7
Reviewed-on: https://git.eclipse.org/r/24998
Tested-by: Hudson CI
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
Tested-by: Roland Grunberg <rgrunber@redhat.com>
Diffstat (limited to 'gcov')
4 files changed, 68 insertions, 20 deletions
diff --git a/gcov/org.eclipse.linuxtools.gcov.core/plugin.properties b/gcov/org.eclipse.linuxtools.gcov.core/plugin.properties index b8ee9ba2aa..0b434138b0 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/plugin.properties +++ b/gcov/org.eclipse.linuxtools.gcov.core/plugin.properties @@ -14,3 +14,6 @@ gcovEditor = Gcov Editor gcov = gcov gcovDescription = Gcov view displays the profiling information contained in gcda/gcno files colorprefpage = Gcov +thoroughCoverage = Thorough Coverage +coverage = Coverage +noCoverage = No Coverage diff --git a/gcov/org.eclipse.linuxtools.gcov.core/plugin.xml b/gcov/org.eclipse.linuxtools.gcov.core/plugin.xml index 9364d2bc2f..5e234505ab 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/plugin.xml +++ b/gcov/org.eclipse.linuxtools.gcov.core/plugin.xml @@ -49,7 +49,7 @@ <extension point="org.eclipse.ui.editors.markerAnnotationSpecification"> <specification - annotationType="org.eclipse.gcov.CoverageAnnotation" + annotationType="org.eclipse.linuxtools.gcov.CoverageAnnotation" colorPreferenceKey="coverage_color" colorPreferenceValue="192,255,192" contributesToHeader="false" @@ -60,7 +60,7 @@ isGoToNextNavigationTargetKey="coverage_isGoToNextNavigationTargetKey" isGoToPreviousNavigationTarget="false" isGoToPreviousNavigationTargetKey="coverage_isGoToPreviousNavigationTargetKey" - label="Coverage" + label="%coverage" overviewRulerPreferenceKey="coverage_overviewRuler" overviewRulerPreferenceValue="false" presentationLayer="0" @@ -73,7 +73,7 @@ verticalRulerPreferenceKey="coverage_verticalRuler" verticalRulerPreferenceValue="true"/> <specification - annotationType="org.eclipse.gcov.NoCoverageAnnotation" + annotationType="org.eclipse.linuxtools.gcov.NoCoverageAnnotation" colorPreferenceKey="nocoverage_color" colorPreferenceValue="255,160,160" contributesToHeader="false" @@ -84,7 +84,7 @@ isGoToNextNavigationTargetKey="nocoverage_isGoToNextNavigationTargetKey" isGoToPreviousNavigationTarget="false" isGoToPreviousNavigationTargetKey="nocoverage_isGoToPreviousNavigationTargetKey" - label="No Coverage" + label="%noCoverage" overviewRulerPreferenceKey="nocoverage_overviewRuler" overviewRulerPreferenceValue="false" presentationLayer="0" @@ -95,15 +95,43 @@ textStylePreferenceKey="nocoverage_stylePreferences" textStylePreferenceValue="BOX" verticalRulerPreferenceKey="nocoverage_verticalRuler" - verticalRulerPreferenceValue="true"/> + verticalRulerPreferenceValue="false"/> + <specification + annotationType="org.eclipse.linuxtools.gcov.ThoroughCoverageAnnotation" + colorPreferenceKey="thcoverage_color" + colorPreferenceValue="0,240,0" + contributesToHeader="false" + highlightPreferenceKey="thcoverage_highlight" + highlightPreferenceValue="true" + includeOnPreferencePage="true" + isGoToNextNavigationTarget="false" + isGoToNextNavigationTargetKey="thcoverage_isGoToNextNavigationTargetKey" + isGoToPreviousNavigationTarget="false" + isGoToPreviousNavigationTargetKey="thcoverage_isGoToPreviousNavigationTargetKey" + label="%thoroughCoverage" + overviewRulerPreferenceKey="thcoverage_overviewRuler" + overviewRulerPreferenceValue="true" + presentationLayer="0" + showInNextPrevDropdownToolbarAction="false" + showInNextPrevDropdownToolbarActionKey="thcoverage_showInNextPrevDropdownToolbarAction" + textPreferenceKey="thcoverage_text" + textPreferenceValue="true" + textStylePreferenceKey="thcoverage_stylePreferences" + textStylePreferenceValue="BOX" + verticalRulerPreferenceKey="thcoverage_verticalRuler" + verticalRulerPreferenceValue="true"> + </specification> </extension> <extension point="org.eclipse.ui.editors.annotationTypes"> <type - name="org.eclipse.gcov.CoverageAnnotation"> + name="org.eclipse.linuxtools.gcov.CoverageAnnotation"> + </type> + <type + name="org.eclipse.linuxtools.gcov.NoCoverageAnnotation"> </type> <type - name="org.eclipse.gcov.NoCoverageAnnotation"> + name="org.eclipse.linuxtools.gcov.ThoroughCoverageAnnotation"> </type> </extension> diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotation.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotation.java index d39d3562d1..01b51a1ab3 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotation.java +++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotation.java @@ -19,14 +19,11 @@ import org.eclipse.osgi.util.NLS; */ public class GcovAnnotation extends Annotation { - private static final String COVERAGE = "org.eclipse.gcov.CoverageAnnotation"; //$NON-NLS-1$ - private static final String NO_COVERAGE = "org.eclipse.gcov.NoCoverageAnnotation"; //$NON-NLS-1$ - private final Position position; private final long count; - public GcovAnnotation(int offset, int length, long count) { - super(getAnnotationType(count), false, null); + public GcovAnnotation(int offset, int length, long count, String type) { + super(type, false, null); this.position = new Position(offset, length); this.count = count; } @@ -47,11 +44,4 @@ public class GcovAnnotation extends Annotation { return Messages.CoverageAnnotationColumn_non_exec_line; } } - - private static String getAnnotationType(long count) { - if (count == 0) { - return NO_COVERAGE; - } - return COVERAGE; - } } diff --git a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java index e37b8225e0..f3170c2d36 100644 --- a/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java +++ b/gcov/org.eclipse.linuxtools.gcov.core/src/org/eclipse/linuxtools/internal/gcov/view/annotatedsource/GcovAnnotationModel.java @@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.gcov.view.annotatedsource; import java.io.IOException; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -48,6 +49,10 @@ import org.eclipse.ui.texteditor.ITextEditor; */ public final class GcovAnnotationModel implements IAnnotationModel { + private static final String THOROUGH_COVERAGE = "org.eclipse.linuxtools.gcov.ThoroughCoverageAnnotation"; //$NON-NLS-1$ + private static final String COVERAGE = "org.eclipse.linuxtools.gcov.CoverageAnnotation"; //$NON-NLS-1$ + private static final String NO_COVERAGE = "org.eclipse.linuxtools.gcov.NoCoverageAnnotation"; //$NON-NLS-1$ + /** Key for identifying our model from other Editor models. */ private static final Object KEY = new Object(); @@ -194,12 +199,34 @@ public final class GcovAnnotationModel implements IAnnotationModel { AnnotationModelEvent event = new AnnotationModelEvent(this); clear(event); List<Line> lines = sourceFile.getLines(); + + List<Long> tmp = new ArrayList<>(); + for (Line line : lines) { + // Remove 0 from our calculation + if (line.getCount() != 0) { + tmp.add(line.getCount()); + } + } + Long[] counts = tmp.toArray(new Long[0]); + Arrays.sort(counts); + + // Formula for outlier (upper quartile) + final int q1 = (int) Math.floor(0.25 * counts.length); + final int q3 = (int) Math.ceil(0.75 * counts.length); + final float outlierThreshold = counts[q3] + (1.5f * (counts[q3] - counts[q1])); + for (int i = 0; i < lines.size(); i++) { try { Line line = lines.get((i+1) % lines.size()); + String type = COVERAGE; + if (line.getCount() == 0) { + type = NO_COVERAGE; + } else if (line.getCount() > outlierThreshold) { + type = THOROUGH_COVERAGE; + } if (line.exists()) { GcovAnnotation ca = new GcovAnnotation(document.getLineOffset(i), - document.getLineLength(i), line.getCount()); + document.getLineLength(i), line.getCount(), type); annotations.add(ca); event.annotationAdded(ca); } |