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)]
665#[cfg(feature = "proposed")]
666pub enum InlineCompletionRequest {}
667
668#[cfg(feature = "proposed")]
669impl Request for InlineCompletionRequest {
670    type Params = crate::InlineCompletionParams;
671    type Result = Option<crate::InlineCompletionResponse>;
672    const METHOD: &'static str = "textDocument/inlineCompletion";
673}
674
675/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open list of
676/// workspace folders. Returns null in the response if only a single file is open in the tool.
677/// Returns an empty array if a workspace is open but no folders are configured.
678#[derive(Debug)]
679pub enum WorkspaceFoldersRequest {}
680
681impl Request for WorkspaceFoldersRequest {
682    type Params = ();
683    type Result = Option<Vec<crate::WorkspaceFolder>>;
684    const METHOD: &'static str = "workspace/workspaceFolders";
685}
686
687/// The `window/workDoneProgress/create` request is sent from the server
688/// to the client to ask the client to create a work done progress.
689#[derive(Debug)]
690pub enum WorkDoneProgressCreate {}
691
692impl Request for WorkDoneProgressCreate {
693    type Params = crate::WorkDoneProgressCreateParams;
694    type Result = ();
695    const METHOD: &'static str = "window/workDoneProgress/create";
696}
697
698/// The selection range request is sent from the client to the server to return
699/// suggested selection ranges at given positions. A selection range is a range
700/// around the cursor position which the user might be interested in selecting.
701///
702/// A selection range in the return array is for the position in the provided parameters at the same index.
703/// Therefore `positions[i]` must be contained in `result[i].range`.
704///
705/// Typically, but not necessary, selection ranges correspond to the nodes of the
706/// syntax tree.
707pub enum SelectionRangeRequest {}
708
709impl Request for SelectionRangeRequest {
710    type Params = crate::SelectionRangeParams;
711    type Result = Option<Vec<crate::SelectionRange>>;
712    const METHOD: &'static str = "textDocument/selectionRange";
713}
714
715pub enum CallHierarchyPrepare {}
716
717impl Request for CallHierarchyPrepare {
718    type Params = crate::CallHierarchyPrepareParams;
719    type Result = Option<Vec<crate::CallHierarchyItem>>;
720    const METHOD: &'static str = "textDocument/prepareCallHierarchy";
721}
722
723pub enum CallHierarchyIncomingCalls {}
724
725impl Request for CallHierarchyIncomingCalls {
726    type Params = crate::CallHierarchyIncomingCallsParams;
727    type Result = Option<Vec<crate::CallHierarchyIncomingCall>>;
728    const METHOD: &'static str = "callHierarchy/incomingCalls";
729}
730
731pub enum CallHierarchyOutgoingCalls {}
732
733impl Request for CallHierarchyOutgoingCalls {
734    type Params = crate::CallHierarchyOutgoingCallsParams;
735    type Result = Option<Vec<crate::CallHierarchyOutgoingCall>>;
736    const METHOD: &'static str = "callHierarchy/outgoingCalls";
737}
738
739pub enum SemanticTokensFullRequest {}
740
741impl Request for SemanticTokensFullRequest {
742    type Params = crate::SemanticTokensParams;
743    type Result = Option<crate::SemanticTokensResult>;
744    const METHOD: &'static str = "textDocument/semanticTokens/full";
745}
746
747pub enum SemanticTokensFullDeltaRequest {}
748
749impl Request for SemanticTokensFullDeltaRequest {
750    type Params = crate::SemanticTokensDeltaParams;
751    type Result = Option<crate::SemanticTokensFullDeltaResult>;
752    const METHOD: &'static str = "textDocument/semanticTokens/full/delta";
753}
754
755pub enum SemanticTokensRangeRequest {}
756
757impl Request for SemanticTokensRangeRequest {
758    type Params = crate::SemanticTokensRangeParams;
759    type Result = Option<crate::SemanticTokensRangeResult>;
760    const METHOD: &'static str = "textDocument/semanticTokens/range";
761}
762
763/// The `workspace/semanticTokens/refresh` request is sent from the server to the client.
764///
765/// Servers can use it to ask clients to refresh the editors for which this server provides semantic tokens.
766/// As a result the client should ask the server to recompute the semantic tokens for these editors.
767/// This is useful if a server detects a project wide configuration change which requires a re-calculation of all semantic tokens.
768/// 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.
769pub enum SemanticTokensRefresh {}
770
771impl Request for SemanticTokensRefresh {
772    type Params = ();
773    type Result = ();
774    const METHOD: &'static str = "workspace/semanticTokens/refresh";
775}
776
777/// The workspace/codeLens/refresh request is sent from the server to the client.
778///
779/// Servers can use it to ask clients to refresh the code lenses currently shown in editors.
780/// As a result the client should ask the server to recompute the code lenses for these editors.
781/// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses.
782/// 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.
783pub enum CodeLensRefresh {}
784
785impl Request for CodeLensRefresh {
786    type Params = ();
787    type Result = ();
788    const METHOD: &'static str = "workspace/codeLens/refresh";
789}
790
791/// The will create files request is sent from the client to the server before
792/// files are actually created as long as the creation is triggered from within
793/// the client. The request can return a `WorkspaceEdit` which will be applied to
794/// workspace before the files are created. Please note that clients might drop
795/// results if computing the edit took too long or if a server constantly fails on
796/// this request. This is done to keep creates fast and reliable.
797pub enum WillCreateFiles {}
798
799impl Request for WillCreateFiles {
800    type Params = crate::CreateFilesParams;
801    type Result = Option<crate::WorkspaceEdit>;
802    const METHOD: &'static str = "workspace/willCreateFiles";
803}
804
805/// 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.
806pub enum WillRenameFiles {}
807
808impl Request for WillRenameFiles {
809    type Params = crate::RenameFilesParams;
810    type Result = Option<crate::WorkspaceEdit>;
811    const METHOD: &'static str = "workspace/willRenameFiles";
812}
813
814/// 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.
815pub enum WillDeleteFiles {}
816
817impl Request for WillDeleteFiles {
818    type Params = crate::DeleteFilesParams;
819    type Result = Option<crate::WorkspaceEdit>;
820    const METHOD: &'static str = "workspace/willDeleteFiles";
821}
822
823/// 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.
824pub enum ShowDocument {}
825
826impl Request for ShowDocument {
827    type Params = crate::ShowDocumentParams;
828    type Result = crate::ShowDocumentResult;
829    const METHOD: &'static str = "window/showDocument";
830}
831
832pub enum MonikerRequest {}
833
834impl Request for MonikerRequest {
835    type Params = crate::MonikerParams;
836    type Result = Option<Vec<crate::Moniker>>;
837    const METHOD: &'static str = "textDocument/moniker";
838}
839
840/// The inlay hints request is sent from the client to the server to compute inlay hints for a given
841/// [text document, range] tuple that may be rendered in the editor in place with other text.
842pub enum InlayHintRequest {}
843
844impl Request for InlayHintRequest {
845    type Params = crate::InlayHintParams;
846    type Result = Option<Vec<crate::InlayHint>>;
847    const METHOD: &'static str = "textDocument/inlayHint";
848}
849
850/// The `inlayHint/resolve` request is sent from the client to the server to resolve additional
851/// information for a given inlay hint. This is usually used to compute the tooltip, location or
852/// command properties of a inlay hint’s label part to avoid its unnecessary computation during the
853/// `textDocument/inlayHint` request.
854pub enum InlayHintResolveRequest {}
855
856impl Request for InlayHintResolveRequest {
857    type Params = crate::InlayHint;
858    type Result = crate::InlayHint;
859    const METHOD: &'static str = "inlayHint/resolve";
860}
861
862/// The `workspace/inlayHint/refresh` request is sent from the server to the client. Servers can use
863/// it to ask clients to refresh the inlay hints currently shown in editors. As a result the client
864/// should ask the server to recompute the inlay hints for these editors. This is useful if a server
865/// detects a configuration change which requires a re-calculation of all inlay hints. Note that the
866/// client still has the freedom to delay the re-calculation of the inlay hints if for example an
867/// editor is currently not visible.
868pub enum InlayHintRefreshRequest {}
869
870impl Request for InlayHintRefreshRequest {
871    type Params = ();
872    type Result = ();
873    const METHOD: &'static str = "workspace/inlayHint/refresh";
874}
875
876/// The inline value request is sent from the client to the server to compute inline values for a
877/// given text document that may be rendered in the editor at the end of lines.
878pub enum InlineValueRequest {}
879
880impl Request for InlineValueRequest {
881    type Params = crate::InlineValueParams;
882    type Result = Option<Vec<crate::InlineValue>>;
883    const METHOD: &'static str = "textDocument/inlineValue";
884}
885
886/// The `workspace/inlineValue/refresh` request is sent from the server to the client. Servers can
887/// use it to ask clients to refresh the inline values currently shown in editors. As a result the
888/// client should ask the server to recompute the inline values for these editors. This is useful if
889/// a server detects a configuration change which requires a re-calculation of all inline values.
890/// Note that the client still has the freedom to delay the re-calculation of the inline values if
891/// for example an editor is currently not visible.
892pub enum InlineValueRefreshRequest {}
893
894impl Request for InlineValueRefreshRequest {
895    type Params = ();
896    type Result = ();
897    const METHOD: &'static str = "workspace/inlineValue/refresh";
898}
899
900/// The text document diagnostic request is sent from the client to the server to ask the server to
901/// compute the diagnostics for a given document. As with other pull requests the server is asked
902/// to compute the diagnostics for the currently synced version of the document.
903#[derive(Debug)]
904pub enum DocumentDiagnosticRequest {}
905
906impl Request for DocumentDiagnosticRequest {
907    type Params = crate::DocumentDiagnosticParams;
908    type Result = crate::DocumentDiagnosticReportResult;
909    const METHOD: &'static str = "textDocument/diagnostic";
910}
911
912/// The workspace diagnostic request is sent from the client to the server to ask the server to
913/// compute workspace wide diagnostics which previously where pushed from the server to the client.
914/// In contrast to the document diagnostic request the workspace request can be long running and is
915/// not bound to a specific workspace or document state. If the client supports streaming for the
916/// workspace diagnostic pull it is legal to provide a document diagnostic report multiple times
917/// for the same document URI. The last one reported will win over previous reports.
918#[derive(Debug)]
919pub enum WorkspaceDiagnosticRequest {}
920
921impl Request for WorkspaceDiagnosticRequest {
922    type Params = crate::WorkspaceDiagnosticParams;
923    const METHOD: &'static str = "workspace/diagnostic";
924    type Result = crate::WorkspaceDiagnosticReportResult;
925}
926
927/// The `workspace/diagnostic/refresh` request is sent from the server to the client. Servers can
928/// use it to ask clients to refresh all needed document and workspace diagnostics. This is useful
929/// if a server detects a project wide configuration change which requires a re-calculation of all
930/// diagnostics.
931#[derive(Debug)]
932pub enum WorkspaceDiagnosticRefresh {}
933
934impl Request for WorkspaceDiagnosticRefresh {
935    type Params = ();
936    type Result = ();
937    const METHOD: &'static str = "workspace/diagnostic/refresh";
938}
939
940/// The type hierarchy request is sent from the client to the server to return a type hierarchy for
941/// the language element of given text document positions. Will return null if the server couldn’t
942/// infer a valid type from the position. The type hierarchy requests are executed in two steps:
943///
944/// 1. first a type hierarchy item is prepared for the given text document position.
945/// 2. for a type hierarchy item the supertype or subtype type hierarchy items are resolved.
946pub enum TypeHierarchyPrepare {}
947
948impl Request for TypeHierarchyPrepare {
949    type Params = crate::TypeHierarchyPrepareParams;
950    type Result = Option<Vec<crate::TypeHierarchyItem>>;
951    const METHOD: &'static str = "textDocument/prepareTypeHierarchy";
952}
953
954/// The `typeHierarchy/supertypes` request is sent from the client to the server to resolve the
955/// supertypes for a given type hierarchy item. Will return null if the server couldn’t infer a
956/// valid type from item in the params. The request doesn’t define its own client and server
957/// capabilities. It is only issued if a server registers for the
958/// `textDocument/prepareTypeHierarchy` request.
959pub enum TypeHierarchySupertypes {}
960
961impl Request for TypeHierarchySupertypes {
962    type Params = crate::TypeHierarchySupertypesParams;
963    type Result = Option<Vec<crate::TypeHierarchyItem>>;
964    const METHOD: &'static str = "typeHierarchy/supertypes";
965}
966
967/// The `typeHierarchy/subtypes` request is sent from the client to the server to resolve the
968/// subtypes for a given type hierarchy item. Will return null if the server couldn’t infer a valid
969/// type from item in the params. The request doesn’t define its own client and server capabilities.
970/// It is only issued if a server registers for the textDocument/prepareTypeHierarchy request.
971pub enum TypeHierarchySubtypes {}
972
973impl Request for TypeHierarchySubtypes {
974    type Params = crate::TypeHierarchySubtypesParams;
975    type Result = Option<Vec<crate::TypeHierarchyItem>>;
976    const METHOD: &'static str = "typeHierarchy/subtypes";
977}
978
979#[cfg(test)]
980mod test {
981    use super::*;
982
983    fn fake_call<R>()
984    where
985        R: Request,
986        R::Params: serde::Serialize,
987        R::Result: serde::de::DeserializeOwned,
988    {
989    }
990
991    macro_rules! check_macro {
992        ($name:tt) => {
993            // check whether the macro name matches the method
994            assert_eq!(<lsp_request!($name) as Request>::METHOD, $name);
995            // test whether type checking passes for each component
996            fake_call::<lsp_request!($name)>();
997        };
998    }
999
1000    #[test]
1001    fn check_macro_definitions() {
1002        check_macro!("initialize");
1003        check_macro!("shutdown");
1004
1005        check_macro!("window/showDocument");
1006        check_macro!("window/showMessageRequest");
1007        check_macro!("window/workDoneProgress/create");
1008
1009        check_macro!("client/registerCapability");
1010        check_macro!("client/unregisterCapability");
1011
1012        check_macro!("textDocument/willSaveWaitUntil");
1013        check_macro!("textDocument/completion");
1014        check_macro!("textDocument/hover");
1015        check_macro!("textDocument/signatureHelp");
1016        check_macro!("textDocument/declaration");
1017        check_macro!("textDocument/definition");
1018        check_macro!("textDocument/references");
1019        check_macro!("textDocument/documentHighlight");
1020        check_macro!("textDocument/documentSymbol");
1021        check_macro!("textDocument/codeAction");
1022        check_macro!("textDocument/codeLens");
1023        check_macro!("textDocument/documentLink");
1024        check_macro!("textDocument/rangeFormatting");
1025        check_macro!("textDocument/onTypeFormatting");
1026        check_macro!("textDocument/formatting");
1027        check_macro!("textDocument/rename");
1028        check_macro!("textDocument/documentColor");
1029        check_macro!("textDocument/colorPresentation");
1030        check_macro!("textDocument/foldingRange");
1031        check_macro!("textDocument/prepareRename");
1032        check_macro!("textDocument/implementation");
1033        check_macro!("textDocument/selectionRange");
1034        check_macro!("textDocument/typeDefinition");
1035        check_macro!("textDocument/moniker");
1036        check_macro!("textDocument/linkedEditingRange");
1037        check_macro!("textDocument/prepareCallHierarchy");
1038        check_macro!("textDocument/prepareTypeHierarchy");
1039        check_macro!("textDocument/semanticTokens/full");
1040        check_macro!("textDocument/semanticTokens/full/delta");
1041        check_macro!("textDocument/semanticTokens/range");
1042        check_macro!("textDocument/inlayHint");
1043        check_macro!("textDocument/inlineValue");
1044        check_macro!("textDocument/diagnostic");
1045
1046        check_macro!("workspace/applyEdit");
1047        check_macro!("workspace/symbol");
1048        check_macro!("workspace/executeCommand");
1049        check_macro!("workspace/configuration");
1050        check_macro!("workspace/diagnostic");
1051        check_macro!("workspace/diagnostic/refresh");
1052        check_macro!("workspace/willCreateFiles");
1053        check_macro!("workspace/willRenameFiles");
1054        check_macro!("workspace/willDeleteFiles");
1055        check_macro!("workspace/workspaceFolders");
1056        check_macro!("workspace/semanticTokens/refresh");
1057        check_macro!("workspace/codeLens/refresh");
1058        check_macro!("workspace/inlayHint/refresh");
1059        check_macro!("workspace/inlineValue/refresh");
1060
1061        check_macro!("callHierarchy/incomingCalls");
1062        check_macro!("callHierarchy/outgoingCalls");
1063        check_macro!("codeAction/resolve");
1064        check_macro!("codeLens/resolve");
1065        check_macro!("completionItem/resolve");
1066        check_macro!("documentLink/resolve");
1067        check_macro!("inlayHint/resolve");
1068        check_macro!("typeHierarchy/subtypes");
1069        check_macro!("typeHierarchy/supertypes");
1070        check_macro!("workspaceSymbol/resolve");
1071    }
1072
1073    #[test]
1074    #[cfg(feature = "proposed")]
1075    fn check_proposed_macro_definitions() {}
1076}