diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2018-06-06 15:36:48 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-06-11 20:20:48 +0200 |
commit | 65d171d1893dbeb55282254dd19c4461776fae1d (patch) | |
tree | 8bcd1f8729cd5d314be88479807ec4b84bf8c9dc /sonar-scanner-engine/src/main/java/org | |
parent | 17968cf78d5f505c1ce3fb3ae5c8be6bf22684cd (diff) | |
download | sonarqube-65d171d1893dbeb55282254dd19c4461776fae1d.tar.gz sonarqube-65d171d1893dbeb55282254dd19c4461776fae1d.zip |
SONAR-10201 Expose issue precise location in the FilterableIssue API
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultFilterableIssue.java | 15 |
1 files changed, 15 insertions, 0 deletions
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,12 +69,24 @@ 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; } |