aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-03-30 09:29:50 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-03-31 21:42:42 +0200
commitbe05689a5f84c433a2893ec1707bb40ecc37668d (patch)
tree8e3b673e21eaf4f68d13279ea50ebf26f953ce98 /sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
parent22ae199fb6c1e162ccf5be8e45794ab00c85ddbb (diff)
downloadsonarqube-be05689a5f84c433a2893ec1707bb40ecc37668d.tar.gz
sonarqube-be05689a5f84c433a2893ec1707bb40ecc37668d.zip
SONAR-6319 SONAR-6321 Feed highlighting and symbols in compute report
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java27
1 files changed, 17 insertions, 10 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
index d20fbebb147..fa9326a1604 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/source/HighlightableBuilder.java
@@ -20,10 +20,14 @@
package org.sonar.batch.source;
import com.google.common.collect.ImmutableSet;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.component.Component;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.source.Highlightable;
-import org.sonar.batch.index.ComponentDataCache;
+import org.sonar.batch.index.BatchResource;
+import org.sonar.batch.index.ResourceCache;
import org.sonar.core.component.PerspectiveBuilder;
import org.sonar.core.component.ResourceComponent;
@@ -31,27 +35,30 @@ import javax.annotation.CheckForNull;
import java.util.Set;
-/**
- * @since 3.6
- * @deprecated since 4.5 no more used in batch 2.0
- */
-@Deprecated
public class HighlightableBuilder extends PerspectiveBuilder<Highlightable> {
private static final Set<String> SUPPORTED_QUALIFIERS = ImmutableSet.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE);
- private final ComponentDataCache cache;
+ private final ResourceCache cache;
+ private final SensorStorage sensorStorage;
- public HighlightableBuilder(ComponentDataCache cache) {
+ public HighlightableBuilder(ResourceCache cache, SensorStorage sensorStorage) {
super(Highlightable.class);
this.cache = cache;
+ this.sensorStorage = sensorStorage;
}
@CheckForNull
@Override
- protected Highlightable loadPerspective(Class<Highlightable> perspectiveClass, Component component) {
+ public Highlightable loadPerspective(Class<Highlightable> perspectiveClass, Component component) {
boolean supported = SUPPORTED_QUALIFIERS.contains(component.qualifier());
if (supported && component instanceof ResourceComponent) {
- return new DefaultHighlightable(component, cache);
+ BatchResource batchComponent = cache.get(component.key());
+ if (batchComponent != null) {
+ InputFile path = (InputFile) batchComponent.inputPath();
+ if (path != null) {
+ return new DefaultHighlightable((DefaultInputFile) path, sensorStorage);
+ }
+ }
}
return null;
}