How sonarsource/sonarlint-vscode works
This repository is a Visual Studio Code extension for SonarQube for IDE (formerly SonarLint). Its core job is to analyze files in the editor, surface issues in VS Code, and optionally synchronize rules/settings with SonarQube Server or SonarQube Cloud in Connected Mode.
1. Runtime boundary
- The main product runs inside the VS Code extension host, with the extension entry point in src/extension.ts.
- It is not a standalone app: VS Code provides the UI shell, editor events, and command system, while this repo supplies analysis, diagnostics, views, and webviews.
2. Analysis engine integration
- The repository contains an LSP boundary in src/lsp/client.ts, src/lsp/server.ts, and src/lsp/protocol.ts.
- This is the main technical seam between the extension UI/state layer and the language-analysis backend.
- Analysis results ultimately flow back into VS Code diagnostics and issue nodes shown in the Problems panel and custom trees.
3. File, workspace, and language-specific processing
- src/fileSystem/* abstracts file access and subscriptions to file-system changes.
- Language-specific integration is split into areas like src/java/*, src/cfamily/*, src/secrets/*, and rules/helpers under src/rules/*.
- This indicates the extension is multi-language, but not all language support is handled identically; some analyzers likely require extra runtime support or platform-specific setup.
4. Connected Mode and server synchronization
- src/connected/* handles binding to SonarQube/SonarCloud, automatic connection flows, and shared settings.
- This is the main boundary to external services and changes the analysis behavior by importing remote quality profiles, project configuration, and broader language support.
- The repository’s README confirms Connected Mode unlocks deeper rulesets and additional languages.
5. Issue and findings model
- Findings are modeled in src/findings/* with typed nodes for hotspots, taint vulnerabilities, dependency risk, notebooks, and generic findings.
- src/issue/* contains the issue abstraction and resolution logic, so the extension distinguishes between detecting an issue, representing it in the UI, and resolving/remediating it.
- This model is what drives the Findings tree and related code-navigation interactions.
6. UI surfaces inside VS Code
- src/statusbar/*, src/plugin/pluginStatusPanel.ts, src/remediationPanel/*, src/hotspot/*, src/help/*, and src/labs/* define the extension’s user-facing panels and tree views.
- webview-ui/* and styles/* provide the static HTML/JS/CSS for those webviews.
- The repo is therefore split between VS Code-native UI elements (status bar, tree views, commands) and embedded webview apps for richer interactions.
7. AI-assisted features
- src/aiAgentsConfiguration/* and src/languageModelTools/* add AI-related configuration and tools.
- These tools appear to support actions such as analyzing a file, excluding files/folders, listing security issues, and setting up Connected Mode.
- This is a distinct feature boundary layered on top of the standard analysis workflow, not the core analyzer itself.
8. Monitoring, telemetry, and dogfooding
- src/monitoring/* covers archiving, diagnostics execution, flight recording, process management, and recording storage.
- telemetry-sample.md and src/util/utm.ts show that anonymous usage telemetry is part of the product architecture.
- The dogfood/ folder is a separate self-hosted extension package used for internal validation and likely exercises the same extension behavior against real workflows.
9. Command and context orchestration
- src/commandsManager.ts, src/contextManager.ts, and helpers under src/util/* coordinate activation, command registration, state, and shared utilities.
- This is the glue layer that connects editor events, settings, tree providers, diagnostics, and webviews into one coherent extension lifecycle.
10. Settings, labs, and feature gating
- src/settings/* manages user and connected-mode settings, including analysis behavior and connection settings.
- src/labs/* suggests experimental or feature-flagged capabilities, likely surfaced through a dedicated webview and gated by management services.
- This separation matters architecturally because some capabilities are optional, controlled remotely, or enabled only for certain users.
11. Source-control and code-change context
- src/scm/*, src/newcode/*, and src/rules/code-diff.ts indicate support for diff-aware and SCM-aware workflows.
- This likely feeds new-code definitions, code-diff presentation, and issue prioritization based on modified files or recent changes.
12. Build, packaging, and release pipeline
- build-sonarlint/* contains the packaging/deployment toolchain, including hashing, signing, JRE download, SBOM generation, and release publishing.
- .github/workflows/* and .github/actions/* define CI, release, scanning, publishing to extension marketplaces, and release gating.
- This repo has a serious release engineering layer because it produces signed VSIX artifacts and coordinates marketplace publication.
13. Integration and sample test harnesses
- its/ contains integration-test workspaces and sample projects across languages and file types; it exercises the extension against realistic project layouts.
- test/ contains unit tests for most subsystems, while its/src/test/* drives end-to-end extension scenarios.
- The presence of many sample workspaces suggests the architecture is validated by language/workspace shape, not just by isolated unit tests.
14. Key external dependencies
- The primary external systems are VS Code itself, SonarQube Server/Cloud, and marketplace/publishing infrastructure.
- Java support also implies a downloaded JRE/runtime component, managed by build/runtime code rather than bundled uniformly with the extension.
Overall, the architecture is centered on a VS Code extension host that orchestrates local analysis, connected-mode synchronization, and multiple UI surfaces, with a clear split between backend analysis services, VS Code-facing presentation layers, and release/operations tooling.
Main entry points: extension.ts Extension · server.ts LSP Server · connections.ts Connected Mode · pluginStatus.html Webviews
Components 24
Extension Runtime
VS Code extension host, orchestration, analysis, and state
- Extension · Activates the VS Code extension and wires the main lifecycle
src/extension.ts - Commands · Registers commands and coordinates user-triggered actions
src/commandsManager.ts - Context · Tracks shared extension state and activation context
src/contextManager.ts - Settings · Automatic analysis, connection, and user settings
src/settings/settings.ts - SCM and New Code · Git-aware and new-code-aware prioritization for analysis and issues
src/scm/scm.ts
VS Code UI
Native views, panels, and embedded webviews
- Status Panel · Status bar and plugin status surface in VS Code
src/statusbar/statusBar.ts - Plugin Panel · Tree or panel view for plugin status and health
src/plugin/pluginStatusPanel.ts - Findings View · VS Code tree views for findings and issue navigation
src/findings/findingsTreeDataProvider.ts - Remediation · Remediation and fix-suggestion surface for selected issues
src/remediationPanel/remediationWebviewProvider.ts - Labs · Feature-gated labs view and management surface
src/labs/labsWebviewProvider.ts - Help · Help and feedback tree provider with support links
src/help/helpAndFeedbackTreeDataProvider.ts - Webviews · Static HTML, JS, and CSS for embedded extension webviews
webview-ui/pluginStatus.html
Analysis Backend
Language analysis, file access, and issue modeling
- LSP Client · Extension-side boundary to the analysis server
src/lsp/client.ts - LSP Server · Backend analysis process that produces diagnostics and findings
src/lsp/server.ts - File System · Abstracts file access and file-system subscriptions
src/fileSystem/fileSystemServiceImpl.ts - Languages · Language-specific integration for Java, C/C++, and secrets
src/java/java.ts - Findings · Typed findings and tree nodes for hotspots, taint, dependency risk, and notebooks
src/findings/findingsTreeDataProvider.ts - Issues · Issue abstraction and resolution/remediation handling
src/issue/issue.ts
Connected Mode
Synchronization and remote configuration
- Connected Mode · Binds the extension to SonarQube Server or SonarQube Cloud
src/connected/connections.ts - Connection Setup · Automatic binding and assisted connection creation
src/connected/connectionsetup.ts - Shared Settings · Stores and applies connected-mode settings across the extension
src/connected/sharedConnectedModeSettingsService.ts
Build and Operations
Packaging, telemetry, monitoring, and dogfooding
- Monitoring · Archiving, flight recording, diagnostics, and process management
src/monitoring/monitoring.ts - Build and Release · Packaging, signing, SBOM generation, deployment, and release automation
build-sonarlint/package.mjs - Dogfood · Self-hosted validation extension used for internal workflows
dogfood/src/extension.ts
Connections 25
- Extension → Commands: registers · Extension activation wires command handlers
- Extension → Context: initializes · Sets up shared state and activation context
- Extension → LSP Client: starts · Boots the language-analysis client
- LSP Client → LSP Server: protocol · Sends requests and receives diagnostics/results
- LSP Server → File System: reads · Analyzes workspace files through the file-system layer
- LSP Server → Languages: adapts · Runs language-specific analysis and setup
- LSP Server → Findings: produces · Maps analysis output into typed findings
- Findings → Issues: delegates · Issue nodes connect to resolution and remediation logic
- Issues → Remediation: feeds · Selected issues drive remediation experiences
- Extension → Connected Mode: enables · Activates connected-mode workflows when bound
- Connected Mode → Connection Setup: uses · Supports assisted and automatic binding flows
- Connected Mode → Shared Settings: syncs · Applies shared configuration from the server
- Extension → Settings: loads · Reads analysis and connection settings
- Extension → SCM and New Code: consumes · Uses SCM and new-code context for prioritization
- Extension → Status Panel: shows · Surfaces extension status in the VS Code chrome
- Extension → Plugin Panel: renders · Exposes plugin state and health views
- Extension → Findings View: publishes · Provides issue and finding trees to the UI
- Extension → Help: offers · Exposes help and feedback navigation
- Extension → Labs: gates · Hosts experimental features behind labs management
- Labs → Webviews: loads · Uses embedded webview assets for richer UI
- Plugin Panel → Webviews: loads · Renders via static webview assets
- Remediation → Webviews: loads · Renders remediation content through webview assets
- Monitoring → Dogfood: validates · Dogfood exercises the extension in realistic workflows
- Build and Release → Dogfood: packages · Build tooling supports internal and release packaging
- Build and Release → Monitoring: instruments · Release engineering includes diagnostics and telemetry support