fix(java-lsp): resolve symlinked git-clone project paths to virtual URIs - #6148
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening a Java problem (Problems → Java tab) or a Hierarchy node for a project cloned via the Git perspective failed with a 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 didjson.replace(realRoot, virtualRoot), whererealRootis…/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
JdtLsInstancenow 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 plainrealRootreplace (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()(stripfile:///workspace) keeps working unchanged for the Problems and Hierarchy views.Also swaps the
view-javalabels per request: view "Java" → "Hierarchy", inner tab "Hierarchy" → "Java" (tab id unchanged).Verification
Rebuilt
ide-java-lsp+view-javaand the application jar, restarted, and against the clonedsample-intent-multi-modelproject:POST /services/ide/java-lsp/diagnosticsnow returns virtual URIs, e.g.file:///workspace/workspace/countries/gen/countries/api/settings/CountryController.java(clone prefix gone).GET /services/ide/workspaces/workspace/countries/gen/countries/api/settings/CityController.java— returns 200.formatter:validatepasses on the changed module.🤖 Generated with Claude Code