Skip to content

Commit

Permalink
Remove code no longer needed since version 0.6.5 of the server (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Nov 8, 2021
1 parent dac1b91 commit 4b7d227
Showing 1 changed file with 2 additions and 39 deletions.
41 changes: 2 additions & 39 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .protocol import InlayHint, InlayHintRequestParams, InlayHintResponse, CompletionCodeActionCommand
from .protocol import InlayHint, InlayHintRequestParams, InlayHintResponse
from html import escape as html_escape
from LSP.plugin import ClientConfig
from LSP.plugin import SessionBufferProtocol
from LSP.plugin import uri_to_filename
from LSP.plugin import WorkspaceFolder
from LSP.plugin.core.protocol import Point
from LSP.plugin.core.typing import Any, Callable, Dict, List, Mapping, Optional
from LSP.plugin.core.typing import Any, Callable, List, Optional
from LSP.plugin.core.views import point_to_offset
from LSP.plugin.core.views import text_document_identifier
from lsp_utils import ApiWrapperInterface
Expand All @@ -14,14 +14,6 @@
import os
import sublime

try:
from LSP.plugin.core.edit import apply_workspace_edit
from LSP.plugin.core.edit import TextEditTuple
except ImportError:
# Not supported in ST3
TextEditTuple = Any
pass


def plugin_loaded() -> None:
LspTypescriptPlugin.setup()
Expand Down Expand Up @@ -55,26 +47,6 @@ def inlay_hint_to_phantom(view: sublime.View, hint: InlayHint) -> sublime.Phanto
return sublime.Phantom(region, html, sublime.LAYOUT_INLINE)


def to_lsp_edits(items: List[CompletionCodeActionCommand]) -> Dict[str, List[TextEditTuple]]:
workspace_edits = {} # type: Dict[str, List[TextEditTuple]]
for item in items:
for change in item['changes']:
file_changes = [] # List[TextEditTuple]
for text_change in change['textChanges']:
start = text_change['start']
end = text_change['end']
file_changes.append(
(
(start['line'] - 1, start['offset'] - 1),
(end['line'] - 1, end['offset'] - 1),
text_change['newText'].replace("\r", ""),
None,
)
)
workspace_edits[change['fileName']] = file_changes
return workspace_edits


class LspTypescriptPlugin(NpmClientHandler):
package_name = __package__
server_directory = 'typescript-language-server'
Expand Down Expand Up @@ -120,15 +92,6 @@ def on_typescript_rename(self, position_params: Any, respond: Callable[[None], N
def on_session_buffer_changed_async(self, session_buffer: SessionBufferProtocol) -> None:
self._request_inlay_hints_async(session_buffer)

def on_pre_server_command(self, command: Mapping[str, Any], done_callback: Callable[[], None]) -> bool:
if command['command'] == '_typescript.applyCompletionCodeAction':
_, items = command['arguments']
session = self.weaksession()
if session:
apply_workspace_edit(session.window, to_lsp_edits(items)).then(lambda _: done_callback())
return True
return False

# --- Inlay Hints handlers -----------------------------------------------------------------------------------------

def _request_inlay_hints_async(self, session_buffer: SessionBufferProtocol) -> None:
Expand Down

0 comments on commit 4b7d227

Please sign in to comment.