Skip to content

Commit

Permalink
Update to latest Language Server Protocol (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig authored Jun 6, 2024
1 parent a9f0921 commit 9554a2f
Show file tree
Hide file tree
Showing 17 changed files with 730 additions and 577 deletions.
440 changes: 251 additions & 189 deletions generator/lsp.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions packages/python/lsprotocol/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ def _language_kind_hook(
return object_
return converter.structure(object_, lsp_types.LanguageKind)

def _text_edit_hook(
object_: Any, _: type
) -> Union[
lsp_types.TextEdit, lsp_types.AnnotatedTextEdit, lsp_types.SnippetTextEdit
]:
if "snippet" in object_:
return converter.structure(object_, lsp_types.SnippetTextEdit)
if "annotationId" in object_:
return converter.structure(object_, lsp_types.AnnotatedTextEdit)
return converter.structure(object_, lsp_types.TextEdit)

structure_hooks = [
(
Optional[
Expand Down Expand Up @@ -1079,6 +1090,14 @@ def _language_kind_hook(
Union[lsp_types.LanguageKind, str],
_language_kind_hook,
),
(
Union[
lsp_types.TextEdit,
lsp_types.AnnotatedTextEdit,
lsp_types.SnippetTextEdit,
],
_text_edit_hook,
),
]
for type_, hook in structure_hooks:
converter.register_structure_hook(type_, hook)
Expand Down
Loading

0 comments on commit 9554a2f

Please sign in to comment.