1use super::*;
2
3use serde::{de::DeserializeOwned, Serialize};
4
5pub trait Request {
6 type Params: DeserializeOwned + Serialize + Send + Sync + 'static;
7 type Result: DeserializeOwned + Serialize + Send + Sync + 'static;
8 const METHOD: &'static str;
9}
10
11#[macro_export]
12macro_rules! lsp_request {
13 ("initialize") => {
14 $crate::request::Initialize
15 };
16 ("shutdown") => {
17 $crate::request::Shutdown
18 };
19
20 ("window/showMessageRequest") => {
21 $crate::request::ShowMessageRequest
22 };
23
24 ("client/registerCapability") => {
25 $crate::request::RegisterCapability
26 };
27 ("client/unregisterCapability") => {
28 $crate::request::UnregisterCapability
29 };
30
31 ("workspace/symbol") => {
32 $crate::request::WorkspaceSymbolRequest
33 };
34 ("workspaceSymbol/resolve") => {
35 $crate::request::WorkspaceSymbolResolve
36 };
37 ("workspace/executeCommand") => {
38 $crate::request::ExecuteCommand
39 };
40
41 ("textDocument/willSaveWaitUntil") => {
42 $crate::request::WillSaveWaitUntil
43 };
44
45 ("textDocument/completion") => {
46 $crate::request::Completion
47 };
48 ("completionItem/resolve") => {
49 $crate::request::ResolveCompletionItem
50 };
51 ("textDocument/hover") => {
52 $crate::request::HoverRequest
53 };
54 ("textDocument/signatureHelp") => {
55 $crate::request::SignatureHelpRequest
56 };
57 ("textDocument/declaration") => {
58 $crate::request::GotoDeclaration
59 };
60 ("textDocument/definition") => {
61 $crate::request::GotoDefinition
62 };
63 ("textDocument/references") => {
64 $crate::request::References
65 };
66 ("textDocument/documentHighlight") => {
67 $crate::request::DocumentHighlightRequest
68 };
69 ("textDocument/documentSymbol") => {
70 $crate::request::DocumentSymbolRequest
71 };
72 ("textDocument/codeAction") => {
73 $crate::request::CodeActionRequest
74 };
75 ("textDocument/codeLens") => {
76 $crate::request::CodeLensRequest
77 };
78 ("codeLens/resolve") => {
79 $crate::request::CodeLensResolve
80 };
81 ("textDocument/documentLink") => {
82 $crate::request::DocumentLinkRequest
83 };
84 ("documentLink/resolve") => {
85 $crate::request::DocumentLinkResolve
86 };
87 ("workspace/applyEdit") => {
88 $crate::request::ApplyWorkspaceEdit
89 };
90 ("textDocument/rangeFormatting") => {
91 $crate::request::RangeFormatting
92 };
93 ("textDocument/onTypeFormatting") => {
94 $crate::request::OnTypeFormatting
95 };
96 ("textDocument/formatting") => {
97 $crate::request::Formatting
98 };
99 ("textDocument/rename") => {
100 $crate::request::Rename
101 };
102 ("textDocument/documentColor") => {
103 $crate::request::DocumentColor
104 };
105 ("textDocument/colorPresentation") => {
106 $crate::request::ColorPresentationRequest
107 };
108 ("textDocument/foldingRange") => {
109 $crate::request::FoldingRangeRequest
110 };
111 ("textDocument/prepareRename") => {
112 $crate::request::PrepareRenameRequest
113 };
114 ("textDocument/implementation") => {
115 $crate::request::GotoImplementation
116 };
117 ("textDocument/typeDefinition") => {
118 $crate::request::GotoTypeDefinition
119 };
120 ("textDocument/selectionRange") => {
121 $crate::request::SelectionRangeRequest
122 };
123 ("workspace/workspaceFolders") => {
124 $crate::request::WorkspaceFoldersRequest
125 };
126 ("workspace/configuration") => {
127 $crate::request::WorkspaceConfiguration
128 };
129 ("window/workDoneProgress/create") => {
130 $crate::request::WorkDoneProgressCreate
131 };
132 ("callHierarchy/incomingCalls") => {
133 $crate::request::CallHierarchyIncomingCalls
134 };
135 ("callHierarchy/outgoingCalls") => {
136 $crate::request::CallHierarchyOutgoingCalls
137 };
138 ("textDocument/moniker") => {
139 $crate::request::MonikerRequest
140 };
141 ("textDocument/linkedEditingRange") => {
142 $crate::request::LinkedEditingRange
143 };
144 ("textDocument/prepareCallHierarchy") => {
145 $crate::request::CallHierarchyPrepare
146 };
147 ("textDocument/prepareTypeHierarchy") => {
148 $crate::request::TypeHierarchyPrepare
149 };
150 ("textDocument/semanticTokens/full") => {
151 $crate::request::SemanticTokensFullRequest
152 };
153 ("textDocument/semanticTokens/full/delta") => {
154 $crate::request::SemanticTokensFullDeltaRequest
155 };
156 ("textDocument/semanticTokens/range") => {
157 $crate::request::SemanticTokensRangeRequest
158 };
159 ("textDocument/inlayHint") => {
160 $crate::request::InlayHintRequest
161 };
162 ("textDocument/inlineValue") => {
163 $crate::request::InlineValueRequest
164 };
165 ("textDocument/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#[derive(Debug)]
664#[cfg(feature = "proposed")]
665pub enum InlineCompletionRequest {}
666
667#[cfg(feature = "proposed")]
668impl Request for InlineCompletionRequest {
669 type Params = InlineCompletionParams;
670 type Result = Option<InlineCompletionResponse>;
671 const METHOD: &'static str = "textDocument/inlineCompletion";
672}
673
674/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open list of
675/// workspace folders. Returns null in the response if only a single file is open in the tool.
676/// Returns an empty array if a workspace is open but no folders are configured.
677#[derive(Debug)]
678pub enum WorkspaceFoldersRequest {}
679
680impl Request for WorkspaceFoldersRequest {
681 type Params = ();
682 type Result = Option<Vec<WorkspaceFolder>>;
683 const METHOD: &'static str = "workspace/workspaceFolders";
684}
685
686/// The `window/workDoneProgress/create` request is sent from the server
687/// to the client to ask the client to create a work done progress.
688#[derive(Debug)]
689pub enum WorkDoneProgressCreate {}
690
691impl Request for WorkDoneProgressCreate {
692 type Params = WorkDoneProgressCreateParams;
693 type Result = ();
694 const METHOD: &'static str = "window/workDoneProgress/create";
695}
696
697/// The selection range request is sent from the client to the server to return
698/// suggested selection ranges at given positions. A selection range is a range
699/// around the cursor position which the user might be interested in selecting.
700///
701/// A selection range in the return array is for the position in the provided parameters at the same index.
702/// Therefore `positions[i]` must be contained in `result[i].range`.
703///
704/// Typically, but not necessary, selection ranges correspond to the nodes of the
705/// syntax tree.
706pub enum SelectionRangeRequest {}
707
708impl Request for SelectionRangeRequest {
709 type Params = SelectionRangeParams;
710 type Result = Option<Vec<SelectionRange>>;
711 const METHOD: &'static str = "textDocument/selectionRange";
712}
713
714pub enum CallHierarchyPrepare {}
715
716impl Request for CallHierarchyPrepare {
717 type Params = CallHierarchyPrepareParams;
718 type Result = Option<Vec<CallHierarchyItem>>;
719 const METHOD: &'static str = "textDocument/prepareCallHierarchy";
720}
721
722pub enum CallHierarchyIncomingCalls {}
723
724impl Request for CallHierarchyIncomingCalls {
725 type Params = CallHierarchyIncomingCallsParams;
726 type Result = Option<Vec<CallHierarchyIncomingCall>>;
727 const METHOD: &'static str = "callHierarchy/incomingCalls";
728}
729
730pub enum CallHierarchyOutgoingCalls {}
731
732impl Request for CallHierarchyOutgoingCalls {
733 type Params = CallHierarchyOutgoingCallsParams;
734 type Result = Option<Vec<CallHierarchyOutgoingCall>>;
735 const METHOD: &'static str = "callHierarchy/outgoingCalls";
736}
737
738pub enum SemanticTokensFullRequest {}
739
740impl Request for SemanticTokensFullRequest {
741 type Params = SemanticTokensParams;
742 type Result = Option<SemanticTokensResult>;
743 const METHOD: &'static str = "textDocument/semanticTokens/full";
744}
745
746pub enum SemanticTokensFullDeltaRequest {}
747
748impl Request for SemanticTokensFullDeltaRequest {
749 type Params = SemanticTokensDeltaParams;
750 type Result = Option<SemanticTokensFullDeltaResult>;
751 const METHOD: &'static str = "textDocument/semanticTokens/full/delta";
752}
753
754pub enum SemanticTokensRangeRequest {}
755
756impl Request for SemanticTokensRangeRequest {
757 type Params = SemanticTokensRangeParams;
758 type Result = Option<SemanticTokensRangeResult>;
759 const METHOD: &'static str = "textDocument/semanticTokens/range";
760}
761
762/// The `workspace/semanticTokens/refresh` request is sent from the server to the client.
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/// Servers can use it to ask clients to refresh the code lenses currently shown in editors.
777/// As a result the client should ask the server to recompute the code lenses for these editors.
778/// This is useful if a server detects a configuration change which requires a re-calculation of all code lenses.
779/// 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.
780pub enum CodeLensRefresh {}
781
782impl Request for CodeLensRefresh {
783 type Params = ();
784 type Result = ();
785 const METHOD: &'static str = "workspace/codeLens/refresh";
786}
787
788/// 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.
789pub enum WillCreateFiles {}
790
791impl Request for WillCreateFiles {
792 type Params = CreateFilesParams;
793 type Result = Option<WorkspaceEdit>;
794 const METHOD: &'static str = "workspace/willCreateFiles";
795}
796
797/// 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.
798pub enum WillRenameFiles {}
799
800impl Request for WillRenameFiles {
801 type Params = RenameFilesParams;
802 type Result = Option<WorkspaceEdit>;
803 const METHOD: &'static str = "workspace/willRenameFiles";
804}
805
806/// 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.
807pub enum WillDeleteFiles {}
808
809impl Request for WillDeleteFiles {
810 type Params = DeleteFilesParams;
811 type Result = Option<WorkspaceEdit>;
812 const METHOD: &'static str = "workspace/willDeleteFiles";
813}
814
815/// 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.
816pub enum ShowDocument {}
817
818impl Request for ShowDocument {
819 type Params = ShowDocumentParams;
820 type Result = ShowDocumentResult;
821 const METHOD: &'static str = "window/showDocument";
822}
823
824pub enum MonikerRequest {}
825
826impl Request for MonikerRequest {
827 type Params = MonikerParams;
828 type Result = Option<Vec<Moniker>>;
829 const METHOD: &'static str = "textDocument/moniker";
830}
831
832/// The inlay hints request is sent from the client to the server to compute inlay hints for a given
833/// [text document, range] tuple that may be rendered in the editor in place with other text.
834pub enum InlayHintRequest {}
835
836impl Request for InlayHintRequest {
837 type Params = InlayHintParams;
838 type Result = Option<Vec<InlayHint>>;
839 const METHOD: &'static str = "textDocument/inlayHint";
840}
841
842/// The `inlayHint/resolve` request is sent from the client to the server to resolve additional
843/// information for a given inlay hint. This is usually used to compute the tooltip, location or
844/// command properties of a inlay hint’s label part to avoid its unnecessary computation during the
845/// `textDocument/inlayHint` request.
846pub enum InlayHintResolveRequest {}
847
848impl Request for InlayHintResolveRequest {
849 type Params = InlayHint;
850 type Result = InlayHint;
851 const METHOD: &'static str = "inlayHint/resolve";
852}
853
854/// The `workspace/inlayHint/refresh` request is sent from the server to the client. Servers can use
855/// it to ask clients to refresh the inlay hints currently shown in editors. As a result the client
856/// should ask the server to recompute the inlay hints for these editors. This is useful if a server
857/// detects a configuration change which requires a re-calculation of all inlay hints. Note that the
858/// client still has the freedom to delay the re-calculation of the inlay hints if for example an
859/// editor is currently not visible.
860pub enum InlayHintRefreshRequest {}
861
862impl Request for InlayHintRefreshRequest {
863 type Params = ();
864 type Result = ();
865 const METHOD: &'static str = "workspace/inlayHint/refresh";
866}
867
868/// The inline value request is sent from the client to the server to compute inline values for a
869/// given text document that may be rendered in the editor at the end of lines.
870pub enum InlineValueRequest {}
871
872impl Request for InlineValueRequest {
873 type Params = InlineValueParams;
874 type Result = Option<InlineValue>;
875 const METHOD: &'static str = "textDocument/inlineValue";
876}
877
878/// The `workspace/inlineValue/refresh` request is sent from the server to the client. Servers can
879/// use it to ask clients to refresh the inline values currently shown in editors. As a result the
880/// client should ask the server to recompute the inline values for these editors. This is useful if
881/// a server detects a configuration change which requires a re-calculation of all inline values.
882/// Note that the client still has the freedom to delay the re-calculation of the inline values if
883/// for example an editor is currently not visible.
884pub enum InlineValueRefreshRequest {}
885
886impl Request for InlineValueRefreshRequest {
887 type Params = ();
888 type Result = ();
889 const METHOD: &'static str = "workspace/inlineValue/refresh";
890}
891
892/// The text document diagnostic request is sent from the client to the server to ask the server to
893/// compute the diagnostics for a given document. As with other pull requests the server is asked
894/// to compute the diagnostics for the currently synced version of the document.
895#[derive(Debug)]
896pub enum DocumentDiagnosticRequest {}
897
898impl Request for DocumentDiagnosticRequest {
899 type Params = DocumentDiagnosticParams;
900 type Result = DocumentDiagnosticReportResult;
901 const METHOD: &'static str = "textDocument/diagnostic";
902}
903
904/// The workspace diagnostic request is sent from the client to the server to ask the server to
905/// compute workspace wide diagnostics which previously where pushed from the server to the client.
906/// In contrast to the document diagnostic request the workspace request can be long running and is
907/// not bound to a specific workspace or document state. If the client supports streaming for the
908/// workspace diagnostic pull it is legal to provide a document diagnostic report multiple times
909/// for the same document URI. The last one reported will win over previous reports.
910#[derive(Debug)]
911pub enum WorkspaceDiagnosticRequest {}
912
913impl Request for WorkspaceDiagnosticRequest {
914 type Params = WorkspaceDiagnosticParams;
915 const METHOD: &'static str = "workspace/diagnostic";
916 type Result = WorkspaceDiagnosticReportResult;
917}
918
919/// The `workspace/diagnostic/refresh` request is sent from the server to the client. Servers can
920/// use it to ask clients to refresh all needed document and workspace diagnostics. This is useful
921/// if a server detects a project wide configuration change which requires a re-calculation of all
922/// diagnostics.
923#[derive(Debug)]
924pub enum WorkspaceDiagnosticRefresh {}
925
926impl Request for WorkspaceDiagnosticRefresh {
927 type Params = ();
928 type Result = ();
929 const METHOD: &'static str = "workspace/diagnostic/refresh";
930}
931
932/// The type hierarchy request is sent from the client to the server to return a type hierarchy for
933/// the language element of given text document positions. Will return null if the server couldn’t
934/// infer a valid type from the position. The type hierarchy requests are executed in two steps:
935///
936/// 1. first a type hierarchy item is prepared for the given text document position.
937/// 2. for a type hierarchy item the supertype or subtype type hierarchy items are resolved.
938pub enum TypeHierarchyPrepare {}
939
940impl Request for TypeHierarchyPrepare {
941 type Params = TypeHierarchyPrepareParams;
942 type Result = Option<Vec<TypeHierarchyItem>>;
943 const METHOD: &'static str = "textDocument/prepareTypeHierarchy";
944}
945
946/// The `typeHierarchy/supertypes` request is sent from the client to the server to resolve the
947/// supertypes for a given type hierarchy item. Will return null if the server couldn’t infer a
948/// valid type from item in the params. The request doesn’t define its own client and server
949/// capabilities. It is only issued if a server registers for the
950/// `textDocument/prepareTypeHierarchy` request.
951pub enum TypeHierarchySupertypes {}
952
953impl Request for TypeHierarchySupertypes {
954 type Params = TypeHierarchySupertypesParams;
955 type Result = Option<Vec<TypeHierarchyItem>>;
956 const METHOD: &'static str = "typeHierarchy/supertypes";
957}
958
959/// The `typeHierarchy/subtypes` request is sent from the client to the server to resolve the
960/// subtypes for a given type hierarchy item. Will return null if the server couldn’t infer a valid
961/// type from item in the params. The request doesn’t define its own client and server capabilities.
962/// It is only issued if a server registers for the textDocument/prepareTypeHierarchy request.
963pub enum TypeHierarchySubtypes {}
964
965impl Request for TypeHierarchySubtypes {
966 type Params = TypeHierarchySubtypesParams;
967 type Result = Option<Vec<TypeHierarchyItem>>;
968 const METHOD: &'static str = "typeHierarchy/subtypes";
969}
970
971#[cfg(test)]
972mod test {
973 use super::*;
974
975 fn fake_call<R>()
976 where
977 R: Request,
978 R::Params: serde::Serialize,
979 R::Result: serde::de::DeserializeOwned,
980 {
981 }
982
983 macro_rules! check_macro {
984 ($name:tt) => {
985 // check whether the macro name matches the method
986 assert_eq!(<lsp_request!($name) as Request>::METHOD, $name);
987 // test whether type checking passes for each component
988 fake_call::<lsp_request!($name)>();
989 };
990 }
991
992 #[test]
993 fn check_macro_definitions() {
994 check_macro!("initialize");
995 check_macro!("shutdown");
996
997 check_macro!("window/showDocument");
998 check_macro!("window/showMessageRequest");
999 check_macro!("window/workDoneProgress/create");
1000
1001 check_macro!("client/registerCapability");
1002 check_macro!("client/unregisterCapability");
1003
1004 check_macro!("textDocument/willSaveWaitUntil");
1005 check_macro!("textDocument/completion");
1006 check_macro!("textDocument/hover");
1007 check_macro!("textDocument/signatureHelp");
1008 check_macro!("textDocument/declaration");
1009 check_macro!("textDocument/definition");
1010 check_macro!("textDocument/references");
1011 check_macro!("textDocument/documentHighlight");
1012 check_macro!("textDocument/documentSymbol");
1013 check_macro!("textDocument/codeAction");
1014 check_macro!("textDocument/codeLens");
1015 check_macro!("textDocument/documentLink");
1016 check_macro!("textDocument/rangeFormatting");
1017 check_macro!("textDocument/onTypeFormatting");
1018 check_macro!("textDocument/formatting");
1019 check_macro!("textDocument/rename");
1020 check_macro!("textDocument/documentColor");
1021 check_macro!("textDocument/colorPresentation");
1022 check_macro!("textDocument/foldingRange");
1023 check_macro!("textDocument/prepareRename");
1024 check_macro!("textDocument/implementation");
1025 check_macro!("textDocument/selectionRange");
1026 check_macro!("textDocument/typeDefinition");
1027 check_macro!("textDocument/moniker");
1028 check_macro!("textDocument/linkedEditingRange");
1029 check_macro!("textDocument/prepareCallHierarchy");
1030 check_macro!("textDocument/prepareTypeHierarchy");
1031 check_macro!("textDocument/semanticTokens/full");
1032 check_macro!("textDocument/semanticTokens/full/delta");
1033 check_macro!("textDocument/semanticTokens/range");
1034 check_macro!("textDocument/inlayHint");
1035 check_macro!("textDocument/inlineValue");
1036 check_macro!("textDocument/diagnostic");
1037
1038 check_macro!("workspace/applyEdit");
1039 check_macro!("workspace/symbol");
1040 check_macro!("workspace/executeCommand");
1041 check_macro!("workspace/configuration");
1042 check_macro!("workspace/diagnostic");
1043 check_macro!("workspace/diagnostic/refresh");
1044 check_macro!("workspace/willCreateFiles");
1045 check_macro!("workspace/willRenameFiles");
1046 check_macro!("workspace/willDeleteFiles");
1047 check_macro!("workspace/workspaceFolders");
1048 check_macro!("workspace/semanticTokens/refresh");
1049 check_macro!("workspace/codeLens/refresh");
1050 check_macro!("workspace/inlayHint/refresh");
1051 check_macro!("workspace/inlineValue/refresh");
1052
1053 check_macro!("callHierarchy/incomingCalls");
1054 check_macro!("callHierarchy/outgoingCalls");
1055 check_macro!("codeAction/resolve");
1056 check_macro!("codeLens/resolve");
1057 check_macro!("completionItem/resolve");
1058 check_macro!("documentLink/resolve");
1059 check_macro!("inlayHint/resolve");
1060 check_macro!("typeHierarchy/subtypes");
1061 check_macro!("typeHierarchy/supertypes");
1062 check_macro!("workspaceSymbol/resolve");
1063 }
1064
1065 #[test]
1066 #[cfg(feature = "proposed")]
1067 fn check_proposed_macro_definitions() {}
1068}
1069