aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-07-24 16:10:22 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-07 11:44:06 +0200
commit4ae8b49d7960957c6b4de2f3470d9c71eb933d54 (patch)
treecfac2fe123f1d5018497c3804f71722396195c2d /sonar-scanner-protocol
parentce007ea402d4a0aac78c5d6e3d1ec19864067e77 (diff)
downloadsonarqube-4ae8b49d7960957c6b4de2f3470d9c71eb933d54.tar.gz
sonarqube-4ae8b49d7960957c6b4de2f3470d9c71eb933d54.zip
Add CPD text blocks to report viewer
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, 24 insertions, 1 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 f78175e033c..e34e0421444 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
@@ -97,6 +97,8 @@ public class ScannerReportViewerApp {
private JEditorPane scmEditor;
private JScrollPane activeRuleTab;
private JEditorPane activeRuleEditor;
+ private JScrollPane cpdTextBlocksTab;
+ private JEditorPane cpdTextBlocksEditor;
/**
* Create the application.
@@ -245,8 +247,23 @@ public class ScannerReportViewerApp {
updateIssues(component);
updateMeasures(component);
updateScm(component);
+ updateCpdTextBlocks(component);
}
+ private void updateCpdTextBlocks(Component component) {
+ cpdTextBlocksEditor.setText("");
+ if (reader.hasCoverage(component.getRef())) {
+ try (CloseableIterator<ScannerReport.CpdTextBlock> it = reader.readCpdTextBlocks(component.getRef())) {
+ while (it.hasNext()) {
+ ScannerReport.CpdTextBlock textBlock = it.next();
+ cpdTextBlocksEditor.getDocument().insertString(cpdTextBlocksEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException("Can't read CPD text blocks for " + getNodeName(component), e);
+ }
+ }
+ }
+
private void updateDuplications(Component component) {
duplicationEditor.setText("");
if (reader.hasCoverage(component.getRef())) {
@@ -484,11 +501,17 @@ public class ScannerReportViewerApp {
scmTab.setViewportView(scmEditor);
activeRuleTab = new JScrollPane();
- tabbedPane.addTab("ActiveRules", null, activeRuleTab, null);
+ tabbedPane.addTab("Active Rules", null, activeRuleTab, null);
activeRuleEditor = new JEditorPane();
activeRuleTab.setViewportView(activeRuleEditor);
+ cpdTextBlocksTab = new JScrollPane();
+ tabbedPane.addTab("CPD Text Blocks", null, cpdTextBlocksTab, null);
+
+ cpdTextBlocksEditor = new JEditorPane();
+ cpdTextBlocksTab.setViewportView(cpdTextBlocksEditor);
+
treeScrollPane = new JScrollPane();
treeScrollPane.setPreferredSize(new Dimension(200, 400));
splitPane.setLeftComponent(treeScrollPane);