Skip to content

Fix hover and qualified-symbol resolution for jdtls#139

Open
briiiqtt wants to merge 1 commit into
isaacphi:mainfrom
briiiqtt:fix/jdtls-hover-and-qualified-symbols
Open

Fix hover and qualified-symbol resolution for jdtls#139
briiiqtt wants to merge 1 commit into
isaacphi:mainfrom
briiiqtt:fix/jdtls-hover-and-qualified-symbols

Conversation

@briiiqtt

@briiiqtt briiiqtt commented Jun 5, 2026

Copy link
Copy Markdown

Summary

The Eclipse JDT language server (jdtls) behaves differently from the servers this project was built against, which breaks hover and qualified (e.g. Foo.bar) definition/reference lookups. This reworks the affected tools to handle jdtls while degrading safely for every other server.

Hover

  • Widen Hover.Contents to the spec union Or_Hover_contents so jdtls' deprecated MarkedString / []MarkedString shapes decode instead of collapsing to empty, and render all three shapes uniformly.
  • Advertise hover contentFormat [Markdown, PlainText] so servers prefer MarkupContent going forward.
  • Fix the empty-hover line fallback dropping text on a file's last line.

Qualified-symbol resolution

  • Add a workspace/symbol + textDocument/documentSymbol fallback that resolves Foo.bar style names, scoping members to their container type (handling hierarchical and flat symbols, nested/generic containers).
  • Pass server-provided names as args rather than into the format string to avoid %-verb injection; dedup members across results.

Robustness

  • Route URI→path through uriToPath, recovering the panic on non-file URIs (jdt://) so all tools degrade gracefully instead of crashing.
  • Unify the references error policy: skip per-file open errors but surface a hard references RPC failure only when nothing resolved.
  • Fix line-number padding width off-by-one.

Tests

Adds unit tests for hover shapes, qualified resolution, container scoping, cross-result dedup, fallback wiring, and the line helpers.

🤖 Generated with Claude Code

The Eclipse JDT language server (jdtls) behaves differently from the
servers this project was built against, breaking hover and qualified
(e.g. Foo.bar) definition/reference lookups. This reworks the affected
tools to handle it while degrading safely for every other server.

Hover:
- Widen Hover.Contents to the spec union Or_Hover_contents so jdtls'
  deprecated MarkedString / []MarkedString shapes decode instead of
  collapsing to empty, and render all three shapes uniformly.
- Advertise hover contentFormat [Markdown, PlainText] so servers prefer
  MarkupContent going forward.
- Fix the empty-hover line fallback dropping text on a file's last line.

Qualified-symbol resolution:
- Add a workspace/symbol + textDocument/documentSymbol fallback that
  resolves Foo.bar style names, scoping members to their container type
  (handling hierarchical and flat symbols, nested/generic containers).
- Pass server-provided names as args rather than into the format string
  to avoid %-verb injection; dedup members across results.

Robustness:
- Route URI->path through uriToPath, recovering the panic on non-file
  URIs (jdt://) so all tools degrade gracefully instead of crashing.
- Unify the references error policy: skip per-file open errors but
  surface a hard references RPC failure only when nothing resolved.
- Fix line-number padding width off-by-one.

Adds unit tests for hover shapes, qualified resolution, container
scoping, cross-result dedup, fallback wiring, and the line helpers.
@briiiqtt briiiqtt marked this pull request as ready for review June 5, 2026 13:31
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