SLCORE-2241 Adjust plugin model types and add foundational resolver s…#1923
SLCORE-2241 Adjust plugin model types and add foundational resolver s…#1923Krosovok wants to merge 1 commit intofeature/on-demand-analyzersfrom
Conversation
SummaryThis PR refactors plugin model types and introduces foundational support for plugin resolvers. Key changes include: (1) splitting What reviewers should knowStart with
|
There was a problem hiding this comment.
Pull request overview
This PR evolves the backend plugin model to distinguish language-indexed plugins from “companion” plugins, and introduces foundational utilities/services to support resolving, caching, and lifecycle management of plugin artifacts.
Changes:
- Refactors
PluginStatusto carry a plugin key, optional language, an (intended) new artifact state model, and an optional on-disk path. - Adds foundational building blocks:
CompanionPluginResolver,ServerPluginsCache,PluginJarUtils, andAnalyzerArtifacts. - Extends plugin lifecycle/unload flows (embedded plugins) and updates/introduces tests for the new behaviors.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/core/src/test/java/org/sonarsource/sonarlint/core/plugin/ServerPluginsCacheTest.java | Adds unit tests for ServerPluginsCache caching and invalidation behavior. |
| backend/core/src/test/java/org/sonarsource/sonarlint/core/plugin/PluginStatusNotifierServiceTest.java | Updates test setup to use the new PluginStatus factories/state type. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/resolvers/CompanionPluginResolver.java | Introduces an extension point for resolving “companion” plugin statuses. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/ServerPluginsCache.java | Adds a new Guava-based cache for server-installed plugins with event-based invalidation hooks. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginsRepository.java | Adds unloadEmbedded() to support unloading embedded plugins independently. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginStatusMapper.java | Updates status mapping to DTOs to accept the new artifact-state type. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginStatus.java | Refactors the plugin status record structure and adds factory helpers. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginLifecycleService.java | Adds embedded-plugin lifecycle orchestration and cache eviction coordination. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/PluginJarUtils.java | Adds a helper to read plugin versions from jars. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/DotnetSupport.java | Adjusts .NET support model to carry omnisharp artifacts and explicit support flags. |
| backend/core/src/main/java/org/sonarsource/sonarlint/core/plugin/AnalyzerArtifacts.java | Introduces a record to group a plugin status with its jar and extra artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| public record PluginStatus( | ||
| String pluginName, | ||
| PluginState state, | ||
| String pluginKey, | ||
| @Nullable SonarLanguage language, | ||
| ArtifactState state, | ||
| @Nullable ArtifactSource source, | ||
| @Nullable Version actualVersion, | ||
| @Nullable Version overriddenVersion) { | ||
| @Nullable Version overriddenVersion, | ||
| @Nullable Path path) { |
| LOG.debug("Unloading embedded plugins and evicting all related caches"); | ||
|
|
||
| pluginsService.unloadEmbeddedPlugins(); | ||
| rulesRepository.evictEmbedded(); | ||
| activeRulesService.evictStandalone(); |
| DotnetSupport(@Nullable Path actualCsharpAnalyzerPath, boolean shouldUseCsharpEnterprise, | ||
| boolean shouldUseVbNetEnterprise, boolean supportsCsharp, boolean supportsVbNet, | ||
| Map<String, Path> omnisharpArtifacts) { | ||
| this.actualCsharpAnalyzerPath = actualCsharpAnalyzerPath; | ||
| this.shouldUseCsharpEnterprise = shouldUseCsharpEnterprise; | ||
| this.shouldUseVbNetEnterprise = shouldUseVbNetEnterprise; | ||
| this.supportsCsharp = supportsCsharp; | ||
| this.supportsVbNet = supportsVbNet; | ||
| this.omnisharpArtifacts = omnisharpArtifacts; |
| public static Version readVersion(Path jarPath) { | ||
| try { | ||
| return PluginInfo.create(jarPath).getVersion(); | ||
| } catch (IllegalStateException e) { |
| private Optional<List<ServerPlugin>> fetchAndCache(String connectionId) { | ||
| var result = sonarQubeClientManager.withActiveClientAndReturn(connectionId, | ||
| api -> api.plugins().getInstalled(new SonarLintCancelMonitor())); | ||
| result.ifPresent(plugins -> cache.put(connectionId, plugins)); | ||
| return result; |
| public Optional<List<ServerPlugin>> getPlugins(String connectionId) { | ||
| var cached = cache.getIfPresent(connectionId); | ||
| if (cached != null) { | ||
| return Optional.of(cached); | ||
| } | ||
| return fetchAndCache(connectionId); | ||
| } |
| @EventListener | ||
| public void connectionRemoved(ConnectionConfigurationRemovedEvent event) { | ||
| cache.invalidate(event.removedConnectionId()); | ||
| } | ||
|
|
||
| @EventListener | ||
| public void connectionUpdated(ConnectionConfigurationUpdatedEvent event) { | ||
| cache.invalidate(event.updatedConnectionId()); | ||
| } |
| private void verifyApiCalledTimes(String connectionId, int times) { | ||
| verify(sonarQubeClientManager, times(times)).withActiveClientAndReturn(eq(connectionId), any(Function.class)); |
No description provided.