aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-protocol')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java5
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java6
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto6
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java15
4 files changed, 30 insertions, 2 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
index 019e64d169d..44ae856a6c2 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
@@ -42,7 +42,8 @@ public class FileStructure {
COVERAGES("coverages-", Domain.PB),
TESTS("tests-", Domain.PB),
COVERAGE_DETAILS("coverage-details-", Domain.PB),
- SOURCE("source-", ".txt");
+ SOURCE("source-", ".txt"),
+ SGNIFICANT_CODE("sgnificant-code-", Domain.PB);
private static final String PB = ".pb";
private final String filePrefix;
@@ -82,7 +83,7 @@ public class FileStructure {
public File contextProperties() {
return new File(dir, "context-props.pb");
}
-
+
public File root() {
return dir;
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
index ebb6fe925e2..7df46f355cc 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
@@ -73,6 +73,12 @@ public class ScannerReportWriter {
return file;
}
+ public File writeComponentSignificantCode(int componentRef, Iterable<ScannerReport.LineSgnificantCode> lineSignificantCode) {
+ File file = fileStructure.fileFor(FileStructure.Domain.SGNIFICANT_CODE, componentRef);
+ Protobuf.writeStream(lineSignificantCode, file, false);
+ return file;
+ }
+
public void appendComponentIssue(int componentRef, ScannerReport.Issue issue) {
File file = fileStructure.fileFor(FileStructure.Domain.ISSUES, componentRef);
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file, true))) {
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index 922adca6f57..66930fb3a69 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -263,6 +263,12 @@ message TextRange {
int32 end_offset = 4;
}
+message LineSgnificantCode {
+ int32 line = 1;
+ int32 start_offset = 2;
+ int32 end_offset = 3;
+}
+
message Symbol {
TextRange declaration = 1;
repeated TextRange reference = 2;
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
index f4ee4dc3ed3..6d0223be28d 100644
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
+++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java
@@ -284,6 +284,21 @@ public class ScannerReportWriterTest {
}
@Test
+ public void write_line_significant_code() {
+ // no data yet
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SGNIFICANT_CODE, 1)).isFalse();
+
+ underTest.writeComponentSignificantCode(1, asList(
+ ScannerReport.LineSgnificantCode.newBuilder()
+ .setLine(1)
+ .setStartOffset(2)
+ .setEndOffset(3)
+ .build()));
+
+ assertThat(underTest.hasComponentData(FileStructure.Domain.SGNIFICANT_CODE, 1)).isTrue();
+ }
+
+ @Test
public void write_coverage() {
// no data yet
assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isFalse();