Update inlay hints for upstream

This commit is contained in:
Laurențiu Nicola 2022-02-09 19:14:18 +02:00
parent 2ae8248cee
commit 5a49dbd2e0
2 changed files with 23 additions and 19 deletions

View File

@ -242,21 +242,25 @@ pub struct InlayHintsParams {
pub text_document: TextDocumentIdentifier, pub text_document: TextDocumentIdentifier,
} }
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] #[derive(Eq, PartialEq, Debug, Copy, Clone, Serialize, Deserialize)]
pub enum InlayKind { #[serde(transparent)]
Other, pub struct InlayHintKind(u8);
Type,
Parameter, impl InlayHintKind {
pub const OTHER: InlayHintKind = InlayHintKind(0);
pub const TYPE: InlayHintKind = InlayHintKind(1);
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
} }
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct InlayHint { pub struct InlayHint {
pub text: String, pub label: String,
pub range: Range, pub position: Position,
pub kind: Option<InlayKind>, pub kind: Option<InlayHintKind>,
pub description: Option<String>, pub tooltip: Option<String>,
pub whitespace_before: Option<bool>, pub padding_left: Option<bool>,
pub whitespace_after: Option<bool>, pub padding_right: Option<bool>,
} }
pub enum Ssr {} pub enum Ssr {}

View File

@ -412,16 +412,16 @@ pub(crate) fn signature_help(
pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint { pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint {
lsp_ext::InlayHint { lsp_ext::InlayHint {
text: inlay_hint.label.to_string(), label: inlay_hint.label.to_string(),
range: range(line_index, inlay_hint.range), position: position(line_index, inlay_hint.range.start()),
kind: Some(match inlay_hint.kind { kind: Some(match inlay_hint.kind {
InlayKind::ParameterHint => lsp_ext::InlayKind::Parameter, InlayKind::ParameterHint => lsp_ext::InlayHintKind::PARAMETER,
InlayKind::TypeHint => lsp_ext::InlayKind::Type, InlayKind::TypeHint => lsp_ext::InlayHintKind::TYPE,
InlayKind::ChainingHint => lsp_ext::InlayKind::Other, InlayKind::ChainingHint => lsp_ext::InlayHintKind::OTHER,
}), }),
description: Some("test description".to_string()), tooltip: Some("test description".to_string()),
whitespace_before: Some(true), padding_left: Some(true),
whitespace_after: Some(true), padding_right: Some(true),
} }
} }