minor: add missing definitions of lsp_ext::InlayHintLabel

This commit is contained in:
Lukas Wirth 2022-03-11 22:36:58 +01:00
parent 62265ee9cb
commit 119ba82e4b
3 changed files with 22 additions and 4 deletions

View file

@ -255,7 +255,7 @@ impl InlayHintKind {
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct InlayHint { pub struct InlayHint {
pub label: String, pub label: InlayHintLabel,
pub position: Position, pub position: Position,
pub kind: Option<InlayHintKind>, pub kind: Option<InlayHintKind>,
pub tooltip: Option<String>, pub tooltip: Option<String>,
@ -263,6 +263,24 @@ pub struct InlayHint {
pub padding_right: Option<bool>, pub padding_right: Option<bool>,
} }
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum InlayHintLabel {
String(String),
Parts(Vec<InlayHintLabelPart>),
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHintLabelPart {
pub value: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub tooltip: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<lsp_types::LocationLink>,
#[serde(skip_serializing_if = "Option::is_none")]
pub command: Option<lsp_types::Command>,
}
pub enum Ssr {} pub enum Ssr {}
impl Request for Ssr { impl Request for Ssr {

View file

@ -419,11 +419,11 @@ pub(crate) fn inlay_hint(
inlay_hint: InlayHint, inlay_hint: InlayHint,
) -> lsp_ext::InlayHint { ) -> lsp_ext::InlayHint {
lsp_ext::InlayHint { lsp_ext::InlayHint {
label: match inlay_hint.kind { label: lsp_ext::InlayHintLabel::String(match inlay_hint.kind {
InlayKind::ParameterHint if render_colons => format!("{}:", inlay_hint.label), InlayKind::ParameterHint if render_colons => format!("{}:", inlay_hint.label),
InlayKind::TypeHint if render_colons => format!(": {}", inlay_hint.label), InlayKind::TypeHint if render_colons => format!(": {}", inlay_hint.label),
_ => inlay_hint.label.to_string(), _ => inlay_hint.label.to_string(),
}, }),
position: match inlay_hint.kind { position: match inlay_hint.kind {
InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()), InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()),
InlayKind::TypeHint | InlayKind::ChainingHint => { InlayKind::TypeHint | InlayKind::ChainingHint => {

View file

@ -1,5 +1,5 @@
<!--- <!---
lsp_ext.rs hash: e32fdde032ff6ebc lsp_ext.rs hash: 854109e98d02a780
If you need to change the above hash to make the test pass, please check if you If you need to change the above hash to make the test pass, please check if you
need to adjust this doc as well and ping this issue: need to adjust this doc as well and ping this issue: