Skip to content

SLCORE-2241 Adjust plugin model types and add foundational resolver s…#1923

Open
Krosovok wants to merge 1 commit intofeature/on-demand-analyzersfrom
feature/vt/SLCORE-2241-adjust-existing-models
Open

SLCORE-2241 Adjust plugin model types and add foundational resolver s…#1923
Krosovok wants to merge 1 commit intofeature/on-demand-analyzersfrom
feature/vt/SLCORE-2241-adjust-existing-models

Conversation

@Krosovok
Copy link
Contributor

No description provided.

@Krosovok Krosovok requested a review from nquinquenel March 18, 2026 12:06
@sonar-review-alpha
Copy link

sonar-review-alpha bot commented Mar 18, 2026

Summary

This PR refactors plugin model types and introduces foundational support for plugin resolvers. Key changes include: (1) splitting PluginStatus into language-specific and companion plugin variants with factory methods, adding path and state metadata; (2) introducing new AnalyzerArtifacts record to manage plugin jars and extra artifacts; (3) adding ServerPluginsCache with 1-hour TTL for caching server plugin lists; (4) introducing CompanionPluginResolver interface for plugins not indexed by a language; (5) extracting DotnetSupport construction from InitializeParams to accept resolved parameters directly; (6) adding methods to PluginLifecycleService for embedded plugin reload/unload; (7) renaming PluginState to ArtifactState for clarity. Overall, this creates the foundation for flexible plugin resolution strategies.

What reviewers should know

Start with PluginStatus (line 41–60) to understand the new plugin model structure and factory methods—this is the central change. Review how pluginKey, language, and state now distinguish between language plugins and companions. ServerPluginsCache demonstrates the new caching pattern. DotnetSupport shows how plugin construction is being decoupled from RPC initialization params. The CompanionPluginResolver interface is foundational but empty—expect follow-up PRs to add implementations. Watch for any code paths still using the old PluginState enum (now ArtifactState) or constructing PluginStatus directly instead of via factory methods.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 18, 2026

SLCORE-2241

Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conclusion: Clean foundational PR — the model changes are well-structured and the new ServerPluginsCache follows established patterns. No blocking issues.

🗣️ Give feedback

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PluginStatus to 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, and AnalyzerArtifacts.
  • 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.

Comment on lines 36 to +43
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) {
Comment on lines +54 to +58
LOG.debug("Unloading embedded plugins and evicting all related caches");

pluginsService.unloadEmbeddedPlugins();
rulesRepository.evictEmbedded();
activeRulesService.evictStandalone();
Comment on lines +35 to +43
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) {
Comment on lines +59 to +63
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;
Comment on lines +46 to +52
public Optional<List<ServerPlugin>> getPlugins(String connectionId) {
var cached = cache.getIfPresent(connectionId);
if (cached != null) {
return Optional.of(cached);
}
return fetchAndCache(connectionId);
}
Comment on lines +66 to +74
@EventListener
public void connectionRemoved(ConnectionConfigurationRemovedEvent event) {
cache.invalidate(event.removedConnectionId());
}

@EventListener
public void connectionUpdated(ConnectionConfigurationUpdatedEvent event) {
cache.invalidate(event.updatedConnectionId());
}
Comment on lines +140 to +141
private void verifyApiCalledTimes(String connectionId, int times) {
verify(sonarQubeClientManager, times(times)).withActiveClientAndReturn(eq(connectionId), any(Function.class));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants