use of org.sonarsource.sonarlint.core.plugin.PluginInfo in project sonarlint-core by SonarSource.
the class ComponentContainerTest method shouldDeclareExtensionWithoutAddingIt.
@Test
public void shouldDeclareExtensionWithoutAddingIt() {
ComponentContainer container = new ComponentContainer();
PluginInfo plugin = mock(PluginInfo.class);
container.declareExtension(plugin, ComponentWithProperty.class);
PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
assertThat(propertyDefinitions.get("foo")).isNotNull();
assertThat(container.getComponentByType(ComponentWithProperty.class)).isNull();
}
use of org.sonarsource.sonarlint.core.plugin.PluginInfo in project sonarlint-core by SonarSource.
the class ExtensionInstaller method install.
public ExtensionInstaller install(ComponentContainer container, boolean global) {
// plugin extensions
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin plugin = pluginRepository.getPluginInstance(pluginInfo.getKey());
Plugin.Context context = new Plugin.Context(sqRuntime);
plugin.define(context);
loadExtensions(container, pluginInfo, context, global);
}
if (!global) {
List<ExtensionProvider> providers = container.getComponentsByType(ExtensionProvider.class);
for (ExtensionProvider provider : providers) {
Object object = provider.provide();
if (object instanceof Iterable) {
for (Object extension : (Iterable) object) {
container.addExtension(null, extension);
}
} else {
container.addExtension(null, object);
}
}
}
return this;
}
use of org.sonarsource.sonarlint.core.plugin.PluginInfo in project sonarlint-core by SonarSource.
the class StorageContainer method installPlugins.
protected void installPlugins() {
PluginRepository pluginRepository = getComponentByType(PluginRepository.class);
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Plugin instance = pluginRepository.getPluginInstance(pluginInfo.getKey());
addExtension(pluginInfo, instance);
}
}
use of org.sonarsource.sonarlint.core.plugin.PluginInfo in project sonarlint-core by SonarSource.
the class ComponentContainerTest method shouldDeclareExtensionWhenAdding.
@Test
public void shouldDeclareExtensionWhenAdding() {
ComponentContainer container = new ComponentContainer();
PluginInfo plugin = mock(PluginInfo.class);
container.addExtension(plugin, ComponentWithProperty.class);
PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
assertThat(propertyDefinitions.get("foo")).isNotNull();
assertThat(container.getComponentByType(ComponentWithProperty.class)).isNotNull();
assertThat(container.getComponentByKey(ComponentWithProperty.class)).isNotNull();
}
use of org.sonarsource.sonarlint.core.plugin.PluginInfo in project sonarlint-core by SonarSource.
the class ComponentContainerTest method display_plugin_name_when_failing_to_add_extension.
@Test
public void display_plugin_name_when_failing_to_add_extension() {
ComponentContainer container = new ComponentContainer();
PluginInfo plugin = mock(PluginInfo.class);
container.startComponents();
thrown.expect(IllegalStateException.class);
thrown.expectMessage("Unable to register extension org.sonarsource.sonarlint.core.container.ComponentContainerTest$UnstartableComponent");
container.addExtension(plugin, UnstartableComponent.class);
}
Aggregations