From 4b95fc51186b0f5708cd2886b076c7d2deeb509f Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 15 Feb 2016 14:41:03 +0100 Subject: [PATCH] Add symbol references to the ReportViewer application. --- .../protocol/viewer/ViewerApplication.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java index 48cc04e2e87..a3476adab4e 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/viewer/ViewerApplication.java @@ -66,8 +66,10 @@ public class ViewerApplication { private JScrollPane treeScrollPane; private JScrollPane componentDetailsTab; private JScrollPane highlightingTab; + private JScrollPane symbolTab; private JEditorPane componentEditor; private JEditorPane highlightingEditor; + private JEditorPane symbolEditor; private JScrollPane sourceTab; private JEditorPane sourceEditor; private JScrollPane coverageTab; @@ -183,6 +185,7 @@ public class ViewerApplication { private void updateDetails(Component component) { componentEditor.setText(component.toString()); updateHighlighting(component); + updateSymbols(component); updateSource(component); updateCoverage(component); updateDuplications(component); @@ -243,6 +246,18 @@ public class ViewerApplication { } } + private void updateSymbols(Component component) { + symbolEditor.setText(""); + try (CloseableIterator it = reader.readComponentSymbols(component.getRef())) { + while (it.hasNext()) { + BatchReport.Symbol symbol = it.next(); + symbolEditor.getDocument().insertString(symbolEditor.getDocument().getEndPosition().getOffset(), symbol.toString() + "\n", null); + } + } catch (Exception e) { + throw new IllegalStateException("Can't read symbol references for " + getNodeName(component), e); + } + } + /** * Initialize the contents of the frame. */ @@ -289,6 +304,12 @@ public class ViewerApplication { highlightingEditor = new JEditorPane(); highlightingTab.setViewportView(highlightingEditor); + symbolTab = new JScrollPane(); + tabbedPane.addTab("Symbol references", null, symbolTab, null); + + symbolEditor = new JEditorPane(); + symbolTab.setViewportView(symbolEditor); + coverageTab = new JScrollPane(); tabbedPane.addTab("Coverage", null, coverageTab, null); -- 2.39.5