aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-05-01 15:30:13 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-09 20:20:46 +0200
commit1f61e5ace03f23bfcf7a7bd70e0c619fd3201990 (patch)
tree1b6b9805717f07d4794925effaf401dc0cb7eff0 /sonar-scanner-protocol
parent72a0fe6977f60c81b894ad7bb8dd3f0374e9285f (diff)
downloadsonarqube-1f61e5ace03f23bfcf7a7bd70e0c619fd3201990.tar.gz
sonarqube-1f61e5ace03f23bfcf7a7bd70e0c619fd3201990.zip
Add to scanner report viewer: tab with significant code ranges
Diffstat (limited to 'sonar-scanner-protocol')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
index 64ad8683d9a..c7ab72ff6d3 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
@@ -104,6 +104,8 @@ public class ScannerReportViewerApp {
private JEditorPane pluginEditor;
private JScrollPane cpdTextBlocksTab;
private JEditorPane cpdTextBlocksEditor;
+ private JScrollPane significantCodeTab;
+ private JEditorPane significantCodeEditor;
/**
* Create the application.
@@ -255,6 +257,7 @@ public class ScannerReportViewerApp {
updateMeasures(component);
updateScm(component);
updateCpdTextBlocks(component);
+ updateSignificantCode(component);
}
private void updateCpdTextBlocks(Component component) {
@@ -271,6 +274,22 @@ public class ScannerReportViewerApp {
}
}
+ private void updateSignificantCode(Component component) {
+ significantCodeEditor.setText("");
+ if (reader.hasCoverage(component.getRef())) {
+ try (CloseableIterator<ScannerReport.LineSgnificantCode> it = reader.readComponentSignificantCode(component.getRef())) {
+ if (it != null) {
+ while (it.hasNext()) {
+ ScannerReport.LineSgnificantCode textBlock = it.next();
+ significantCodeEditor.getDocument().insertString(significantCodeEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null);
+ }
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't read significant code for " + getNodeName(component), e);
+ }
+ }
+ }
+
private void updateDuplications(Component component) {
duplicationEditor.setText("");
if (reader.hasCoverage(component.getRef())) {
@@ -553,6 +572,12 @@ public class ScannerReportViewerApp {
cpdTextBlocksEditor = new JEditorPane();
cpdTextBlocksTab.setViewportView(cpdTextBlocksEditor);
+ significantCodeTab = new JScrollPane();
+ tabbedPane.addTab("Significant Code Ranges", null, significantCodeTab, null);
+
+ significantCodeEditor = new JEditorPane();
+ significantCodeTab.setViewportView(significantCodeEditor);
+
treeScrollPane = new JScrollPane();
treeScrollPane.setPreferredSize(new Dimension(200, 400));
splitPane.setLeftComponent(treeScrollPane);