mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
Apply suggestions from @kjeremy review
This commit is contained in:
parent
92cfc0f2a1
commit
e35418ceb9
@ -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<Range>,
|
||||
#[serde(flatten)]
|
||||
pub hover: lsp_types::Hover,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub actions: Option<Vec<CommandLinkGroup>>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
pub commands: Vec<CommandLink>,
|
||||
}
|
||||
|
||||
// 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<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub arguments: Option<Vec<serde_json::Value>>,
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user