From f18f19a4e2b89269b46cb6e9ff3e384ed41f76c5 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 23 May 2016 14:45:23 +0200 Subject: [PATCH] SONAR-7509 Revert to not check empty ranges to not break Java plugin --- .../api/batch/fs/internal/DefaultInputFile.java | 2 -- .../highlighting/internal/DefaultHighlighting.java | 2 ++ .../internal/DefaultHighlightingTest.java | 12 ------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java index 98fb14864c2..2d0c593a5de 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java @@ -238,7 +238,6 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile public TextRange newRange(int startLine, int startLineOffset, int endLine, int endLineOffset) { TextPointer start = newPointer(startLine, startLineOffset); TextPointer end = newPointer(endLine, endLineOffset); - Preconditions.checkArgument(start.compareTo(end) < 0, "Start pointer %s should be before end pointer %s", start, end); return newRangeValidPointers(start, end); } @@ -263,7 +262,6 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile * Create Range from global offsets. Used for backward compatibility with older API. */ public TextRange newRange(int startOffset, int endOffset) { - Preconditions.checkArgument(startOffset < endOffset, "Start offset %s should be strictly before end offset %s", startOffset, endOffset); return newRangeValidPointers(newPointer(startOffset), newPointer(endOffset)); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java index 6ccc541dad3..34df663e54a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java @@ -79,6 +79,8 @@ public class DefaultHighlighting extends DefaultStorable implements NewHighlight checkInputFileNotNull(); TextRange newRange; try { + // TODO remove when SONAR-7664 is implemented + Preconditions.checkArgument(startOffset < endOffset, "start offset should be strictly before end offset"); newRange = inputFile.newRange(startOffset, endOffset); } catch (Exception e) { throw new IllegalArgumentException("Unable to highlight file " + inputFile, e); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java index 14cae212525..bd3766962f4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java @@ -107,18 +107,6 @@ public class DefaultHighlightingTest { .save(); } - @Test - public void should_prevent_start_equal_end2() { - throwable.expect(IllegalArgumentException.class); - throwable - .expectMessage("Unable to highlight file"); - - new DefaultHighlighting(mock(SensorStorage.class)) - .onFile(INPUT_FILE) - .highlight(1, 10, 1, 10, KEYWORD) - .save(); - } - @Test public void should_prevent_boudaries_overlapping() { throwable.expect(IllegalStateException.class); -- 2.39.5