From e35418ceb9b07bd596cc09144f4f4df13432a712 Mon Sep 17 00:00:00 2001 From: vsrs Date: Wed, 3 Jun 2020 16:39:32 +0300 Subject: Apply suggestions from @kjeremy review --- crates/rust-analyzer/src/lsp_ext.rs | 16 +++++++--------- crates/rust-analyzer/src/main_loop/handlers.rs | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 145a389ce..75ea48892 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -271,26 +271,24 @@ impl Request for HoverRequest { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] pub struct Hover { - pub contents: lsp_types::HoverContents, - #[serde(skip_serializing_if = "Option::is_none")] - pub range: Option, + #[serde(flatten)] + pub hover: lsp_types::Hover, #[serde(skip_serializing_if = "Option::is_none")] pub actions: Option>, } -#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] pub struct CommandLinkGroup { + #[serde(skip_serializing_if = "Option::is_none")] pub title: Option, pub commands: Vec, } // LSP v3.15 Command does not have a `tooltip` field, vscode supports one. -#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)] +#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)] pub struct CommandLink { - pub title: String, - pub command: String, + #[serde(flatten)] + pub command: lsp_types::Command, #[serde(skip_serializing_if = "Option::is_none")] pub tooltip: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub arguments: Option>, } diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index d998d9ddd..894df5837 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -547,15 +547,18 @@ pub fn handle_hover( }; let line_index = snap.analysis.file_line_index(position.file_id)?; let range = to_proto::range(&line_index, info.range); - let res = lsp_ext::Hover { - contents: HoverContents::Markup(MarkupContent { - kind: MarkupKind::Markdown, - value: crate::markdown::format_docs(&info.info.to_markup()), - }), - range: Some(range), + let hover = lsp_ext::Hover { + hover: lsp_types::Hover { + contents: HoverContents::Markup(MarkupContent { + kind: MarkupKind::Markdown, + value: crate::markdown::format_docs(&info.info.to_markup()), + }), + range: Some(range), + }, actions: Some(prepare_hover_actions(&snap, info.info.actions())), }; - Ok(Some(res)) + + Ok(Some(hover)) } pub fn handle_prepare_rename( @@ -1169,9 +1172,7 @@ fn show_references_command( fn to_command_link(command: Command, tooltip: String) -> lsp_ext::CommandLink { lsp_ext::CommandLink { tooltip: Some(tooltip), - title: command.title, - command: command.command, - arguments: command.arguments, + command, } } -- cgit v1.2.3