lsp_types/
request.rs

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