Skip to content

fix(java-lsp): resolve symlinked git-clone project paths to virtual URIs - #6148

Merged
delchev merged 2 commits into
masterfrom
fix/java-lsp-symlinked-clone-uri-resolution
Jul 5, 2026
Merged

fix(java-lsp): resolve symlinked git-clone project paths to virtual URIs#6148
delchev merged 2 commits into
masterfrom
fix/java-lsp-symlinked-clone-uri-resolution

Conversation

@delchev

@delchev delchev commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening a Java problem (Problems → Java tab) or a Hierarchy node for a project cloned via the Git perspective failed with a 404:

GET /services/ide/workspaces/file:/Users/.../target/dirigible/repository/.git/admin/workspace/
    sample-intent-multi-model/countries/gen/countries/api/settings/CityController.java  404

The editor received a raw absolute filesystem path instead of a workspace-relative one.

Root cause

Dirigible stores git clones under repository/.git/<user>/<workspace>/<clone-repo>/ and symlinks each contained project into the workspace root (root/users/<user>/<workspace>/<project> → the clone dir). JDT.LS resolves those symlinks and reports the canonical clone path.

JdtLsInstance's stdout real→virtual translation only did json.replace(realRoot, virtualRoot), where realRoot is …/root/users/<user>/<workspace>/. That never matches the canonical …/.git/…/<clone>/<project>/… path, so the untranslated real URI leaked to the browser.

A client-side lastIndexOf('/workspace/') resolver (like the debugger's) can't fix this — it can't know <clone-repo> is a folder to drop, and would produce /workspace/<clone-repo>/<project>/…, which still 404s. The mapping is only knowable on the server, where the symlink targets are visible.

Fix

JdtLsInstance now maintains a canonical-real → virtual URI prefix map, one entry per project whose workspace directory is a symlink (child.toRealPath() ≠ nominal path). It's rebuilt on a 5s TTL so a freshly cloned project is picked up without restarting JDT.LS. translateToVirtual() applies the plain realRoot replace (regular projects) then the symlink map (git clones), so diagnostics, call/type hierarchy, and all forwarded LSP messages get correct virtual URIs.

Because the fix is server-side, the client toWorkspacePath() (strip file:///workspace) keeps working unchanged for the Problems and Hierarchy views.

Also swaps the view-java labels per request: view "Java" → "Hierarchy", inner tab "Hierarchy" → "Java" (tab id unchanged).

Verification

Rebuilt ide-java-lsp + view-java and the application jar, restarted, and against the cloned sample-intent-multi-model project:

  • POST /services/ide/java-lsp/diagnostics now returns virtual URIs, e.g. file:///workspace/workspace/countries/gen/countries/api/settings/CountryController.java (clone prefix gone).
  • The exact URL the editor builds — GET /services/ide/workspaces/workspace/countries/gen/countries/api/settings/CityController.java — returns 200.
  • formatter:validate passes on the changed module.

🤖 Generated with Claude Code

delchev and others added 2 commits July 5, 2026 22:34
…URIs

JDT.LS resolves the per-project symlinks Dirigible creates for git clones
(stored under repository/.git/<user>/<workspace>/<clone>/ and symlinked into
the workspace root) and reports the canonical clone path. The stdout
real->virtual translation only did json.replace(realRoot, virtualRoot), which
never matched those canonical paths, so raw filesystem URIs leaked to the
browser and opening a Java problem / hierarchy node 404'd against the
workspaces endpoint.

JdtLsInstance now also maintains a canonical-real -> virtual URI prefix map for
symlinked project dirs (rebuilt on a 5s TTL so freshly cloned projects are
picked up without restart) and applies it in translateToVirtual(), fixing the
Problems (Java tab) and Hierarchy views for cloned multi-project repos.

Also swap the view-java labels: view "Java" -> "Hierarchy" and the inner tab
"Hierarchy" -> "Java".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@delchev
delchev merged commit 261b853 into master Jul 5, 2026
3 checks passed
@delchev
delchev deleted the fix/java-lsp-symlinked-clone-uri-resolution branch July 5, 2026 20:48
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