try to reuse coverage infrastructure:
authorAnna.Kozlova <anna.kozlova@jetbrains.com>
Wed, 12 Oct 2016 17:29:21 +0000 (19:29 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 18 Oct 2016 10:05:34 +0000 (12:05 +0200)
inherit from coverageDataManager so profile suites would be collected and current suite can be tracked;
provide custom suites bundle to paint gutter icons;
problems:
1. data is not loaded!
2. mutual coverage/profile would be shown at the same position, won't exclude each other

plugins/coverage-common/src/com/intellij/coverage/CoverageLineMarkerRenderer.java
plugins/coverage-common/src/com/intellij/coverage/CoverageSuitesBundle.java
plugins/coverage-common/src/com/intellij/coverage/LineMarkerRendererWithErrorStripe.java [new file with mode: 0644]
plugins/coverage-common/src/com/intellij/coverage/SrcFileAnnotator.java

index e039a74712e0968677dc9d05000d7ff0d34330db..29e1a4062fb3e3867d3fbf7e4e736f2088efc315 100644 (file)
@@ -70,7 +70,7 @@ import java.util.TreeMap;
 /**
  * @author ven
  */
 /**
  * @author ven
  */
-public class CoverageLineMarkerRenderer implements LineMarkerRendererEx, ActiveGutterRenderer {
+public class CoverageLineMarkerRenderer implements ActiveGutterRenderer, LineMarkerRendererWithErrorStripe {
   private static final int THICKNESS = 8;
   private final TextAttributesKey myKey;
   private final String myClassName;
   private static final int THICKNESS = 8;
   private final TextAttributesKey myKey;
   private final String myClassName;
index 15ee14ec430c4895109864d4c405cd9927190319..481f6009f3565b31822dd4079910d586a71ca900 100644 (file)
@@ -14,6 +14,7 @@ import com.intellij.psi.util.CachedValue;
 import com.intellij.psi.util.CachedValueProvider;
 import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.reference.SoftReference;
 import com.intellij.psi.util.CachedValueProvider;
 import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.reference.SoftReference;
+import com.intellij.rt.coverage.data.LineData;
 import com.intellij.rt.coverage.data.ProjectData;
 import com.intellij.util.ArrayUtilRt;
 import com.intellij.util.Function;
 import com.intellij.rt.coverage.data.ProjectData;
 import com.intellij.util.ArrayUtilRt;
 import com.intellij.util.Function;
@@ -22,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.util.HashSet;
 import java.util.Set;
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.TreeMap;
 
 /**
  * User: anna
 
 /**
  * User: anna
@@ -117,6 +119,16 @@ public class CoverageSuitesBundle {
     return myEngine;
   }
 
     return myEngine;
   }
 
+  public LineMarkerRendererWithErrorStripe getLineMarkerRenderer(int lineNumber,
+                                                                 @Nullable final String className,
+                                                                 final TreeMap<Integer, LineData> lines,
+                                                                 final boolean coverageByTestApplicable,
+                                                                 @NotNull final CoverageSuitesBundle coverageSuite,
+                                                                 final Function<Integer, Integer> newToOldConverter,
+                                                                 final Function<Integer, Integer> oldToNewConverter, boolean subCoverageActive) {
+    return myEngine.getLineMarkerRenderer(lineNumber, className, lines, coverageByTestApplicable, coverageSuite, newToOldConverter, oldToNewConverter, subCoverageActive);
+  }
+
   public CoverageAnnotator getAnnotator(Project project) {
     return myEngine.getCoverageAnnotator(project);
   }
   public CoverageAnnotator getAnnotator(Project project) {
     return myEngine.getCoverageAnnotator(project);
   }
diff --git a/plugins/coverage-common/src/com/intellij/coverage/LineMarkerRendererWithErrorStripe.java b/plugins/coverage-common/src/com/intellij/coverage/LineMarkerRendererWithErrorStripe.java
new file mode 100644 (file)
index 0000000..32329cc
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.coverage;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.markup.LineMarkerRendererEx;
+
+import java.awt.*;
+
+//todo
+public interface LineMarkerRendererWithErrorStripe extends LineMarkerRendererEx {
+  Color getErrorStripeColor(Editor editor);
+}
index 5b8030c4519bfca9456fae3e64b56c61f73f4354..5c32427e05d0df7aadfaceafece08f7e014e80a7 100644 (file)
@@ -510,7 +510,7 @@ public class SrcFileAnnotator implements Disposable {
       final TIntIntHashMap newLineMapping = getOldToNewLineMapping(date, editorBean);
       return newLineMapping != null ? newLineMapping.get(newLine.intValue()) : newLine.intValue();
     };
       final TIntIntHashMap newLineMapping = getOldToNewLineMapping(date, editorBean);
       return newLineMapping != null ? newLineMapping.get(newLine.intValue()) : newLine.intValue();
     };
-    final CoverageLineMarkerRenderer markerRenderer = coverageSuite.getCoverageEngine()
+    final LineMarkerRendererWithErrorStripe markerRenderer = coverageSuite
       .getLineMarkerRenderer(line, className, executableLines, coverageByTestApplicable, coverageSuite, newToOldConverter,
                              oldToNewConverter, CoverageDataManager.getInstance(myProject).isSubCoverageActive());
     highlighter.setLineMarkerRenderer(markerRenderer);
       .getLineMarkerRenderer(line, className, executableLines, coverageByTestApplicable, coverageSuite, newToOldConverter,
                              oldToNewConverter, CoverageDataManager.getInstance(myProject).isSubCoverageActive());
     highlighter.setLineMarkerRenderer(markerRenderer);