Debian Codegraph @

LspCpp/include/LibLsp/lsp/general/lsServerCapabilities.h

raw
1 #pragma once
2 #include "LibLsp/lsp/method_type.h"
3
4 #include <stdexcept>
5 #include "LibLsp/JsonRpc/message.h"
6 #include "LibLsp/lsp/lsDocumentUri.h"
7 #include "LibLsp/lsp/lsAny.h"
8 #include "InitializeParams.h"
9 #include "LibLsp/lsp/textDocument/SemanticTokens.h"
10
11 extern void Reflect(Reader&, std::pair<optional<lsTextDocumentSyncKind>, optional<lsTextDocumentSyncOptions>>&);
12
13 //
14 // Code Action options.
15 //
16 struct CodeActionOptions : WorkDoneProgressOptions
17 {
18 //
19 // CodeActionKinds that this server may return.
20 //
21 // The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
22 // may list out every specific kind they provide.
23 //
24 typedef std::string CodeActionKind;
25 std::vector<CodeActionKind> codeActionKinds;
26
27 MAKE_SWAP_METHOD(CodeActionOptions, workDoneProgress, codeActionKinds);
28 };
29 MAKE_REFLECT_STRUCT(CodeActionOptions, workDoneProgress, codeActionKinds)
30 struct CodeLensOptions : WorkDoneProgressOptions
31 {
32 //
33 // Code lens has a resolve provider as well.
34 //
35 optional<bool> resolveProvider;
36 MAKE_SWAP_METHOD(CodeLensOptions, workDoneProgress, resolveProvider);
37 };
38 MAKE_REFLECT_STRUCT(CodeLensOptions, workDoneProgress, resolveProvider)
39
40 // Format document on type options
41 struct lsDocumentOnTypeFormattingOptions : WorkDoneProgressOptions
42 {
43 // A character on which formatting should be triggered, like `}`.
44 std::string firstTriggerCharacter;
45
46 // More trigger characters.
47 std::vector<std::string> moreTriggerCharacter;
48 MAKE_SWAP_METHOD(lsDocumentOnTypeFormattingOptions, workDoneProgress, firstTriggerCharacter, moreTriggerCharacter);
49 };
50 MAKE_REFLECT_STRUCT(lsDocumentOnTypeFormattingOptions, workDoneProgress, firstTriggerCharacter, moreTriggerCharacter);
51 struct RenameOptions : WorkDoneProgressOptions
52 {
53 //
54 // Renames should be checked and tested before being executed.
55 //
56 optional<bool> prepareProvider;
57 MAKE_SWAP_METHOD(RenameOptions, workDoneProgress, prepareProvider);
58 };
59 MAKE_REFLECT_STRUCT(RenameOptions, workDoneProgress, prepareProvider)
60
61 struct DocumentFilter
62 {
63 //
64 // A language id, like `typescript`.
65 //
66 optional<std::string> language;
67 //
68 // A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
69 //
70 optional<std::string> scheme;
71 //
72 // A glob pattern, like `*.{ts,js}`.
73 //
74 // Glob patterns can have the following syntax:
75 // - `*` to match one or more characters in a path segment
76 // - `?` to match on one character in a path segment
77 // - `**` to match any number of path segments, including none
78 // - `{}` to group sub patterns into an OR expression. (e.g. `**/*.{ts,js}
79 // matches all TypeScript and JavaScript files)
80 // - `[]` to declare a range of characters to match in a path segment
81 // (e.g., `example.[0-9]` to match on `example.0`, `example.1`,...)
82 // - `[!...]` to negate a range of characters to match in a path segment
83 // (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but
84 // not `example.0`)
85 //
86 optional<std::string> pattern;
87 MAKE_SWAP_METHOD(DocumentFilter, language, scheme, pattern)
88 };
89 MAKE_REFLECT_STRUCT(DocumentFilter, language, scheme, pattern)
90
91 //A document selector is the combination of one or more document filters.
92 using DocumentSelector = std::vector<DocumentFilter>;
93
94 // Document link options
95 struct lsDocumentLinkOptions : WorkDoneProgressOptions
96 {
97 // Document links have a resolve provider as well.
98 optional<bool> resolveProvider;
99 MAKE_SWAP_METHOD(lsDocumentLinkOptions, workDoneProgress, resolveProvider);
100 };
101 MAKE_REFLECT_STRUCT(lsDocumentLinkOptions, workDoneProgress, resolveProvider);
102
103 // Execute command options.
104 struct lsExecuteCommandOptions : WorkDoneProgressOptions
105 {
106 // The commands to be executed on the server
107 std::vector<std::string> commands;
108 MAKE_SWAP_METHOD(lsExecuteCommandOptions, workDoneProgress, commands);
109 };
110 MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, workDoneProgress, commands);
111
112 struct TextDocumentRegistrationOptions
113 {
114 //
115 // A document selector to identify the scope of the registration. If set to null
116 // the document selector provided on the client side will be used.
117 //
118 optional<DocumentSelector> documentSelector;
119
120 MAKE_SWAP_METHOD(TextDocumentRegistrationOptions, documentSelector);
121 };
122 MAKE_REFLECT_STRUCT(TextDocumentRegistrationOptions, documentSelector);
123
124 //
125 // Static registration options to be returned in the initialize request.
126 //
127 struct StaticRegistrationOptions : public TextDocumentRegistrationOptions
128 {
129 //
130 // The id used to register the request. The id can be used to deregister
131 // the request again. See also Registration#id.
132 //
133 optional<std::string> id;
134 MAKE_SWAP_METHOD(StaticRegistrationOptions, documentSelector, id)
135 };
136 MAKE_REFLECT_STRUCT(StaticRegistrationOptions, documentSelector, id)
137
138 //
139 // The server supports workspace folder.
140 //
141 // Since 3.6.0
142 //
143
144 struct WorkspaceFoldersOptions
145 {
146 //
147 // The server has support for workspace folders
148 //
149 optional<bool> supported;
150
151 //
152 // Whether the server wants to receive workspace folder
153 // change notifications.
154 //
155 // If a string is provided, the string is treated as an ID
156 // under which the notification is registered on the client
157 // side. The ID can be used to unregister for these events
158 // using the `client/unregisterCapability` request.
159 //
160 optional<std::pair<optional<std::string>, optional<bool>>> changeNotifications;
161 MAKE_SWAP_METHOD(WorkspaceFoldersOptions, supported, changeNotifications);
162 };
163 MAKE_REFLECT_STRUCT(WorkspaceFoldersOptions, supported, changeNotifications);
164
165 //
166 // A pattern kind describing if a glob pattern matches a file a folder or
167 // both.
168 //
169 // @since 3.16.0
170 //
171 enum lsFileOperationPatternKind
172 {
173 file,
174 folder
175 };
176 MAKE_REFLECT_TYPE_PROXY(lsFileOperationPatternKind)
177
178 //
179 // Matching options for the file operation pattern.
180 //
181 // @since 3.16.0
182 //
183 struct lsFileOperationPatternOptions
184 {
185
186 //
187 // The pattern should be matched ignoring casing.
188 //
189 optional<bool> ignoreCase;
190 MAKE_SWAP_METHOD(lsFileOperationPatternOptions, ignoreCase)
191 };
192 MAKE_REFLECT_STRUCT(lsFileOperationPatternOptions, ignoreCase)
193 //
194 // A pattern to describe in which file operation requests or notifications
195 // the server is interested in.
196 //
197 // @since 3.16.0
198 //
199 struct lsFileOperationPattern
200 {
201 //
202 // The glob pattern to match. Glob patterns can have the following syntax:
203 // - `*` to match one or more characters in a path segment
204 // - `?` to match on one character in a path segment
205 // - `**` to match any number of path segments, including none
206 // - `{}` to group sub patterns into an OR expression. (e.g. `**/*.{ts,js}`
207 // matches all TypeScript and JavaScript files)
208 // - `[]` to declare a range of characters to match in a path segment
209 // (e.g., `example.[0-9]` to match on `example.0`, `example.1`,...)
210 // - `[!...]` to negate a range of characters to match in a path segment
211 // (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but
212 // not `example.0`)
213 //
214 std::string glob;
215
216 //
217 // Whether to match files or folders with this pattern.
218 //
219 // Matches both if undefined.
220 //
221 optional<lsFileOperationPatternKind> matches;
222
223 //
224 // Additional options used during matching.
225 //
226 optional<lsFileOperationPatternOptions> options;
227 MAKE_SWAP_METHOD(lsFileOperationPattern, glob, matches, options)
228 };
229 MAKE_REFLECT_STRUCT(lsFileOperationPattern, glob, matches, options)
230 //
231 // A filter to describe in which file operation requests or notifications
232 // the server is interested in.
233 //
234 // @since 3.16.0
235 //
236 struct lsFileOperationFilter
237 {
238
239 //
240 // A Uri like `file` or `untitled`.
241 //
242 optional<std::string> scheme;
243
244 //
245 // The actual file operation pattern.
246 //
247 optional<lsFileOperationPattern> pattern;
248 MAKE_SWAP_METHOD(lsFileOperationFilter, scheme, pattern)
249 };
250 MAKE_REFLECT_STRUCT(lsFileOperationFilter, scheme, pattern)
251 //
252 // The options to register for file operations.
253 //
254 // @since 3.16.0
255 //
256 struct lsFileOperationRegistrationOptions
257 {
258 //
259 // The actual filters.
260 //
261 optional<std::vector<lsFileOperationFilter>> filters;
262 MAKE_SWAP_METHOD(lsFileOperationRegistrationOptions, filters)
263 };
264 MAKE_REFLECT_STRUCT(lsFileOperationRegistrationOptions, filters)
265
266 struct WorkspaceServerCapabilities
267 {
268 //
269 // The server supports workspace folder.
270 //
271 // Since 3.6.0
272 //
273 WorkspaceFoldersOptions workspaceFolders;
274
275 //
276 // The server is interested in file notifications/requests.
277 //
278 // @since 3.16.0
279 //
280 struct lsFileOperations
281 {
282 //
283 // The server is interested in receiving didCreateFiles
284 // notifications.
285 //
286 optional<lsFileOperationRegistrationOptions> didCreate;
287
288 //
289 // The server is interested in receiving willCreateFiles requests.
290 //
291 optional<lsFileOperationRegistrationOptions> willCreate;
292
293 //
294 // The server is interested in receiving didRenameFiles
295 // notifications.
296 //
297 optional<lsFileOperationRegistrationOptions> didRename;
298
299 //
300 // The server is interested in receiving willRenameFiles requests.
301 //
302 optional<lsFileOperationRegistrationOptions> willRename;
303
304 //
305 // The server is interested in receiving didDeleteFiles file
306 // notifications.
307 //
308 optional<lsFileOperationRegistrationOptions> didDelete;
309
310 //
311 // The server is interested in receiving willDeleteFiles file
312 // requests.
313 //
314 optional<lsFileOperationRegistrationOptions> willDelete;
315 MAKE_SWAP_METHOD(lsFileOperations, didCreate, willCreate, didRename, willRename, didDelete, willDelete)
316 };
317 optional<lsFileOperations> fileOperations;
318
319 MAKE_SWAP_METHOD(WorkspaceServerCapabilities, workspaceFolders, fileOperations)
320 };
321 MAKE_REFLECT_STRUCT(WorkspaceServerCapabilities, workspaceFolders, fileOperations)
322 MAKE_REFLECT_STRUCT(
323 WorkspaceServerCapabilities::lsFileOperations, didCreate, willCreate, didRename, willRename, didDelete, willDelete
324 )
325
326 //
327 // Semantic highlighting server capabilities.
328 //
329 // <p>
330 // <b>Note:</b> the <a href=
331 // "https://github.com/Microsoft/vscode-languageserver-node/pull/367">{@code textDocument/semanticHighlighting}
332 // language feature</a> is not yet part of the official LSP specification.
333 //
334
335 struct SemanticHighlightingServerCapabilities
336 {
337 //
338 // A "lookup table" of semantic highlighting <a href="https://manual.macromates.com/en/language_grammars">TextMate scopes</a>
339 // supported by the language server. If not defined or empty, then the server does not support the semantic highlighting
340 // feature. Otherwise, clients should reuse this "lookup table" when receiving semantic highlighting notifications from
341 // the server.
342 //
343 std::vector<std::vector<std::string>> scopes;
344 MAKE_SWAP_METHOD(SemanticHighlightingServerCapabilities, scopes)
345 };
346 MAKE_REFLECT_STRUCT(SemanticHighlightingServerCapabilities, scopes)
347
348 struct SemanticTokensServerFull
349 {
350 //
351 // The server supports deltas for full documents.
352 //
353 bool delta = false;
354 MAKE_SWAP_METHOD(SemanticTokensServerFull, delta)
355 };
356 MAKE_REFLECT_STRUCT(SemanticTokensServerFull, delta)
357 struct SemanticTokensWithRegistrationOptions
358 {
359 SemanticTokensLegend legend;
360
361 //
362 // Server supports providing semantic tokens for a specific range
363 // of a document.
364 //
365 optional<std::pair<optional<bool>, optional<lsp::Any>>> range;
366
367 //
368 // Server supports providing semantic tokens for a full document.
369 //
370 optional<std::pair<optional<bool>, optional<SemanticTokensServerFull>>> full;
371
372 //
373 // A document selector to identify the scope of the registration. If set to null
374 // the document selector provided on the client side will be used.
375 //
376 optional<std::vector<DocumentFilter>> documentSelector;
377 //
378 // The id used to register the request. The id can be used to deregister
379 // the request again. See also Registration#id.
380 //
381 optional<std::string> id;
382 MAKE_SWAP_METHOD(SemanticTokensWithRegistrationOptions, legend, range, full, documentSelector, id)
383 };
384 MAKE_REFLECT_STRUCT(SemanticTokensWithRegistrationOptions, legend, range, full, documentSelector, id)
385
386 using DocumentColorOptions = WorkDoneProgressOptions;
387 using FoldingRangeOptions = WorkDoneProgressOptions;
388
389 struct InlayHintOptions : WorkDoneProgressOptions
390 {
391
392 /**
393 * The server provides support to resolve additional
394 * information for an inlay hint item.
395 */
396 optional<bool> resolveProvider;
397
398 MAKE_SWAP_METHOD(InlayHintOptions, workDoneProgress, resolveProvider);
399 };
400
401 MAKE_REFLECT_STRUCT(InlayHintOptions, workDoneProgress, resolveProvider)
402
403 struct lsServerCapabilities
404 {
405 // Defines how text documents are synced. Is either a detailed structure
406 // defining each notification or for backwards compatibility the
407
408 // TextDocumentSyncKind number.
409 optional<std::pair<optional<lsTextDocumentSyncKind>, optional<lsTextDocumentSyncOptions>>> textDocumentSync;
410
411 // The server provides hover support.
412 optional<bool> hoverProvider;
413
414 // The server provides completion support.
415 optional<lsCompletionOptions> completionProvider;
416
417 // The server provides signature help support.
418 optional<lsSignatureHelpOptions> signatureHelpProvider;
419
420 // The server provides goto definition support.
421 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> definitionProvider;
422
423 //
424 // The server provides Goto Type Definition support.
425 //
426 // Since 3.6.0
427 //
428 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> typeDefinitionProvider;
429
430 // The server provides implementation support.
431 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> implementationProvider;
432
433 // The server provides find references support.
434 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> referencesProvider;
435
436 // The server provides document highlight support.
437 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> documentHighlightProvider;
438
439 // The server provides document symbol support.
440 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> documentSymbolProvider;
441
442 // The server provides workspace symbol support.
443 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> workspaceSymbolProvider;
444
445 // The server provides code actions.
446 optional<std::pair<optional<bool>, optional<CodeActionOptions>>> codeActionProvider;
447
448 // The server provides code lens.
449 optional<CodeLensOptions> codeLensProvider;
450
451 // The server provides document formatting.
452 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> documentFormattingProvider;
453
454 // The server provides document range formatting.
455 optional<std::pair<optional<bool>, optional<WorkDoneProgressOptions>>> documentRangeFormattingProvider;
456
457 // The server provides document formatting on typing.
458 optional<lsDocumentOnTypeFormattingOptions> documentOnTypeFormattingProvider;
459
460 // The server provides rename support.
461 optional<std::pair<optional<bool>, optional<RenameOptions>>> renameProvider;
462
463 // The server provides document link support.
464 optional<lsDocumentLinkOptions> documentLinkProvider;
465
466 //
467 // The server provides color provider support.
468 //
469 // @since 3.6.0
470 //
471 optional<std::pair<optional<bool>, optional<DocumentColorOptions>>> colorProvider;
472
473 //
474 // The server provides folding provider support.
475 //
476 // @since 3.10.0
477 //
478 optional<std::pair<optional<bool>, optional<FoldingRangeOptions>>> foldingRangeProvider;
479
480 // The server provides execute command support.
481 optional<lsExecuteCommandOptions> executeCommandProvider;
482
483 //
484 // Workspace specific server capabilities
485 //
486 optional<WorkspaceServerCapabilities> workspace;
487
488 //
489 // Semantic highlighting server capabilities.
490 //
491
492 optional<SemanticHighlightingServerCapabilities> semanticHighlighting;
493
494 //
495 // Server capability for calculating super- and subtype hierarchies.
496 // The LS supports the type hierarchy language feature, if this capability is set to {@code true}.
497 //
498 // <p>
499 // <b>Note:</b> the <a href=
500 // "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
501 // language feature</a> is not yet part of the official LSP specification.
502 //
503
504 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> typeHierarchyProvider;
505
506 //
507 // The server provides Call Hierarchy support.
508 //
509
510 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> callHierarchyProvider;
511
512 //
513 // The server provides selection range support.
514 //
515 // Since 3.15.0
516 //
517 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> selectionRangeProvider;
518
519 //
520 // The server provides linked editing range support.
521 //
522 // Since 3.16.0
523 //
524 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> linkedEditingRangeProvider;
525
526 //
527 // The server provides semantic tokens support.
528 //
529 // Since 3.16.0
530 //
531 optional<SemanticTokensWithRegistrationOptions> semanticTokensProvider;
532
533 //
534 // Whether server provides moniker support.
535 //
536 // Since 3.16.0
537 //
538 optional<std::pair<optional<bool>, optional<StaticRegistrationOptions>>> monikerProvider;
539
540 /**
541 * The server provides inlay hints.
542 *
543 * @since 3.17.0
544 */
545 optional<std::pair<optional<bool>, optional<InlayHintOptions>>> inlayHintProvider;
546
547 optional<lsp::Any> experimental;
548
549 MAKE_SWAP_METHOD(
550 lsServerCapabilities, textDocumentSync, hoverProvider, completionProvider, signatureHelpProvider,
551 definitionProvider, typeDefinitionProvider, implementationProvider, referencesProvider,
552 documentHighlightProvider, documentSymbolProvider, workspaceSymbolProvider, codeActionProvider,
553 codeLensProvider, documentFormattingProvider, documentRangeFormattingProvider, documentOnTypeFormattingProvider,
554 renameProvider, documentLinkProvider, executeCommandProvider, workspace, semanticHighlighting,
555 typeHierarchyProvider, callHierarchyProvider, selectionRangeProvider, experimental, colorProvider,
556 foldingRangeProvider, linkedEditingRangeProvider, monikerProvider, semanticTokensProvider
557 )
558 };
559 MAKE_REFLECT_STRUCT(
560 lsServerCapabilities, textDocumentSync, hoverProvider, completionProvider, signatureHelpProvider,
561 definitionProvider, typeDefinitionProvider, implementationProvider, referencesProvider, documentHighlightProvider,
562 documentSymbolProvider, workspaceSymbolProvider, codeActionProvider, codeLensProvider, documentFormattingProvider,
563 documentRangeFormattingProvider, documentOnTypeFormattingProvider, renameProvider, documentLinkProvider,
564 executeCommandProvider, workspace, semanticHighlighting, typeHierarchyProvider, callHierarchyProvider,
565 selectionRangeProvider, experimental, colorProvider, foldingRangeProvider, linkedEditingRangeProvider,
566 monikerProvider, semanticTokensProvider
567 )