From e96686ffd551939bfc459cdd5b92c132feb213a6 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Tue, 4 Aug 2020 10:03:00 -0500 Subject: [PATCH] Fix scanner report viewer --- .../viewer/ScannerReportViewerApp.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 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 f185c909000..7349fa688f8 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 @@ -255,7 +255,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readCpdTextBlocks(component.getRef())) { while (it.hasNext()) { ScannerReport.CpdTextBlock textBlock = it.next(); - cpdTextBlocksEditor.getDocument().insertString(cpdTextBlocksEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); + cpdTextBlocksEditor.getDocument().insertString(cpdTextBlocksEditor.getDocument().getLength(), textBlock + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read CPD text blocks for " + getNodeName(component), e); @@ -270,7 +270,7 @@ public class ScannerReportViewerApp { if (it != null) { while (it.hasNext()) { ScannerReport.LineSgnificantCode textBlock = it.next(); - significantCodeEditor.getDocument().insertString(significantCodeEditor.getDocument().getEndPosition().getOffset(), textBlock + "\n", null); + significantCodeEditor.getDocument().insertString(significantCodeEditor.getDocument().getLength(), textBlock + "\n", null); } } } catch (Exception e) { @@ -285,7 +285,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentDuplications(component.getRef())) { while (it.hasNext()) { ScannerReport.Duplication dup = it.next(); - duplicationEditor.getDocument().insertString(duplicationEditor.getDocument().getEndPosition().getOffset(), dup + "\n", null); + duplicationEditor.getDocument().insertString(duplicationEditor.getDocument().getLength(), dup + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read duplications for " + getNodeName(component), e); @@ -298,7 +298,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentIssues(component.getRef())) { while (it.hasNext()) { Issue issue = it.next(); - int offset = issuesEditor.getDocument().getEndPosition().getOffset(); + int offset = issuesEditor.getDocument().getLength(); issuesEditor.getDocument().insertString(offset, issue.toString(), null); } } catch (Exception e) { @@ -311,7 +311,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentExternalIssues(component.getRef())) { while (it.hasNext()) { ScannerReport.ExternalIssue issue = it.next(); - int offset = externalIssuesEditor.getDocument().getEndPosition().getOffset(); + int offset = externalIssuesEditor.getDocument().getLength(); externalIssuesEditor.getDocument().insertString(offset, issue.toString(), null); } } catch (Exception e) { @@ -324,7 +324,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentCoverage(component.getRef())) { while (it.hasNext()) { ScannerReport.LineCoverage coverage = it.next(); - coverageEditor.getDocument().insertString(coverageEditor.getDocument().getEndPosition().getOffset(), coverage + "\n", null); + coverageEditor.getDocument().insertString(coverageEditor.getDocument().getLength(), coverage + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read code coverage for " + getNodeName(component), e); @@ -399,7 +399,8 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentSyntaxHighlighting(component.getRef())) { while (it.hasNext()) { ScannerReport.SyntaxHighlightingRule rule = it.next(); - highlightingEditor.getDocument().insertString(highlightingEditor.getDocument().getEndPosition().getOffset(), rule + "\n", null); + int offset = highlightingEditor.getDocument().getLength(); + highlightingEditor.getDocument().insertString(offset, rule + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read syntax highlighting for " + getNodeName(component), e); @@ -411,7 +412,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentMeasures(component.getRef())) { while (it.hasNext()) { ScannerReport.Measure measure = it.next(); - measuresEditor.getDocument().insertString(measuresEditor.getDocument().getEndPosition().getOffset(), measure + "\n", null); + measuresEditor.getDocument().insertString(measuresEditor.getDocument().getLength(), measure + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read measures for " + getNodeName(component), e); @@ -428,15 +429,15 @@ public class ScannerReportViewerApp { try { int index = 0; for (Changeset changeset : changesets.getChangesetList()) { - scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), index + "\n", null); - scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), changeset + "\n", null); + scmEditor.getDocument().insertString(scmEditor.getDocument().getLength(), index + "\n", null); + scmEditor.getDocument().insertString(scmEditor.getDocument().getLength(), changeset + "\n", null); index++; } - scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), "\n", null); + scmEditor.getDocument().insertString(scmEditor.getDocument().getLength(), "\n", null); int line = 1; for (Integer idx : changesetIndexByLine) { - scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), line + ": " + idx + "\n", null); + scmEditor.getDocument().insertString(scmEditor.getDocument().getLength(), line + ": " + idx + "\n", null); line++; } @@ -450,7 +451,7 @@ public class ScannerReportViewerApp { try (CloseableIterator it = reader.readComponentSymbols(component.getRef())) { while (it.hasNext()) { ScannerReport.Symbol symbol = it.next(); - symbolEditor.getDocument().insertString(symbolEditor.getDocument().getEndPosition().getOffset(), symbol + "\n", null); + symbolEditor.getDocument().insertString(symbolEditor.getDocument().getLength(), symbol + "\n", null); } } catch (Exception e) { throw new IllegalStateException("Can't read symbol references for " + getNodeName(component), e); -- 2.39.5