From: Julien HENRY Date: Mon, 23 May 2016 12:45:23 +0000 (+0200) Subject: SONAR-7509 Revert to not check empty ranges to not break Java plugin X-Git-Tag: 5.6-RC2~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F1008%2Fhead;p=sonarqube.git SONAR-7509 Revert to not check empty ranges to not break Java plugin --- 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);