diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2022-02-09 19:14:18 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2022-03-04 07:45:51 +0200 |
| commit | 5a49dbd2e07c99fc0bdfb5940e064fac580d2c92 (patch) | |
| tree | dbd514426bd2cb75b38bd7695d755bb300be779a | |
| parent | 2ae8248ceec0fbf55c00c3b9e46ea319203d1df9 (diff) | |
| download | rust-5a49dbd2e07c99fc0bdfb5940e064fac580d2c92.tar.gz rust-5a49dbd2e07c99fc0bdfb5940e064fac580d2c92.zip | |
Update inlay hints for upstream
| -rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 26 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 16 |
2 files changed, 23 insertions, 19 deletions
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 7e7f96da21e..1681c766f36 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -242,21 +242,25 @@ pub struct InlayHintsParams { pub text_document: TextDocumentIdentifier, } -#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] -pub enum InlayKind { - Other, - Type, - Parameter, +#[derive(Eq, PartialEq, Debug, Copy, Clone, Serialize, Deserialize)] +#[serde(transparent)] +pub struct InlayHintKind(u8); + +impl InlayHintKind { + pub const OTHER: InlayHintKind = InlayHintKind(0); + pub const TYPE: InlayHintKind = InlayHintKind(1); + pub const PARAMETER: InlayHintKind = InlayHintKind(2); } #[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] pub struct InlayHint { - pub text: String, - pub range: Range, - pub kind: Option<InlayKind>, - pub description: Option<String>, - pub whitespace_before: Option<bool>, - pub whitespace_after: Option<bool>, + pub label: String, + pub position: Position, + pub kind: Option<InlayHintKind>, + pub tooltip: Option<String>, + pub padding_left: Option<bool>, + pub padding_right: Option<bool>, } pub enum Ssr {} diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index a5d7b3a86f7..59b5a917398 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -412,16 +412,16 @@ pub(crate) fn signature_help( pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint { lsp_ext::InlayHint { - text: inlay_hint.label.to_string(), - range: range(line_index, inlay_hint.range), + label: inlay_hint.label.to_string(), + position: position(line_index, inlay_hint.range.start()), kind: Some(match inlay_hint.kind { - InlayKind::ParameterHint => lsp_ext::InlayKind::Parameter, - InlayKind::TypeHint => lsp_ext::InlayKind::Type, - InlayKind::ChainingHint => lsp_ext::InlayKind::Other, + InlayKind::ParameterHint => lsp_ext::InlayHintKind::PARAMETER, + InlayKind::TypeHint => lsp_ext::InlayHintKind::TYPE, + InlayKind::ChainingHint => lsp_ext::InlayHintKind::OTHER, }), - description: Some("test description".to_string()), - whitespace_before: Some(true), - whitespace_after: Some(true), + tooltip: Some("test description".to_string()), + padding_left: Some(true), + padding_right: Some(true), } } |
