@difizen/libro-language-client 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/es/common/api.d.ts +38 -0
  4. package/es/common/api.d.ts.map +1 -0
  5. package/es/common/api.js +9 -0
  6. package/es/common/callHierarchy.d.ts +39 -0
  7. package/es/common/callHierarchy.d.ts.map +1 -0
  8. package/es/common/callHierarchy.js +139 -0
  9. package/es/common/client.d.ts +482 -0
  10. package/es/common/client.d.ts.map +1 -0
  11. package/es/common/client.js +2731 -0
  12. package/es/common/codeAction.d.ts +22 -0
  13. package/es/common/codeAction.d.ts.map +1 -0
  14. package/es/common/codeAction.js +149 -0
  15. package/es/common/codeConverter.d.ts +81 -0
  16. package/es/common/codeConverter.d.ts.map +1 -0
  17. package/es/common/codeConverter.js +1040 -0
  18. package/es/common/codeLens.d.ts +26 -0
  19. package/es/common/codeLens.d.ts.map +1 -0
  20. package/es/common/codeLens.js +125 -0
  21. package/es/common/colorProvider.d.ts +27 -0
  22. package/es/common/colorProvider.d.ts.map +1 -0
  23. package/es/common/colorProvider.js +104 -0
  24. package/es/common/completion.d.ts +22 -0
  25. package/es/common/completion.d.ts.map +1 -0
  26. package/es/common/completion.js +130 -0
  27. package/es/common/configuration.d.ts +71 -0
  28. package/es/common/configuration.d.ts.map +1 -0
  29. package/es/common/configuration.js +292 -0
  30. package/es/common/declaration.d.ts +18 -0
  31. package/es/common/declaration.d.ts.map +1 -0
  32. package/es/common/declaration.js +88 -0
  33. package/es/common/definition.d.ts +18 -0
  34. package/es/common/definition.d.ts.map +1 -0
  35. package/es/common/definition.js +80 -0
  36. package/es/common/diagnostic.d.ts +125 -0
  37. package/es/common/diagnostic.d.ts.map +1 -0
  38. package/es/common/diagnostic.js +1442 -0
  39. package/es/common/documentHighlight.d.ts +17 -0
  40. package/es/common/documentHighlight.d.ts.map +1 -0
  41. package/es/common/documentHighlight.js +73 -0
  42. package/es/common/documentLink.d.ts +21 -0
  43. package/es/common/documentLink.d.ts.map +1 -0
  44. package/es/common/documentLink.js +90 -0
  45. package/es/common/documentSymbol.d.ts +20 -0
  46. package/es/common/documentSymbol.d.ts.map +1 -0
  47. package/es/common/documentSymbol.js +134 -0
  48. package/es/common/executeCommand.d.ts +22 -0
  49. package/es/common/executeCommand.d.ts.map +1 -0
  50. package/es/common/executeCommand.js +117 -0
  51. package/es/common/features.d.ts +421 -0
  52. package/es/common/features.d.ts.map +1 -0
  53. package/es/common/features.js +576 -0
  54. package/es/common/fileOperations.d.ts +118 -0
  55. package/es/common/fileOperations.d.ts.map +1 -0
  56. package/es/common/fileOperations.js +705 -0
  57. package/es/common/fileSystemWatcher.d.ts +19 -0
  58. package/es/common/fileSystemWatcher.d.ts.map +1 -0
  59. package/es/common/fileSystemWatcher.js +173 -0
  60. package/es/common/foldingRange.d.ts +22 -0
  61. package/es/common/foldingRange.d.ts.map +1 -0
  62. package/es/common/foldingRange.js +127 -0
  63. package/es/common/formatting.d.ts +41 -0
  64. package/es/common/formatting.d.ts.map +1 -0
  65. package/es/common/formatting.js +233 -0
  66. package/es/common/hover.d.ts +18 -0
  67. package/es/common/hover.d.ts.map +1 -0
  68. package/es/common/hover.js +80 -0
  69. package/es/common/implementation.d.ts +18 -0
  70. package/es/common/implementation.d.ts.map +1 -0
  71. package/es/common/implementation.js +88 -0
  72. package/es/common/inlayHint.d.ts +23 -0
  73. package/es/common/inlayHint.d.ts.map +1 -0
  74. package/es/common/inlayHint.js +187 -0
  75. package/es/common/inlineCompletion.d.ts +20 -0
  76. package/es/common/inlineCompletion.d.ts.map +1 -0
  77. package/es/common/inlineCompletion.js +74 -0
  78. package/es/common/inlineValue.d.ts +21 -0
  79. package/es/common/inlineValue.d.ts.map +1 -0
  80. package/es/common/inlineValue.js +124 -0
  81. package/es/common/linkedEditingRange.d.ts +23 -0
  82. package/es/common/linkedEditingRange.d.ts.map +1 -0
  83. package/es/common/linkedEditingRange.js +94 -0
  84. package/es/common/notebook.d.ts +97 -0
  85. package/es/common/notebook.d.ts.map +1 -0
  86. package/es/common/notebook.js +1444 -0
  87. package/es/common/progress.d.ts +12 -0
  88. package/es/common/progress.d.ts.map +1 -0
  89. package/es/common/progress.js +75 -0
  90. package/es/common/progressPart.d.ts +25 -0
  91. package/es/common/progressPart.d.ts.map +1 -0
  92. package/es/common/progressPart.js +147 -0
  93. package/es/common/protocolCallHierarchyItem.d.ts +9 -0
  94. package/es/common/protocolCallHierarchyItem.d.ts.map +1 -0
  95. package/es/common/protocolCallHierarchyItem.js +34 -0
  96. package/es/common/protocolCodeAction.d.ts +7 -0
  97. package/es/common/protocolCodeAction.d.ts.map +1 -0
  98. package/es/common/protocolCodeAction.js +32 -0
  99. package/es/common/protocolCodeLens.d.ts +7 -0
  100. package/es/common/protocolCodeLens.d.ts.map +1 -0
  101. package/es/common/protocolCodeLens.js +29 -0
  102. package/es/common/protocolCompletionItem.d.ts +13 -0
  103. package/es/common/protocolCompletionItem.d.ts.map +1 -0
  104. package/es/common/protocolCompletionItem.js +29 -0
  105. package/es/common/protocolConverter.d.ts +174 -0
  106. package/es/common/protocolConverter.d.ts.map +1 -0
  107. package/es/common/protocolConverter.js +1982 -0
  108. package/es/common/protocolDiagnostic.d.ts +20 -0
  109. package/es/common/protocolDiagnostic.d.ts.map +1 -0
  110. package/es/common/protocolDiagnostic.js +46 -0
  111. package/es/common/protocolDocumentLink.d.ts +8 -0
  112. package/es/common/protocolDocumentLink.d.ts.map +1 -0
  113. package/es/common/protocolDocumentLink.js +29 -0
  114. package/es/common/protocolInlayHint.d.ts +8 -0
  115. package/es/common/protocolInlayHint.d.ts.map +1 -0
  116. package/es/common/protocolInlayHint.js +29 -0
  117. package/es/common/protocolTypeHierarchyItem.d.ts +9 -0
  118. package/es/common/protocolTypeHierarchyItem.d.ts.map +1 -0
  119. package/es/common/protocolTypeHierarchyItem.js +34 -0
  120. package/es/common/protocolWorkspaceSymbol.d.ts +9 -0
  121. package/es/common/protocolWorkspaceSymbol.d.ts.map +1 -0
  122. package/es/common/protocolWorkspaceSymbol.js +36 -0
  123. package/es/common/reference.d.ts +22 -0
  124. package/es/common/reference.d.ts.map +1 -0
  125. package/es/common/reference.js +78 -0
  126. package/es/common/rename.d.ts +29 -0
  127. package/es/common/rename.d.ts.map +1 -0
  128. package/es/common/rename.js +132 -0
  129. package/es/common/selectionRange.d.ts +18 -0
  130. package/es/common/selectionRange.d.ts.map +1 -0
  131. package/es/common/selectionRange.js +108 -0
  132. package/es/common/semanticTokens.d.ts +36 -0
  133. package/es/common/semanticTokens.d.ts.map +1 -0
  134. package/es/common/semanticTokens.js +226 -0
  135. package/es/common/signatureHelp.d.ts +18 -0
  136. package/es/common/signatureHelp.d.ts.map +1 -0
  137. package/es/common/signatureHelp.js +103 -0
  138. package/es/common/textSynchronization.d.ts +104 -0
  139. package/es/common/textSynchronization.d.ts.map +1 -0
  140. package/es/common/textSynchronization.js +771 -0
  141. package/es/common/typeDefinition.d.ts +18 -0
  142. package/es/common/typeDefinition.d.ts.map +1 -0
  143. package/es/common/typeDefinition.js +89 -0
  144. package/es/common/typeHierarchy.d.ts +33 -0
  145. package/es/common/typeHierarchy.d.ts.map +1 -0
  146. package/es/common/typeHierarchy.js +138 -0
  147. package/es/common/utils/async.d.ts +42 -0
  148. package/es/common/utils/async.d.ts.map +1 -0
  149. package/es/common/utils/async.js +441 -0
  150. package/es/common/utils/is.d.ts +13 -0
  151. package/es/common/utils/is.d.ts.map +1 -0
  152. package/es/common/utils/is.js +52 -0
  153. package/es/common/utils/uuid.d.ts +23 -0
  154. package/es/common/utils/uuid.d.ts.map +1 -0
  155. package/es/common/utils/uuid.js +85 -0
  156. package/es/common/vscodeAdaptor/convertor.d.ts +7 -0
  157. package/es/common/vscodeAdaptor/convertor.d.ts.map +1 -0
  158. package/es/common/vscodeAdaptor/convertor.js +66 -0
  159. package/es/common/vscodeAdaptor/diagnosticCollection.d.ts +33 -0
  160. package/es/common/vscodeAdaptor/diagnosticCollection.d.ts.map +1 -0
  161. package/es/common/vscodeAdaptor/diagnosticCollection.js +310 -0
  162. package/es/common/vscodeAdaptor/extHostTypes.d.ts +1496 -0
  163. package/es/common/vscodeAdaptor/extHostTypes.d.ts.map +1 -0
  164. package/es/common/vscodeAdaptor/extHostTypes.js +3825 -0
  165. package/es/common/vscodeAdaptor/fileWatcher.d.ts +19 -0
  166. package/es/common/vscodeAdaptor/fileWatcher.d.ts.map +1 -0
  167. package/es/common/vscodeAdaptor/fileWatcher.js +45 -0
  168. package/es/common/vscodeAdaptor/hostTypeUtil.d.ts +192 -0
  169. package/es/common/vscodeAdaptor/hostTypeUtil.d.ts.map +1 -0
  170. package/es/common/vscodeAdaptor/hostTypeUtil.js +566 -0
  171. package/es/common/vscodeAdaptor/libro-fs.d.ts +21 -0
  172. package/es/common/vscodeAdaptor/libro-fs.d.ts.map +1 -0
  173. package/es/common/vscodeAdaptor/libro-fs.js +64 -0
  174. package/es/common/vscodeAdaptor/libroWindow.d.ts +21 -0
  175. package/es/common/vscodeAdaptor/libroWindow.d.ts.map +1 -0
  176. package/es/common/vscodeAdaptor/libroWindow.js +75 -0
  177. package/es/common/vscodeAdaptor/libroWorkspace.d.ts +33 -0
  178. package/es/common/vscodeAdaptor/libroWorkspace.d.ts.map +1 -0
  179. package/es/common/vscodeAdaptor/libroWorkspace.js +250 -0
  180. package/es/common/vscodeAdaptor/lspEnv.d.ts +8 -0
  181. package/es/common/vscodeAdaptor/lspEnv.d.ts.map +1 -0
  182. package/es/common/vscodeAdaptor/lspEnv.js +31 -0
  183. package/es/common/vscodeAdaptor/monaco-converter.d.ts +229 -0
  184. package/es/common/vscodeAdaptor/monaco-converter.d.ts.map +1 -0
  185. package/es/common/vscodeAdaptor/monaco-converter.js +1613 -0
  186. package/es/common/vscodeAdaptor/monacoLanguages.d.ts +48 -0
  187. package/es/common/vscodeAdaptor/monacoLanguages.d.ts.map +1 -0
  188. package/es/common/vscodeAdaptor/monacoLanguages.js +484 -0
  189. package/es/common/vscodeAdaptor/services.d.ts +85 -0
  190. package/es/common/vscodeAdaptor/services.d.ts.map +1 -0
  191. package/es/common/vscodeAdaptor/services.js +3 -0
  192. package/es/common/vscodeAdaptor/typings.d.ts +10 -0
  193. package/es/common/vscodeAdaptor/util.d.ts +3 -0
  194. package/es/common/vscodeAdaptor/util.d.ts.map +1 -0
  195. package/es/common/vscodeAdaptor/util.js +6 -0
  196. package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts +77 -0
  197. package/es/common/vscodeAdaptor/vscodeAdaptor.d.ts.map +1 -0
  198. package/es/common/vscodeAdaptor/vscodeAdaptor.js +124 -0
  199. package/es/common/workspaceFolder.d.ts +32 -0
  200. package/es/common/workspaceFolder.d.ts.map +1 -0
  201. package/es/common/workspaceFolder.js +204 -0
  202. package/es/common/workspaceSymbol.d.ts +21 -0
  203. package/es/common/workspaceSymbol.d.ts.map +1 -0
  204. package/es/common/workspaceSymbol.js +101 -0
  205. package/es/constants.d.ts +2 -0
  206. package/es/constants.d.ts.map +1 -0
  207. package/es/constants.js +1 -0
  208. package/es/index.d.ts +6 -0
  209. package/es/index.d.ts.map +1 -0
  210. package/es/index.js +5 -0
  211. package/es/libro-language-client-contribution.d.ts +10 -0
  212. package/es/libro-language-client-contribution.d.ts.map +1 -0
  213. package/es/libro-language-client-contribution.js +143 -0
  214. package/es/libro-language-client-manager.d.ts +34 -0
  215. package/es/libro-language-client-manager.d.ts.map +1 -0
  216. package/es/libro-language-client-manager.js +277 -0
  217. package/es/libro-language-client.d.ts +27 -0
  218. package/es/libro-language-client.d.ts.map +1 -0
  219. package/es/libro-language-client.js +141 -0
  220. package/es/module.d.ts +3 -0
  221. package/es/module.d.ts.map +1 -0
  222. package/es/module.js +13 -0
  223. package/package.json +69 -0
  224. package/src/common/api.ts +155 -0
  225. package/src/common/callHierarchy.ts +269 -0
  226. package/src/common/client.ts +3192 -0
  227. package/src/common/codeAction.ts +237 -0
  228. package/src/common/codeConverter.ts +1409 -0
  229. package/src/common/codeLens.ts +188 -0
  230. package/src/common/colorProvider.ts +192 -0
  231. package/src/common/completion.ts +281 -0
  232. package/src/common/configuration.ts +338 -0
  233. package/src/common/declaration.ts +140 -0
  234. package/src/common/definition.ts +138 -0
  235. package/src/common/diagnostic.ts +1408 -0
  236. package/src/common/documentHighlight.ts +140 -0
  237. package/src/common/documentLink.ts +180 -0
  238. package/src/common/documentSymbol.ts +186 -0
  239. package/src/common/executeCommand.ts +129 -0
  240. package/src/common/features.ts +1157 -0
  241. package/src/common/fileOperations.ts +635 -0
  242. package/src/common/fileSystemWatcher.ts +184 -0
  243. package/src/common/foldingRange.ts +160 -0
  244. package/src/common/formatting.ts +465 -0
  245. package/src/common/hover.ts +133 -0
  246. package/src/common/implementation.ts +142 -0
  247. package/src/common/inlayHint.ts +201 -0
  248. package/src/common/inlineCompletion.ts +160 -0
  249. package/src/common/inlineValue.ts +158 -0
  250. package/src/common/linkedEditingRange.ts +141 -0
  251. package/src/common/notebook.ts +1443 -0
  252. package/src/common/progress.ts +61 -0
  253. package/src/common/progressPart.ts +151 -0
  254. package/src/common/protocolCallHierarchyItem.ts +29 -0
  255. package/src/common/protocolCodeAction.ts +17 -0
  256. package/src/common/protocolCodeLens.ts +15 -0
  257. package/src/common/protocolCompletionItem.ts +22 -0
  258. package/src/common/protocolConverter.ts +2627 -0
  259. package/src/common/protocolDiagnostic.ts +47 -0
  260. package/src/common/protocolDocumentLink.ts +17 -0
  261. package/src/common/protocolInlayHint.ts +21 -0
  262. package/src/common/protocolTypeHierarchyItem.ts +29 -0
  263. package/src/common/protocolWorkspaceSymbol.ts +39 -0
  264. package/src/common/reference.ts +144 -0
  265. package/src/common/rename.ts +230 -0
  266. package/src/common/selectionRange.ts +136 -0
  267. package/src/common/semanticTokens.ts +383 -0
  268. package/src/common/signatureHelp.ts +170 -0
  269. package/src/common/textSynchronization.ts +819 -0
  270. package/src/common/typeDefinition.ts +146 -0
  271. package/src/common/typeHierarchy.ts +248 -0
  272. package/src/common/utils/async.ts +354 -0
  273. package/src/common/utils/is.ts +63 -0
  274. package/src/common/utils/uuid.ts +136 -0
  275. package/src/common/vscodeAdaptor/convertor.ts +73 -0
  276. package/src/common/vscodeAdaptor/diagnosticCollection.ts +238 -0
  277. package/src/common/vscodeAdaptor/extHostTypes.ts +4498 -0
  278. package/src/common/vscodeAdaptor/fileWatcher.ts +36 -0
  279. package/src/common/vscodeAdaptor/hostTypeUtil.ts +539 -0
  280. package/src/common/vscodeAdaptor/libro-fs.ts +51 -0
  281. package/src/common/vscodeAdaptor/libroWindow.ts +85 -0
  282. package/src/common/vscodeAdaptor/libroWorkspace.ts +261 -0
  283. package/src/common/vscodeAdaptor/lspEnv.ts +16 -0
  284. package/src/common/vscodeAdaptor/monaco-converter.ts +1800 -0
  285. package/src/common/vscodeAdaptor/monacoLanguages.ts +511 -0
  286. package/src/common/vscodeAdaptor/services.ts +278 -0
  287. package/src/common/vscodeAdaptor/typings.d.ts +10 -0
  288. package/src/common/vscodeAdaptor/util.ts +7 -0
  289. package/src/common/vscodeAdaptor/vscodeAdaptor.ts +122 -0
  290. package/src/common/workspaceFolder.ts +236 -0
  291. package/src/common/workspaceSymbol.ts +166 -0
  292. package/src/constants.ts +1 -0
  293. package/src/index.spec.ts +7 -0
  294. package/src/index.ts +5 -0
  295. package/src/libro-language-client-contribution.ts +49 -0
  296. package/src/libro-language-client-manager.ts +131 -0
  297. package/src/libro-language-client.ts +100 -0
  298. package/src/module.ts +19 -0
@@ -0,0 +1,1157 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ import {
7
+ languages as Languages,
8
+ workspace as Workspace,
9
+ EventEmitter,
10
+ CancellationError,
11
+ } from './vscodeAdaptor/vscodeAdaptor.js';
12
+ import type {
13
+ CallHierarchyPrepareRequest,
14
+ ClientCapabilities,
15
+ CodeActionRequest,
16
+ CodeLensRequest,
17
+ CompletionRequest,
18
+ DeclarationRequest,
19
+ DefinitionRequest,
20
+ DidChangeTextDocumentNotification,
21
+ DidCloseTextDocumentNotification,
22
+ DidCreateFilesNotification,
23
+ DidDeleteFilesNotification,
24
+ DidOpenTextDocumentNotification,
25
+ DidRenameFilesNotification,
26
+ DidSaveTextDocumentNotification,
27
+ DocumentColorRequest,
28
+ DocumentDiagnosticRequest,
29
+ DocumentFormattingRequest,
30
+ DocumentHighlightRequest,
31
+ DocumentLinkRequest,
32
+ DocumentOnTypeFormattingRequest,
33
+ DocumentRangeFormattingRequest,
34
+ DocumentSelector,
35
+ DocumentSymbolRequest,
36
+ ExecuteCommandOptions,
37
+ ExecuteCommandRequest,
38
+ FileOperationRegistrationOptions,
39
+ FoldingRangeRequest,
40
+ GenericNotificationHandler,
41
+ GenericRequestHandler,
42
+ HoverRequest,
43
+ ImplementationRequest,
44
+ InitializeParams,
45
+ InlayHintRequest,
46
+ InlineCompletionRegistrationOptions,
47
+ InlineCompletionRequest,
48
+ InlineValueRequest,
49
+ LinkedEditingRangeRequest,
50
+ MessageSignature,
51
+ NotebookDocumentSyncRegistrationOptions,
52
+ NotebookDocumentSyncRegistrationType,
53
+ NotificationHandler,
54
+ NotificationHandler0,
55
+ NotificationType,
56
+ NotificationType0,
57
+ ProgressType,
58
+ ProtocolNotificationType,
59
+ ProtocolNotificationType0,
60
+ ProtocolRequestType,
61
+ ProtocolRequestType0,
62
+ ReferencesRequest,
63
+ RegistrationType,
64
+ RenameRequest,
65
+ RequestHandler,
66
+ RequestHandler0,
67
+ RequestType,
68
+ RequestType0,
69
+ SelectionRangeRequest,
70
+ SemanticTokensRegistrationType,
71
+ ServerCapabilities,
72
+ SignatureHelpRequest,
73
+ TextDocumentIdentifier,
74
+ TypeDefinitionRequest,
75
+ TypeHierarchyPrepareRequest,
76
+ WillCreateFilesRequest,
77
+ WillDeleteFilesRequest,
78
+ WillRenameFilesRequest,
79
+ WillSaveTextDocumentNotification,
80
+ WillSaveTextDocumentWaitUntilRequest,
81
+ WorkspaceSymbolRequest,
82
+ } from '@difizen/vscode-languageserver-protocol';
83
+ import {
84
+ StaticRegistrationOptions,
85
+ TextDocumentRegistrationOptions,
86
+ WorkDoneProgressOptions,
87
+ } from '@difizen/vscode-languageserver-protocol';
88
+ import type {
89
+ TextDocument,
90
+ Event as VEvent,
91
+ DocumentSelector as VDocumentSelector,
92
+ Event,
93
+ Disposable,
94
+ CancellationToken,
95
+ ProviderResult,
96
+ TextEdit as VTextEdit,
97
+ ReferenceProvider,
98
+ DefinitionProvider,
99
+ SignatureHelpProvider,
100
+ HoverProvider,
101
+ CompletionItemProvider,
102
+ WorkspaceSymbolProvider,
103
+ DocumentHighlightProvider,
104
+ CodeActionProvider,
105
+ DocumentFormattingEditProvider,
106
+ DocumentRangeFormattingEditProvider,
107
+ OnTypeFormattingEditProvider,
108
+ RenameProvider,
109
+ DocumentSymbolProvider,
110
+ DocumentLinkProvider,
111
+ DocumentColorProvider,
112
+ DeclarationProvider,
113
+ ImplementationProvider,
114
+ SelectionRangeProvider,
115
+ TypeDefinitionProvider,
116
+ CallHierarchyProvider,
117
+ LinkedEditingRangeProvider,
118
+ TypeHierarchyProvider,
119
+ FileCreateEvent,
120
+ FileRenameEvent,
121
+ FileDeleteEvent,
122
+ FileWillCreateEvent,
123
+ FileWillRenameEvent,
124
+ FileWillDeleteEvent,
125
+ InlineCompletionItemProvider,
126
+ } from 'vscode';
127
+
128
+ import type * as c2p from './codeConverter.js';
129
+
130
+ export class LSPCancellationError extends CancellationError {
131
+ public readonly data: object | NonNullable<unknown>;
132
+ constructor(data: object | NonNullable<unknown>) {
133
+ super();
134
+ this.data = data;
135
+ }
136
+ }
137
+
138
+ export function ensure<T, K extends keyof T>(target: T, key: K): T[K] {
139
+ if (target[key] === undefined) {
140
+ target[key] = {} as any;
141
+ }
142
+ return target[key];
143
+ }
144
+
145
+ export interface NextSignature<P, R> {
146
+ (this: void, data: P, next: (data: P) => R): R;
147
+ }
148
+
149
+ export interface RegistrationData<T> {
150
+ id: string;
151
+ registerOptions: T;
152
+ }
153
+
154
+ export type FeatureStateKind = 'document' | 'workspace' | 'static' | 'window';
155
+
156
+ export type FeatureState =
157
+ | {
158
+ kind: 'document';
159
+
160
+ /**
161
+ * The features's id. This is usually the method names used during
162
+ * registration.
163
+ */
164
+ id: string;
165
+
166
+ /**
167
+ * Has active registrations.
168
+ */
169
+ registrations: boolean;
170
+
171
+ /**
172
+ * A registration matches an open document.
173
+ */
174
+ matches: boolean;
175
+ }
176
+ | {
177
+ kind: 'workspace';
178
+
179
+ /**
180
+ * The features's id. This is usually the method names used during
181
+ * registration.
182
+ */
183
+ id: string;
184
+
185
+ /**
186
+ * Has active registrations.
187
+ */
188
+ registrations: boolean;
189
+ }
190
+ | {
191
+ kind: 'window';
192
+
193
+ /**
194
+ * The features's id. This is usually the method names used during
195
+ * registration.
196
+ */
197
+ id: string;
198
+
199
+ /**
200
+ * Has active registrations.
201
+ */
202
+ registrations: boolean;
203
+ }
204
+ | {
205
+ kind: 'static';
206
+ };
207
+
208
+ /**
209
+ * A static feature. A static feature can't be dynamically activated via the
210
+ * server. It is wired during the initialize sequence.
211
+ */
212
+ export interface StaticFeature {
213
+ /**
214
+ * Called to fill the initialize params.
215
+ *
216
+ * @params the initialize params.
217
+ */
218
+ fillInitializeParams?: (params: InitializeParams) => void;
219
+
220
+ /**
221
+ * Called to fill in the client capabilities this feature implements.
222
+ *
223
+ * @param capabilities The client capabilities to fill.
224
+ */
225
+ fillClientCapabilities(capabilities: ClientCapabilities): void;
226
+
227
+ /**
228
+ * A preflight where the server capabilities are shown to all features
229
+ * before a feature is actually initialized. This allows feature to
230
+ * capture some state if they are a pre-requisite for other features.
231
+ *
232
+ * @param capabilities the server capabilities
233
+ * @param documentSelector the document selector pass to the client's constructor.
234
+ * May be `undefined` if the client was created without a selector.
235
+ */
236
+ preInitialize?: (
237
+ capabilities: ServerCapabilities,
238
+ documentSelector: DocumentSelector | undefined,
239
+ ) => void;
240
+
241
+ /**
242
+ * Initialize the feature. This method is called on a feature instance
243
+ * when the client has successfully received the initialize request from
244
+ * the server and before the client sends the initialized notification
245
+ * to the server.
246
+ *
247
+ * @param capabilities the server capabilities
248
+ * @param documentSelector the document selector pass to the client's constructor.
249
+ * May be `undefined` if the client was created without a selector.
250
+ */
251
+ initialize(
252
+ capabilities: ServerCapabilities,
253
+ documentSelector: DocumentSelector | undefined,
254
+ ): void;
255
+
256
+ /**
257
+ * Returns the state the feature is in.
258
+ */
259
+ getState(): FeatureState;
260
+
261
+ /**
262
+ * Called when the client is stopped or re-started to clear this feature.
263
+ * Usually a feature un-registers listeners registered hooked up with the
264
+ * VS Code extension host.
265
+ */
266
+ clear(): void;
267
+ }
268
+
269
+ export namespace StaticFeature {
270
+ export function is(value: any): value is StaticFeature {
271
+ const candidate: StaticFeature = value;
272
+ return (
273
+ candidate !== undefined &&
274
+ candidate !== null &&
275
+ Is.func(candidate.fillClientCapabilities) &&
276
+ Is.func(candidate.initialize) &&
277
+ Is.func(candidate.getState) &&
278
+ Is.func(candidate.clear) &&
279
+ (candidate.fillInitializeParams === undefined ||
280
+ Is.func(candidate.fillInitializeParams))
281
+ );
282
+ }
283
+ }
284
+
285
+ /**
286
+ * A dynamic feature can be activated via the server.
287
+ */
288
+ export interface DynamicFeature<RO> {
289
+ /**
290
+ * Called to fill the initialize params.
291
+ *
292
+ * @params the initialize params.
293
+ */
294
+ fillInitializeParams?: (params: InitializeParams) => void;
295
+
296
+ /**
297
+ * Called to fill in the client capabilities this feature implements.
298
+ *
299
+ * @param capabilities The client capabilities to fill.
300
+ */
301
+ fillClientCapabilities(capabilities: ClientCapabilities): void;
302
+
303
+ /**
304
+ * A preflight where the server capabilities are shown to all features
305
+ * before a feature is actually initialized. This allows feature to
306
+ * capture some state if they are a pre-requisite for other features.
307
+ *
308
+ * @param capabilities the server capabilities
309
+ * @param documentSelector the document selector pass to the client's constructor.
310
+ * May be `undefined` if the client was created without a selector.
311
+ */
312
+ preInitialize?: (
313
+ capabilities: ServerCapabilities,
314
+ documentSelector: DocumentSelector | undefined,
315
+ ) => void;
316
+
317
+ /**
318
+ * Initialize the feature. This method is called on a feature instance
319
+ * when the client has successfully received the initialize request from
320
+ * the server and before the client sends the initialized notification
321
+ * to the server.
322
+ *
323
+ * @param capabilities the server capabilities.
324
+ * @param documentSelector the document selector pass to the client's constructor.
325
+ * May be `undefined` if the client was created without a selector.
326
+ */
327
+ initialize(
328
+ capabilities: ServerCapabilities,
329
+ documentSelector: DocumentSelector | undefined,
330
+ ): void;
331
+
332
+ /**
333
+ * Returns the state the feature is in.
334
+ */
335
+ getState(): FeatureState;
336
+
337
+ /**
338
+ * The signature (e.g. method) for which this features support dynamic activation / registration.
339
+ */
340
+ registrationType: RegistrationType<RO>;
341
+
342
+ /**
343
+ * Is called when the server send a register request for the given message.
344
+ *
345
+ * @param data additional registration data as defined in the protocol.
346
+ */
347
+ register(data: RegistrationData<RO>): void;
348
+
349
+ /**
350
+ * Is called when the server wants to unregister a feature.
351
+ *
352
+ * @param id the id used when registering the feature.
353
+ */
354
+ unregister(id: string): void;
355
+
356
+ /**
357
+ * Called when the client is stopped or re-started to clear this feature.
358
+ * Usually a feature un-registers listeners registered hooked up with the
359
+ * VS Code extension host.
360
+ */
361
+ clear(): void;
362
+ }
363
+
364
+ export namespace DynamicFeature {
365
+ export function is<T>(value: any): value is DynamicFeature<T> {
366
+ const candidate: DynamicFeature<T> = value;
367
+ return (
368
+ candidate !== undefined &&
369
+ candidate !== null &&
370
+ Is.func(candidate.fillClientCapabilities) &&
371
+ Is.func(candidate.initialize) &&
372
+ Is.func(candidate.getState) &&
373
+ Is.func(candidate.clear) &&
374
+ (candidate.fillInitializeParams === undefined ||
375
+ Is.func(candidate.fillInitializeParams)) &&
376
+ Is.func(candidate.register) &&
377
+ Is.func(candidate.unregister) &&
378
+ candidate.registrationType !== undefined
379
+ );
380
+ }
381
+ }
382
+
383
+ interface CreateParamsSignature<E, P> {
384
+ (data: E): P;
385
+ }
386
+
387
+ export interface NotificationSendEvent<
388
+ P extends { textDocument: TextDocumentIdentifier },
389
+ > {
390
+ textDocument: TextDocument;
391
+ type: ProtocolNotificationType<P, TextDocumentRegistrationOptions>;
392
+ params: P;
393
+ }
394
+
395
+ export interface NotifyingFeature<P extends { textDocument: TextDocumentIdentifier }> {
396
+ onNotificationSent: VEvent<NotificationSendEvent<P>>;
397
+ }
398
+
399
+ /**
400
+ * An abstract dynamic feature implementation that operates on documents (e.g. text
401
+ * documents or notebooks).
402
+ */
403
+ export abstract class DynamicDocumentFeature<RO, MW, CO = object>
404
+ implements DynamicFeature<RO>
405
+ {
406
+ protected readonly _client: FeatureClient<MW, CO>;
407
+
408
+ constructor(client: FeatureClient<MW, CO>) {
409
+ this._client = client;
410
+ }
411
+
412
+ // Repeat from interface.
413
+ public abstract fillClientCapabilities(capabilities: ClientCapabilities): void;
414
+ public abstract initialize(
415
+ capabilities: ServerCapabilities,
416
+ documentSelector: DocumentSelector | undefined,
417
+ ): void;
418
+ public abstract get registrationType(): RegistrationType<RO>;
419
+ public abstract register(data: RegistrationData<RO>): void;
420
+ public abstract unregister(id: string): void;
421
+ public abstract clear(): void;
422
+
423
+ /**
424
+ * Returns the state the feature is in.
425
+ */
426
+ public getState(): FeatureState {
427
+ const selectors = this.getDocumentSelectors();
428
+
429
+ let count = 0;
430
+ for (const selector of selectors) {
431
+ count++;
432
+ for (const document of Workspace.textDocuments) {
433
+ if (Languages.match(selector, document) > 0) {
434
+ return {
435
+ kind: 'document',
436
+ id: this.registrationType.method,
437
+ registrations: true,
438
+ matches: true,
439
+ };
440
+ }
441
+ }
442
+ }
443
+ const registrations = count > 0;
444
+ return {
445
+ kind: 'document',
446
+ id: this.registrationType.method,
447
+ registrations,
448
+ matches: false,
449
+ };
450
+ }
451
+
452
+ protected abstract getDocumentSelectors(): IterableIterator<VDocumentSelector>;
453
+ }
454
+
455
+ /**
456
+ * A mixin type that allows to send notification or requests using a registered
457
+ * provider.
458
+ */
459
+ // eslint-disable-next-line @typescript-eslint/ban-types
460
+ export interface TextDocumentSendFeature<T extends Function> {
461
+ /**
462
+ * Returns a provider for the given text document.
463
+ */
464
+ getProvider(document: TextDocument): { send: T } | undefined;
465
+ }
466
+
467
+ /**
468
+ * An abstract base class to implement features that react to events
469
+ * emitted from text documents.
470
+ */
471
+ export abstract class TextDocumentEventFeature<
472
+ P extends { textDocument: TextDocumentIdentifier },
473
+ E,
474
+ M,
475
+ >
476
+ extends DynamicDocumentFeature<TextDocumentRegistrationOptions, M>
477
+ implements TextDocumentSendFeature<(data: E) => Promise<void>>, NotifyingFeature<P>
478
+ {
479
+ private readonly _event: Event<E>;
480
+ protected readonly _type: ProtocolNotificationType<
481
+ P,
482
+ TextDocumentRegistrationOptions
483
+ >;
484
+ protected readonly _middleware: () => NextSignature<E, Promise<void>> | undefined;
485
+ protected readonly _createParams: CreateParamsSignature<E, P>;
486
+ protected readonly _textDocument: (data: E) => TextDocument;
487
+ protected readonly _selectorFilter?: (
488
+ selectors: IterableIterator<VDocumentSelector>,
489
+ data: E,
490
+ ) => boolean;
491
+
492
+ private _listener: Disposable | undefined;
493
+ protected readonly _selectors: Map<string, VDocumentSelector>;
494
+ private readonly _onNotificationSent: EventEmitter<NotificationSendEvent<P>>;
495
+
496
+ public static textDocumentFilter(
497
+ selectors: IterableIterator<VDocumentSelector>,
498
+ textDocument: TextDocument,
499
+ ): boolean {
500
+ for (const selector of selectors) {
501
+ if (Languages.match(selector, textDocument) > 0) {
502
+ return true;
503
+ }
504
+ }
505
+ return false;
506
+ }
507
+
508
+ constructor(
509
+ client: FeatureClient<M>,
510
+ event: Event<E>,
511
+ type: ProtocolNotificationType<P, TextDocumentRegistrationOptions>,
512
+ middleware: () => NextSignature<E, Promise<void>> | undefined,
513
+ createParams: CreateParamsSignature<E, P>,
514
+ textDocument: (data: E) => TextDocument,
515
+ selectorFilter?: (
516
+ selectors: IterableIterator<VDocumentSelector>,
517
+ data: E,
518
+ ) => boolean,
519
+ ) {
520
+ super(client);
521
+ this._event = event;
522
+ this._type = type;
523
+ this._middleware = middleware;
524
+ this._createParams = createParams;
525
+ this._textDocument = textDocument;
526
+ this._selectorFilter = selectorFilter;
527
+
528
+ this._selectors = new Map<string, VDocumentSelector>();
529
+ this._onNotificationSent = new EventEmitter<NotificationSendEvent<P>>();
530
+ }
531
+
532
+ protected getStateInfo(): [IterableIterator<VDocumentSelector>, boolean] {
533
+ return [this._selectors.values(), false];
534
+ }
535
+ protected getDocumentSelectors(): IterableIterator<VDocumentSelector> {
536
+ return this._selectors.values();
537
+ }
538
+
539
+ public register(data: RegistrationData<TextDocumentRegistrationOptions>): void {
540
+ if (!data.registerOptions.documentSelector) {
541
+ return;
542
+ }
543
+ if (!this._listener) {
544
+ this._listener = this._event((data) => {
545
+ this.callback(data).catch((error) => {
546
+ this._client.error(
547
+ `Sending document notification ${this._type.method} failed.`,
548
+ error,
549
+ );
550
+ });
551
+ });
552
+ }
553
+ this._selectors.set(
554
+ data.id,
555
+ this._client.protocol2CodeConverter.asDocumentSelector(
556
+ data.registerOptions.documentSelector,
557
+ ),
558
+ );
559
+ }
560
+
561
+ protected async callback(data: E): Promise<void> {
562
+ const doSend = async (data: E): Promise<void> => {
563
+ const params = this._createParams(data);
564
+ await this._client.sendNotification(this._type, params);
565
+ this.notificationSent(this.getTextDocument(data), this._type, params);
566
+ };
567
+ if (this.matches(data)) {
568
+ const middleware = this._middleware();
569
+ return middleware ? middleware(data, (data) => doSend(data)) : doSend(data);
570
+ }
571
+ }
572
+
573
+ private matches(data: E): boolean {
574
+ if (this._client.hasDedicatedTextSynchronizationFeature(this._textDocument(data))) {
575
+ return false;
576
+ }
577
+ return (
578
+ !this._selectorFilter || this._selectorFilter(this._selectors.values(), data)
579
+ );
580
+ }
581
+
582
+ public get onNotificationSent(): VEvent<NotificationSendEvent<P>> {
583
+ return this._onNotificationSent.event;
584
+ }
585
+
586
+ protected notificationSent(
587
+ textDocument: TextDocument,
588
+ type: ProtocolNotificationType<P, TextDocumentRegistrationOptions>,
589
+ params: P,
590
+ ): void {
591
+ this._onNotificationSent.fire({ textDocument, type, params });
592
+ }
593
+
594
+ protected abstract getTextDocument(data: E): TextDocument;
595
+
596
+ public unregister(id: string): void {
597
+ this._selectors.delete(id);
598
+ if (this._selectors.size === 0 && this._listener) {
599
+ this._listener.dispose();
600
+ this._listener = undefined;
601
+ }
602
+ }
603
+
604
+ public clear(): void {
605
+ this._selectors.clear();
606
+ this._onNotificationSent.dispose();
607
+ if (this._listener) {
608
+ this._listener.dispose();
609
+ this._listener = undefined;
610
+ }
611
+ }
612
+
613
+ public getProvider(
614
+ document: TextDocument,
615
+ ): { send: (data: E) => Promise<void> } | undefined {
616
+ for (const selector of this._selectors.values()) {
617
+ if (Languages.match(selector, document) > 0) {
618
+ return {
619
+ send: (data: E) => {
620
+ return this.callback(data);
621
+ },
622
+ };
623
+ }
624
+ }
625
+ return undefined;
626
+ }
627
+ }
628
+
629
+ type TextDocumentFeatureRegistration<RO, PR> = {
630
+ disposable: Disposable;
631
+ data: RegistrationData<RO>;
632
+ provider: PR;
633
+ };
634
+
635
+ /**
636
+ * A mixin type to access a provider that is registered for a
637
+ * given text document / document selector.
638
+ */
639
+ export interface TextDocumentProviderFeature<T> {
640
+ /**
641
+ * Triggers the corresponding RPC method.
642
+ */
643
+ getProvider(textDocument: TextDocument): T | undefined;
644
+ }
645
+
646
+ export type DocumentSelectorOptions = {
647
+ documentSelector: DocumentSelector;
648
+ };
649
+
650
+ /**
651
+ * A abstract feature implementation that registers language providers
652
+ * for text documents using a given document selector.
653
+ */
654
+ export abstract class TextDocumentLanguageFeature<
655
+ PO,
656
+ RO extends TextDocumentRegistrationOptions & PO,
657
+ PR,
658
+ MW,
659
+ CO = object,
660
+ > extends DynamicDocumentFeature<RO, MW, CO> {
661
+ private readonly _registrationType: RegistrationType<RO>;
662
+ private readonly _registrations: Map<string, TextDocumentFeatureRegistration<RO, PR>>;
663
+
664
+ constructor(client: FeatureClient<MW, CO>, registrationType: RegistrationType<RO>) {
665
+ super(client);
666
+ this._registrationType = registrationType;
667
+ this._registrations = new Map();
668
+ }
669
+
670
+ protected *getDocumentSelectors(): IterableIterator<VDocumentSelector> {
671
+ for (const registration of this._registrations.values()) {
672
+ const selector = registration.data.registerOptions.documentSelector;
673
+ if (selector === null) {
674
+ continue;
675
+ }
676
+ yield this._client.protocol2CodeConverter.asDocumentSelector(selector);
677
+ }
678
+ }
679
+
680
+ public get registrationType(): RegistrationType<RO> {
681
+ return this._registrationType;
682
+ }
683
+
684
+ public abstract override fillClientCapabilities(
685
+ capabilities: ClientCapabilities,
686
+ ): void;
687
+
688
+ public abstract override initialize(
689
+ capabilities: ServerCapabilities,
690
+ documentSelector: DocumentSelector,
691
+ ): void;
692
+
693
+ public register(data: RegistrationData<RO>): void {
694
+ if (!data.registerOptions.documentSelector) {
695
+ return;
696
+ }
697
+ const registration = this.registerLanguageProvider(data.registerOptions, data.id);
698
+ this._registrations.set(data.id, {
699
+ disposable: registration[0],
700
+ data,
701
+ provider: registration[1],
702
+ });
703
+ }
704
+
705
+ protected abstract registerLanguageProvider(
706
+ options: RO,
707
+ id: string,
708
+ ): [Disposable, PR];
709
+
710
+ public unregister(id: string): void {
711
+ const registration = this._registrations.get(id);
712
+ if (registration !== undefined) {
713
+ this._registrations.delete(id);
714
+ registration.disposable.dispose();
715
+ }
716
+ }
717
+
718
+ public clear(): void {
719
+ this._registrations.forEach((value) => {
720
+ value.disposable.dispose();
721
+ });
722
+ this._registrations.clear();
723
+ }
724
+
725
+ protected getRegistration(
726
+ documentSelector: DocumentSelector | undefined,
727
+ capability: undefined | PO | (RO & StaticRegistrationOptions),
728
+ ): [string | undefined, (RO & { documentSelector: DocumentSelector }) | undefined] {
729
+ if (!capability) {
730
+ return [undefined, undefined];
731
+ } else if (TextDocumentRegistrationOptions.is(capability)) {
732
+ const id = StaticRegistrationOptions.hasId(capability)
733
+ ? capability.id
734
+ : UUID.generateUuid();
735
+ const selector = capability.documentSelector ?? documentSelector;
736
+ if (selector) {
737
+ return [id, Object.assign({}, capability, { documentSelector: selector })];
738
+ }
739
+ } else if (
740
+ (Is.boolean(capability) && capability === true) ||
741
+ WorkDoneProgressOptions.is(capability)
742
+ ) {
743
+ if (!documentSelector) {
744
+ return [undefined, undefined];
745
+ }
746
+ const options: RO & { documentSelector: DocumentSelector } = (
747
+ Is.boolean(capability) && capability === true
748
+ ? { documentSelector }
749
+ : Object.assign({}, capability, { documentSelector })
750
+ ) as any;
751
+ return [UUID.generateUuid(), options];
752
+ }
753
+ return [undefined, undefined];
754
+ }
755
+
756
+ protected getRegistrationOptions(
757
+ documentSelector: DocumentSelector | undefined,
758
+ capability: undefined | PO,
759
+ ): (RO & { documentSelector: DocumentSelector }) | undefined {
760
+ if (!documentSelector || !capability) {
761
+ return undefined;
762
+ }
763
+ return (
764
+ Is.boolean(capability) && capability === true
765
+ ? { documentSelector }
766
+ : Object.assign({}, capability, { documentSelector })
767
+ ) as RO & { documentSelector: DocumentSelector };
768
+ }
769
+
770
+ public getProvider(textDocument: TextDocument): PR | undefined {
771
+ for (const registration of this._registrations.values()) {
772
+ const selector = registration.data.registerOptions.documentSelector;
773
+ if (
774
+ selector !== null &&
775
+ Languages.match(
776
+ this._client.protocol2CodeConverter.asDocumentSelector(selector),
777
+ textDocument,
778
+ ) > 0
779
+ ) {
780
+ return registration.provider;
781
+ }
782
+ }
783
+ return undefined;
784
+ }
785
+
786
+ protected getAllProviders(): Iterable<PR> {
787
+ const result: PR[] = [];
788
+ for (const item of this._registrations.values()) {
789
+ result.push(item.provider);
790
+ }
791
+ return result;
792
+ }
793
+ }
794
+
795
+ export interface WorkspaceProviderFeature<PR> {
796
+ getProviders(): PR[] | undefined;
797
+ }
798
+
799
+ type WorkspaceFeatureRegistration<PR> = {
800
+ disposable: Disposable;
801
+ provider: PR;
802
+ };
803
+
804
+ export abstract class WorkspaceFeature<RO, PR, M> implements DynamicFeature<RO> {
805
+ protected readonly _client: FeatureClient<M>;
806
+ private readonly _registrationType: RegistrationType<RO>;
807
+ protected readonly _registrations: Map<string, WorkspaceFeatureRegistration<PR>>;
808
+
809
+ constructor(client: FeatureClient<M>, registrationType: RegistrationType<RO>) {
810
+ this._client = client;
811
+ this._registrationType = registrationType;
812
+ this._registrations = new Map();
813
+ }
814
+
815
+ public getState(): FeatureState {
816
+ const registrations = this._registrations.size > 0;
817
+ return { kind: 'workspace', id: this._registrationType.method, registrations };
818
+ }
819
+
820
+ public get registrationType(): RegistrationType<RO> {
821
+ return this._registrationType;
822
+ }
823
+
824
+ public abstract fillClientCapabilities(capabilities: ClientCapabilities): void;
825
+
826
+ public abstract initialize(
827
+ capabilities: ServerCapabilities,
828
+ documentSelector: DocumentSelector | undefined,
829
+ ): void;
830
+
831
+ public register(data: RegistrationData<RO>): void {
832
+ const registration = this.registerLanguageProvider(data.registerOptions);
833
+ this._registrations.set(data.id, {
834
+ disposable: registration[0],
835
+ provider: registration[1],
836
+ });
837
+ }
838
+
839
+ protected abstract registerLanguageProvider(options: RO): [Disposable, PR];
840
+
841
+ public unregister(id: string): void {
842
+ const registration = this._registrations.get(id);
843
+ if (registration !== undefined) {
844
+ this._registrations.delete(id);
845
+ registration.disposable.dispose();
846
+ }
847
+ }
848
+
849
+ public clear(): void {
850
+ this._registrations.forEach((registration) => {
851
+ registration.disposable.dispose();
852
+ });
853
+ this._registrations.clear();
854
+ }
855
+
856
+ public getProviders(): PR[] {
857
+ const result: PR[] = [];
858
+ for (const registration of this._registrations.values()) {
859
+ result.push(registration.provider);
860
+ }
861
+ return result;
862
+ }
863
+ }
864
+
865
+ export interface DedicatedTextSynchronizationFeature {
866
+ handles(textDocument: TextDocument): boolean;
867
+ }
868
+
869
+ // Features can refer to other feature when implementing themselves.
870
+ // Hence the feature client needs to provide access to them. To
871
+ // avoid cyclic dependencies these import MUST ALL be type imports.
872
+ import type { CodeLensProviderShape } from './codeLens.js';
873
+ import type { DiagnosticProviderShape } from './diagnostic.js';
874
+ import type { FoldingRangeProviderShape } from './foldingRange.js';
875
+ import type { InlayHintsProviderShape } from './inlayHint.js';
876
+ import type { InlineValueProviderShape } from './inlineValue.js';
877
+ import type { NotebookDocumentProviderShape } from './notebook.js';
878
+ import type * as p2c from './protocolConverter.js';
879
+ import type { SemanticTokensProviderShape } from './semanticTokens.js';
880
+ import type {
881
+ DidChangeTextDocumentFeatureShape,
882
+ DidCloseTextDocumentFeatureShape,
883
+ DidOpenTextDocumentFeatureShape,
884
+ DidSaveTextDocumentFeatureShape,
885
+ } from './textSynchronization.js';
886
+ import * as Is from './utils/is.js';
887
+ import * as UUID from './utils/uuid.js';
888
+
889
+ export interface FeatureClient<M, CO = object> {
890
+ protocol2CodeConverter: p2c.Converter;
891
+ code2ProtocolConverter: c2p.Converter;
892
+
893
+ clientOptions: CO;
894
+ middleware: M;
895
+
896
+ start(): Promise<void>;
897
+ isRunning(): boolean;
898
+ stop(): Promise<void>;
899
+
900
+ sendRequest<R, PR, E, RO>(
901
+ type: ProtocolRequestType0<R, PR, E, RO>,
902
+ token?: CancellationToken,
903
+ ): Promise<R>;
904
+ sendRequest<P, R, PR, E, RO>(
905
+ type: ProtocolRequestType<P, R, PR, E, RO>,
906
+ params: P,
907
+ token?: CancellationToken,
908
+ ): Promise<R>;
909
+ sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
910
+ sendRequest<P, R, E>(
911
+ type: RequestType<P, R, E>,
912
+ params: P,
913
+ token?: CancellationToken,
914
+ ): Promise<R>;
915
+ sendRequest<R>(method: string, token?: CancellationToken): Promise<R>;
916
+ sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>;
917
+
918
+ onRequest<R, PR, E, RO>(
919
+ type: ProtocolRequestType0<R, PR, E, RO>,
920
+ handler: RequestHandler0<R, E>,
921
+ ): Disposable;
922
+ onRequest<P, R, PR, E, RO>(
923
+ type: ProtocolRequestType<P, R, PR, E, RO>,
924
+ handler: RequestHandler<P, R, E>,
925
+ ): Disposable;
926
+ onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
927
+ onRequest<P, R, E>(
928
+ type: RequestType<P, R, E>,
929
+ handler: RequestHandler<P, R, E>,
930
+ ): Disposable;
931
+ onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
932
+
933
+ sendNotification<RO>(type: ProtocolNotificationType0<RO>): Promise<void>;
934
+ sendNotification<P, RO>(
935
+ type: ProtocolNotificationType<P, RO>,
936
+ params?: P,
937
+ ): Promise<void>;
938
+ sendNotification(type: NotificationType0): Promise<void>;
939
+ sendNotification<P>(type: NotificationType<P>, params?: P): Promise<void>;
940
+ sendNotification(method: string): Promise<void>;
941
+ sendNotification(method: string, params: any): Promise<void>;
942
+
943
+ onNotification<RO>(
944
+ type: ProtocolNotificationType0<RO>,
945
+ handler: NotificationHandler0,
946
+ ): Disposable;
947
+ onNotification<P, RO>(
948
+ type: ProtocolNotificationType<P, RO>,
949
+ handler: NotificationHandler<P>,
950
+ ): Disposable;
951
+ onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
952
+ onNotification<P>(
953
+ type: NotificationType<P>,
954
+ handler: NotificationHandler<P>,
955
+ ): Disposable;
956
+ onNotification(method: string, handler: GenericNotificationHandler): Disposable;
957
+
958
+ onProgress<P>(
959
+ type: ProgressType<P>,
960
+ token: string | number,
961
+ handler: NotificationHandler<P>,
962
+ ): Disposable;
963
+
964
+ info(message: string, data?: any, showNotification?: boolean): void;
965
+ warn(message: string, data?: any, showNotification?: boolean): void;
966
+ error(message: string, data?: any, showNotification?: boolean | 'force'): void;
967
+
968
+ handleFailedRequest<T>(
969
+ type: MessageSignature,
970
+ token: CancellationToken | undefined,
971
+ error: any,
972
+ defaultValue: T,
973
+ showNotification?: boolean,
974
+ ): T;
975
+
976
+ hasDedicatedTextSynchronizationFeature(textDocument: TextDocument): boolean;
977
+
978
+ getFeature(
979
+ request: typeof DidOpenTextDocumentNotification.method,
980
+ ): DidOpenTextDocumentFeatureShape;
981
+ getFeature(
982
+ request: typeof DidChangeTextDocumentNotification.method,
983
+ ): DidChangeTextDocumentFeatureShape;
984
+ getFeature(
985
+ request: typeof WillSaveTextDocumentNotification.method,
986
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
987
+ TextDocumentSendFeature<(textDocument: TextDocument) => Promise<void>>;
988
+ getFeature(
989
+ request: typeof WillSaveTextDocumentWaitUntilRequest.method,
990
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
991
+ TextDocumentSendFeature<
992
+ (textDocument: TextDocument) => ProviderResult<VTextEdit[]>
993
+ >;
994
+ getFeature(
995
+ request: typeof DidSaveTextDocumentNotification.method,
996
+ ): DidSaveTextDocumentFeatureShape;
997
+ getFeature(
998
+ request: typeof DidCloseTextDocumentNotification.method,
999
+ ): DidCloseTextDocumentFeatureShape;
1000
+ getFeature(
1001
+ request: typeof DidCreateFilesNotification.method,
1002
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1003
+ send: (event: FileCreateEvent) => Promise<void>;
1004
+ };
1005
+ getFeature(
1006
+ request: typeof DidRenameFilesNotification.method,
1007
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1008
+ send: (event: FileRenameEvent) => Promise<void>;
1009
+ };
1010
+ getFeature(
1011
+ request: typeof DidDeleteFilesNotification.method,
1012
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1013
+ send: (event: FileDeleteEvent) => Promise<void>;
1014
+ };
1015
+ getFeature(
1016
+ request: typeof WillCreateFilesRequest.method,
1017
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1018
+ send: (event: FileWillCreateEvent) => Promise<void>;
1019
+ };
1020
+ getFeature(
1021
+ request: typeof WillRenameFilesRequest.method,
1022
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1023
+ send: (event: FileWillRenameEvent) => Promise<void>;
1024
+ };
1025
+ getFeature(
1026
+ request: typeof WillDeleteFilesRequest.method,
1027
+ ): DynamicFeature<FileOperationRegistrationOptions> & {
1028
+ send: (event: FileWillDeleteEvent) => Promise<void>;
1029
+ };
1030
+ getFeature(
1031
+ request: typeof CompletionRequest.method,
1032
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1033
+ TextDocumentProviderFeature<CompletionItemProvider>;
1034
+ getFeature(
1035
+ request: typeof HoverRequest.method,
1036
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1037
+ TextDocumentProviderFeature<HoverProvider>;
1038
+ getFeature(
1039
+ request: typeof SignatureHelpRequest.method,
1040
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1041
+ TextDocumentProviderFeature<SignatureHelpProvider>;
1042
+ getFeature(
1043
+ request: typeof DefinitionRequest.method,
1044
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1045
+ TextDocumentProviderFeature<DefinitionProvider>;
1046
+ getFeature(
1047
+ request: typeof ReferencesRequest.method,
1048
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1049
+ TextDocumentProviderFeature<ReferenceProvider>;
1050
+ getFeature(
1051
+ request: typeof DocumentHighlightRequest.method,
1052
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1053
+ TextDocumentProviderFeature<DocumentHighlightProvider>;
1054
+ getFeature(
1055
+ request: typeof CodeActionRequest.method,
1056
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1057
+ TextDocumentProviderFeature<CodeActionProvider>;
1058
+ getFeature(
1059
+ request: typeof CodeLensRequest.method,
1060
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1061
+ TextDocumentProviderFeature<CodeLensProviderShape>;
1062
+ getFeature(
1063
+ request: typeof DocumentFormattingRequest.method,
1064
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1065
+ TextDocumentProviderFeature<DocumentFormattingEditProvider>;
1066
+ getFeature(
1067
+ request: typeof DocumentRangeFormattingRequest.method,
1068
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1069
+ TextDocumentProviderFeature<DocumentRangeFormattingEditProvider>;
1070
+ getFeature(
1071
+ request: typeof DocumentOnTypeFormattingRequest.method,
1072
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1073
+ TextDocumentProviderFeature<OnTypeFormattingEditProvider>;
1074
+ getFeature(
1075
+ request: typeof RenameRequest.method,
1076
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1077
+ TextDocumentProviderFeature<RenameProvider>;
1078
+ getFeature(
1079
+ request: typeof DocumentSymbolRequest.method,
1080
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1081
+ TextDocumentProviderFeature<DocumentSymbolProvider>;
1082
+ getFeature(
1083
+ request: typeof DocumentLinkRequest.method,
1084
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1085
+ TextDocumentProviderFeature<DocumentLinkProvider>;
1086
+ getFeature(
1087
+ request: typeof DocumentColorRequest.method,
1088
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1089
+ TextDocumentProviderFeature<DocumentColorProvider>;
1090
+ getFeature(
1091
+ request: typeof DeclarationRequest.method,
1092
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1093
+ TextDocumentProviderFeature<DeclarationProvider>;
1094
+ getFeature(
1095
+ request: typeof FoldingRangeRequest.method,
1096
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1097
+ TextDocumentProviderFeature<FoldingRangeProviderShape>;
1098
+ getFeature(
1099
+ request: typeof ImplementationRequest.method,
1100
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1101
+ TextDocumentProviderFeature<ImplementationProvider>;
1102
+ getFeature(
1103
+ request: typeof SelectionRangeRequest.method,
1104
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1105
+ TextDocumentProviderFeature<SelectionRangeProvider>;
1106
+ getFeature(
1107
+ request: typeof TypeDefinitionRequest.method,
1108
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1109
+ TextDocumentProviderFeature<TypeDefinitionProvider>;
1110
+ getFeature(
1111
+ request: typeof CallHierarchyPrepareRequest.method,
1112
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1113
+ TextDocumentProviderFeature<CallHierarchyProvider>;
1114
+ getFeature(
1115
+ request: typeof SemanticTokensRegistrationType.method,
1116
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1117
+ TextDocumentProviderFeature<SemanticTokensProviderShape>;
1118
+ getFeature(
1119
+ request: typeof LinkedEditingRangeRequest.method,
1120
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1121
+ TextDocumentProviderFeature<LinkedEditingRangeProvider>;
1122
+ getFeature(
1123
+ request: typeof TypeHierarchyPrepareRequest.method,
1124
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1125
+ TextDocumentProviderFeature<TypeHierarchyProvider>;
1126
+ getFeature(
1127
+ request: typeof InlineValueRequest.method,
1128
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1129
+ TextDocumentProviderFeature<InlineValueProviderShape>;
1130
+ getFeature(
1131
+ request: typeof InlayHintRequest.method,
1132
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1133
+ TextDocumentProviderFeature<InlayHintsProviderShape>;
1134
+ getFeature(
1135
+ request: typeof WorkspaceSymbolRequest.method,
1136
+ ): DynamicFeature<TextDocumentRegistrationOptions> &
1137
+ WorkspaceProviderFeature<WorkspaceSymbolProvider>;
1138
+ getFeature(
1139
+ request: typeof DocumentDiagnosticRequest.method,
1140
+ ):
1141
+ | (DynamicFeature<TextDocumentRegistrationOptions> &
1142
+ TextDocumentProviderFeature<DiagnosticProviderShape>)
1143
+ | undefined;
1144
+ getFeature(
1145
+ request: typeof NotebookDocumentSyncRegistrationType.method,
1146
+ ):
1147
+ | (DynamicFeature<NotebookDocumentSyncRegistrationOptions> &
1148
+ NotebookDocumentProviderShape)
1149
+ | undefined;
1150
+ getFeature(
1151
+ request: typeof InlineCompletionRequest.method,
1152
+ ): DynamicFeature<InlineCompletionRegistrationOptions> &
1153
+ TextDocumentProviderFeature<InlineCompletionItemProvider>;
1154
+ getFeature(
1155
+ request: typeof ExecuteCommandRequest.method,
1156
+ ): DynamicFeature<ExecuteCommandOptions>;
1157
+ }