aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-06-09 16:26:56 -0500
committersonartech <sonartech@sonarsource.com>2021-06-17 20:03:08 +0000
commit2754feca4e5fa8fdd804c827783250f48676296c (patch)
tree1ed9522bbc9eff9444fae6bf0a951d976da2b859 /sonar-plugin-api-impl
parent97f2c01fdd4ae863134d4aa1bf32b7dcd512b10c (diff)
downloadsonarqube-2754feca4e5fa8fdd804c827783250f48676296c.tar.gz
sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.zip
SONAR-14925 Remove code deprecated before 7.0 in the Plugin API
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java12
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java12
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java11
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java23
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java19
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java23
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java2
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java10
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java12
9 files changed, 24 insertions, 100 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java
index 34758d387e5..b513c8f55bf 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/coverage/internal/DefaultCoverage.java
@@ -25,7 +25,6 @@ import java.util.TreeMap;
import javax.annotation.Nullable;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.coverage.CoverageType;
import org.sonar.api.batch.sensor.coverage.NewCoverage;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.internal.SensorStorage;
@@ -36,7 +35,6 @@ import static org.sonar.api.utils.Preconditions.checkState;
public class DefaultCoverage extends DefaultStorable implements NewCoverage {
private InputFile inputFile;
- private CoverageType type;
private int totalCoveredLines = 0;
private int totalConditions = 0;
private int totalCoveredConditions = 0;
@@ -63,16 +61,6 @@ public class DefaultCoverage extends DefaultStorable implements NewCoverage {
}
@Override
- public NewCoverage ofType(CoverageType type) {
- this.type = requireNonNull(type, "type can't be null");
- return this;
- }
-
- public CoverageType type() {
- return type;
- }
-
- @Override
public NewCoverage lineHits(int line, int hits) {
validateFile();
if (isExcluded()) {
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
index 34a74bb2d40..84ca63f5586 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
@@ -76,18 +76,6 @@ public class DefaultHighlighting extends DefaultStorable implements NewHighlight
}
@Override
- public DefaultHighlighting highlight(int startOffset, int endOffset, TypeOfText typeOfText) {
- checkInputFileNotNull();
- TextRange newRange;
- try {
- newRange = inputFile.newRange(startOffset, endOffset);
- } catch (Exception e) {
- throw new IllegalArgumentException("Unable to highlight file " + inputFile, e);
- }
- return highlight(newRange, typeOfText);
- }
-
- @Override
public DefaultHighlighting highlight(int startLine, int startLineOffset, int endLine, int endLineOffset, TypeOfText typeOfText) {
checkInputFileNotNull();
TextRange newRange;
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
index 29de3ad4ece..ee5ced6886b 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptor.java
@@ -96,17 +96,6 @@ public class DefaultSensorDescriptor implements SensorDescriptor {
}
@Override
- public DefaultSensorDescriptor requireProperty(String... propertyKey) {
- return requireProperties(propertyKey);
- }
-
- @Override
- public DefaultSensorDescriptor requireProperties(String... propertyKeys) {
- this.configurationPredicate = config -> Arrays.stream(propertyKeys).allMatch(config::hasKey);
- return this;
- }
-
- @Override
public SensorDescriptor global() {
this.global = true;
return this;
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java
index a79813f243f..87a820b06d3 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTable.java
@@ -74,18 +74,6 @@ public class DefaultSymbolTable extends DefaultStorable implements NewSymbolTabl
}
@Override
- public NewSymbol newSymbol(int startOffset, int endOffset) {
- checkInputFileNotNull();
- TextRange declarationRange;
- try {
- declarationRange = inputFile.newRange(startOffset, endOffset);
- } catch (Exception e) {
- throw new IllegalArgumentException("Unable to create symbol on file " + inputFile, e);
- }
- return newSymbol(declarationRange);
- }
-
- @Override
public NewSymbol newSymbol(TextRange range) {
checkInputFileNotNull();
TreeSet<TextRange> references = new TreeSet<>((o1, o2) -> o1.start().compareTo(o2.start()));
@@ -106,17 +94,6 @@ public class DefaultSymbolTable extends DefaultStorable implements NewSymbolTabl
}
@Override
- public NewSymbol newReference(int startOffset, int endOffset) {
- TextRange referenceRange;
- try {
- referenceRange = inputFile.newRange(startOffset, endOffset);
- } catch (Exception e) {
- throw new IllegalArgumentException("Unable to create symbol reference on file " + inputFile, e);
- }
- return newReference(referenceRange);
- }
-
- @Override
public NewSymbol newReference(int startLine, int startLineOffset, int endLine, int endLineOffset) {
TextRange referenceRange;
try {
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java
index ecb2caacca8..90140b89905 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/impl/server/RulesDefinitionContext.java
@@ -30,7 +30,6 @@ import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.internal.DefaultNewRepository;
import org.sonar.api.server.rule.internal.DefaultRepository;
-import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import static org.sonar.api.utils.Preconditions.checkState;
@@ -49,12 +48,6 @@ public class RulesDefinitionContext extends RulesDefinition.Context {
}
@Override
- @Deprecated
- public RulesDefinition.NewRepository extendRepository(String key, String language) {
- return createRepository(key, language);
- }
-
- @Override
@CheckForNull
public RulesDefinition.Repository repository(String key) {
return repositoriesByKey.get(key);
@@ -65,18 +58,6 @@ public class RulesDefinitionContext extends RulesDefinition.Context {
return unmodifiableList(new ArrayList<>(repositoriesByKey.values()));
}
- @Override
- @Deprecated
- public List<RulesDefinition.ExtendedRepository> extendedRepositories(String repositoryKey) {
- return emptyList();
- }
-
- @Override
- @Deprecated
- public List<RulesDefinition.ExtendedRepository> extendedRepositories() {
- return emptyList();
- }
-
public void registerRepository(DefaultNewRepository newRepository) {
RulesDefinition.Repository existing = repositoriesByKey.get(newRepository.key());
if (existing != null) {
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
index d042facca99..7a3c09c3a5b 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlightingTest.java
@@ -34,7 +34,6 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import static org.sonar.api.batch.sensor.highlighting.TypeOfText.COMMENT;
-import static org.sonar.api.batch.sensor.highlighting.TypeOfText.CPP_DOC;
import static org.sonar.api.batch.sensor.highlighting.TypeOfText.KEYWORD;
public class DefaultHighlightingTest {
@@ -56,12 +55,12 @@ public class DefaultHighlightingTest {
DefaultHighlighting highlightingDataBuilder = new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 10, COMMENT)
+ .highlight(1, 0, 1, 10, COMMENT)
.highlight(1, 10, 1, 12, KEYWORD)
- .highlight(24, 38, KEYWORD)
- .highlight(42, 50, KEYWORD)
- .highlight(24, 65, CPP_DOC)
- .highlight(12, 20, COMMENT);
+ .highlight(1, 24, 1, 38, KEYWORD)
+ .highlight(1, 42, 2, 0, KEYWORD)
+ .highlight(1, 24, 2, 15, COMMENT)
+ .highlight(1, 12, 1, 20, COMMENT);
highlightingDataBuilder.save();
@@ -86,15 +85,15 @@ public class DefaultHighlightingTest {
rangeOf(1, 24, 2, 15),
rangeOf(1, 24, 1, 38),
rangeOf(1, 42, 2, 0));
- Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, CPP_DOC, KEYWORD, KEYWORD);
+ Assertions.assertThat(highlightingRules).extracting("textType").containsExactly(COMMENT, KEYWORD, COMMENT, COMMENT, KEYWORD, KEYWORD);
}
@Test
public void should_support_overlapping() {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 15, KEYWORD)
- .highlight(8, 12, CPP_DOC)
+ .highlight(1, 0, 1, 15, KEYWORD)
+ .highlight(1, 8, 1, 12, COMMENT)
.save();
}
@@ -106,7 +105,7 @@ public class DefaultHighlightingTest {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(10, 10, KEYWORD)
+ .highlight(1, 10, 1, 10, KEYWORD)
.save();
}
@@ -118,8 +117,8 @@ public class DefaultHighlightingTest {
new DefaultHighlighting(Mockito.mock(SensorStorage.class))
.onFile(INPUT_FILE)
- .highlight(0, 10, KEYWORD)
- .highlight(8, 15, KEYWORD)
+ .highlight(1, 0, 1, 10, KEYWORD)
+ .highlight(1, 8, 1, 15, KEYWORD)
.save();
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
index 719b042b277..ac6c72c24dd 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/DefaultSensorDescriptorTest.java
@@ -34,7 +34,7 @@ public class DefaultSensorDescriptorTest {
.name("Foo")
.onlyOnLanguage("java")
.onlyOnFileType(InputFile.Type.MAIN)
- .requireProperty("sonar.foo.reportPath", "sonar.foo.reportPath2")
+ .onlyWhenConfiguration(c -> c.hasKey("sonar.foo.reportPath2") && c.hasKey("sonar.foo.reportPath"))
.createIssuesForRuleRepository("squid-java");
assertThat(descriptor.name()).isEqualTo("Foo");
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
index 62f5a7ffb67..7f9aa09466d 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
@@ -198,8 +198,8 @@ public class SensorContextTesterTest {
tester.newHighlighting()
.onFile(new TestInputFileBuilder("foo", "src/Foo.java").initMetadata("annot dsf fds foo bar").build())
.highlight(1, 0, 1, 5, TypeOfText.ANNOTATION)
- .highlight(8, 10, TypeOfText.CONSTANT)
- .highlight(9, 10, TypeOfText.COMMENT)
+ .highlight(1, 8, 1, 10, TypeOfText.CONSTANT)
+ .highlight(1, 9, 1, 10, TypeOfText.COMMENT)
.save();
assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 3)).containsExactly(TypeOfText.ANNOTATION);
assertThat(tester.highlightingTypeAt("foo:src/Foo.java", 1, 9)).containsExactly(TypeOfText.CONSTANT, TypeOfText.COMMENT);
@@ -228,15 +228,15 @@ public class SensorContextTesterTest {
symbolTable
.newSymbol(1, 1, 1, 5)
- .newReference(6, 9)
.newReference(1, 10, 1, 13);
symbolTable.save();
assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 0)).isNull();
assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 8)).isEmpty();
- assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3)).extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset").containsExactly(tuple(1, 6, 1, 9),
- tuple(1, 10, 1, 13));
+ assertThat(tester.referencesForSymbolAt("foo:src/Foo.java", 1, 3))
+ .extracting("start.line", "start.lineOffset", "end.line", "end.lineOffset")
+ .containsExactly(tuple(1, 10, 1, 13));
}
@Test(expected = UnsupportedOperationException.class)
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
index 2aad9aeb42e..6db2e987d54 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/symbol/internal/DefaultSymbolTableTest.java
@@ -27,8 +27,8 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
-import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -53,11 +53,13 @@ public class DefaultSymbolTableTest {
DefaultSymbolTable symbolTableBuilder = new DefaultSymbolTable(mock(SensorStorage.class))
.onFile(INPUT_FILE);
symbolTableBuilder
- .newSymbol(0, 10)
- .newReference(12, 15)
- .newReference(2, 10, 2, 15);
+ .newSymbol(1, 0, 1, 10)
+ .newReference(2, 10, 2, 15)
+ .newReference(1, 16, 1, 20);
- symbolTableBuilder.newSymbol(1, 12, 1, 15).newReference(52, 55);
+ symbolTableBuilder
+ .newSymbol(1, 12, 1, 15)
+ .newReference(2, 1, 2, 5);
symbolTableBuilder.save();