Skip to main content

lsp_types_max/
request.rs

1use super::*;
2
3use serde::{de::DeserializeOwned, Serialize};
4
5pub trait Request {
6    type Params: DeserializeOwned + Serialize + Send + Sync + 'static;
7    type Result: DeserializeOwned + Serialize + Send + Sync + 'static;
8    const METHOD: &'static str;
9}
10
11#[macro_export]
12macro_rules! lsp_request {
13    ("initialize") => {
14        $crate::request::Initialize
15    };
16    ("shutdown") => {
17        $crate::request::Shutdown
18    };
19
20    ("window/showMessageRequest") => {
21        $crate::request::ShowMessageRequest
22    };
23
24    ("client/registerCapability") => {
25        $crate::request::RegisterCapability
26    };
27    ("client/unregisterCapability") => {
28        $crate::request::UnregisterCapability
29    };
30
31    ("workspace/symbol") => {
32        $crate::request::WorkspaceSymbolRequest
33    };
34    ("workspaceSymbol/resolve") => {
35        $crate::request::WorkspaceSymbolResolve
36    };
37    ("workspace/executeCommand") => {
38        $crate::request::ExecuteCommand
39    };
40
41    ("textDocument/willSaveWaitUntil") => {
42        $crate::request::WillSaveWaitUntil
43    };
44
45    ("textDocument/completion") => {
46        $crate::request::Completion
47    };
48    ("completionItem/resolve") => {
49        $crate::request::ResolveCompletionItem
50    };
51    ("textDocument/hover") => {
52        $crate::request::HoverRequest
53    };
54    ("textDocument/signatureHelp") => {
55        $crate::request::SignatureHelpRequest
56    };
57    ("textDocument/declaration") => {
58        $crate::request::GotoDeclaration
59    };
60    ("textDocument/definition") => {
61        $crate::request::GotoDefinition
62    };
63    ("textDocument/references") => {
64        $crate::request::References
65    };
66    ("textDocument/documentHighlight") => {
67        $crate::request::DocumentHighlightRequest
68    };
69    ("textDocument/documentSymbol") => {
70        $crate::request::DocumentSymbolRequest
71    };
72    ("textDocument/codeAction") => {
73        $crate::request::CodeActionRequest
74    };
75    ("textDocument/codeLens") => {
76        $crate::request::CodeLensRequest
77    };
78    ("codeLens/resolve") => {
79        $crate::request::CodeLensResolve
80    };
81    ("textDocument/documentLink") => {
82        $crate::request::DocumentLinkRequest
83    };
84    ("documentLink/resolve") => {
85        $crate::request::DocumentLinkResolve
86    };
87    ("workspace/applyEdit") => {
88        $crate::request::ApplyWorkspaceEdit
89    };
90    ("textDocument/rangeFormatting") => {
91        $crate::request::RangeFormatting
92    };
93    ("textDocument/onTypeFormatting") => {
94        $crate::request::OnTypeFormatting
95    };
96    ("textDocument/formatting") => {
97        $crate::request::Formatting
98    };
99    ("textDocument/rename") => {
100        $crate::request::Rename
101    };
102    ("textDocument/documentColor") => {
103        $crate::request::DocumentColor
104    };
105    ("textDocument/colorPresentation") => {
106        $crate::request::ColorPresentationRequest
107    };
108    ("textDocument/foldingRange") => {
109        $crate::request::FoldingRangeRequest
110    };
111    ("textDocument/prepareRename") => {
112        $crate::request::PrepareRenameRequest
113    };
114    ("textDocument/implementation") => {
115        $crate::request::GotoImplementation
116    };
117    ("textDocument/typeDefinition") => {
118        $crate::request::GotoTypeDefinition
119    };
120    ("textDocument/selectionRange") => {
121        $crate::request::SelectionRangeRequest
122    };
123    ("workspace/workspaceFolders") => {
124        $crate::request::WorkspaceFoldersRequest
125    };
126    ("workspace/configuration") => {
127        $crate::request::WorkspaceConfiguration
128    };
129    ("window/workDoneProgress/create") => {
130        $crate::request::WorkDoneProgressCreate
131    };
132    ("callHierarchy/incomingCalls") => {
133        $crate::request::CallHierarchyIncomingCalls
134    };
135    ("callHierarchy/outgoingCalls") => {
136        $crate::request::CallHierarchyOutgoingCalls
137    };
138    ("textDocument/moniker") => {
139        $crate::request::MonikerRequest
140    };
141    ("textDocument/linkedEditingRange") => {
142        $crate::request::LinkedEditingRange
143    };
144    ("textDocument/prepareCallHierarchy") => {
145        $crate::request::CallHierarchyPrepare
146    };
147    ("textDocument/prepareTypeHierarchy") => {
148        $crate::request::TypeHierarchyPrepare
149    };
150    ("textDocument/semanticTokens/full") => {
151        $crate::request::SemanticTokensFullRequest
152    };
153    ("textDocument/semanticTokens/full/delta") => {
154        $crate::request::SemanticTokensFullDeltaRequest
155    };
156    ("textDocument/semanticTokens/range") => {
157        $crate::request::SemanticTokensRangeRequest
158    };
159    ("textDocument/inlayHint") => {
160        $crate::request::InlayHintRequest
161    };
162    ("textDocument/inlineValue") => {
163        $crate::request::InlineValueRequest
164    };
165    ("textDocument/inlineCompletion") => {
166        $crate::request::InlineCompletionRequest
167    };
168    ("textDocument/diagnostic") => {
169        $crate::request::DocumentDiagnosticRequest
170    };
171    ("workspace/diagnostic") => {
172        $crate::request::WorkspaceDiagnosticRequest
173    };
174    ("workspace/diagnostic/refresh") => {
175        $crate::request::WorkspaceDiagnosticRefresh
176    };
177    ("typeHierarchy/supertypes") => {
178        $crate::request::TypeHierarchySupertypes
179    };
180    ("typeHierarchy/subtypes") => {
181        $crate::request::TypeHierarchySubtypes
182    };
183    ("workspace/willCreateFiles") => {
184        $crate::request::WillCreateFiles
185    };
186    ("workspace/willRenameFiles") => {
187        $crate::request::WillRenameFiles
188    };
189    ("workspace/willDeleteFiles") => {
190        $crate::request::WillDeleteFiles
191    };
192    ("workspace/semanticTokens/refresh") => {
193        $crate::request::SemanticTokensRefresh
194    };
195    ("workspace/codeLens/refresh") => {
196        $crate::request::CodeLensRefresh
197    };
198    ("workspace/inlayHint/refresh") => {
199        $crate::request::InlayHintRefreshRequest
200    };
201    ("workspace/inlineValue/refresh") => {
202        $crate::request::InlineValueRefreshRequest
203    };
204    ("codeAction/resolve") => {
205        $crate::request::CodeActionResolveRequest
206    };
207    ("inlayHint/resolve") => {
208        $crate::request::InlayHintResolveRequest
209    };
210    ("window/showDocument") => {
211        $crate::request::ShowDocument
212    };
213}
214
215/// The initialize request is sent as the first request from the client to the server.
216/// If the server receives request or notification before the `initialize` request it should act as follows:
217///
218/// * for a request the respond should be errored with `code: -32001`. The message can be picked by the server.
219/// * notifications should be dropped.
220#[derive(Debug)]
221pub enum Initialize {}
222
223impl Request for Initialize {
224    type Params = InitializeParams;
225    type Result = InitializeResult;
226    const METHOD: &'static str = "initialize";
227}
228
229/// The shutdown request is sent from the client to the server. It asks the server to shut down,
230/// but to not exit (otherwise the response might not be delivered correctly to the client).
231/// There is a separate exit notification that asks the server to exit.
232#[derive(Debug)]
233pub enum Shutdown {}
234
235impl Request for Shutdown {
236    type Params = ();
237    type Result = ();
238    const METHOD: &'static str = "shutdown";
239}
240
241/// The show message request is sent from a server to a client to ask the client to display a particular message
242/// in the user interface. In addition to the show message notification the request allows to pass actions and to
243/// wait for an answer from the client.
244#[derive(Debug)]
245pub enum ShowMessageRequest {}
246
247impl Request for ShowMessageRequest {
248    type Params = ShowMessageRequestParams;
249    type Result = Option<MessageActionItem>;
250    const METHOD: &'static str = "window/showMessageRequest";
251}
252
253/// The client/registerCapability request is sent from the server to the client to register for a new capability
254/// on the client side. Not all clients need to support dynamic capability registration. A client opts in via the
255/// ClientCapabilities.GenericCapability property.
256#[derive(Debug)]
257pub enum RegisterCapability {}
258
259impl Request for RegisterCapability {
260    type Params = RegistrationParams;
261    type Result = ();
262    const METHOD: &'static str = "client/registerCapability";
263}
264
265/// The client/unregisterCapability request is sent from the server to the client to unregister a
266/// previously register capability.
267#[derive(Debug)]
268pub enum UnregisterCapability {}
269
270impl Request for UnregisterCapability {
271    type Params = UnregistrationParams;
272    type Result = ();
273    const METHOD: &'static str = "client/unregisterCapability";
274}
275
276/// The Completion request is sent from the client to the server to compute completion items at a given cursor position.
277/// Completion items are presented in the IntelliSense user interface. If computing full completion items is expensive,
278/// servers can additionally provide a handler for the completion item resolve request ('completionItem/resolve').
279/// This request is sent when a completion item is selected in the user interface. A typical use case is for example:
280/// the 'textDocument/completion' request doesn’t fill in the documentation property for returned completion items
281/// since it is expensive to compute. When the item is selected in the user interface then a ‘completionItem/resolve’
282/// request is sent with the selected completion item as a param. The returned completion item should have the
283/// documentation property filled in. The request can delay the computation of the detail and documentation properties.
284/// However, properties that are needed for the initial sorting and filtering, like sortText, filterText, insertText,
285/// and textEdit must be provided in the textDocument/completion request and must not be changed during resolve.
286#[derive(Debug)]
287pub enum Completion {}
288
289impl Request for Completion {
290    type Params = CompletionParams;
291    type Result = Option<CompletionResponse>;
292    const METHOD: &'static str = "textDocument/completion";
293}
294
295/// The request is sent from the client to the server to resolve additional information for a given completion item.
296#[derive(Debug)]
297pub enum ResolveCompletionItem {}
298
299impl Request for ResolveCompletionItem {
300    type Params = CompletionItem;
301    type Result = CompletionItem;
302    const METHOD: &'static str = "completionItem/resolve";
303}
304
305/// The hover request is sent from the client to the server to request hover information at a given text
306/// document position.
307#[derive(Debug)]
308pub enum HoverRequest {}
309
310impl Request for HoverRequest {
311    type Params = HoverParams;
312    type Result = Option<Hover>;
313    const METHOD: &'static str = "textDocument/hover";
314}
315
316/// The signature help request is sent from the client to the server to request signature information at
317/// a given cursor position.
318#[derive(Debug)]
319pub enum SignatureHelpRequest {}
320
321impl Request for SignatureHelpRequest {
322    type Params = SignatureHelpParams;
323    type Result = Option<SignatureHelp>;
324    const METHOD: &'static str = "textDocument/signatureHelp";
325}
326
327#[derive(Debug)]
328pub enum GotoDeclaration {}
329pub type GotoDeclarationParams = GotoDefinitionParams;
330pub type GotoDeclarationResponse = GotoDefinitionResponse;
331
332/// The goto declaration request is sent from the client to the server to resolve the declaration location of
333/// a symbol at a given text document position.
334impl Request for GotoDeclaration {
335    type Params = GotoDeclarationParams;
336    type Result = Option<GotoDeclarationResponse>;
337    const METHOD: &'static str = "textDocument/declaration";
338}
339
340/// The goto definition request is sent from the client to the server to resolve the definition location of
341/// a symbol at a given text document position.
342#[derive(Debug)]
343pub enum GotoDefinition {}
344
345impl Request for GotoDefinition {
346    type Params = GotoDefinitionParams;
347    type Result = Option<GotoDefinitionResponse>;
348    const METHOD: &'static str = "textDocument/definition";
349}
350
351/// The references request is sent from the client to the server to resolve project-wide references for the
352/// symbol denoted by the given text document position.
353#[derive(Debug)]
354pub enum References {}
355
356impl Request for References {
357    type Params = ReferenceParams;
358    type Result = Option<Vec<Location>>;
359    const METHOD: &'static str = "textDocument/references";
360}
361
362/// The goto type definition request is sent from the client to the
363/// server to resolve the type definition location of a symbol at a
364/// given text document position.
365#[derive(Debug)]
366pub enum GotoTypeDefinition {}
367
368pub type GotoTypeDefinitionParams = GotoDefinitionParams;
369pub type GotoTypeDefinitionResponse = GotoDefinitionResponse;
370
371impl Request for GotoTypeDefinition {
372    type Params = GotoTypeDefinitionParams;
373    type Result = Option<GotoTypeDefinitionResponse>;
374    const METHOD: &'static str = "textDocument/typeDefinition";
375}
376
377/// The goto implementation request is sent from the client to the
378/// server to resolve the implementation location of a symbol at a
379/// given text document position.
380#[derive(Debug)]
381pub enum GotoImplementation {}
382
383pub type GotoImplementationParams = GotoTypeDefinitionParams;
384pub type GotoImplementationResponse = GotoDefinitionResponse;
385
386impl Request for GotoImplementation {
387    type Params = GotoImplementationParams;
388    type Result = Option<GotoImplementationResponse>;
389    const METHOD: &'static str = "textDocument/implementation";
390}
391
392/// The document highlight request is sent from the client to the server to resolve a document highlights
393/// for a given text document position.
394/// For programming languages this usually highlights all references to the symbol scoped to this file.
395/// However we kept 'textDocument/documentHighlight' and 'textDocument/references' separate requests since
396/// the first one is allowed to be more fuzzy.
397/// Symbol matches usually have a DocumentHighlightKind of Read or Write whereas fuzzy or textual matches
398/// use Text as the kind.
399#[derive(Debug)]
400pub enum DocumentHighlightRequest {}
401
402impl Request for DocumentHighlightRequest {
403    type Params = DocumentHighlightParams;
404    type Result = Option<Vec<DocumentHighlight>>;
405    const METHOD: &'static str = "textDocument/documentHighlight";
406}
407
408/// The document symbol request is sent from the client to the server to list all symbols found in a given
409/// text document.
410#[derive(Debug)]
411pub enum DocumentSymbolRequest {}
412
413impl Request for DocumentSymbolRequest {
414    type Params = DocumentSymbolParams;
415    type Result = Option<DocumentSymbolResponse>;
416    const METHOD: &'static str = "textDocument/documentSymbol";
417}
418
419/// The workspace symbol request is sent from the client to the server to list project-wide symbols
420/// matching the query string.
421#[derive(Debug)]
422pub enum WorkspaceSymbolRequest {}
423
424impl Request for WorkspaceSymbolRequest {
425    type Params = WorkspaceSymbolParams;
426    type Result = Option<WorkspaceSymbolResponse>;
427    const METHOD: &'static str = "workspace/symbol";
428}
429
430/// The `workspaceSymbol/resolve` request is sent from the client to the server to resolve
431/// additional information for a given workspace symbol.
432#[derive(Debug)]
433pub enum WorkspaceSymbolResolve {}
434
435impl Request for WorkspaceSymbolResolve {
436    type Params = WorkspaceSymbol;
437    type Result = WorkspaceSymbol;
438    const METHOD: &'static str = "workspaceSymbol/resolve";
439}
440
441/// The workspace/executeCommand request is sent from the client to the server to trigger command execution on the server.
442/// In most cases the server creates a WorkspaceEdit structure and applies the changes to the workspace using the request
443/// workspace/applyEdit which is sent from the server to the client.
444#[derive(Debug)]
445pub enum ExecuteCommand {}
446
447impl Request for ExecuteCommand {
448    type Params = ExecuteCommandParams;
449    type Result = Option<Value>;
450    const METHOD: &'static str = "workspace/executeCommand";
451}
452
453/// The document will save request is sent from the client to the server before the document is
454/// actually saved. The request can return an array of TextEdits which will be applied to the text
455/// document before it is saved. Please note that clients might drop results if computing the text
456/// edits took too long or if a server constantly fails on this request. This is done to keep the
457/// save fast and reliable.
458#[derive(Debug)]
459pub enum WillSaveWaitUntil {}
460
461impl Request for WillSaveWaitUntil {
462    type Params = WillSaveTextDocumentParams;
463    type Result = Option<Vec<TextEdit>>;
464    const METHOD: &'static str = "textDocument/willSaveWaitUntil";
465}
466
467/// The workspace/applyEdit request is sent from the server to the client to modify resource on the
468/// client side.
469#[derive(Debug)]
470pub enum ApplyWorkspaceEdit {}
471
472impl Request for ApplyWorkspaceEdit {
473    type Params = ApplyWorkspaceEditParams;
474    type Result = ApplyWorkspaceEditResponse;
475    const METHOD: &'static str = "workspace/applyEdit";
476}
477
478/// The workspace/configuration request is sent from the server to the client to fetch configuration settings
479/// from the client. The request can fetch several configuration settings in one roundtrip.
480/// The order of the returned configuration settings correspond to the order of the passed ConfigurationItems
481/// (e.g. the first item in the response is the result for the first configuration item in the params).
482///
483/// A ConfigurationItem consists of the configuration section to ask for and an additional scope URI.
484/// The configuration section ask for is defined by the server and doesn’t necessarily need to correspond to
485/// the configuration store used be the client. So a server might ask for a configuration cpp.formatterOptions
486/// but the client stores the configuration in a XML store layout differently.
487/// It is up to the client to do the necessary conversion. If a scope URI is provided the client should return
488/// the setting scoped to the provided resource. If the client for example uses EditorConfig to manage its
489/// settings the configuration should be returned for the passed resource URI. If the client can’t provide a
490/// configuration setting for a given scope then null need to be present in the returned array.
491#[derive(Debug)]
492pub enum WorkspaceConfiguration {}
493
494impl Request for WorkspaceConfiguration {
495    type Params = ConfigurationParams;
496    type Result = Vec<Value>;
497    const METHOD: &'static str = "workspace/configuration";
498}
499
500/// The code action request is sent from the client to the server to compute commands for a given text document
501/// and range. The request is triggered when the user moves the cursor into a problem marker in the editor or
502/// presses the lightbulb associated with a marker.
503#[derive(Debug)]
504pub enum CodeActionRequest {}
505
506impl Request for CodeActionRequest {
507    type Params = CodeActionParams;
508    type Result = Option<CodeActionResponse>;
509    const METHOD: &'static str = "textDocument/codeAction";
510}
511
512/// The request is sent from the client to the server to resolve additional information for a given code action.
513/// This is usually used to compute the `edit` property of a code action to avoid its unnecessary computation
514/// during the `textDocument/codeAction` request.
515///
516/// @since 3.16.0
517#[derive(Debug)]
518pub enum CodeActionResolveRequest {}
519
520impl Request for CodeActionResolveRequest {
521    type Params = CodeAction;
522    type Result = CodeAction;
523    const METHOD: &'static str = "codeAction/resolve";
524}
525
526/// The code lens request is sent from the client to the server to compute code lenses for a given text document.
527#[derive(Debug)]
528pub enum CodeLensRequest {}
529
530impl Request for CodeLensRequest {
531    type Params = CodeLensParams;
532    type Result = Option<Vec<CodeLens>>;
533    const METHOD: &'static str = "textDocument/codeLens";
534}
535
536/// The code lens resolve request is sent from the client to the server to resolve the command for a
537/// given code lens item.
538#[derive(Debug)]
539pub enum CodeLensResolve {}
540
541impl Request for CodeLensResolve {
542    type Params = CodeLens;
543    type Result = CodeLens;
544    const METHOD: &'static str = "codeLens/resolve";
545}
546
547/// The document links request is sent from the client to the server to request the location of links in a document.
548#[derive(Debug)]
549pub enum DocumentLinkRequest {}
550
551impl Request for DocumentLinkRequest {
552    type Params = DocumentLinkParams;
553    type Result = Option<Vec<DocumentLink>>;
554    const METHOD: &'static str = "textDocument/documentLink";
555}
556
557/// The document link resolve request is sent from the client to the server to resolve the target of
558/// a given document link.
559#[derive(Debug)]
560pub enum DocumentLinkResolve {}
561
562impl Request for DocumentLinkResolve {
563    type Params = DocumentLink;
564    type Result = DocumentLink;
565    const METHOD: &'static str = "documentLink/resolve";
566}
567
568/// The document formatting request is sent from the server to the client to format a whole document.
569#[derive(Debug)]
570pub enum Formatting {}
571
572impl Request for Formatting {
573    type Params = DocumentFormattingParams;
574    type Result = Option<Vec<TextEdit>>;
575    const METHOD: &'static str = "textDocument/formatting";
576}
577
578/// The document range formatting request is sent from the client to the server to format a given range in a document.
579#[derive(Debug)]
580pub enum RangeFormatting {}
581
582impl Request for RangeFormatting {
583    type Params = DocumentRangeFormattingParams;
584    type Result = Option<Vec<TextEdit>>;
585    const METHOD: &'static str = "textDocument/rangeFormatting";
586}
587
588/// The document on type formatting request is sent from the client to the server to format parts of
589/// the document during typing.
590#[derive(Debug)]
591pub enum OnTypeFormatting {}
592
593impl Request for OnTypeFormatting {
594    type Params = DocumentOnTypeFormattingParams;
595    type Result = Option<Vec<TextEdit>>;
596    const METHOD: &'static str = "textDocument/onTypeFormatting";
597}
598
599/// The linked editing request is sent from the client to the server to return for a given position in a document
600/// the range of the symbol at the position and all ranges that have the same content.
601/// Optionally a word pattern can be returned to describe valid contents. A rename to one of the ranges can be applied
602/// to all other ranges if the new content is valid. If no result-specific word pattern is provided, the word pattern from
603/// the client’s language configuration is used.
604#[derive(Debug)]
605pub enum LinkedEditingRange {}
606
607impl Request for LinkedEditingRange {
608    type Params = LinkedEditingRangeParams;
609    type Result = Option<LinkedEditingRanges>;
610    const METHOD: &'static str = "textDocument/linkedEditingRange";
611}
612
613/// The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.
614#[derive(Debug)]
615pub enum Rename {}
616
617impl Request for Rename {
618    type Params = RenameParams;
619    type Result = Option<WorkspaceEdit>;
620    const METHOD: &'static str = "textDocument/rename";
621}
622
623/// The document color request is sent from the client to the server to list all color references found in a given text document.
624/// Along with the range, a color value in RGB is returned.
625#[derive(Debug)]
626pub enum DocumentColor {}
627
628impl Request for DocumentColor {
629    type Params = DocumentColorParams;
630    type Result = Vec<ColorInformation>;
631    const METHOD: &'static str = "textDocument/documentColor";
632}
633
634/// The color presentation request is sent from the client to the server to obtain a list of presentations for a color value
635/// at a given location.
636#[derive(Debug)]
637pub enum ColorPresentationRequest {}
638
639impl Request for ColorPresentationRequest {
640    type Params = ColorPresentationParams;
641    type Result = Vec<ColorPresentation>;
642    const METHOD: &'static str = "textDocument/colorPresentation";
643}
644
645/// The folding range request is sent from the client to the server to return all folding ranges found in a given text document.
646#[derive(Debug)]
647pub enum FoldingRangeRequest {}
648
649impl Request for FoldingRangeRequest {
650    type Params = FoldingRangeParams;
651    type Result = Option<Vec<FoldingRange>>;
652    const METHOD: &'static str = "textDocument/foldingRange";
653}
654
655/// The prepare rename request is sent from the client to the server to setup and test the validity of a rename operation
656/// at a given location.
657#[derive(Debug)]
658pub enum PrepareRenameRequest {}
659
660impl Request for PrepareRenameRequest {
661    type Params = TextDocumentPositionParams;
662    type Result = Option<PrepareRenameResponse>;
663    const METHOD: &'static str = "textDocument/prepareRename";
664}
665
666#[derive(Debug)]
667#[cfg(feature = "proposed")]
668pub enum InlineCompletionRequest {}
669
670#[cfg(feature = "proposed")]
671impl Request for InlineCompletionRequest {
672    type Params = InlineCompletionParams;
673    type Result = Option<InlineCompletionResponse>;
674    const METHOD: &'static str = "textDocument/inlineCompletion";
675}
676
677#[derive(Debug)]
678#[cfg(not(feature = "proposed"))]
679pub enum InlineCompletionRequest {}
680
681#[cfg(not(feature = "proposed"))]
682impl Request for InlineCompletionRequest {
683    type Params = ();
684    type Result = ();
685    const METHOD: &'static str = "textDocument/inlineCompletion";
686}
687
688/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open list of
689/// workspace folders. Returns null in the response if only a single file is open in the tool.
690/// Returns an empty array if a workspace is open but no folders are configured.
691#[derive(Debug)]
692pub enum WorkspaceFoldersRequest {}
693
694impl Request for WorkspaceFoldersRequest {
695    type Params = ();
696    type Result = Option<Vec<WorkspaceFolder>>;
697    const METHOD: &'static str = "workspace/workspaceFolders";
698}
699
700/// The `window/workDoneProgress/create` request is sent from the server
701/// to the client to ask the client to create a work done progress.
702#[derive(Debug)]
703pub enum WorkDoneProgressCreate {}
704
705impl Request for WorkDoneProgressCreate {
706    type Params = WorkDoneProgressCreateParams;
707    type Result = ();
708    const METHOD: &'static str = "window/workDoneProgress/create";
709}
710
711/// The selection range request is sent from the client to the server to return
712/// suggested selection ranges at given positions. A selection range is a range
713/// around the cursor position which the user might be interested in selecting.
714///
715/// A selection range in the return array is for the position in the provided parameters at the same index.
716/// Therefore `positions[i]` must be contained in `result[i].range`.
717///
718/// Typically, but not necessary, selection ranges correspond to the nodes of the
719/// syntax tree.
720pub enum SelectionRangeRequest {}
721
722impl Request for SelectionRangeRequest {
723    type Params = SelectionRangeParams;
724    type Result = Option<Vec<SelectionRange>>;
725    const METHOD: &'static str = "textDocument/selectionRange";
726}
727
728pub enum CallHierarchyPrepare {}
729
730impl Request for CallHierarchyPrepare {
731    type Params = CallHierarchyPrepareParams;
732    type Result = Option<Vec<CallHierarchyItem>>;
733    const METHOD: &'static str = "textDocument/prepareCallHierarchy";
734}
735
736pub enum CallHierarchyIncomingCalls {}
737
738impl Request for CallHierarchyIncomingCalls {
739    type Params = CallHierarchyIncomingCallsParams;
740    type Result = Option<Vec<CallHierarchyIncomingCall>>;
741    const METHOD: &'static str = "callHierarchy/incomingCalls";
742}
743
744pub enum CallHierarchyOutgoingCalls {}
745
746impl Request for CallHierarchyOutgoingCalls {
747    type Params = CallHierarchyOutgoingCallsParams;
748    type Result = Option<Vec<CallHierarchyOutgoingCall>>;
749    const METHOD: &'static str = "callHierarchy/outgoingCalls";
750}
751
752pub enum SemanticTokensFullRequest {}
753
754impl Request for SemanticTokensFullRequest {
755    type Params = SemanticTokensParams;
756    type Result = Option<SemanticTokensResult>;
757    const METHOD: &'static str = "textDocument/semanticTokens/full";
758}
759
760pub enum SemanticTokensFullDeltaRequest {}
761
762impl Request for SemanticTokensFullDeltaRequest {
763    type Params = SemanticTokensDeltaParams;
764    type Result = Option<SemanticTokensFullDeltaResult>;
765    const METHOD: &'static str = "textDocument/semanticTokens/full/delta";
766}
767
768pub enum SemanticTokensRangeRequest {}
769
770impl Request for SemanticTokensRangeRequest {
771    type Params = SemanticTokensRangeParams;
772    type Result = Option<SemanticTokensRangeResult>;
773    const METHOD: &'static str = "textDocument/semanticTokens/range";
774}
775
776/// The `workspace/semanticTokens/refresh` request is sent from the server to the client.
777/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
778/// As a result the client should ask the server to recompute the semantic tokens for these editors.
779/// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens.
780/// Note that the client still has the freedom to delay the re-calculation of the semantic tokens if for example an editor is currently not visible.
781pub enum SemanticTokensRefresh {}
782
783impl Request for SemanticTokensRefresh {
784    type Params = ();
785    type Result = ();
786    const METHOD: &'static str = "workspace/semanticTokens/refresh";
787}
788
789/// The workspace/codeLens/refresh request is sent from the server to the client.
790/// Servers can use it to ask clients to refresh the code lenses currently shown in editors.
791/// As a result the client should ask the server to recompute the code lenses for these editors.
792/// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses.
793/// Note that the client still has the freedom to delay the re-calculation of the code lenses if for example an editor is currently not visible.
794pub enum CodeLensRefresh {}
795
796impl Request for CodeLensRefresh {
797    type Params = ();
798    type Result = ();
799    const METHOD: &'static str = "workspace/codeLens/refresh";
800}
801
802/// The will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a WorkspaceEdit which will be applied to workspace before the files are created. Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep creates fast and reliable.
803pub enum WillCreateFiles {}
804
805impl Request for WillCreateFiles {
806    type Params = CreateFilesParams;
807    type Result = Option<WorkspaceEdit>;
808    const METHOD: &'static str = "workspace/willCreateFiles";
809}
810
811/// The will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. The request can return a WorkspaceEdit which will be applied to workspace before the files are renamed. Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep renames fast and reliable.
812pub enum WillRenameFiles {}
813
814impl Request for WillRenameFiles {
815    type Params = RenameFilesParams;
816    type Result = Option<WorkspaceEdit>;
817    const METHOD: &'static str = "workspace/willRenameFiles";
818}
819
820/// The will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. The request can return a WorkspaceEdit which will be applied to workspace before the files are deleted. Please note that clients might drop results if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable.
821pub enum WillDeleteFiles {}
822
823impl Request for WillDeleteFiles {
824    type Params = DeleteFilesParams;
825    type Result = Option<WorkspaceEdit>;
826    const METHOD: &'static str = "workspace/willDeleteFiles";
827}
828
829/// The show document request is sent from a server to a client to ask the client to display a particular document in the user interface.
830pub enum ShowDocument {}
831
832impl Request for ShowDocument {
833    type Params = ShowDocumentParams;
834    type Result = ShowDocumentResult;
835    const METHOD: &'static str = "window/showDocument";
836}
837
838pub enum MonikerRequest {}
839
840impl Request for MonikerRequest {
841    type Params = MonikerParams;
842    type Result = Option<Vec<Moniker>>;
843    const METHOD: &'static str = "textDocument/moniker";
844}
845
846/// The inlay hints request is sent from the client to the server to compute inlay hints for a given
847/// [text document, range] tuple that may be rendered in the editor in place with other text.
848pub enum InlayHintRequest {}
849
850impl Request for InlayHintRequest {
851    type Params = InlayHintParams;
852    type Result = Option<Vec<InlayHint>>;
853    const METHOD: &'static str = "textDocument/inlayHint";
854}
855
856/// The `inlayHint/resolve` request is sent from the client to the server to resolve additional
857/// information for a given inlay hint. This is usually used to compute the tooltip, location or
858/// command properties of a inlay hint’s label part to avoid its unnecessary computation during the
859/// `textDocument/inlayHint` request.
860pub enum InlayHintResolveRequest {}
861
862impl Request for InlayHintResolveRequest {
863    type Params = InlayHint;
864    type Result = InlayHint;
865    const METHOD: &'static str = "inlayHint/resolve";
866}
867
868/// The `workspace/inlayHint/refresh` request is sent from the server to the client. Servers can use
869/// it to ask clients to refresh the inlay hints currently shown in editors. As a result the client
870/// should ask the server to recompute the inlay hints for these editors. This is useful if a server
871/// detects a configuration change which requires a re-calculation of all inlay hints. Note that the
872/// client still has the freedom to delay the re-calculation of the inlay hints if for example an
873/// editor is currently not visible.
874pub enum InlayHintRefreshRequest {}
875
876impl Request for InlayHintRefreshRequest {
877    type Params = ();
878    type Result = ();
879    const METHOD: &'static str = "workspace/inlayHint/refresh";
880}
881
882/// The inline value request is sent from the client to the server to compute inline values for a
883/// given text document that may be rendered in the editor at the end of lines.
884pub enum InlineValueRequest {}
885
886impl Request for InlineValueRequest {
887    type Params = InlineValueParams;
888    type Result = Option<Vec<InlineValue>>;
889    const METHOD: &'static str = "textDocument/inlineValue";
890}
891
892/// The `workspace/inlineValue/refresh` request is sent from the server to the client. Servers can
893/// use it to ask clients to refresh the inline values currently shown in editors. As a result the
894/// client should ask the server to recompute the inline values for these editors. This is useful if
895/// a server detects a configuration change which requires a re-calculation of all inline values.
896/// Note that the client still has the freedom to delay the re-calculation of the inline values if
897/// for example an editor is currently not visible.
898pub enum InlineValueRefreshRequest {}
899
900impl Request for InlineValueRefreshRequest {
901    type Params = ();
902    type Result = ();
903    const METHOD: &'static str = "workspace/inlineValue/refresh";
904}
905
906/// The text document diagnostic request is sent from the client to the server to ask the server to
907/// compute the diagnostics for a given document. As with other pull requests the server is asked
908/// to compute the diagnostics for the currently synced version of the document.
909#[derive(Debug)]
910pub enum DocumentDiagnosticRequest {}
911
912impl Request for DocumentDiagnosticRequest {
913    type Params = DocumentDiagnosticParams;
914    type Result = DocumentDiagnosticReportResult;
915    const METHOD: &'static str = "textDocument/diagnostic";
916}
917
918/// The workspace diagnostic request is sent from the client to the server to ask the server to
919/// compute workspace wide diagnostics which previously where pushed from the server to the client.
920/// In contrast to the document diagnostic request the workspace request can be long running and is
921/// not bound to a specific workspace or document state. If the client supports streaming for the
922/// workspace diagnostic pull it is legal to provide a document diagnostic report multiple times
923/// for the same document URI. The last one reported will win over previous reports.
924#[derive(Debug)]
925pub enum WorkspaceDiagnosticRequest {}
926
927impl Request for WorkspaceDiagnosticRequest {
928    type Params = WorkspaceDiagnosticParams;
929    const METHOD: &'static str = "workspace/diagnostic";
930    type Result = WorkspaceDiagnosticReportResult;
931}
932
933/// The `workspace/diagnostic/refresh` request is sent from the server to the client. Servers can
934/// use it to ask clients to refresh all needed document and workspace diagnostics. This is useful
935/// if a server detects a project wide configuration change which requires a re-calculation of all
936/// diagnostics.
937#[derive(Debug)]
938pub enum WorkspaceDiagnosticRefresh {}
939
940impl Request for WorkspaceDiagnosticRefresh {
941    type Params = ();
942    type Result = ();
943    const METHOD: &'static str = "workspace/diagnostic/refresh";
944}
945
946/// The type hierarchy request is sent from the client to the server to return a type hierarchy for
947/// the language element of given text document positions. Will return null if the server couldn’t
948/// infer a valid type from the position. The type hierarchy requests are executed in two steps:
949///
950/// 1. first a type hierarchy item is prepared for the given text document position.
951/// 2. for a type hierarchy item the supertype or subtype type hierarchy items are resolved.
952pub enum TypeHierarchyPrepare {}
953
954impl Request for TypeHierarchyPrepare {
955    type Params = TypeHierarchyPrepareParams;
956    type Result = Option<Vec<TypeHierarchyItem>>;
957    const METHOD: &'static str = "textDocument/prepareTypeHierarchy";
958}
959
960/// The `typeHierarchy/supertypes` request is sent from the client to the server to resolve the
961/// supertypes for a given type hierarchy item. Will return null if the server couldn’t infer a
962/// valid type from item in the params. The request doesn’t define its own client and server
963/// capabilities. It is only issued if a server registers for the
964/// `textDocument/prepareTypeHierarchy` request.
965pub enum TypeHierarchySupertypes {}
966
967impl Request for TypeHierarchySupertypes {
968    type Params = TypeHierarchySupertypesParams;
969    type Result = Option<Vec<TypeHierarchyItem>>;
970    const METHOD: &'static str = "typeHierarchy/supertypes";
971}
972
973/// The `typeHierarchy/subtypes` request is sent from the client to the server to resolve the
974/// subtypes for a given type hierarchy item. Will return null if the server couldn’t infer a valid
975/// type from item in the params. The request doesn’t define its own client and server capabilities.
976/// It is only issued if a server registers for the textDocument/prepareTypeHierarchy request.
977pub enum TypeHierarchySubtypes {}
978
979impl Request for TypeHierarchySubtypes {
980    type Params = TypeHierarchySubtypesParams;
981    type Result = Option<Vec<TypeHierarchyItem>>;
982    const METHOD: &'static str = "typeHierarchy/subtypes";
983}
984
985#[cfg(test)]
986mod test {
987    use super::*;
988
989    fn fake_call<R>()
990    where
991        R: Request,
992        R::Params: serde::Serialize,
993        R::Result: serde::de::DeserializeOwned,
994    {
995    }
996
997    macro_rules! check_macro {
998        ($name:tt) => {
999            // check whether the macro name matches the method
1000            assert_eq!(<lsp_request!($name) as Request>::METHOD, $name);
1001            // test whether type checking passes for each component
1002            fake_call::<lsp_request!($name)>();
1003        };
1004    }
1005
1006    #[test]
1007    fn check_macro_definitions() {
1008        check_macro!("initialize");
1009        check_macro!("shutdown");
1010
1011        check_macro!("window/showDocument");
1012        check_macro!("window/showMessageRequest");
1013        check_macro!("window/workDoneProgress/create");
1014
1015        check_macro!("client/registerCapability");
1016        check_macro!("client/unregisterCapability");
1017
1018        check_macro!("textDocument/willSaveWaitUntil");
1019        check_macro!("textDocument/completion");
1020        check_macro!("textDocument/hover");
1021        check_macro!("textDocument/signatureHelp");
1022        check_macro!("textDocument/declaration");
1023        check_macro!("textDocument/definition");
1024        check_macro!("textDocument/references");
1025        check_macro!("textDocument/documentHighlight");
1026        check_macro!("textDocument/documentSymbol");
1027        check_macro!("textDocument/codeAction");
1028        check_macro!("textDocument/codeLens");
1029        check_macro!("textDocument/documentLink");
1030        check_macro!("textDocument/rangeFormatting");
1031        check_macro!("textDocument/onTypeFormatting");
1032        check_macro!("textDocument/formatting");
1033        check_macro!("textDocument/rename");
1034        check_macro!("textDocument/documentColor");
1035        check_macro!("textDocument/colorPresentation");
1036        check_macro!("textDocument/foldingRange");
1037        check_macro!("textDocument/prepareRename");
1038        check_macro!("textDocument/implementation");
1039        check_macro!("textDocument/selectionRange");
1040        check_macro!("textDocument/typeDefinition");
1041        check_macro!("textDocument/moniker");
1042        check_macro!("textDocument/linkedEditingRange");
1043        check_macro!("textDocument/prepareCallHierarchy");
1044        check_macro!("textDocument/prepareTypeHierarchy");
1045        check_macro!("textDocument/semanticTokens/full");
1046        check_macro!("textDocument/semanticTokens/full/delta");
1047        check_macro!("textDocument/semanticTokens/range");
1048        check_macro!("textDocument/inlayHint");
1049        check_macro!("textDocument/inlineValue");
1050        check_macro!("textDocument/diagnostic");
1051
1052        check_macro!("workspace/applyEdit");
1053        check_macro!("workspace/symbol");
1054        check_macro!("workspace/executeCommand");
1055        check_macro!("workspace/configuration");
1056        check_macro!("workspace/diagnostic");
1057        check_macro!("workspace/diagnostic/refresh");
1058        check_macro!("workspace/willCreateFiles");
1059        check_macro!("workspace/willRenameFiles");
1060        check_macro!("workspace/willDeleteFiles");
1061        check_macro!("workspace/workspaceFolders");
1062        check_macro!("workspace/semanticTokens/refresh");
1063        check_macro!("workspace/codeLens/refresh");
1064        check_macro!("workspace/inlayHint/refresh");
1065        check_macro!("workspace/inlineValue/refresh");
1066
1067        check_macro!("callHierarchy/incomingCalls");
1068        check_macro!("callHierarchy/outgoingCalls");
1069        check_macro!("codeAction/resolve");
1070        check_macro!("codeLens/resolve");
1071        check_macro!("completionItem/resolve");
1072        check_macro!("documentLink/resolve");
1073        check_macro!("inlayHint/resolve");
1074        check_macro!("typeHierarchy/subtypes");
1075        check_macro!("typeHierarchy/supertypes");
1076        check_macro!("workspaceSymbol/resolve");
1077    }
1078
1079    #[test]
1080    #[cfg(feature = "proposed")]
1081    fn check_proposed_macro_definitions() {}
1082}