diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-03-30 09:29:50 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-03-31 21:42:42 +0200 |
commit | be05689a5f84c433a2893ec1707bb40ecc37668d (patch) | |
tree | 8e3b673e21eaf4f68d13279ea50ebf26f953ce98 /plugins | |
parent | 22ae199fb6c1e162ccf5be8e45794ab00c85ddbb (diff) | |
download | sonarqube-be05689a5f84c433a2893ec1707bb40ecc37668d.tar.gz sonarqube-be05689a5f84c433a2893ec1707bb40ecc37668d.zip |
SONAR-6319 SONAR-6321 Feed highlighting and symbols in compute report
Diffstat (limited to 'plugins')
6 files changed, 19 insertions, 16 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java index 1ac4c1a4f3a..c6ecc1ba900 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java @@ -36,7 +36,7 @@ import org.sonar.batch.index.ResourceCache; import org.sonar.batch.protocol.output.BatchReport.Scm; import org.sonar.batch.protocol.output.BatchReport.Scm.Changeset; import org.sonar.batch.protocol.output.BatchReportReader; -import org.sonar.batch.report.PublishReportJob; +import org.sonar.batch.report.ReportPublisher; import javax.annotation.Nullable; @@ -53,17 +53,17 @@ import java.util.Map; public abstract class AbstractNewCoverageFileAnalyzer implements Decorator { private final List<PeriodStruct> structs; - private final PublishReportJob publishReportJob; + private final ReportPublisher publishReportJob; private final ResourceCache resourceCache; - public AbstractNewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, PublishReportJob publishReportJob, ResourceCache resourceCache) { + public AbstractNewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) { this(Lists.<PeriodStruct>newArrayList(), publishReportJob, resourceCache); for (Period period : timeMachineConfiguration.periods()) { structs.add(new PeriodStruct(period.getIndex(), period.getDate())); } } - AbstractNewCoverageFileAnalyzer(List<PeriodStruct> structs, PublishReportJob publishReportJob, ResourceCache resourceCache) { + AbstractNewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, ResourceCache resourceCache) { this.resourceCache = resourceCache; this.publishReportJob = publishReportJob; this.structs = structs; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java index 38aac00f0ea..d13df7224ef 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java @@ -23,17 +23,17 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.index.ResourceCache; -import org.sonar.batch.report.PublishReportJob; +import org.sonar.batch.report.ReportPublisher; import java.util.List; public class NewCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { - public NewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, PublishReportJob publishReportJob, ResourceCache resourceCache) { + public NewCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) { super(timeMachineConfiguration, publishReportJob, resourceCache); } - NewCoverageFileAnalyzer(List<PeriodStruct> structs, PublishReportJob publishReportJob, ResourceCache resourceCache) { + NewCoverageFileAnalyzer(List<PeriodStruct> structs, ReportPublisher publishReportJob, ResourceCache resourceCache) { super(structs, publishReportJob, resourceCache); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java index 48222f59ce2..f069a633b4e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java @@ -23,11 +23,11 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.index.ResourceCache; -import org.sonar.batch.report.PublishReportJob; +import org.sonar.batch.report.ReportPublisher; public class NewItCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { - public NewItCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, PublishReportJob publishReportJob, ResourceCache resourceCache) { + public NewItCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) { super(timeMachineConfiguration, publishReportJob, resourceCache); } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java index 75a1a83686c..fc61e4eafe3 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java @@ -23,11 +23,11 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.index.ResourceCache; -import org.sonar.batch.report.PublishReportJob; +import org.sonar.batch.report.ReportPublisher; public class NewOverallCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { - public NewOverallCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, PublishReportJob publishReportJob, ResourceCache resourceCache) { + public NewOverallCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration, ReportPublisher publishReportJob, ResourceCache resourceCache) { super(timeMachineConfiguration, publishReportJob, resourceCache); } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzerTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzerTest.java index af6d25828a6..6f02ac2f626 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzerTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzerTest.java @@ -35,7 +35,7 @@ import org.sonar.batch.index.ResourceCache; import org.sonar.batch.protocol.output.BatchReport.Scm; import org.sonar.batch.protocol.output.BatchReport.Scm.Changeset; import org.sonar.batch.protocol.output.BatchReportWriter; -import org.sonar.batch.report.PublishReportJob; +import org.sonar.batch.report.ReportPublisher; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -69,7 +69,7 @@ public class NewCoverageFileAnalyzerTest { List<AbstractNewCoverageFileAnalyzer.PeriodStruct> structs = Arrays.asList( new AbstractNewCoverageFileAnalyzer.PeriodStruct(1, newDate("2009-12-25")), new AbstractNewCoverageFileAnalyzer.PeriodStruct(3, newDate("2011-02-18"))); - PublishReportJob publishReportJob = mock(PublishReportJob.class); + ReportPublisher publishReportJob = mock(ReportPublisher.class); java.io.File reportBaseDir = temp.newFolder(); when(publishReportJob.getReportDir()).thenReturn(reportBaseDir); writer = new BatchReportWriter(reportBaseDir); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java index d31724c73e8..9d27f526e33 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java @@ -25,12 +25,14 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.FileMetadata; import org.sonar.api.batch.sensor.highlighting.TypeOfText; import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; import org.sonar.api.batch.sensor.internal.SensorContextTester; import java.io.File; import java.io.IOException; +import java.io.StringReader; import static org.assertj.core.api.Assertions.assertThat; @@ -66,12 +68,13 @@ public class SyntaxHighlightingSensorTest { public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.highlighting"); FileUtils.write(symbol, "1:4:k\n12:15:cppd\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo").setLastValidOffset(100); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo") + .initMetadata(new FileMetadata().readMetadata(new StringReader(" xoo\nazertyazer\nfoo"))); context.fileSystem().add(inputFile); sensor.execute(context); - assertThat(context.highlightingTypeFor("foo:src/foo.xoo", 2)).containsOnly(TypeOfText.KEYWORD); - assertThat(context.highlightingTypeFor("foo:src/foo.xoo", 13)).containsOnly(TypeOfText.CPP_DOC); + assertThat(context.highlightingTypeAt("foo:src/foo.xoo", 1, 2)).containsOnly(TypeOfText.KEYWORD); + assertThat(context.highlightingTypeAt("foo:src/foo.xoo", 2, 8)).containsOnly(TypeOfText.CPP_DOC); } } |