Skip to content

Commit

Permalink
Adapt to API changes in LSP 1.28.0 (#47)
Browse files Browse the repository at this point in the history
* Adapt to API changes in LSP 1.28.0

* uri_from_view

* reverse focus removal
  • Loading branch information
rchl authored Jan 26, 2024
1 parent 303f47b commit 2a1d6d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions modules/jdtls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 [],
):
Expand Down
2 changes: 1 addition & 1 deletion modules/protocol_extensions_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions modules/test_extension_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions modules/workspace_execute_command_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())
)


Expand Down
4 changes: 3 additions & 1 deletion sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@
"Do not show any build status on start"
]
},
"boolean"
{
"type": "boolean"
}
],
"description": "Automatically show build status on startup.",
"default": "notification",
Expand Down

0 comments on commit 2a1d6d0

Please sign in to comment.