Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Jun 6, 2024
1 parent ff1d54d commit 16c1870
Showing 1 changed file with 19 additions and 0 deletions.
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 "annotation_id" in object_:
return converter.structure(object_, lsp_types.AnnotatedTextEdit)
if "snippet" 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

0 comments on commit 16c1870

Please sign in to comment.