diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2022-03-11 22:36:58 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2022-03-12 01:08:33 +0100 |
| commit | 119ba82e4b099bf33a9eb266e518f010a6bae7be (patch) | |
| tree | 2c823d019cd8e116c465e3fae2b508d922585311 | |
| parent | 62265ee9cb702209f95fc529c3de02b0ac973c8f (diff) | |
| download | rust-119ba82e4b099bf33a9eb266e518f010a6bae7be.tar.gz rust-119ba82e4b099bf33a9eb266e518f010a6bae7be.zip | |
minor: add missing definitions of lsp_ext::InlayHintLabel
| -rw-r--r-- | crates/rust-analyzer/src/lsp_ext.rs | 20 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 4 | ||||
| -rw-r--r-- | docs/dev/lsp-extensions.md | 2 |
3 files changed, 22 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs index 846f1513044..2e131eeac95 100644 --- a/crates/rust-analyzer/src/lsp_ext.rs +++ b/crates/rust-analyzer/src/lsp_ext.rs @@ -255,7 +255,7 @@ impl InlayHintKind { #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct InlayHint { - pub label: String, + pub label: InlayHintLabel, pub position: Position, pub kind: Option<InlayHintKind>, pub tooltip: Option<String>, @@ -263,6 +263,24 @@ pub struct InlayHint { 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 {} impl Request for Ssr { diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 6db47cdb1fd..fd6602624f3 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -419,11 +419,11 @@ pub(crate) fn inlay_hint( inlay_hint: 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::TypeHint if render_colons => format!(": {}", inlay_hint.label), _ => inlay_hint.label.to_string(), - }, + }), position: match inlay_hint.kind { InlayKind::ParameterHint => position(line_index, inlay_hint.range.start()), InlayKind::TypeHint | InlayKind::ChainingHint => { diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 9f1c7fe0a3a..3091bdcbf07 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -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 need to adjust this doc as well and ping this issue: |
