@@ -634,6 +634,88 @@ def _notebook_sync_option_selector_hook(
634634 object_ , lsp_types .NotebookDocumentSyncOptionsNotebookSelectorType2
635635 )
636636
637+ def _semantic_token_registration_options_hook (
638+ object_ : Any , _ : type
639+ ) -> Optional [
640+ Union [OptionalPrimitive , lsp_types .SemanticTokensRegistrationOptionsFullType1 ]
641+ ]:
642+ if object_ is None :
643+ return None
644+ if isinstance (object_ , (bool , int , str , float )):
645+ return object_
646+ return converter .structure (
647+ object_ , lsp_types .SemanticTokensRegistrationOptionsFullType1
648+ )
649+
650+ def _inline_completion_provider_hook (
651+ object_ : Any , _ : type
652+ ) -> Optional [Union [OptionalPrimitive , lsp_types .InlineCompletionOptions ]]:
653+ if object_ is None :
654+ return None
655+ if isinstance (object_ , (bool , int , str , float )):
656+ return object_
657+ return converter .structure (object_ , lsp_types .InlineCompletionOptions )
658+
659+ def _inline_completion_list_hook (
660+ object_ : Any , _ : type
661+ ) -> Optional [
662+ Union [lsp_types .InlineCompletionList , List [lsp_types .InlineCompletionItem ]]
663+ ]:
664+ if object_ is None :
665+ return None
666+ if isinstance (object_ , list ):
667+ return [
668+ converter .structure (item , lsp_types .InlineCompletionItem )
669+ for item in object_
670+ ]
671+ return converter .structure (object_ , lsp_types .InlineCompletionList )
672+
673+ def _string_value_hook (
674+ object_ : Any , _ : type
675+ ) -> Union [OptionalPrimitive , lsp_types .StringValue ]:
676+ if object_ is None :
677+ return None
678+ if isinstance (object_ , (bool , int , str , float )):
679+ return object_
680+ return converter .structure (object_ , lsp_types .StringValue )
681+
682+ def _symbol_list_hook (
683+ object_ : Any , _ : type
684+ ) -> Optional [
685+ Union [List [lsp_types .SymbolInformation ], List [lsp_types .WorkspaceSymbol ]]
686+ ]:
687+ if object_ is None :
688+ return None
689+ assert isinstance (object_ , list )
690+ if len (object_ ) == 0 :
691+ return [] # type: ignore[return-value]
692+ if "location" in object_ [0 ]:
693+ return [
694+ converter .structure (item , lsp_types .SymbolInformation )
695+ for item in object_
696+ ]
697+ else :
698+ return [
699+ converter .structure (item , lsp_types .WorkspaceSymbol ) for item in object_
700+ ]
701+
702+ def _notebook_sync_registration_option_selector_hook (
703+ object_ : Any , _ : type
704+ ) -> Union [
705+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType1 ,
706+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType2 ,
707+ ]:
708+ if "notebook" in object_ :
709+ return converter .structure (
710+ object_ ,
711+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType1 ,
712+ )
713+ else :
714+ return converter .structure (
715+ object_ ,
716+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType2 ,
717+ )
718+
637719 structure_hooks = [
638720 (
639721 Optional [
@@ -940,6 +1022,41 @@ def _notebook_sync_option_selector_hook(
9401022 ],
9411023 _position_encoding_hook ,
9421024 ),
1025+ (
1026+ Optional [Union [bool , lsp_types .SemanticTokensRegistrationOptionsFullType1 ]],
1027+ _semantic_token_registration_options_hook ,
1028+ ),
1029+ (
1030+ Optional [Union [bool , lsp_types .InlineCompletionOptions ]],
1031+ _inline_completion_provider_hook ,
1032+ ),
1033+ (
1034+ Optional [
1035+ Union [
1036+ lsp_types .InlineCompletionList , List [lsp_types .InlineCompletionItem ]
1037+ ]
1038+ ],
1039+ _inline_completion_list_hook ,
1040+ ),
1041+ (
1042+ Union [str , lsp_types .StringValue ],
1043+ _string_value_hook ,
1044+ ),
1045+ (
1046+ Optional [
1047+ Union [
1048+ List [lsp_types .SymbolInformation ], List [lsp_types .WorkspaceSymbol ]
1049+ ]
1050+ ],
1051+ _symbol_list_hook ,
1052+ ),
1053+ (
1054+ Union [
1055+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType1 ,
1056+ lsp_types .NotebookDocumentSyncRegistrationOptionsNotebookSelectorType2 ,
1057+ ],
1058+ _notebook_sync_registration_option_selector_hook ,
1059+ ),
9431060 ]
9441061 for type_ , hook in structure_hooks :
9451062 converter .register_structure_hook (type_ , hook )
0 commit comments