aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java6
2 files changed, 6 insertions, 5 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
index 3d292b68e19..ba90c68b4c8 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java
@@ -112,6 +112,11 @@ public class BatchReportReader {
return Collections.emptyList();
}
+ public boolean hasSyntaxHighlighting(int componentRef) {
+ File file = fileStructure.fileFor(FileStructure.Domain.SYNTAX_HIGHLIGHTING, componentRef);
+ return file.exists();
+ }
+
public List<BatchReport.SyntaxHighlighting.HighlightingRule> readComponentSyntaxHighlighting(int componentRef) {
File file = fileStructure.fileFor(FileStructure.Domain.SYNTAX_HIGHLIGHTING, componentRef);
if (file.exists() && file.isFile()) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
index ea2314398c5..7581b44b14d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizerSensor.java
@@ -26,13 +26,10 @@ import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.batch.index.ResourceCache;
-import org.sonar.batch.protocol.output.BatchReport.SyntaxHighlighting.HighlightingRule;
import org.sonar.batch.protocol.output.BatchReportReader;
import org.sonar.batch.report.ReportPublisher;
import org.sonar.colorizer.CodeColorizer;
-import java.util.List;
-
/**
* Execute deprecated {@link CodeColorizer} if necessary.
*/
@@ -61,9 +58,8 @@ public final class CodeColorizerSensor implements Sensor {
for (InputFile f : fs.inputFiles(fs.predicates().all())) {
BatchReportReader reader = new BatchReportReader(reportPublisher.getReportDir());
int batchId = resourceCache.get(f).batchId();
- List<HighlightingRule> highlightingRules = reader.readComponentSyntaxHighlighting(batchId);
String language = f.language();
- if (!highlightingRules.isEmpty() || language == null) {
+ if (reader.hasSyntaxHighlighting(batchId) || language == null) {
continue;
}
codeColorizers.toSyntaxHighlighting(f.file(), fs.encoding(), language, context.newHighlighting().onFile(f));