aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-06-03 14:39:32 +0100
committervsrs <[email protected]>2020-06-05 13:00:31 +0100
commite35418ceb9b07bd596cc09144f4f4df13432a712 (patch)
treec7936f3f1db7082e5585e83160fac76b6f91095f /crates
parent92cfc0f2a1edd4e825d4dea96d4f96dcea513629 (diff)
Apply suggestions from @kjeremy review
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs16
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs21
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 {
271 271
272#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] 272#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
273pub struct Hover { 273pub struct Hover {
274 pub contents: lsp_types::HoverContents, 274 #[serde(flatten)]
275 #[serde(skip_serializing_if = "Option::is_none")] 275 pub hover: lsp_types::Hover,
276 pub range: Option<Range>,
277 #[serde(skip_serializing_if = "Option::is_none")] 276 #[serde(skip_serializing_if = "Option::is_none")]
278 pub actions: Option<Vec<CommandLinkGroup>>, 277 pub actions: Option<Vec<CommandLinkGroup>>,
279} 278}
280 279
281#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)] 280#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
282pub struct CommandLinkGroup { 281pub struct CommandLinkGroup {
282 #[serde(skip_serializing_if = "Option::is_none")]
283 pub title: Option<String>, 283 pub title: Option<String>,
284 pub commands: Vec<CommandLink>, 284 pub commands: Vec<CommandLink>,
285} 285}
286 286
287// LSP v3.15 Command does not have a `tooltip` field, vscode supports one. 287// LSP v3.15 Command does not have a `tooltip` field, vscode supports one.
288#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)] 288#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
289pub struct CommandLink { 289pub struct CommandLink {
290 pub title: String, 290 #[serde(flatten)]
291 pub command: String, 291 pub command: lsp_types::Command,
292 #[serde(skip_serializing_if = "Option::is_none")] 292 #[serde(skip_serializing_if = "Option::is_none")]
293 pub tooltip: Option<String>, 293 pub tooltip: Option<String>,
294 #[serde(skip_serializing_if = "Option::is_none")]
295 pub arguments: Option<Vec<serde_json::Value>>,
296} 294}
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(
547 }; 547 };
548 let line_index = snap.analysis.file_line_index(position.file_id)?; 548 let line_index = snap.analysis.file_line_index(position.file_id)?;
549 let range = to_proto::range(&line_index, info.range); 549 let range = to_proto::range(&line_index, info.range);
550 let res = lsp_ext::Hover { 550 let hover = lsp_ext::Hover {
551 contents: HoverContents::Markup(MarkupContent { 551 hover: lsp_types::Hover {
552 kind: MarkupKind::Markdown, 552 contents: HoverContents::Markup(MarkupContent {
553 value: crate::markdown::format_docs(&info.info.to_markup()), 553 kind: MarkupKind::Markdown,
554 }), 554 value: crate::markdown::format_docs(&info.info.to_markup()),
555 range: Some(range), 555 }),
556 range: Some(range),
557 },
556 actions: Some(prepare_hover_actions(&snap, info.info.actions())), 558 actions: Some(prepare_hover_actions(&snap, info.info.actions())),
557 }; 559 };
558 Ok(Some(res)) 560
561 Ok(Some(hover))
559} 562}
560 563
561pub fn handle_prepare_rename( 564pub fn handle_prepare_rename(
@@ -1169,9 +1172,7 @@ fn show_references_command(
1169fn to_command_link(command: Command, tooltip: String) -> lsp_ext::CommandLink { 1172fn to_command_link(command: Command, tooltip: String) -> lsp_ext::CommandLink {
1170 lsp_ext::CommandLink { 1173 lsp_ext::CommandLink {
1171 tooltip: Some(tooltip), 1174 tooltip: Some(tooltip),
1172 title: command.title, 1175 command,
1173 command: command.command,
1174 arguments: command.arguments,
1175 } 1176 }
1176} 1177}
1177 1178