-use super::*;
-
-use serde::{de::DeserializeOwned, Serialize};
-
-pub trait Request {
- type Params: DeserializeOwned + Serialize;
- type Result: DeserializeOwned + Serialize;
- const METHOD: &'static str;
-}
-
-#[macro_export]
-macro_rules! lsp_request {
- ("initialize") => {
- $crate::request::Initialize
- };
- ("shutdown") => {
- $crate::request::Shutdown
- };
-
- ("window/showMessageRequest") => {
- $crate::request::ShowMessageRequest
- };
-
- ("client/registerCapability") => {
- $crate::request::RegisterCapability
- };
- ("client/unregisterCapability") => {
- $crate::request::UnregisterCapability
- };
-
- ("workspace/symbol") => {
- $crate::request::WorkspaceSymbol
- };
- ("workspace/executeCommand") => {
- $crate::request::ExecuteCommand
- };
-
- ("textDocument/willSaveWaitUntil") => {
- $crate::request::WillSaveWaitUntil
- };
-
- ("textDocument/completion") => {
- $crate::request::Completion
- };
- ("completionItem/resolve") => {
- $crate::request::ResolveCompletionItem
- };
- ("textDocument/hover") => {
- $crate::request::HoverRequest
- };
- ("textDocument/signatureHelp") => {
- $crate::request::SignatureHelpRequest
- };
- ("textDocument/declaration") => {
- $crate::request::GotoDeclaration
- };
- ("textDocument/definition") => {
- $crate::request::GotoDefinition
- };
- ("textDocument/references") => {
- $crate::request::References
- };
- ("textDocument/documentHighlight") => {
- $crate::request::DocumentHighlightRequest
- };
- ("textDocument/documentSymbol") => {
- $crate::request::DocumentSymbolRequest
- };
- ("textDocument/codeAction") => {
- $crate::request::CodeActionRequest
- };
- ("textDocument/codeLens") => {
- $crate::request::CodeLensRequest
- };
- ("codeLens/resolve") => {
- $crate::request::CodeLensResolve
- };
- ("textDocument/documentLink") => {
- $crate::request::DocumentLinkRequest
- };
- ("documentLink/resolve") => {
- $crate::request::DocumentLinkResolve
- };
- ("workspace/applyEdit") => {
- $crate::request::ApplyWorkspaceEdit
- };
- ("textDocument/rangeFormatting") => {
- $crate::request::RangeFormatting
- };
- ("textDocument/onTypeFormatting") => {
- $crate::request::OnTypeFormatting
- };
- ("textDocument/formatting") => {
- $crate::request::Formatting
- };
- ("textDocument/rename") => {
- $crate::request::Rename
- };
- ("textDocument/documentColor") => {
- $crate::request::DocumentColor
- };
- ("textDocument/colorPresentation") => {
- $crate::request::ColorPresentationRequest
- };
- ("textDocument/foldingRange") => {
- $crate::request::FoldingRangeRequest
- };
- ("textDocument/prepareRename") => {
- $crate::request::PrepareRenameRequest
- };
- ("textDocument/implementation") => {
- $crate::request::GotoImplementation
- };
- ("textDocument/typeDefinition") => {
- $crate::request::GotoTypeDefinition
- };
- ("textDocument/selectionRange") => {
- $crate::request::SelectionRangeRequest
- };
- ("workspace/workspaceFolders") => {
- $crate::request::WorkspaceFoldersRequest
- };
- ("workspace/configuration") => {
- $crate::request::WorkspaceConfiguration
- };
- ("window/workDoneProgress/create") => {
- $crate::request::WorkDoneProgressCreate
- };
- // Requires #[cfg(feature = "proposed")]
- ("callHierarchy/incomingCalls") => {
- $crate::request::CallHierarchyIncomingCalls
- };
- // Requires #[cfg(feature = "proposed")]
- ("callHierarchy/outgoingCalls") => {
- $crate::request::CallHierarchyOutgoingCalls
- };
- // Requires #[cfg(feature = "proposed")]
- ("textDocument/prepareCallHierarchy") => {
- $crate::request::CallHierarchyPrepare
- };
- // Requires #[cfg(feature = "proposed")]
- ("textDocument/semanticTokens") => {
- $crate::request::SemanticTokensRequest
- };
- // Requires #[cfg(feature = "proposed")]
- ("textDocument/semanticTokens/edits") => {
- $crate::request::SemanticTokensEditsRequest
- };
- // Requires #[cfg(feature = "proposed")]
- ("textDocument/semanticTokens/range") => {
- $crate::request::SemanticTokensRangeRequest
- };
-}
-
-/// The initialize request is sent as the first request from the client to the server.
-/// If the server receives request or notification before the `initialize` request it should act as follows:
-///
-/// * for a request the respond should be errored with `code: -32001`. The message can be picked by the server.
-/// * notifications should be dropped.
-#[derive(Debug)]
-pub enum Initialize {}
-
-impl Request for Initialize {
- type Params = InitializeParams;
- type Result = InitializeResult;
- const METHOD: &'static str = "initialize";
-}
-
-/// The shutdown request is sent from the client to the server. It asks the server to shut down,
-/// but to not exit (otherwise the response might not be delivered correctly to the client).
-/// There is a separate exit notification that asks the server to exit.
-#[derive(Debug)]
-pub enum Shutdown {}
-
-impl Request for Shutdown {
- type Params = ();
- type Result = ();
- const METHOD: &'static str = "shutdown";
-}
-
-/// The show message request is sent from a server to a client to ask the client to display a particular message
-/// in the user interface. In addition to the show message notification the request allows to pass actions and to
-/// wait for an answer from the client.
-#[derive(Debug)]
-pub enum ShowMessageRequest {}
-
-impl Request for ShowMessageRequest {
- type Params = ShowMessageRequestParams;
- type Result = Option<MessageActionItem>;
- const METHOD: &'static str = "window/showMessageRequest";
-}
-
-/// The client/registerCapability request is sent from the server to the client to register for a new capability
-/// on the client side. Not all clients need to support dynamic capability registration. A client opts in via the
-/// ClientCapabilities.GenericCapability property.
-#[derive(Debug)]
-pub enum RegisterCapability {}
-
-impl Request for RegisterCapability {
- type Params = RegistrationParams;
- type Result = ();
- const METHOD: &'static str = "client/registerCapability";
-}
-
-/// The client/unregisterCapability request is sent from the server to the client to unregister a
-/// previously register capability.
-#[derive(Debug)]
-pub enum UnregisterCapability {}
-
-impl Request for UnregisterCapability {
- type Params = UnregistrationParams;
- type Result = ();
- const METHOD: &'static str = "client/unregisterCapability";
-}
-
-/// The Completion request is sent from the client to the server to compute completion items at a given cursor position.
-/// Completion items are presented in the IntelliSense user interface. If computing full completion items is expensive,
-/// servers can additionally provide a handler for the completion item resolve request ('completionItem/resolve').
-/// This request is sent when a completion item is selected in the user interface. A typical use case is for example:
-/// the 'textDocument/completion' request doesn’t fill in the documentation property for returned completion items
-/// since it is expensive to compute. When the item is selected in the user interface then a ‘completionItem/resolve’
-/// request is sent with the selected completion item as a param. The returned completion item should have the
-/// documentation property filled in. The request can delay the computation of the detail and documentation properties.
-/// However, properties that are needed for the initial sorting and filtering, like sortText, filterText, insertText,
-/// and textEdit must be provided in the textDocument/completion request and must not be changed during resolve.
-#[derive(Debug)]
-pub enum Completion {}
-
-impl Request for Completion {
- type Params = CompletionParams;
- type Result = Option<CompletionResponse>;
- const METHOD: &'static str = "textDocument/completion";
-}
-
-/// The request is sent from the client to the server to resolve additional information for a given completion item.
-#[derive(Debug)]
-pub enum ResolveCompletionItem {}
-
-impl Request for ResolveCompletionItem {
- type Params = CompletionItem;
- type Result = CompletionItem;
- const METHOD: &'static str = "completionItem/resolve";
-}
-
-/// The hover request is sent from the client to the server to request hover information at a given text
-/// document position.
-#[derive(Debug)]
-pub enum HoverRequest {}
-
-impl Request for HoverRequest {
- type Params = HoverParams;
- type Result = Option<Hover>;
- const METHOD: &'static str = "textDocument/hover";
-}
-
-/// The signature help request is sent from the client to the server to request signature information at
-/// a given cursor position.
-#[derive(Debug)]
-pub enum SignatureHelpRequest {}
-
-impl Request for SignatureHelpRequest {
- type Params = SignatureHelpParams;
- type Result = Option<SignatureHelp>;
- const METHOD: &'static str = "textDocument/signatureHelp";
-}
-
-#[derive(Debug)]
-pub enum GotoDeclaration {}
-pub type GotoDeclarationParams = GotoDefinitionParams;
-pub type GotoDeclarationResponse = GotoDefinitionResponse;
-
-/// The goto declaration request is sent from the client to the server to resolve the declaration location of
-/// a symbol at a given text document position.
-impl Request for GotoDeclaration {
- type Params = GotoDeclarationParams;
- type Result = Option<GotoDeclarationResponse>;
- const METHOD: &'static str = "textDocument/declaration";
-}
-
-/// The goto definition request is sent from the client to the server to resolve the definition location of
-/// a symbol at a given text document position.
-#[derive(Debug)]
-pub enum GotoDefinition {}
-
-impl Request for GotoDefinition {
- type Params = GotoDefinitionParams;
- type Result = Option<GotoDefinitionResponse>;
- const METHOD: &'static str = "textDocument/definition";
-}
-
-/// The references request is sent from the client to the server to resolve project-wide references for the
-/// symbol denoted by the given text document position.
-#[derive(Debug)]
-pub enum References {}
-
-impl Request for References {
- type Params = ReferenceParams;
- type Result = Option<Vec<Location>>;
- const METHOD: &'static str = "textDocument/references";
-}
-
-/// The goto type definition request is sent from the client to the
-/// server to resolve the type definition location of a symbol at a
-/// given text document position.
-#[derive(Debug)]
-pub enum GotoTypeDefinition {}
-
-pub type GotoTypeDefinitionParams = GotoDefinitionParams;
-pub type GotoTypeDefinitionResponse = GotoDefinitionResponse;
-
-impl Request for GotoTypeDefinition {
- type Params = GotoTypeDefinitionParams;
- type Result = Option<GotoTypeDefinitionResponse>;
- const METHOD: &'static str = "textDocument/typeDefinition";
-}
-
-/// The goto implementation request is sent from the client to the
-/// server to resolve the implementation location of a symbol at a
-/// given text document position.
-#[derive(Debug)]
-pub enum GotoImplementation {}
-
-pub type GotoImplementationParams = GotoTypeDefinitionParams;
-pub type GotoImplementationResponse = GotoDefinitionResponse;
-
-impl Request for GotoImplementation {
- type Params = GotoImplementationParams;
- type Result = Option<GotoImplementationResponse>;
- const METHOD: &'static str = "textDocument/implementation";
-}
-
-/// The document highlight request is sent from the client to the server to resolve a document highlights
-/// for a given text document position.
-/// For programming languages this usually highlights all references to the symbol scoped to this file.
-/// However we kept 'textDocument/documentHighlight' and 'textDocument/references' separate requests since
-/// the first one is allowed to be more fuzzy.
-/// Symbol matches usually have a DocumentHighlightKind of Read or Write whereas fuzzy or textual matches
-/// use Text as the kind.
-#[derive(Debug)]
-pub enum DocumentHighlightRequest {}
-
-impl Request for DocumentHighlightRequest {
- type Params = DocumentHighlightParams;
- type Result = Option<Vec<DocumentHighlight>>;
- const METHOD: &'static str = "textDocument/documentHighlight";
-}
-
-/// The document symbol request is sent from the client to the server to list all symbols found in a given
-/// text document.
-#[derive(Debug)]
-pub enum DocumentSymbolRequest {}
-
-impl Request for DocumentSymbolRequest {
- type Params = DocumentSymbolParams;
- type Result = Option<DocumentSymbolResponse>;
- const METHOD: &'static str = "textDocument/documentSymbol";
-}
-
-/// The workspace symbol request is sent from the client to the server to list project-wide symbols
-/// matching the query string.
-#[derive(Debug)]
-pub enum WorkspaceSymbol {}
-
-impl Request for WorkspaceSymbol {
- type Params = WorkspaceSymbolParams;
- type Result = Option<Vec<SymbolInformation>>;
- const METHOD: &'static str = "workspace/symbol";
-}
-
-/// The workspace/executeCommand request is sent from the client to the server to trigger command execution on the server.
-/// In most cases the server creates a WorkspaceEdit structure and applies the changes to the workspace using the request
-/// workspace/applyEdit which is sent from the server to the client.
-#[derive(Debug)]
-pub enum ExecuteCommand {}
-
-impl Request for ExecuteCommand {
- type Params = ExecuteCommandParams;
- type Result = Option<Value>;
- const METHOD: &'static str = "workspace/executeCommand";
-}
-
-/// The document will save request is sent from the client to the server before the document is
-/// actually saved. The request can return an array of TextEdits which will be applied to the text
-/// document before it is saved. Please note that clients might drop results if computing the text
-/// edits took too long or if a server constantly fails on this request. This is done to keep the
-/// save fast and reliable.
-#[derive(Debug)]
-pub enum WillSaveWaitUntil {}
-
-impl Request for WillSaveWaitUntil {
- type Params = WillSaveTextDocumentParams;
- type Result = Option<Vec<TextEdit>>;
- const METHOD: &'static str = "textDocument/willSaveWaitUntil";
-}
-
-/// The workspace/applyEdit request is sent from the server to the client to modify resource on the
-/// client side.
-#[derive(Debug)]
-pub enum ApplyWorkspaceEdit {}
-
-impl Request for ApplyWorkspaceEdit {
- type Params = ApplyWorkspaceEditParams;
- type Result = ApplyWorkspaceEditResponse;
- const METHOD: &'static str = "workspace/applyEdit";
-}
-
-/// The workspace/configuration request is sent from the server to the client to fetch configuration settings
-/// from the client. The request can fetch several configuration settings in one roundtrip.
-/// The order of the returned configuration settings correspond to the order of the passed ConfigurationItems
-/// (e.g. the first item in the response is the result for the first configuration item in the params).
-///
-/// A ConfigurationItem consists of the configuration section to ask for and an additional scope URI.
-/// The configuration section ask for is defined by the server and doesn’t necessarily need to correspond to
-/// the configuration store used be the client. So a server might ask for a configuration cpp.formatterOptions
-/// but the client stores the configuration in a XML store layout differently.
-/// It is up to the client to do the necessary conversion. If a scope URI is provided the client should return
-/// the setting scoped to the provided resource. If the client for example uses EditorConfig to manage its
-/// settings the configuration should be returned for the passed resource URI. If the client can’t provide a
-/// configuration setting for a given scope then null need to be present in the returned array.
-#[derive(Debug)]
-pub enum WorkspaceConfiguration {}
-
-impl Request for WorkspaceConfiguration {
- type Params = ConfigurationParams;
- type Result = Vec<Value>;
- const METHOD: &'static str = "workspace/configuration";
-}
-
-/// The code action request is sent from the client to the server to compute commands for a given text document
-/// and range. The request is triggered when the user moves the cursor into a problem marker in the editor or
-/// presses the lightbulb associated with a marker.
-#[derive(Debug)]
-pub enum CodeActionRequest {}
-
-impl Request for CodeActionRequest {
- type Params = CodeActionParams;
- type Result = Option<CodeActionResponse>;
- const METHOD: &'static str = "textDocument/codeAction";
-}
-
-/// The code lens request is sent from the client to the server to compute code lenses for a given text document.
-#[derive(Debug)]
-pub enum CodeLensRequest {}
-
-impl Request for CodeLensRequest {
- type Params = CodeLensParams;
- type Result = Option<Vec<CodeLens>>;
- const METHOD: &'static str = "textDocument/codeLens";
-}
-
-/// The code lens resolve request is sent from the client to the server to resolve the command for a
-/// given code lens item.
-#[derive(Debug)]
-pub enum CodeLensResolve {}
-
-impl Request for CodeLensResolve {
- type Params = CodeLens;
- type Result = CodeLens;
- const METHOD: &'static str = "codeLens/resolve";
-}
-
-/// The document links request is sent from the client to the server to request the location of links in a document.
-#[derive(Debug)]
-pub enum DocumentLinkRequest {}
-
-impl Request for DocumentLinkRequest {
- type Params = DocumentLinkParams;
- type Result = Option<Vec<DocumentLink>>;
- const METHOD: &'static str = "textDocument/documentLink";
-}
-
-/// The document link resolve request is sent from the client to the server to resolve the target of
-/// a given document link.
-#[derive(Debug)]
-pub enum DocumentLinkResolve {}
-
-impl Request for DocumentLinkResolve {
- type Params = DocumentLink;
- type Result = DocumentLink;
- const METHOD: &'static str = "documentLink/resolve";
-}
-
-/// The document formatting request is sent from the server to the client to format a whole document.
-#[derive(Debug)]
-pub enum Formatting {}
-
-impl Request for Formatting {
- type Params = DocumentFormattingParams;
- type Result = Option<Vec<TextEdit>>;
- const METHOD: &'static str = "textDocument/formatting";
-}
-
-/// The document range formatting request is sent from the client to the server to format a given range in a document.
-#[derive(Debug)]
-pub enum RangeFormatting {}
-
-impl Request for RangeFormatting {
- type Params = DocumentRangeFormattingParams;
- type Result = Option<Vec<TextEdit>>;
- const METHOD: &'static str = "textDocument/rangeFormatting";
-}
-
-/// The document on type formatting request is sent from the client to the server to format parts of
-/// the document during typing.
-#[derive(Debug)]
-pub enum OnTypeFormatting {}
-
-impl Request for OnTypeFormatting {
- type Params = DocumentOnTypeFormattingParams;
- type Result = Option<Vec<TextEdit>>;
- const METHOD: &'static str = "textDocument/onTypeFormatting";
-}
-
-/// The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.
-#[derive(Debug)]
-pub enum Rename {}
-
-impl Request for Rename {
- type Params = RenameParams;
- type Result = Option<WorkspaceEdit>;
- const METHOD: &'static str = "textDocument/rename";
-}
-
-/// The document color request is sent from the client to the server to list all color references found in a given text document.
-/// Along with the range, a color value in RGB is returned.
-#[derive(Debug)]
-pub enum DocumentColor {}
-
-impl Request for DocumentColor {
- type Params = DocumentColorParams;
- type Result = Vec<ColorInformation>;
- const METHOD: &'static str = "textDocument/documentColor";
-}
-
-/// The color presentation request is sent from the client to the server to obtain a list of presentations for a color value
-/// at a given location.
-#[derive(Debug)]
-pub enum ColorPresentationRequest {}
-
-impl Request for ColorPresentationRequest {
- type Params = ColorPresentationParams;
- type Result = Vec<ColorPresentation>;
- const METHOD: &'static str = "textDocument/colorPresentation";
-}
-
-/// The folding range request is sent from the client to the server to return all folding ranges found in a given text document.
-#[derive(Debug)]
-pub enum FoldingRangeRequest {}
-
-impl Request for FoldingRangeRequest {
- type Params = FoldingRangeParams;
- type Result = Option<Vec<FoldingRange>>;
- const METHOD: &'static str = "textDocument/foldingRange";
-}
-
-/// The prepare rename request is sent from the client to the server to setup and test the validity of a rename operation
-/// at a given location.
-#[derive(Debug)]
-pub enum PrepareRenameRequest {}
-
-impl Request for PrepareRenameRequest {
- type Params = TextDocumentPositionParams;
- type Result = Option<PrepareRenameResponse>;
- const METHOD: &'static str = "textDocument/prepareRename";
-}
-
-/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open list of
-/// workspace folders. Returns null in the response if only a single file is open in the tool.
-/// Returns an empty array if a workspace is open but no folders are configured.
-#[derive(Debug)]
-pub enum WorkspaceFoldersRequest {}
-
-impl Request for WorkspaceFoldersRequest {
- type Params = ();
- type Result = Option<Vec<WorkspaceFolder>>;
- const METHOD: &'static str = "workspace/workspaceFolders";
-}
-
-/// The `window/workDoneProgress/create` request is sent from the server
-/// to the clientto ask the client to create a work done progress.
-#[derive(Debug)]
-pub enum WorkDoneProgressCreate {}
-
-impl Request for WorkDoneProgressCreate {
- type Params = WorkDoneProgressCreateParams;
- type Result = ();
- const METHOD: &'static str = "window/workDoneProgress/create";
-}
-
-/// The selection range request is sent from the client to the server to return
-/// suggested selection ranges at given positions. A selection range is a range
-/// around the cursor position which the user might be interested in selecting.
-///
-/// A selection range in the return array is for the position in the provided parameters at the same index.
-/// Therefore positions[i] must be contained in result[i].range.
-///
-/// Typically, but not necessary, selection ranges correspond to the nodes of the
-/// syntax tree.
-pub enum SelectionRangeRequest {}
-
-impl Request for SelectionRangeRequest {
- type Params = SelectionRangeParams;
- type Result = Option<Vec<SelectionRange>>;
- const METHOD: &'static str = "textDocument/selectionRange";
-}
-
-#[cfg(feature = "proposed")]
-pub enum CallHierarchyPrepare {}
-
-#[cfg(feature = "proposed")]
-impl Request for CallHierarchyPrepare {
- type Params = CallHierarchyPrepareParams;
- type Result = Option<Vec<CallHierarchyItem>>;
- const METHOD: &'static str = "textDocument/prepareCallHierarchy";
-}
-
-#[cfg(feature = "proposed")]
-pub enum CallHierarchyIncomingCalls {}
-
-#[cfg(feature = "proposed")]
-impl Request for CallHierarchyIncomingCalls {
- type Params = CallHierarchyIncomingCallsParams;
- type Result = Option<Vec<CallHierarchyIncomingCall>>;
- const METHOD: &'static str = "callHierarchy/incomingCalls";
-}
-
-#[cfg(feature = "proposed")]
-pub enum CallHierarchyOutgoingCalls {}
-
-#[cfg(feature = "proposed")]
-impl Request for CallHierarchyOutgoingCalls {
- type Params = CallHierarchyOutgoingCallsParams;
- type Result = Option<Vec<CallHierarchyOutgoingCall>>;
- const METHOD: &'static str = "callHierarchy/outgoingCalls";
-}
-
-#[cfg(feature = "proposed")]
-pub enum SemanticTokensRequest {}
-
-#[cfg(feature = "proposed")]
-impl Request for SemanticTokensRequest {
- type Params = SemanticTokensParams;
- type Result = Option<SemanticTokensResult>;
- const METHOD: &'static str = "textDocument/semanticTokens";
-}
-
-#[cfg(feature = "proposed")]
-pub enum SemanticTokensEditsRequest {}
-
-#[cfg(feature = "proposed")]
-impl Request for SemanticTokensEditsRequest {
- type Params = SemanticTokensEditsParams;
- type Result = Option<SemanticTokensEditResult>;
- const METHOD: &'static str = "textDocument/semanticTokens/edits";
-}
-
-#[cfg(feature = "proposed")]
-pub enum SemanticTokensRangeRequest {}
-
-#[cfg(feature = "proposed")]
-impl Request for SemanticTokensRangeRequest {
- type Params = SemanticTokensRangeParams;
- type Result = Option<SemanticTokensRangeResult>;
- const METHOD: &'static str = "textDocument/semanticTokens/range";
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- fn fake_call<R>()
- where
- R: Request,
- R::Params: serde::Serialize,
- R::Result: serde::de::DeserializeOwned,
- {
- }
-
- macro_rules! check_macro {
- ($name:tt) => {
- // check whethe the macro name matches the method
- assert_eq!(<lsp_request!($name) as Request>::METHOD, $name);
- // test whether type checking passes for each component
- fake_call::<lsp_request!($name)>();
- };
- }
-
- #[test]
- fn check_macro_definitions() {
- check_macro!("initialize");
- check_macro!("shutdown");
- check_macro!("window/showMessageRequest");
- check_macro!("window/workDoneProgress/create");
- check_macro!("client/registerCapability");
- check_macro!("client/unregisterCapability");
- check_macro!("workspace/symbol");
- check_macro!("workspace/executeCommand");
- check_macro!("textDocument/willSaveWaitUntil");
- check_macro!("textDocument/completion");
- check_macro!("completionItem/resolve");
- check_macro!("textDocument/hover");
- check_macro!("textDocument/signatureHelp");
- check_macro!("textDocument/declaration");
- check_macro!("textDocument/definition");
- check_macro!("textDocument/references");
- check_macro!("textDocument/documentHighlight");
- check_macro!("textDocument/documentSymbol");
- check_macro!("textDocument/codeAction");
- check_macro!("textDocument/codeLens");
- check_macro!("codeLens/resolve");
- check_macro!("textDocument/documentLink");
- check_macro!("documentLink/resolve");
- check_macro!("workspace/applyEdit");
- check_macro!("textDocument/rangeFormatting");
- check_macro!("textDocument/onTypeFormatting");
- check_macro!("textDocument/formatting");
- check_macro!("textDocument/rename");
- check_macro!("textDocument/documentColor");
- check_macro!("textDocument/colorPresentation");
- check_macro!("textDocument/foldingRange");
- check_macro!("textDocument/prepareRename");
- check_macro!("workspace/workspaceFolders");
- check_macro!("textDocument/implementation");
- check_macro!("textDocument/selectionRange");
- check_macro!("textDocument/typeDefinition");
- check_macro!("workspace/configuration");
- }
-
- #[test]
- #[cfg(feature = "proposed")]
- fn check_proposed_macro_definitions() {
- check_macro!("callHierarchy/incomingCalls");
- check_macro!("callHierarchy/outgoingCalls");
- check_macro!("textDocument/prepareCallHierarchy");
- check_macro!("textDocument/semanticTokens");
- check_macro!("textDocument/semanticTokens/edits");
- check_macro!("textDocument/semanticTokens/range");
- }
-}
+use super::*;\r
+\r
+use serde::{de::DeserializeOwned, Serialize};\r
+\r
+pub trait Request {\r
+ type Params: DeserializeOwned + Serialize;\r
+ type Result: DeserializeOwned + Serialize;\r
+ const METHOD: &'static str;\r
+}\r
+\r
+#[macro_export]\r
+macro_rules! lsp_request {\r
+ ("initialize") => {\r
+ $crate::request::Initialize\r
+ };\r
+ ("shutdown") => {\r
+ $crate::request::Shutdown\r
+ };\r
+\r
+ ("window/showMessageRequest") => {\r
+ $crate::request::ShowMessageRequest\r
+ };\r
+\r
+ ("client/registerCapability") => {\r
+ $crate::request::RegisterCapability\r
+ };\r
+ ("client/unregisterCapability") => {\r
+ $crate::request::UnregisterCapability\r
+ };\r
+\r
+ ("workspace/symbol") => {\r
+ $crate::request::WorkspaceSymbol\r
+ };\r
+ ("workspace/executeCommand") => {\r
+ $crate::request::ExecuteCommand\r
+ };\r
+\r
+ ("textDocument/willSaveWaitUntil") => {\r
+ $crate::request::WillSaveWaitUntil\r
+ };\r
+\r
+ ("textDocument/completion") => {\r
+ $crate::request::Completion\r
+ };\r
+ ("completionItem/resolve") => {\r
+ $crate::request::ResolveCompletionItem\r
+ };\r
+ ("textDocument/hover") => {\r
+ $crate::request::HoverRequest\r
+ };\r
+ ("textDocument/signatureHelp") => {\r
+ $crate::request::SignatureHelpRequest\r
+ };\r
+ ("textDocument/declaration") => {\r
+ $crate::request::GotoDeclaration\r
+ };\r
+ ("textDocument/definition") => {\r
+ $crate::request::GotoDefinition\r
+ };\r
+ ("textDocument/references") => {\r
+ $crate::request::References\r
+ };\r
+ ("textDocument/documentHighlight") => {\r
+ $crate::request::DocumentHighlightRequest\r
+ };\r
+ ("textDocument/documentSymbol") => {\r
+ $crate::request::DocumentSymbolRequest\r
+ };\r
+ ("textDocument/codeAction") => {\r
+ $crate::request::CodeActionRequest\r
+ };\r
+ ("textDocument/codeLens") => {\r
+ $crate::request::CodeLensRequest\r
+ };\r
+ ("codeLens/resolve") => {\r
+ $crate::request::CodeLensResolve\r
+ };\r
+ ("textDocument/documentLink") => {\r
+ $crate::request::DocumentLinkRequest\r
+ };\r
+ ("documentLink/resolve") => {\r
+ $crate::request::DocumentLinkResolve\r
+ };\r
+ ("workspace/applyEdit") => {\r
+ $crate::request::ApplyWorkspaceEdit\r
+ };\r
+ ("textDocument/rangeFormatting") => {\r
+ $crate::request::RangeFormatting\r
+ };\r
+ ("textDocument/onTypeFormatting") => {\r
+ $crate::request::OnTypeFormatting\r
+ };\r
+ ("textDocument/formatting") => {\r
+ $crate::request::Formatting\r
+ };\r
+ ("textDocument/rename") => {\r
+ $crate::request::Rename\r
+ };\r
+ ("textDocument/documentColor") => {\r
+ $crate::request::DocumentColor\r
+ };\r
+ ("textDocument/colorPresentation") => {\r
+ $crate::request::ColorPresentationRequest\r
+ };\r
+ ("textDocument/foldingRange") => {\r
+ $crate::request::FoldingRangeRequest\r
+ };\r
+ ("textDocument/prepareRename") => {\r
+ $crate::request::PrepareRenameRequest\r
+ };\r
+ ("textDocument/implementation") => {\r
+ $crate::request::GotoImplementation\r
+ };\r
+ ("textDocument/typeDefinition") => {\r
+ $crate::request::GotoTypeDefinition\r
+ };\r
+ ("textDocument/selectionRange") => {\r
+ $crate::request::SelectionRangeRequest\r
+ };\r
+ ("workspace/workspaceFolders") => {\r
+ $crate::request::WorkspaceFoldersRequest\r
+ };\r
+ ("workspace/configuration") => {\r
+ $crate::request::WorkspaceConfiguration\r
+ };\r
+ ("window/workDoneProgress/create") => {\r
+ $crate::request::WorkDoneProgressCreate\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("callHierarchy/incomingCalls") => {\r
+ $crate::request::CallHierarchyIncomingCalls\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("callHierarchy/outgoingCalls") => {\r
+ $crate::request::CallHierarchyOutgoingCalls\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("textDocument/prepareCallHierarchy") => {\r
+ $crate::request::CallHierarchyPrepare\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("textDocument/semanticTokens/full") => {\r
+ $crate::request::SemanticTokensFullRequest\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("textDocument/semanticTokens/full/delta") => {\r
+ $crate::request::SemanticTokensFullDeltaRequest\r
+ };\r
+ // Requires #[cfg(feature = "proposed")]\r
+ ("textDocument/semanticTokens/range") => {\r
+ $crate::request::SemanticTokensRangeRequest\r
+ };\r
+}\r
+\r
+/// The initialize request is sent as the first request from the client to the server.\r
+/// If the server receives request or notification before the `initialize` request it should act as follows:\r
+///\r
+/// * for a request the respond should be errored with `code: -32001`. The message can be picked by the server.\r
+/// * notifications should be dropped.\r
+#[derive(Debug)]\r
+pub enum Initialize {}\r
+\r
+impl Request for Initialize {\r
+ type Params = InitializeParams;\r
+ type Result = InitializeResult;\r
+ const METHOD: &'static str = "initialize";\r
+}\r
+\r
+/// The shutdown request is sent from the client to the server. It asks the server to shut down,\r
+/// but to not exit (otherwise the response might not be delivered correctly to the client).\r
+/// There is a separate exit notification that asks the server to exit.\r
+#[derive(Debug)]\r
+pub enum Shutdown {}\r
+\r
+impl Request for Shutdown {\r
+ type Params = ();\r
+ type Result = ();\r
+ const METHOD: &'static str = "shutdown";\r
+}\r
+\r
+/// The show message request is sent from a server to a client to ask the client to display a particular message\r
+/// in the user interface. In addition to the show message notification the request allows to pass actions and to\r
+/// wait for an answer from the client.\r
+#[derive(Debug)]\r
+pub enum ShowMessageRequest {}\r
+\r
+impl Request for ShowMessageRequest {\r
+ type Params = ShowMessageRequestParams;\r
+ type Result = Option<MessageActionItem>;\r
+ const METHOD: &'static str = "window/showMessageRequest";\r
+}\r
+\r
+/// The client/registerCapability request is sent from the server to the client to register for a new capability\r
+/// on the client side. Not all clients need to support dynamic capability registration. A client opts in via the\r
+/// ClientCapabilities.GenericCapability property.\r
+#[derive(Debug)]\r
+pub enum RegisterCapability {}\r
+\r
+impl Request for RegisterCapability {\r
+ type Params = RegistrationParams;\r
+ type Result = ();\r
+ const METHOD: &'static str = "client/registerCapability";\r
+}\r
+\r
+/// The client/unregisterCapability request is sent from the server to the client to unregister a\r
+/// previously register capability.\r
+#[derive(Debug)]\r
+pub enum UnregisterCapability {}\r
+\r
+impl Request for UnregisterCapability {\r
+ type Params = UnregistrationParams;\r
+ type Result = ();\r
+ const METHOD: &'static str = "client/unregisterCapability";\r
+}\r
+\r
+/// The Completion request is sent from the client to the server to compute completion items at a given cursor position.\r
+/// Completion items are presented in the IntelliSense user interface. If computing full completion items is expensive,\r
+/// servers can additionally provide a handler for the completion item resolve request ('completionItem/resolve').\r
+/// This request is sent when a completion item is selected in the user interface. A typical use case is for example:\r
+/// the 'textDocument/completion' request doesn’t fill in the documentation property for returned completion items\r
+/// since it is expensive to compute. When the item is selected in the user interface then a ‘completionItem/resolve’\r
+/// request is sent with the selected completion item as a param. The returned completion item should have the\r
+/// documentation property filled in. The request can delay the computation of the detail and documentation properties.\r
+/// However, properties that are needed for the initial sorting and filtering, like sortText, filterText, insertText,\r
+/// and textEdit must be provided in the textDocument/completion request and must not be changed during resolve.\r
+#[derive(Debug)]\r
+pub enum Completion {}\r
+\r
+impl Request for Completion {\r
+ type Params = CompletionParams;\r
+ type Result = Option<CompletionResponse>;\r
+ const METHOD: &'static str = "textDocument/completion";\r
+}\r
+\r
+/// The request is sent from the client to the server to resolve additional information for a given completion item.\r
+#[derive(Debug)]\r
+pub enum ResolveCompletionItem {}\r
+\r
+impl Request for ResolveCompletionItem {\r
+ type Params = CompletionItem;\r
+ type Result = CompletionItem;\r
+ const METHOD: &'static str = "completionItem/resolve";\r
+}\r
+\r
+/// The hover request is sent from the client to the server to request hover information at a given text\r
+/// document position.\r
+#[derive(Debug)]\r
+pub enum HoverRequest {}\r
+\r
+impl Request for HoverRequest {\r
+ type Params = HoverParams;\r
+ type Result = Option<Hover>;\r
+ const METHOD: &'static str = "textDocument/hover";\r
+}\r
+\r
+/// The signature help request is sent from the client to the server to request signature information at\r
+/// a given cursor position.\r
+#[derive(Debug)]\r
+pub enum SignatureHelpRequest {}\r
+\r
+impl Request for SignatureHelpRequest {\r
+ type Params = SignatureHelpParams;\r
+ type Result = Option<SignatureHelp>;\r
+ const METHOD: &'static str = "textDocument/signatureHelp";\r
+}\r
+\r
+#[derive(Debug)]\r
+pub enum GotoDeclaration {}\r
+pub type GotoDeclarationParams = GotoDefinitionParams;\r
+pub type GotoDeclarationResponse = GotoDefinitionResponse;\r
+\r
+/// The goto declaration request is sent from the client to the server to resolve the declaration location of\r
+/// a symbol at a given text document position.\r
+impl Request for GotoDeclaration {\r
+ type Params = GotoDeclarationParams;\r
+ type Result = Option<GotoDeclarationResponse>;\r
+ const METHOD: &'static str = "textDocument/declaration";\r
+}\r
+\r
+/// The goto definition request is sent from the client to the server to resolve the definition location of\r
+/// a symbol at a given text document position.\r
+#[derive(Debug)]\r
+pub enum GotoDefinition {}\r
+\r
+impl Request for GotoDefinition {\r
+ type Params = GotoDefinitionParams;\r
+ type Result = Option<GotoDefinitionResponse>;\r
+ const METHOD: &'static str = "textDocument/definition";\r
+}\r
+\r
+/// The references request is sent from the client to the server to resolve project-wide references for the\r
+/// symbol denoted by the given text document position.\r
+#[derive(Debug)]\r
+pub enum References {}\r
+\r
+impl Request for References {\r
+ type Params = ReferenceParams;\r
+ type Result = Option<Vec<Location>>;\r
+ const METHOD: &'static str = "textDocument/references";\r
+}\r
+\r
+/// The goto type definition request is sent from the client to the\r
+/// server to resolve the type definition location of a symbol at a\r
+/// given text document position.\r
+#[derive(Debug)]\r
+pub enum GotoTypeDefinition {}\r
+\r
+pub type GotoTypeDefinitionParams = GotoDefinitionParams;\r
+pub type GotoTypeDefinitionResponse = GotoDefinitionResponse;\r
+\r
+impl Request for GotoTypeDefinition {\r
+ type Params = GotoTypeDefinitionParams;\r
+ type Result = Option<GotoTypeDefinitionResponse>;\r
+ const METHOD: &'static str = "textDocument/typeDefinition";\r
+}\r
+\r
+/// The goto implementation request is sent from the client to the\r
+/// server to resolve the implementation location of a symbol at a\r
+/// given text document position.\r
+#[derive(Debug)]\r
+pub enum GotoImplementation {}\r
+\r
+pub type GotoImplementationParams = GotoTypeDefinitionParams;\r
+pub type GotoImplementationResponse = GotoDefinitionResponse;\r
+\r
+impl Request for GotoImplementation {\r
+ type Params = GotoImplementationParams;\r
+ type Result = Option<GotoImplementationResponse>;\r
+ const METHOD: &'static str = "textDocument/implementation";\r
+}\r
+\r
+/// The document highlight request is sent from the client to the server to resolve a document highlights\r
+/// for a given text document position.\r
+/// For programming languages this usually highlights all references to the symbol scoped to this file.\r
+/// However we kept 'textDocument/documentHighlight' and 'textDocument/references' separate requests since\r
+/// the first one is allowed to be more fuzzy.\r
+/// Symbol matches usually have a DocumentHighlightKind of Read or Write whereas fuzzy or textual matches\r
+/// use Text as the kind.\r
+#[derive(Debug)]\r
+pub enum DocumentHighlightRequest {}\r
+\r
+impl Request for DocumentHighlightRequest {\r
+ type Params = DocumentHighlightParams;\r
+ type Result = Option<Vec<DocumentHighlight>>;\r
+ const METHOD: &'static str = "textDocument/documentHighlight";\r
+}\r
+\r
+/// The document symbol request is sent from the client to the server to list all symbols found in a given\r
+/// text document.\r
+#[derive(Debug)]\r
+pub enum DocumentSymbolRequest {}\r
+\r
+impl Request for DocumentSymbolRequest {\r
+ type Params = DocumentSymbolParams;\r
+ type Result = Option<DocumentSymbolResponse>;\r
+ const METHOD: &'static str = "textDocument/documentSymbol";\r
+}\r
+\r
+/// The workspace symbol request is sent from the client to the server to list project-wide symbols\r
+/// matching the query string.\r
+#[derive(Debug)]\r
+pub enum WorkspaceSymbol {}\r
+\r
+impl Request for WorkspaceSymbol {\r
+ type Params = WorkspaceSymbolParams;\r
+ type Result = Option<Vec<SymbolInformation>>;\r
+ const METHOD: &'static str = "workspace/symbol";\r
+}\r
+\r
+/// The workspace/executeCommand request is sent from the client to the server to trigger command execution on the server.\r
+/// In most cases the server creates a WorkspaceEdit structure and applies the changes to the workspace using the request\r
+/// workspace/applyEdit which is sent from the server to the client.\r
+#[derive(Debug)]\r
+pub enum ExecuteCommand {}\r
+\r
+impl Request for ExecuteCommand {\r
+ type Params = ExecuteCommandParams;\r
+ type Result = Option<Value>;\r
+ const METHOD: &'static str = "workspace/executeCommand";\r
+}\r
+\r
+/// The document will save request is sent from the client to the server before the document is\r
+/// actually saved. The request can return an array of TextEdits which will be applied to the text\r
+/// document before it is saved. Please note that clients might drop results if computing the text\r
+/// edits took too long or if a server constantly fails on this request. This is done to keep the\r
+/// save fast and reliable.\r
+#[derive(Debug)]\r
+pub enum WillSaveWaitUntil {}\r
+\r
+impl Request for WillSaveWaitUntil {\r
+ type Params = WillSaveTextDocumentParams;\r
+ type Result = Option<Vec<TextEdit>>;\r
+ const METHOD: &'static str = "textDocument/willSaveWaitUntil";\r
+}\r
+\r
+/// The workspace/applyEdit request is sent from the server to the client to modify resource on the\r
+/// client side.\r
+#[derive(Debug)]\r
+pub enum ApplyWorkspaceEdit {}\r
+\r
+impl Request for ApplyWorkspaceEdit {\r
+ type Params = ApplyWorkspaceEditParams;\r
+ type Result = ApplyWorkspaceEditResponse;\r
+ const METHOD: &'static str = "workspace/applyEdit";\r
+}\r
+\r
+/// The workspace/configuration request is sent from the server to the client to fetch configuration settings\r
+/// from the client. The request can fetch several configuration settings in one roundtrip.\r
+/// The order of the returned configuration settings correspond to the order of the passed ConfigurationItems\r
+/// (e.g. the first item in the response is the result for the first configuration item in the params).\r
+///\r
+/// A ConfigurationItem consists of the configuration section to ask for and an additional scope URI.\r
+/// The configuration section ask for is defined by the server and doesn’t necessarily need to correspond to\r
+/// the configuration store used be the client. So a server might ask for a configuration cpp.formatterOptions\r
+/// but the client stores the configuration in a XML store layout differently.\r
+/// It is up to the client to do the necessary conversion. If a scope URI is provided the client should return\r
+/// the setting scoped to the provided resource. If the client for example uses EditorConfig to manage its\r
+/// settings the configuration should be returned for the passed resource URI. If the client can’t provide a\r
+/// configuration setting for a given scope then null need to be present in the returned array.\r
+#[derive(Debug)]\r
+pub enum WorkspaceConfiguration {}\r
+\r
+impl Request for WorkspaceConfiguration {\r
+ type Params = ConfigurationParams;\r
+ type Result = Vec<Value>;\r
+ const METHOD: &'static str = "workspace/configuration";\r
+}\r
+\r
+/// The code action request is sent from the client to the server to compute commands for a given text document\r
+/// and range. The request is triggered when the user moves the cursor into a problem marker in the editor or\r
+/// presses the lightbulb associated with a marker.\r
+#[derive(Debug)]\r
+pub enum CodeActionRequest {}\r
+\r
+impl Request for CodeActionRequest {\r
+ type Params = CodeActionParams;\r
+ type Result = Option<CodeActionResponse>;\r
+ const METHOD: &'static str = "textDocument/codeAction";\r
+}\r
+\r
+/// The code lens request is sent from the client to the server to compute code lenses for a given text document.\r
+#[derive(Debug)]\r
+pub enum CodeLensRequest {}\r
+\r
+impl Request for CodeLensRequest {\r
+ type Params = CodeLensParams;\r
+ type Result = Option<Vec<CodeLens>>;\r
+ const METHOD: &'static str = "textDocument/codeLens";\r
+}\r
+\r
+/// The code lens resolve request is sent from the client to the server to resolve the command for a\r
+/// given code lens item.\r
+#[derive(Debug)]\r
+pub enum CodeLensResolve {}\r
+\r
+impl Request for CodeLensResolve {\r
+ type Params = CodeLens;\r
+ type Result = CodeLens;\r
+ const METHOD: &'static str = "codeLens/resolve";\r
+}\r
+\r
+/// The document links request is sent from the client to the server to request the location of links in a document.\r
+#[derive(Debug)]\r
+pub enum DocumentLinkRequest {}\r
+\r
+impl Request for DocumentLinkRequest {\r
+ type Params = DocumentLinkParams;\r
+ type Result = Option<Vec<DocumentLink>>;\r
+ const METHOD: &'static str = "textDocument/documentLink";\r
+}\r
+\r
+/// The document link resolve request is sent from the client to the server to resolve the target of\r
+/// a given document link.\r
+#[derive(Debug)]\r
+pub enum DocumentLinkResolve {}\r
+\r
+impl Request for DocumentLinkResolve {\r
+ type Params = DocumentLink;\r
+ type Result = DocumentLink;\r
+ const METHOD: &'static str = "documentLink/resolve";\r
+}\r
+\r
+/// The document formatting request is sent from the server to the client to format a whole document.\r
+#[derive(Debug)]\r
+pub enum Formatting {}\r
+\r
+impl Request for Formatting {\r
+ type Params = DocumentFormattingParams;\r
+ type Result = Option<Vec<TextEdit>>;\r
+ const METHOD: &'static str = "textDocument/formatting";\r
+}\r
+\r
+/// The document range formatting request is sent from the client to the server to format a given range in a document.\r
+#[derive(Debug)]\r
+pub enum RangeFormatting {}\r
+\r
+impl Request for RangeFormatting {\r
+ type Params = DocumentRangeFormattingParams;\r
+ type Result = Option<Vec<TextEdit>>;\r
+ const METHOD: &'static str = "textDocument/rangeFormatting";\r
+}\r
+\r
+/// The document on type formatting request is sent from the client to the server to format parts of\r
+/// the document during typing.\r
+#[derive(Debug)]\r
+pub enum OnTypeFormatting {}\r
+\r
+impl Request for OnTypeFormatting {\r
+ type Params = DocumentOnTypeFormattingParams;\r
+ type Result = Option<Vec<TextEdit>>;\r
+ const METHOD: &'static str = "textDocument/onTypeFormatting";\r
+}\r
+\r
+/// The rename request is sent from the client to the server to perform a workspace-wide rename of a symbol.\r
+#[derive(Debug)]\r
+pub enum Rename {}\r
+\r
+impl Request for Rename {\r
+ type Params = RenameParams;\r
+ type Result = Option<WorkspaceEdit>;\r
+ const METHOD: &'static str = "textDocument/rename";\r
+}\r
+\r
+/// The document color request is sent from the client to the server to list all color references found in a given text document.\r
+/// Along with the range, a color value in RGB is returned.\r
+#[derive(Debug)]\r
+pub enum DocumentColor {}\r
+\r
+impl Request for DocumentColor {\r
+ type Params = DocumentColorParams;\r
+ type Result = Vec<ColorInformation>;\r
+ const METHOD: &'static str = "textDocument/documentColor";\r
+}\r
+\r
+/// The color presentation request is sent from the client to the server to obtain a list of presentations for a color value\r
+/// at a given location.\r
+#[derive(Debug)]\r
+pub enum ColorPresentationRequest {}\r
+\r
+impl Request for ColorPresentationRequest {\r
+ type Params = ColorPresentationParams;\r
+ type Result = Vec<ColorPresentation>;\r
+ const METHOD: &'static str = "textDocument/colorPresentation";\r
+}\r
+\r
+/// The folding range request is sent from the client to the server to return all folding ranges found in a given text document.\r
+#[derive(Debug)]\r
+pub enum FoldingRangeRequest {}\r
+\r
+impl Request for FoldingRangeRequest {\r
+ type Params = FoldingRangeParams;\r
+ type Result = Option<Vec<FoldingRange>>;\r
+ const METHOD: &'static str = "textDocument/foldingRange";\r
+}\r
+\r
+/// The prepare rename request is sent from the client to the server to setup and test the validity of a rename operation\r
+/// at a given location.\r
+#[derive(Debug)]\r
+pub enum PrepareRenameRequest {}\r
+\r
+impl Request for PrepareRenameRequest {\r
+ type Params = TextDocumentPositionParams;\r
+ type Result = Option<PrepareRenameResponse>;\r
+ const METHOD: &'static str = "textDocument/prepareRename";\r
+}\r
+\r
+/// The workspace/workspaceFolders request is sent from the server to the client to fetch the current open list of\r
+/// workspace folders. Returns null in the response if only a single file is open in the tool.\r
+/// Returns an empty array if a workspace is open but no folders are configured.\r
+#[derive(Debug)]\r
+pub enum WorkspaceFoldersRequest {}\r
+\r
+impl Request for WorkspaceFoldersRequest {\r
+ type Params = ();\r
+ type Result = Option<Vec<WorkspaceFolder>>;\r
+ const METHOD: &'static str = "workspace/workspaceFolders";\r
+}\r
+\r
+/// The `window/workDoneProgress/create` request is sent from the server\r
+/// to the clientto ask the client to create a work done progress.\r
+#[derive(Debug)]\r
+pub enum WorkDoneProgressCreate {}\r
+\r
+impl Request for WorkDoneProgressCreate {\r
+ type Params = WorkDoneProgressCreateParams;\r
+ type Result = ();\r
+ const METHOD: &'static str = "window/workDoneProgress/create";\r
+}\r
+\r
+/// The selection range request is sent from the client to the server to return\r
+/// suggested selection ranges at given positions. A selection range is a range\r
+/// around the cursor position which the user might be interested in selecting.\r
+///\r
+/// A selection range in the return array is for the position in the provided parameters at the same index.\r
+/// Therefore positions[i] must be contained in result[i].range.\r
+///\r
+/// Typically, but not necessary, selection ranges correspond to the nodes of the\r
+/// syntax tree.\r
+pub enum SelectionRangeRequest {}\r
+\r
+impl Request for SelectionRangeRequest {\r
+ type Params = SelectionRangeParams;\r
+ type Result = Option<Vec<SelectionRange>>;\r
+ const METHOD: &'static str = "textDocument/selectionRange";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum CallHierarchyPrepare {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for CallHierarchyPrepare {\r
+ type Params = CallHierarchyPrepareParams;\r
+ type Result = Option<Vec<CallHierarchyItem>>;\r
+ const METHOD: &'static str = "textDocument/prepareCallHierarchy";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum CallHierarchyIncomingCalls {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for CallHierarchyIncomingCalls {\r
+ type Params = CallHierarchyIncomingCallsParams;\r
+ type Result = Option<Vec<CallHierarchyIncomingCall>>;\r
+ const METHOD: &'static str = "callHierarchy/incomingCalls";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum CallHierarchyOutgoingCalls {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for CallHierarchyOutgoingCalls {\r
+ type Params = CallHierarchyOutgoingCallsParams;\r
+ type Result = Option<Vec<CallHierarchyOutgoingCall>>;\r
+ const METHOD: &'static str = "callHierarchy/outgoingCalls";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum SemanticTokensFullRequest {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for SemanticTokensFullRequest {\r
+ type Params = SemanticTokensParams;\r
+ type Result = Option<SemanticTokensResult>;\r
+ const METHOD: &'static str = "textDocument/semanticTokens/full";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum SemanticTokensFullDeltaRequest {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for SemanticTokensFullDeltaRequest {\r
+ type Params = SemanticTokensDeltaParams;\r
+ type Result = Option<SemanticTokensFullDeltaResult>;\r
+ const METHOD: &'static str = "textDocument/semanticTokens/full/delta";\r
+}\r
+\r
+#[cfg(feature = "proposed")]\r
+pub enum SemanticTokensRangeRequest {}\r
+\r
+#[cfg(feature = "proposed")]\r
+impl Request for SemanticTokensRangeRequest {\r
+ type Params = SemanticTokensRangeParams;\r
+ type Result = Option<SemanticTokensRangeResult>;\r
+ const METHOD: &'static str = "textDocument/semanticTokens/range";\r
+}\r
+\r
+#[cfg(test)]\r
+mod test {\r
+ use super::*;\r
+\r
+ fn fake_call<R>()\r
+ where\r
+ R: Request,\r
+ R::Params: serde::Serialize,\r
+ R::Result: serde::de::DeserializeOwned,\r
+ {\r
+ }\r
+\r
+ macro_rules! check_macro {\r
+ ($name:tt) => {\r
+ // check whethe the macro name matches the method\r
+ assert_eq!(<lsp_request!($name) as Request>::METHOD, $name);\r
+ // test whether type checking passes for each component\r
+ fake_call::<lsp_request!($name)>();\r
+ };\r
+ }\r
+\r
+ #[test]\r
+ fn check_macro_definitions() {\r
+ check_macro!("initialize");\r
+ check_macro!("shutdown");\r
+ check_macro!("window/showMessageRequest");\r
+ check_macro!("window/workDoneProgress/create");\r
+ check_macro!("client/registerCapability");\r
+ check_macro!("client/unregisterCapability");\r
+ check_macro!("workspace/symbol");\r
+ check_macro!("workspace/executeCommand");\r
+ check_macro!("textDocument/willSaveWaitUntil");\r
+ check_macro!("textDocument/completion");\r
+ check_macro!("completionItem/resolve");\r
+ check_macro!("textDocument/hover");\r
+ check_macro!("textDocument/signatureHelp");\r
+ check_macro!("textDocument/declaration");\r
+ check_macro!("textDocument/definition");\r
+ check_macro!("textDocument/references");\r
+ check_macro!("textDocument/documentHighlight");\r
+ check_macro!("textDocument/documentSymbol");\r
+ check_macro!("textDocument/codeAction");\r
+ check_macro!("textDocument/codeLens");\r
+ check_macro!("codeLens/resolve");\r
+ check_macro!("textDocument/documentLink");\r
+ check_macro!("documentLink/resolve");\r
+ check_macro!("workspace/applyEdit");\r
+ check_macro!("textDocument/rangeFormatting");\r
+ check_macro!("textDocument/onTypeFormatting");\r
+ check_macro!("textDocument/formatting");\r
+ check_macro!("textDocument/rename");\r
+ check_macro!("textDocument/documentColor");\r
+ check_macro!("textDocument/colorPresentation");\r
+ check_macro!("textDocument/foldingRange");\r
+ check_macro!("textDocument/prepareRename");\r
+ check_macro!("workspace/workspaceFolders");\r
+ check_macro!("textDocument/implementation");\r
+ check_macro!("textDocument/selectionRange");\r
+ check_macro!("textDocument/typeDefinition");\r
+ check_macro!("workspace/configuration");\r
+ }\r
+\r
+ #[test]\r
+ #[cfg(feature = "proposed")]\r
+ fn check_proposed_macro_definitions() {\r
+ check_macro!("callHierarchy/incomingCalls");\r
+ check_macro!("callHierarchy/outgoingCalls");\r
+ check_macro!("textDocument/prepareCallHierarchy");\r
+ check_macro!("textDocument/semanticTokens/full");\r
+ check_macro!("textDocument/semanticTokens/full/delta");\r
+ check_macro!("textDocument/semanticTokens/range");\r
+ }\r
+}\r