Skip to content

Commit e35418c

Browse files
committed
Apply suggestions from @kjeremy review
1 parent 92cfc0f commit e35418c

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,26 +271,24 @@ impl Request for HoverRequest {
271271

272272
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
273273
pub struct Hover {
274-
pub contents: lsp_types::HoverContents,
275-
#[serde(skip_serializing_if = "Option::is_none")]
276-
pub range: Option<Range>,
274+
#[serde(flatten)]
275+
pub hover: lsp_types::Hover,
277276
#[serde(skip_serializing_if = "Option::is_none")]
278277
pub actions: Option<Vec<CommandLinkGroup>>,
279278
}
280279

281-
#[derive(Debug, PartialEq, Eq, Clone, Default, Deserialize, Serialize)]
280+
#[derive(Debug, PartialEq, Clone, Default, Deserialize, Serialize)]
282281
pub struct CommandLinkGroup {
282+
#[serde(skip_serializing_if = "Option::is_none")]
283283
pub title: Option<String>,
284284
pub commands: Vec<CommandLink>,
285285
}
286286

287287
// 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)]
289289
pub struct CommandLink {
290-
pub title: String,
291-
pub command: String,
290+
#[serde(flatten)]
291+
pub command: lsp_types::Command,
292292
#[serde(skip_serializing_if = "Option::is_none")]
293293
pub tooltip: Option<String>,
294-
#[serde(skip_serializing_if = "Option::is_none")]
295-
pub arguments: Option<Vec<serde_json::Value>>,
296294
}

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,18 @@ pub fn handle_hover(
547547
};
548548
let line_index = snap.analysis.file_line_index(position.file_id)?;
549549
let range = to_proto::range(&line_index, info.range);
550-
let res = lsp_ext::Hover {
551-
contents: HoverContents::Markup(MarkupContent {
552-
kind: MarkupKind::Markdown,
553-
value: crate::markdown::format_docs(&info.info.to_markup()),
554-
}),
555-
range: Some(range),
550+
let hover = lsp_ext::Hover {
551+
hover: lsp_types::Hover {
552+
contents: HoverContents::Markup(MarkupContent {
553+
kind: MarkupKind::Markdown,
554+
value: crate::markdown::format_docs(&info.info.to_markup()),
555+
}),
556+
range: Some(range),
557+
},
556558
actions: Some(prepare_hover_actions(&snap, info.info.actions())),
557559
};
558-
Ok(Some(res))
560+
561+
Ok(Some(hover))
559562
}
560563

561564
pub fn handle_prepare_rename(
@@ -1169,9 +1172,7 @@ fn show_references_command(
11691172
fn to_command_link(command: Command, tooltip: String) -> lsp_ext::CommandLink {
11701173
lsp_ext::CommandLink {
11711174
tooltip: Some(tooltip),
1172-
title: command.title,
1173-
command: command.command,
1174-
arguments: command.arguments,
1175+
command,
11751176
}
11761177
}
11771178

0 commit comments

Comments
 (0)