Skip to main content

ls_types/
request.rs

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