feat(lsp): support Java class file contents and improve definition navigation handling

- Add `_lsp_java_class_file_contents` request to fetch contents of compiled Java classes via LSP (`java/classFileContents`).
- Handle `java/classFileContents` responses by opening a new buffer with Java syntax highlighting and inserting the returned source.
- Update definition handling to pass URI and range, enabling precise cursor placement after navigation.
- Detect `jdt://` URIs in `textDocument/definition` responses and request class file contents instead of direct navigation.
- Move goto navigation logic into `LSPServerEventsMixin`, using event system to access the active view and position the cursor.
- Expose `emit` and `emit_to` to the response cache for event dispatching.
- Restrict completion activation to `USER_REQUESTED`.
- Add TODO note about mapping language IDs to dedicated response handlers.
This commit is contained in:
2026-03-08 17:54:21 -05:00
parent 449e3c7eb9
commit 3dfb198aa5
5 changed files with 65 additions and 25 deletions

View File

@@ -66,6 +66,9 @@ class ProviderResponseCache(LSPClientEventsMixin, LSPServerEventsMixin, Provider
return True
# TODO: Need to map 'lang_id' to a given language response class and
# pass the controller to a 'server_response' method there.
# It would allow clean separation of each language's idiosyncracies
def server_response(self, lsp_response: LSPResponseTypes):
logger.debug(f"LSP Response: { lsp_response }")
@@ -81,7 +84,16 @@ class ProviderResponseCache(LSPClientEventsMixin, LSPServerEventsMixin, Provider
case "textDocument/completion":
self._handle_completion_response(lsp_response.result)
case "textDocument/definition":
self._handle_definition_response(lsp_response.result)
result = lsp_response.result
if not result: return
uri = result[0]["uri"]
if "jdt://" in uri:
controller._lsp_java_class_file_contents(uri)
return
self._handle_definition_response(uri, result[0]["range"])
case "java/classFileContents":
self._handle_java_class_file_contents(lsp_response.result)
case _:
...
elif isinstance(lsp_response, LSPResponseNotification):