diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-06-09 16:26:56 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-06-17 20:03:08 +0000 |
commit | 2754feca4e5fa8fdd804c827783250f48676296c (patch) | |
tree | 1ed9522bbc9eff9444fae6bf0a951d976da2b859 /sonar-core | |
parent | 97f2c01fdd4ae863134d4aa1bf32b7dcd512b10c (diff) | |
download | sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.tar.gz sonarqube-2754feca4e5fa8fdd804c827783250f48676296c.zip |
SONAR-14925 Remove code deprecated before 7.0 in the Plugin API
Diffstat (limited to 'sonar-core')
4 files changed, 3 insertions, 101 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java index 2190c7f60f6..f71405004db 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/IssueExclusionProperties.java @@ -74,13 +74,11 @@ public final class IssueExclusionProperties { .name(PROPERTY_RULE_KEY_PATTERN) .description("Pattern to match rules which should be ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .name(PROPERTY_FILE_PATH_PATTERN) .description("Pattern to match files which should be ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -97,13 +95,11 @@ public final class IssueExclusionProperties { .name("Regular Expression for Start of Block") .description("If this regular expression is found in a file, then following lines are ignored until end of block.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(END_BLOCK_REGEXP) .name("Regular Expression for End of Block") .description("If specified, this regular expression is used to determine the end of code blocks to ignore. If not, then block ends at the end of file.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -119,7 +115,6 @@ public final class IssueExclusionProperties { .name("Regular Expression") .description("If this regular expression is found in a file, then the whole file is ignored.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build(), @@ -135,16 +130,14 @@ public final class IssueExclusionProperties { .name(PROPERTY_RULE_KEY_PATTERN) .description("Pattern used to match rules which should be restricted.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build(), PropertyFieldDefinition.build(RESOURCE_KEY) .name(PROPERTY_FILE_PATH_PATTERN) .description("Pattern used to match files to which the rules should be restricted.") .type(PropertyType.STRING) - .indicativeSize(LARGE_SIZE) .build() ) .build() - ); + ); } } diff --git a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java index b902b1da811..41fa24cd5e0 100644 --- a/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java +++ b/sonar-core/src/main/java/org/sonar/core/extension/CoreExtensionsInstaller.java @@ -20,13 +20,10 @@ package org.sonar.core.extension; import java.lang.annotation.Annotation; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.function.Predicate; -import org.sonar.api.ExtensionProvider; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; import org.sonar.api.config.internal.MapSettings; @@ -74,8 +71,7 @@ public abstract class CoreExtensionsInstaller { private void install(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, CoreExtension coreExtension) { String coreExtensionName = coreExtension.getName(); try { - List<Object> providerKeys = addDeclaredExtensions(container, extensionFilter, additionalSideFilter, coreExtension); - addProvidedExtensions(container, additionalSideFilter, coreExtensionName, providerKeys); + addDeclaredExtensions(container, extensionFilter, additionalSideFilter, coreExtension); LOG.debug("Installed core extension: " + coreExtensionName); coreExtensionRepository.installed(coreExtension); @@ -84,32 +80,10 @@ public abstract class CoreExtensionsInstaller { } } - private List<Object> addDeclaredExtensions(ComponentContainer container, Predicate<Object> extensionFilter, + private void addDeclaredExtensions(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, CoreExtension coreExtension) { ContextImpl context = new ContextImpl(container, extensionFilter, additionalSideFilter, coreExtension.getName()); coreExtension.load(context); - return context.getProviders(); - } - - private void addProvidedExtensions(ComponentContainer container, Predicate<Object> additionalSideFilter, - String extensionCategory, List<Object> providerKeys) { - providerKeys.stream() - .map(providerKey -> (ExtensionProvider) container.getComponentByKey(providerKey)) - .forEach(provider -> addFromProvider(container, additionalSideFilter, extensionCategory, provider)); - } - - private void addFromProvider(ComponentContainer container, Predicate<Object> additionalSideFilter, - String extensionCategory, ExtensionProvider provider) { - Object obj = provider.provide(); - if (obj != null) { - if (obj instanceof Iterable) { - for (Object ext : (Iterable) obj) { - addSupportedExtension(container, additionalSideFilter, extensionCategory, ext); - } - } else { - addSupportedExtension(container, additionalSideFilter, extensionCategory, obj); - } - } } private <T> boolean addSupportedExtension(ComponentContainer container, Predicate<Object> additionalSideFilter, @@ -130,7 +104,6 @@ public abstract class CoreExtensionsInstaller { private final Predicate<Object> extensionFilter; private final Predicate<Object> additionalSideFilter; private final String extensionCategory; - private final List<Object> providers = new ArrayList<>(); public ContextImpl(ComponentContainer container, Predicate<Object> extensionFilter, Predicate<Object> additionalSideFilter, String extensionCategory) { @@ -160,8 +133,6 @@ public abstract class CoreExtensionsInstaller { if (!addSupportedExtension(container, additionalSideFilter, extensionCategory, component)) { container.declareExtension(extensionCategory, component); - } else if (ExtensionProviderSupport.isExtensionProvider(component)) { - providers.add(component); } return this; } @@ -179,9 +150,5 @@ public abstract class CoreExtensionsInstaller { components.forEach(this::addExtension); return this; } - - public List<Object> getProviders() { - return providers; - } } } diff --git a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java b/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java index 82ca1d870bf..fa6809cc717 100644 --- a/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java +++ b/sonar-core/src/main/java/org/sonar/core/extension/ExtensionProviderSupport.java @@ -19,17 +19,11 @@ */ package org.sonar.core.extension; -import org.sonar.api.ExtensionProvider; - public final class ExtensionProviderSupport { private ExtensionProviderSupport() { // prevents implementation } - public static boolean isExtensionProvider(Object extension) { - return isType(extension, ExtensionProvider.class) || extension instanceof ExtensionProvider; - } - private static boolean isType(Object extension, Class extensionClass) { Class clazz = extension instanceof Class ? (Class) extension : extension.getClass(); return extensionClass.isAssignableFrom(clazz); diff --git a/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java b/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java index 8f3d0e75773..9b21a33d1df 100644 --- a/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/extension/CoreExtensionsInstallerTest.java @@ -40,7 +40,6 @@ import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mockito; import org.picocontainer.ComponentAdapter; -import org.sonar.api.ExtensionProvider; import org.sonar.api.Property; import org.sonar.api.SonarRuntime; import org.sonar.api.config.Configuration; @@ -225,21 +224,6 @@ public class CoreExtensionsInstallerTest { assertPropertyDefinitions(container, coreExtension, propertyDefinitionNoCategory, propertyDefinitionWithCategory); } - @Test - @UseDataProvider("allMethodsToAddExtension") - public void install_adds_providers_to_container_and_install_extensions_they_provide_when_annotated_with_expected_annotation( - BiConsumer<CoreExtension.Context, Collection<Object>> extensionAdder) { - List<Object> extensions = ImmutableList.of(WestSideProvider.class, PartiallyWestSideProvider.class, EastSideProvider.class); - CoreExtension coreExtension = newCoreExtension(context -> extensionAdder.accept(context, extensions)); - when(coreExtensionRepository.loadedCoreExtensions()).thenReturn(Stream.of(coreExtension)); - ComponentContainer container = new ComponentContainer(); - - underTest.install(container, noExtensionFilter(), noAdditionalSideFilter()); - - assertAddedExtensions(container, WestSideProvider.class, WestSideProvided.class, PartiallyWestSideProvider.class); - assertPropertyDefinitions(container); - } - @DataProvider public static Object[][] allMethodsToAddExtension() { BiConsumer<CoreExtension.Context, Collection<Object>> addExtension = (context, objects) -> objects.forEach(context::addExtension); @@ -358,42 +342,6 @@ public class CoreExtensionsInstallerTest { } - @WestSide - public static class WestSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - return WestSideProvided.class; - } - } - - @WestSide - public static class WestSideProvided { - - } - - @WestSide - public static class PartiallyWestSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - return NotWestSideProvided.class; - } - } - - public static class NotWestSideProvided { - - } - - @EastSide - public static class EastSideProvider extends ExtensionProvider { - - @Override - public Object provide() { - throw new IllegalStateException("EastSideProvider#provide should not be called"); - } - } - @Property(key = "westKey", name = "westName") @WestSide public static class WestSidePropertyDefinition { |