From f35b6148731dd11734e57d73dd1cfc182de58b12 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 12 May 2016 11:37:30 +0200 Subject: [PATCH] SONAR-7509 Backport on old API to ease migration --- .../java/org/sonar/api/source/Highlightable.java | 5 +++++ .../sonar/batch/source/DefaultHighlightable.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java b/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java index 4230b2ccdee..5171dec0ae9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/source/Highlightable.java @@ -36,6 +36,11 @@ public interface Highlightable extends Perspective { HighlightingBuilder highlight(int startOffset, int endOffset, String typeOfText); + /** + * @since 5.6 + */ + HighlightingBuilder highlight(int startLine, int startLineOffset, int endLine, int endLineOffset, String typeOfText); + void done(); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultHighlightable.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultHighlightable.java index 80403efc298..52e56e4703b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultHighlightable.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/source/DefaultHighlightable.java @@ -59,6 +59,12 @@ public class DefaultHighlightable implements Highlightable { return this; } + @Override + public HighlightingBuilder highlight(int startLine, int startLineOffset, int endLine, int endLineOffset, String typeOfText) { + // Do nothing + return this; + } + @Override public void done() { // Do nothing @@ -80,6 +86,13 @@ public class DefaultHighlightable implements Highlightable { return this; } + @Override + public HighlightingBuilder highlight(int startLine, int startLineOffset, int endLine, int endLineOffset, String typeOfText) { + TypeOfText type = org.sonar.api.batch.sensor.highlighting.TypeOfText.forCssClass(typeOfText); + defaultHighlighting.highlight(startLine, startLineOffset, endLine, endLineOffset, type); + return this; + } + @Override public void done() { defaultHighlighting.save(); -- 2.39.5