From 2a1d6d0f05a5d61719768bc2252d5ed923fd8214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= <rchl2k@gmail.com> Date: Fri, 26 Jan 2024 20:03:57 +0100 Subject: [PATCH] Adapt to API changes in LSP 1.28.0 (#47) * Adapt to API changes in LSP 1.28.0 * uri_from_view * reverse focus removal --- modules/jdtls.py | 6 +++--- modules/protocol_extensions_handler.py | 2 +- modules/test_extension_commands.py | 12 +++++++----- modules/workspace_execute_command_handler.py | 10 +++------- sublime-package.json | 4 +++- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/jdtls.py b/modules/jdtls.py index b3536ec..234d303 100644 --- a/modules/jdtls.py +++ b/modules/jdtls.py @@ -12,7 +12,7 @@ unregister_plugin, ) from LSP.plugin.core.protocol import DocumentUri -from LSP.plugin.core.sessions import ExecuteCommandParams +from LSP.plugin.core.protocol import ExecuteCommandParams from LSP.plugin.core.types import ClientConfig from LSP.plugin.core.typing import Any, Callable, Dict, List, Optional from LSP.plugin.core.views import text_document_identifier @@ -228,14 +228,14 @@ def on_open_uri_async( ######################### def on_pre_server_command( - self, command: ExecuteCommandParams, done: Callable[[], None] + self, command: ExecuteCommandParams, done_callback: Callable[[], None] ) -> bool: session = self.weaksession() if not session: return False if handle_client_command( session, - done, + done_callback, command["command"], command["arguments"] if "arguments" in command else [], ): diff --git a/modules/protocol_extensions_handler.py b/modules/protocol_extensions_handler.py index 0e00313..db61dce 100644 --- a/modules/protocol_extensions_handler.py +++ b/modules/protocol_extensions_handler.py @@ -4,11 +4,11 @@ See https://github.com/redhat-developer/vscode-java/blob/master/src/standardLanguageClient.ts """ import sublime +from LSP.plugin import Session from LSP.plugin.core.protocol import ( Command, ExecuteCommandParams, # noqa: F401 ) -from LSP.plugin.core.sessions import Session from LSP.plugin.core.typing import Optional from .protocol import ActionableNotification, ProgressReport, StatusReport diff --git a/modules/test_extension_commands.py b/modules/test_extension_commands.py index 45e17d3..9a5fb85 100644 --- a/modules/test_extension_commands.py +++ b/modules/test_extension_commands.py @@ -2,15 +2,15 @@ import os import sublime -from LSP.plugin import Session, parse_uri +from LSP.plugin import Session, parse_uri, uri_from_view from LSP.plugin.core.constants import KIND_CLASS, KIND_METHOD -from LSP.plugin.core.edit import WorkspaceEdit, parse_workspace_edit +from LSP.plugin.core.edit import parse_workspace_edit from LSP.plugin.core.protocol import ExecuteCommandParams # noqa: F401 +from LSP.plugin.core.protocol import WorkspaceEdit from LSP.plugin.core.typing import Callable, List, Tuple from LSP.plugin.core.views import ( first_selection_region, offset_to_point, - uri_from_view, ) from .constants import SESSION_NAME @@ -61,8 +61,10 @@ def open_changed_file(result): open_and_focus_uri(window, uri) return - session.apply_parsed_workspace_edits(parsed_worspace_edit).then( - open_changed_file + sublime.set_timeout_async( + lambda: session.apply_workspace_edit_async(workspace_edit).then( + open_changed_file + ) ) session.execute_command(command, False).then(_on_done) diff --git a/modules/workspace_execute_command_handler.py b/modules/workspace_execute_command_handler.py index cb1cda3..2cc4a2b 100644 --- a/modules/workspace_execute_command_handler.py +++ b/modules/workspace_execute_command_handler.py @@ -2,7 +2,6 @@ import sublime from LSP.plugin import Session -from LSP.plugin.core.edit import apply_workspace_edit, parse_workspace_edit from LSP.plugin.core.types import Callable from LSP.plugin.core.views import location_to_encoded_filename @@ -43,12 +42,9 @@ def _set_null_analysis_mode( def _apply_workspace_edit(session: Session, done: Callable[[], None], *arguments): - changes = parse_workspace_edit(arguments[0]) - window = session.window - sublime.set_timeout( - lambda: apply_workspace_edit(window, changes).then( - lambda _: sublime.set_timeout_async(done) - ) + changes = arguments[0] + sublime.set_timeout_async( + lambda: session.apply_workspace_edit_async(changes).then(lambda _: done()) ) diff --git a/sublime-package.json b/sublime-package.json index eeec599..e9ff1a4 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -520,7 +520,9 @@ "Do not show any build status on start" ] }, - "boolean" + { + "type": "boolean" + } ], "description": "Automatically show build status on startup.", "default": "notification",