From 85d3c30cf86a21e6e7a2581002b27cc49df92bb7 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Sun, 20 Jun 2021 16:34:33 +0200 Subject: [PATCH 1/5] Enable uri schemes --- LSP-jdtls.sublime-settings | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/LSP-jdtls.sublime-settings b/LSP-jdtls.sublime-settings index 805e883..ef78f3e 100644 --- a/LSP-jdtls.sublime-settings +++ b/LSP-jdtls.sublime-settings @@ -1,6 +1,13 @@ { // We start this language server when we open java files. "selector": "source.java", + // Declares what URI schemes this server attaches to. + "schemes": [ + // regular files on disk + "file", + // opened by a DAP-compatible debugger + "jdt" + ], // The startup command. "command": [ "${java_executable}", From 1ccb8718d18fdcf25a60ea55bd8cc70f4f278176 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Sun, 4 Jul 2021 11:27:40 +0200 Subject: [PATCH 2/5] Handle jdt URIs with java/classFileContents request --- plugin.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 28f9d84..656c625 100644 --- a/plugin.py +++ b/plugin.py @@ -4,8 +4,7 @@ from LSP.plugin import unregister_plugin from LSP.plugin import Request from LSP.plugin.core.typing import Optional, Any, List, Dict, Mapping, Callable -from LSP.plugin.core.registry import LspTextCommand -from LSP.plugin.core.protocol import ExecuteCommandParams, Notification + import os import sublime from urllib.request import urlopen @@ -18,6 +17,10 @@ # TODO: Not part of the public API :( from LSP.plugin.core.edit import apply_workspace_edit from LSP.plugin.core.edit import parse_workspace_edit +from LSP.plugin.core.protocol import DocumentUri +from LSP.plugin.core.protocol import ExecuteCommandParams +from LSP.plugin.core.protocol import Notification +from LSP.plugin.core.registry import LspTextCommand from LSP.plugin.core.views import location_to_encoded_filename, text_document_identifier @@ -156,6 +159,20 @@ def install_or_update(cls) -> None: if os.path.isdir(absdir): shutil.move(absdir, serverdir(cls.storage_subpath())) + def on_open_uri_async(self, uri: DocumentUri, callback: Callable[[str, str, str], None]) -> bool: + if not uri.startswith("jdt:"): + return False + session = self.weaksession() + if not session: + return False + view = session.window.active_view() + session.send_request_async( + Request("java/classFileContents", text_document_identifier(uri), view, progress=True), + lambda resp: callback(uri, resp, "Packages/Java/Java.sublime-syntax"), + lambda err: callback("ERROR", str(err), "Packages/Text/Plain text.tmLanguage") + ) + return True + def on_pre_server_command(self, command: Mapping[str, Any], done: Callable[[], None]) -> bool: session = self.weaksession() if not session: From 00ae27428a626a4c6e8f0afb7f09a73061b544a2 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Sun, 4 Jul 2021 11:31:32 +0200 Subject: [PATCH 3/5] Add some references --- plugin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin.py b/plugin.py index 656c625..5af5863 100644 --- a/plugin.py +++ b/plugin.py @@ -166,6 +166,9 @@ def on_open_uri_async(self, uri: DocumentUri, callback: Callable[[str, str, str] if not session: return False view = session.window.active_view() + # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/protocol.ts#L105-L107 + # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/providerDispatcher.ts#L61-L76 + # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/providerDispatcher.ts#L27-L28 session.send_request_async( Request("java/classFileContents", text_document_identifier(uri), view, progress=True), lambda resp: callback(uri, resp, "Packages/Java/Java.sublime-syntax"), From 4b1bdb8af1c2b2e69047fcf559b61f55022bf9c9 Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Tue, 17 Aug 2021 12:41:03 +0200 Subject: [PATCH 4/5] Regard 'java/classFileContents' as a window request --- plugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 5af5863..2309e70 100644 --- a/plugin.py +++ b/plugin.py @@ -165,12 +165,11 @@ def on_open_uri_async(self, uri: DocumentUri, callback: Callable[[str, str, str] session = self.weaksession() if not session: return False - view = session.window.active_view() # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/protocol.ts#L105-L107 # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/providerDispatcher.ts#L61-L76 # https://github.com/redhat-developer/vscode-java/blob/9f32875a67352487f5c414bb7fef04c9b00af89d/src/providerDispatcher.ts#L27-L28 session.send_request_async( - Request("java/classFileContents", text_document_identifier(uri), view, progress=True), + Request("java/classFileContents", text_document_identifier(uri), progress=True), lambda resp: callback(uri, resp, "Packages/Java/Java.sublime-syntax"), lambda err: callback("ERROR", str(err), "Packages/Text/Plain text.tmLanguage") ) From 911256de23609cf91d9c9c123b425fe69bd8396f Mon Sep 17 00:00:00 2001 From: Raoul Wols Date: Tue, 17 Aug 2021 12:42:15 +0200 Subject: [PATCH 5/5] Notification is public --- plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 2309e70..77951c9 100644 --- a/plugin.py +++ b/plugin.py @@ -3,6 +3,7 @@ from LSP.plugin import Session from LSP.plugin import unregister_plugin from LSP.plugin import Request +from LSP.plugin import Notification from LSP.plugin.core.typing import Optional, Any, List, Dict, Mapping, Callable import os @@ -19,9 +20,9 @@ from LSP.plugin.core.edit import parse_workspace_edit from LSP.plugin.core.protocol import DocumentUri from LSP.plugin.core.protocol import ExecuteCommandParams -from LSP.plugin.core.protocol import Notification from LSP.plugin.core.registry import LspTextCommand -from LSP.plugin.core.views import location_to_encoded_filename, text_document_identifier +from LSP.plugin.core.views import location_to_encoded_filename +from LSP.plugin.core.views import text_document_identifier DOWNLOAD_URL = "http://download.eclipse.org/jdtls/snapshots"