From 65d171d1893dbeb55282254dd19c4461776fae1d Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Wed, 6 Jun 2018 15:36:48 +0200 Subject: SONAR-10201 Expose issue precise location in the FilterableIssue API --- .../org/sonar/scanner/issue/DefaultFilterableIssue.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sonar-scanner-engine/src/main/java/org') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java index 58ca9cfb488..b1b9cbc0477 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java @@ -26,7 +26,10 @@ import javax.annotation.concurrent.ThreadSafe; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.sonar.api.batch.fs.InputModule; +import org.sonar.api.batch.fs.TextRange; import org.sonar.api.batch.fs.internal.DefaultInputModule; +import org.sonar.api.batch.fs.internal.DefaultTextPointer; +import org.sonar.api.batch.fs.internal.DefaultTextRange; import org.sonar.api.rule.RuleKey; import org.sonar.api.scan.issue.filter.FilterableIssue; import org.sonar.scanner.ProjectAnalysisInfo; @@ -66,11 +69,23 @@ public class DefaultFilterableIssue implements FilterableIssue { return rawIssue.getMsg(); } + @Deprecated @Override public Integer line() { return rawIssue.hasTextRange() ? rawIssue.getTextRange().getStartLine() : null; } + @Override + public TextRange textRange() { + if (!rawIssue.hasTextRange()) { + return null; + } + + return new DefaultTextRange( + new DefaultTextPointer(rawIssue.getTextRange().getStartLine(), rawIssue.getTextRange().getStartOffset()), + new DefaultTextPointer(rawIssue.getTextRange().getEndLine(), rawIssue.getTextRange().getEndOffset())); + } + @Override public Double gap() { return rawIssue.getGap() != 0 ? rawIssue.getGap() : null; -- cgit v1.2.3