feat(proxy): support multi-level navigation from decompiled JAR classes - #305
feat(proxy): support multi-level navigation from decompiled JAR classes#305FanXingChunShui wants to merge 2 commits into
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: ckwang.
|
JDTLS reports classes inside jars with jdt:// URIs. The proxy already rewrites those into temporary decompiled .java files so Zed can open them, but navigation then stopped: Zed sends follow-up requests against the temporary file:// URI, which JDTLS does not understand. Persist the reverse mapping (file:// -> jdt://) next to each cached decompiled source, and rewrite incoming textDocument request URIs back to jdt:// before forwarding. Also suppress didOpen/didChange/didSave/didClose for decompiled-source worktrees so JDTLS never treats them as editable project files. The mapping lives on disk because Zed opens decompiled files in their own worktree, which spawns a fresh proxy process.
73d215f to
3de5084
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @FanXingChunShui on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@FanXingChunShui Could you point to a readily available example where the issue you are addressing here exists? |
| let rest = uri.strip_prefix("file://")?; | ||
| let decoded = percent_decode_str(rest).decode_utf8().ok()?; | ||
|
|
||
| if cfg!(windows) { |
There was a problem hiding this comment.
Let's please strive to use compile time checks rather than runtime
There was a problem hiding this comment.
Done in b490a90 — file_uri_to_path now uses #[cfg(windows)] / #[cfg(not(windows))] blocks, so only the branch for the current platform is compiled.
- Use compile-time cfg(windows) blocks instead of runtime cfg! in file_uri_to_path - Simplify sidecar_path with Path::with_added_extension
Any Java project reproduces it — no special dependencies required, the JDK alone is enough, since JDTLS returns jdt:// URIs for any class that lives in a JAR. Steps (with the Java extension built from this PR):
Before this PR, step 3 silently does nothing: Zed sends the follow-up request against the temporary file:// URI, which JDTLS does not recognize. This PR maps that URI back to the original jdt:// URI before forwarding, so navigation continues — and it chains, so you can navigate from one decompiled class into the next. |
Summary
When JDTLS resolves a symbol that lives inside a JAR, it returns
jdt://URIs.java-lsp-proxyalready rewrites those into temporary decompiled.javafiles so Zed can open them, but navigation then stopped: Zed sends follow-up requests against the temporaryfile://URI, which JDTLS does not understand.This PR adds the reverse half of that mapping so navigation can continue from one decompiled class into another.
Changes
proxy-common: addfile_uri_to_path(inverse ofpath_to_file_uri).proxy(decompile.rs): persist afile:// -> jdt://mapping as a<name>.java.jdt-urisidecar next to each cached decompiled source.proxy(main.rs):textDocumentrequest URIs back fromfile://tojdt://before forwarding to JDTLS;didOpen/didChange/didSave/didClosefor decompiled-source worktrees so JDTLS never treats them as editable project files.The mapping is stored on disk rather than in memory because Zed opens decompiled files in their own worktree, which spawns a fresh
java-lsp-proxyprocess.Validation
cargo test -p proxy-common -p java-lsp-proxy: 53 + 11 tests pass (including 5 new tests).cargo clippy -p proxy-common -p java-lsp-proxy --all-targets: clean.cargo fmt --all: clean.cargo check -p gradle-lsp-bridge: passes.