Skip to content

refactor(lsp): replace FolderConfig with LspFolderConfig using direct map access [IDE-1639]#797

Draft
bastiandoetsch wants to merge 15 commits intomasterfrom
feat/IDE-1639
Draft

refactor(lsp): replace FolderConfig with LspFolderConfig using direct map access [IDE-1639]#797
bastiandoetsch wants to merge 15 commits intomasterfrom
feat/IDE-1639

Conversation

@bastiandoetsch
Copy link
Copy Markdown
Collaborator

@bastiandoetsch bastiandoetsch commented Mar 10, 2026

User description

Summary

Remove custom FolderConfig data class and LspFolderConfigExtensions.kt. Store LspFolderConfig directly in FolderConfigSettings, eliminating conversion boilerplate between FolderConfig and LspFolderConfig.

All UI consumers and tests now access settings via the LspFolderConfig.settings map using LsFolderSettingsKeys constants. The withSetting extension function is preserved in LanguageServerSettings.kt for immutable config updates.

Changes

  • Removed FolderConfig data class from Types.kt
  • Removed LspFolderConfigExtensions.kt (typed extension properties, factory functions)
  • Updated FolderConfigSettings to store/retrieve LspFolderConfig directly
  • Updated SnykLanguageClient and LanguageServerWrapper to skip FolderConfig conversion
  • Updated UI code (SnykSettingsDialog, ReferenceChooserDialog, SnykToolWindowPanel, SaveConfigHandler) to use direct map access
  • Added TestFolderConfigHelper.kt for test convenience
  • Updated all affected tests

PR Type

Enhancement


Description

  • Refactor LSP configuration to use a new model.

  • Introduce explicit change tracking for settings.

  • Update UI components to use LspFolderConfig.

  • Enhance folder-specific settings management.


Diagram Walkthrough

flowchart LR
  subgraph IDE
    subgraph Settings
      SnykApplicationSettingsStateService -->|Updates| LsSettingsKeys
      SnykApplicationSettingsStateService -->|Updates| LsFolderSettingsKeys
      SnykProjectSettingsConfigurable -->|Uses| withSetting
      SnykSettingsDialog -->|Uses| LspFolderConfig
      ReferenceChooserDialog -->|Uses| LspFolderConfig
      SaveConfigHandler -->|Uses| markExplicitlyChanged
      SaveConfigHandler -->|Uses| updateConfiguration
      SnykToolWindowPanel -->|Uses| LspFolderConfig
    end
    subgraph UI
      ConfigurationDataClasses -->|New fields| LspFolderConfig
      SaveConfigHandler -->|Processes| SaveConfigRequest
    end
    subgraph LSP
      LanguageServerWrapper -->|Sends| InitializationOptions
      LanguageServerWrapper -->|Handles| LspConfigurationParam
      SnykLanguageClient -->|Receives| LspConfigurationParam
      SnykLanguageClient -->|Updates| SnykApplicationSettingsStateService
      SnykLanguageClient -->|Updates| FolderConfigSettings
    end
    subgraph Data Models
      LsSettingsKeys <-->|Defines keys for| ConfigSetting
      LsFolderSettingsKeys <-->|Defines keys for| ConfigSetting
      LspFolderConfig <-->|Wraps| ConfigSetting
      LspConfigurationParam <-->|Contains| LspFolderConfig
      InitializationOptions <-->|Contains| LspConfigurationParam
    end
  end
Loading

File Walkthrough

Relevant files
Dependencies
1 files
build.gradle.kts
Add jackson-bom dependency                                                             
+1/-0     
Enhancement
3 files
SnykApplicationSettingsStateService.kt
Add explicit change tracking and update LSP protocol version
+19/-1   
ConfigurationDataClasses.kt
Add new fields to FolderConfigData for granular settings 
+10/-0   
LanguageServerSettingsKeys.kt
Introduce LsSettingsKeys and LsFolderSettingsKeys constants
+66/-0   
Refactoring
10 files
SnykProjectSettingsConfigurable.kt
Refactor applyFolderConfigChanges to use withSetting         
+14/-6   
ReferenceChooserDialog.kt
Update to use LspFolderConfig and settings map                     
+22/-12 
SnykSettingsDialog.kt
Update UI to use LspFolderConfig and settings map               
+13/-6   
SaveConfigHandler.kt
Implement explicit change tracking and update configuration flow
+192/-31
SnykToolWindowPanel.kt
Update to use LspFolderConfig                                                       
+10/-5   
LanguageServerWrapper.kt
Replace LanguageServerSettings with LspConfigurationParam and
InitializationOptions
+207/-40
SnykLanguageClient.kt
Handle $/snyk.configuration notification and update settings
+216/-16
Types.kt
Remove deprecated FolderConfig and related types                 
+0/-32   
FolderConfigSettings.kt
Update FolderConfigSettings to use LspFolderConfig and settings map
+92/-63 
LanguageServerSettings.kt
Remove obsolete LanguageServerSettings class                         
+53/-55 
Tests
9 files
SnykApplicationSettingsStateServiceTest.kt
Add test for requiredLsProtocolVersion                                     
+6/-0     
SettingsApplyFunctionsTest.kt
Update tests for new settings model and change tracking   
+33/-0   
SnykProjectSettingsConfigurableTest.kt
Update tests for LspFolderConfig and settings map access 
+38/-15 
ReferenceChooserDialogTest.kt
Update tests for LspFolderConfig and settings map access 
+32/-16 
SaveConfigHandlerTest.kt
Add test for LanguageServerWrapper updateConfiguration call
+25/-0   
LanguageServerWrapperTest.kt
Update tests for new configuration data models and keys   
+25/-12 
SnykLanguageClientTest.kt
Update tests for snykConfiguration notification and settings updates
+54/-8   
FolderConfigSettingsTest.kt
Update tests for LspFolderConfig and settings map access 
+191/-106
TestFolderConfigHelper.kt
Add helper function for creating LspFolderConfig instances
+37/-0   
Documentation
4 files
commit.md
Update commit workflow rules for new configuration changes
+221/-0 
create-implementation-plan.md
Update plan creation for new configuration structure         
+110/-0 
implementation.md
Update implementation workflow for new configuration         
+180/-0 
CLAUDE.md
Update project rules for new configuration model                 
+107/-0 
Configuration changes
1 files
plugin.xml
Enable new config dialog by default                                           
+1/-1     
Additional files
4 files
verification.md +239/-0 
SnykToolWindowSnykScanListenerTest.kt +2/-2     
test-output.txt +10/-0   
tests.json +51/-0   

… map access [IDE-1639]

Remove custom FolderConfig data class and LspFolderConfigExtensions.kt.
Store LspFolderConfig directly in FolderConfigSettings, eliminating
conversion boilerplate between FolderConfig and LspFolderConfig.

All UI consumers and tests now access settings via the LspFolderConfig
settings map using LsFolderSettingsKeys constants. The withSetting
extension function is preserved in LanguageServerSettings.kt for
immutable config updates.
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Mar 10, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@bastiandoetsch
Copy link
Copy Markdown
Collaborator Author

/describe

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Description updated to latest commit (a2b9036)

- Remove unused LanguageServerSettings data class (replaced by the
  LspConfigurationParam/getSettings() approach with LsSettingsKeys)
- Remove unused defaultSettings and trustedFolders variables in
  getSettings() that were computed but never referenced
- Remove unused SnykApplicationSettingsStateService import
Adapt .cursor rules and skills to Claude Code equivalents:
- CLAUDE.md: project rules (adapted from .cursor/rules/general.mdc)
- .claude/commands/commit.md: commit workflow skill
- .claude/commands/create-implementation-plan.md: planning skill
- .claude/commands/verification.md: code verification skill
- .claude/commands/implementation.md: implementation workflow skill
- .gitignore: exclude .claude/settings.local.json (machine-specific)
…errides; remove dead env info settings

- Set changed=true for automaticAuthentication and trustEnabled so they
  are always transmitted as user-overrides to the language server
- Set changed=true for token (always a user-override when present)
- Remove environment info entries from settings map (integration_name,
  integration_version, device_id, os_platform, os_arch, runtime_name,
  runtime_version) — snyk-ls reads these from top-level
  InitializationOptions fields, not from the settings map
Force jackson-bom 2.19.0 to override transitive 2.17.0 from
IntelliJ test-framework, fixing directory traversal vulnerability
SNYK-JAVA-COMFASTERXMLJACKSONCORE-12238608 (CWE-22, CVSS 9.2)
in jackson-core.
@bastiandoetsch
Copy link
Copy Markdown
Collaborator Author

/describe

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Description updated to latest commit (ed6e599)

…DE-1639]

- Move product enablement, filters, scan behaviour settings from
  LsSettingsKeys to LsFolderSettingsKeys (folder-scoped)
- Add new machine-scope keys: CLI_RELEASE_CHANNEL, FORMAT,
  HOVER_VERBOSITY, CLIENT_PROTOCOL_VERSION, TRUSTED_FOLDERS
- Add new folder-scope keys: CWE_IDS, CVE_IDS, RULE_IDS,
  REFERENCE_BRANCH, CLI_ADDITIONAL_OSS_PARAMETERS, SAST_SETTINGS
- Update LanguageServerWrapper.getSettings() to properly categorize
  machine-scope vs folder-scope settings
- Refactor SnykLanguageClient to process folder-scope settings from
  folderConfigs instead of top-level settings map
- Call updateConfiguration() after saving config in SaveConfigHandler
- Enable new HTML config dialog by default (snyk.useNewConfigDialog)
- Add test for updateConfiguration() call after config save
@bastiandoetsch
Copy link
Copy Markdown
Collaborator Author

/describe

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Description updated to latest commit (83fd25c)

…[IDE-1639]

Add folderExplicitChanges map to SnykApplicationSettingsStateService to
track which folder-scoped settings were explicitly changed by the user.
This ensures the changed/UserOverride status survives IDE restarts.

Changes:
- Add overloaded markExplicitlyChanged(folderPath, key) and
  isExplicitlyChanged(folderPath, key) following the same pattern as
  global explicit changes
- Wire SaveConfigHandler.applyFolderConfigs to call
  markExplicitlyChanged only when the new value differs from the
  existing setting (value comparison prevents marking unchanged fields)
- Add applyPersistedFolderChangedFlags in LanguageServerWrapper to
  enrich folder configs with persisted changed flags when building
  settings for the Language Server
- Add unit test for folder-level explicit change tracking with
  cross-folder isolation
@bastiandoetsch
Copy link
Copy Markdown
Collaborator Author

/describe

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Description updated to latest commit (336bbfe)

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.

1 participant