Skip to content

fix: the settings of the user-defined language servers and debug adapters keep the path macros of their commands, as stored - #2389

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/settings-keep-command-macros
Dec 1, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/settings-keep-command-macros

Conversation

@lagergren

@lagergren lagergren commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2384.

The Language Servers settings showed the commands of the user-defined language servers with the user's home written out: C:/Users/…/.lsp4ij/lsp/clangd_snapshot_20260517/bin/clangd.exe instead of $USER_HOME$/.lsp4ij/lsp/…. Exporting a server took that path too, and the settings stored it once they were applied.

Cause

Nothing in LSP4IJ resolves the command it stores: the installers keep the macros. ${output.dir} and ${check.file} are as written, as $USER_HOME$/.lsp4ij/lsp/clangd/…, and UICommandLineUpdater stores the command as the installer gives it.

IntelliJ does it. The storage of the application expands the path macros of a component's state when it loads it, and collapses paths into them when it saves it:

  • The file: UserDefinedLanguageServerSettings.xml keeps $USER_HOME$.
  • In memory: after a restart, getCommandLine() returns the expanded path, and so does everything that reads it: the settings page, the export, and the next save of the settings.

PathMacroManager.expandPaths(Element) applies no filter. A PathMacroFilter only acts when the storage collapses paths on save, so a filter can't keep the macros on load.

The new test reproduces it: a state with "$USER_HOME$/.lsp4ij/lsp/clangd/clangd_19.1.2/bin/clangd", saved and loaded as the application's storage does, came back as "/Users/…/.lsp4ij/lsp/clangd/…".

Fix

  • On load: loadState of UserDefinedLanguageServerSettings collapses the command and the working directory again, with the application's PathMacroManager, through the new CommandUtils.collapsePathMacros. So does loadState of UserDefinedDebugAdapterServerSettings for its command. They show and export as the file stores them.
  • At start: the macros are resolved when the server starts, by CommandUtils.resolveCommandLine, as before.
  • A command that the user typed with an absolute path in the home: it shows with $USER_HOME$. That's how the storage has always written it in the file, and it starts the same.

Behaviour changes

Before After
After a restart, a command or working directory in the user's home showed, and exported, as an absolute path It shows and exports with $USER_HOME$, as stored, and is resolved when the server starts

Tests

  • UserDefinedSettingsPathMacrosTest: a state goes through the application's PathMacroManager as the storage handles a file: collapsed on save, expanded on load, then loadState. It checks that:

    • a language server keeps $USER_HOME$ in its command and its working directory;
    • a debug adapter keeps it in its command;
    • a command typed with an absolute path in the home shows with $USER_HOME$;
    • settings without a command load.

    Without the fix, the first three fail with /Users/marcus/… in place of $USER_HOME$.

  • Platforms: the tests pass on 2024.2 and 2026.3.

  • Whole suite: 2,861 tests, 0 failures, 7 skipped.

…ters keep the path macros of their commands, as stored

The storage of the application expands the path macros of a component
when it loads it, so a command which an installer gave with $USER_HOME$
showed, and exported, with the path of the user's home after a restart.
loadState collapses the command and the working directory again; the
macros are resolved when the server starts, as before.

Fixes redhat-developer#2384
@lagergren lagergren added this to the 0.30.3 milestone Dec 1, 2026
@lagergren lagergren added bug Something isn't working user-defined LS install labels Dec 1, 2026
@lagergren
lagergren requested a review from angelozerr December 1, 2026 10:33
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Custom language server and debug adapter settings now retain path macros in command lines when loaded.
    • Language server working directories now also retain path macros when settings are loaded, helping stored paths continue to work across application save and load cycles.

Loading persisted user-defined language-server and debug-adapter settings now collapses application path macros in command lines. Language-server settings also collapse macros in working directories. Tests cover these values and settings with no command.

Changes: User-defined settings path macros

Layer / File(s) Summary
Add path-macro collapsing helper
src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/CommandUtils.java
CommandUtils.collapsePathMacros collapses application path macros in supplied text and returns null for null input.
Collapse macros when loading settings
src/main/java/com/redhat/devtools/lsp4ij/launching/UserDefinedLanguageServerSettings.java, src/main/java/com/redhat/devtools/lsp4ij/dap/settings/UserDefinedDebugAdapterServerSettings.java, src/test/java/com/redhat/devtools/lsp4ij/launching/UserDefinedSettingsPathMacrosTest.java
Language-server settings collapse macros in command lines and working directories. Debug-adapter settings collapse macros in command lines. Tests cover save/load behavior, home paths, and a missing command.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to bbfb6

Path macros in user-defined language server and debug adapter settings are now kept as stored after a restart, and they are still expanded when a server starts. I found no merge-blocking risk in this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: user-defined language server and debug adapter settings keep the path macros of their commands as stored. The raw summary and objectives confirm that loadState now col…
Description check Passed The description is detailed and relevant. It gives the cause (IntelliJ expands path macros on load), the fix (collapse in loadState via CommandUtils.collapsePathMacros), the behaviour change, and the …
Linked Issues check Passed [#2384] The issue title asks that the start command not be resolved and stored as a resolved command. The issue body gives no further criteria. At the reviewed head, UserDefinedLanguageServerSettings.…
Out of Scope Changes check Passed The changes listed in the raw summary all relate to the linked issue. They are: loadState collapse in UserDefinedLanguageServerSettings and UserDefinedDebugAdapterServerSettings; a new CommandUtils.co…
Full details: Title check

Explanation

The title names the main change: user-defined language server and debug adapter settings keep the path macros of their commands as stored. The raw summary and objectives confirm that loadState now collapses macros in commands and working directories, and that a test covers this. The title is long and somewhat wordy, but it is related to the changeset and specific enough.

Full details: Description check

Explanation

The description is detailed and relevant. It gives the cause (IntelliJ expands path macros on load), the fix (collapse in loadState via CommandUtils.collapsePathMacros), the behaviour change, and the new test. It matches the changed files and objectives.

Full details: Linked Issues check

Explanation

[#2384] The issue title asks that the start command not be resolved and stored as a resolved command. The issue body gives no further criteria. At the reviewed head, UserDefinedLanguageServerSettings.loadState calls CommandUtils.collapsePathMacros on the command line and working directory of each stored server. The settings page and export therefore show the $USER_HOME$ form as stored. The PR description states that UserDefinedDebugAdapterServerSettings.loadState does the same for its command, and that CommandUtils.resolveCommandLine still resolves macros when a server starts. The PR summary and the raw summary both describe these changes. I read UserDefinedLanguageServerSettings.java at head, which confirms the loadState change. I could not read the CommandUtils.java or test diffs through the repository tool, because the changed blobs were missing from the checkout. The CommandUtils and test behaviour rests on the PR description and summaries.

Full details: Out of Scope Changes check

Explanation

The changes listed in the raw summary all relate to the linked issue. They are: loadState collapse in UserDefinedLanguageServerSettings and UserDefinedDebugAdapterServerSettings; a new CommandUtils.collapsePathMacros helper used by those loadState methods; and the new UserDefinedSettingsPathMacrosTest, which covers the same behaviour. The raw summary lists no other production files. The UserDefinedLanguageServerSettings.java change at head matches the description. I could not inspect the CommandUtils and test diffs directly, so this verdict relies on the summaries for those files.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: feb30e6a-75d8-4d94-85bf-3b022fc31465
Commits

Reviewing files that changed from the base of the PR and between 89d31ea and bbfb68c.

Files selected for processing: 4

  • src/main/java/com/redhat/devtools/lsp4ij/dap/settings/UserDefinedDebugAdapterServerSettings.java
  • src/main/java/com/redhat/devtools/lsp4ij/launching/UserDefinedLanguageServerSettings.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/CommandUtils.java
  • src/test/java/com/redhat/devtools/lsp4ij/launching/UserDefinedSettingsPathMacrosTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 59.82%. Comparing base (89d31ea) to head (bbfb68c).

Files with missing lines Patch % Lines
...j/launching/UserDefinedLanguageServerSettings.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2389      +/-   ##
==========================================
+ Coverage   59.80%   59.82%   +0.02%     
==========================================
  Files         859      859              
  Lines       37602    37609       +7     
  Branches     7792     7793       +1     
==========================================
+ Hits        22488    22501      +13     
+ Misses      12031    12023       -8     
- Partials     3083     3085       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 9605ed5 into redhat-developer:main Dec 1, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working install user-defined LS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Something resolves the start command and store the resolved command

1 participant