mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Remove unnecessary Hint suffix on InlayKind variants
This commit is contained in:
parent
60075a6625
commit
f2444b2a40
13 changed files with 87 additions and 95 deletions
|
@ -86,17 +86,17 @@ pub enum AdjustmentHintsMode {
|
|||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum InlayKind {
|
||||
BindingModeHint,
|
||||
ChainingHint,
|
||||
ClosingBraceHint,
|
||||
ClosureReturnTypeHint,
|
||||
GenericParamListHint,
|
||||
AdjustmentHint,
|
||||
AdjustmentHintPostfix,
|
||||
LifetimeHint,
|
||||
ParameterHint,
|
||||
TypeHint,
|
||||
DiscriminantHint,
|
||||
BindingMode,
|
||||
Chaining,
|
||||
ClosingBrace,
|
||||
ClosureReturnType,
|
||||
GenericParamList,
|
||||
Adjustment,
|
||||
AdjustmentPostfix,
|
||||
Lifetime,
|
||||
Parameter,
|
||||
Type,
|
||||
Discriminant,
|
||||
OpeningParenthesis,
|
||||
ClosingParenthesis,
|
||||
}
|
||||
|
|
|
@ -97,11 +97,7 @@ pub(super) fn hints(
|
|||
};
|
||||
acc.push(InlayHint {
|
||||
range: expr.syntax().text_range(),
|
||||
kind: if postfix {
|
||||
InlayKind::AdjustmentHintPostfix
|
||||
} else {
|
||||
InlayKind::AdjustmentHint
|
||||
},
|
||||
kind: if postfix { InlayKind::AdjustmentPostfix } else { InlayKind::Adjustment },
|
||||
label: if postfix { format!(".{}", text.trim_end()).into() } else { text.into() },
|
||||
});
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ pub(super) fn hints(
|
|||
Some(name) => name.syntax().text_range(),
|
||||
None => pat.syntax().text_range(),
|
||||
},
|
||||
kind: InlayKind::TypeHint,
|
||||
kind: InlayKind::Type,
|
||||
label,
|
||||
});
|
||||
|
||||
|
@ -316,14 +316,14 @@ fn main(a: SliceIter<'_, Container>) {
|
|||
[
|
||||
InlayHint {
|
||||
range: 484..554,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"impl Iterator<Item = impl Iterator<Item = &&str>>",
|
||||
],
|
||||
},
|
||||
InlayHint {
|
||||
range: 484..485,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
|
|
@ -40,11 +40,7 @@ pub(super) fn hints(
|
|||
(true, false) => "&",
|
||||
_ => return,
|
||||
};
|
||||
acc.push(InlayHint {
|
||||
range,
|
||||
kind: InlayKind::BindingModeHint,
|
||||
label: r.to_string().into(),
|
||||
});
|
||||
acc.push(InlayHint { range, kind: InlayKind::BindingMode, label: r.to_string().into() });
|
||||
});
|
||||
match pat {
|
||||
ast::Pat::IdentPat(pat) if pat.ref_token().is_none() && pat.mut_token().is_none() => {
|
||||
|
@ -56,7 +52,7 @@ pub(super) fn hints(
|
|||
};
|
||||
acc.push(InlayHint {
|
||||
range: pat.syntax().text_range(),
|
||||
kind: InlayKind::BindingModeHint,
|
||||
kind: InlayKind::BindingMode,
|
||||
label: bm.to_string().into(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ pub(super) fn hints(
|
|||
}
|
||||
acc.push(InlayHint {
|
||||
range: expr.syntax().text_range(),
|
||||
kind: InlayKind::ChainingHint,
|
||||
kind: InlayKind::Chaining,
|
||||
label: label_of_ty(famous_defs, config, ty)?,
|
||||
});
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 147..172,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -130,7 +130,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 147..154,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -195,14 +195,14 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 143..190,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"C",
|
||||
],
|
||||
},
|
||||
InlayHint {
|
||||
range: 143..179,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"B",
|
||||
],
|
||||
|
@ -238,7 +238,7 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 143..190,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -258,7 +258,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 143..179,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -308,7 +308,7 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 246..283,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -341,7 +341,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 246..265,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -406,28 +406,28 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 174..241,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"impl Iterator<Item = ()>",
|
||||
],
|
||||
},
|
||||
InlayHint {
|
||||
range: 174..224,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"impl Iterator<Item = ()>",
|
||||
],
|
||||
},
|
||||
InlayHint {
|
||||
range: 174..206,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"impl Iterator<Item = ()>",
|
||||
],
|
||||
},
|
||||
InlayHint {
|
||||
range: 174..189,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"&mut ",
|
||||
InlayHintLabelPart {
|
||||
|
@ -476,7 +476,7 @@ fn main() {
|
|||
[
|
||||
InlayHint {
|
||||
range: 124..130,
|
||||
kind: TypeHint,
|
||||
kind: Type,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -496,7 +496,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 145..185,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -516,7 +516,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 145..168,
|
||||
kind: ChainingHint,
|
||||
kind: Chaining,
|
||||
label: [
|
||||
"",
|
||||
InlayHintLabelPart {
|
||||
|
@ -536,7 +536,7 @@ fn main() {
|
|||
},
|
||||
InlayHint {
|
||||
range: 222..228,
|
||||
kind: ParameterHint,
|
||||
kind: Parameter,
|
||||
label: [
|
||||
InlayHintLabelPart {
|
||||
text: "self",
|
||||
|
|
|
@ -113,7 +113,7 @@ pub(super) fn hints(
|
|||
.flatten();
|
||||
acc.push(InlayHint {
|
||||
range: closing_token.text_range(),
|
||||
kind: InlayKind::ClosingBraceHint,
|
||||
kind: InlayKind::ClosingBrace,
|
||||
label: InlayHintLabel::simple(label, None, linked_location),
|
||||
});
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ pub(super) fn hints(
|
|||
}
|
||||
acc.push(InlayHint {
|
||||
range: param_list.syntax().text_range(),
|
||||
kind: InlayKind::ClosureReturnTypeHint,
|
||||
kind: InlayKind::ClosureReturnType,
|
||||
label: label_of_ty(famous_defs, config, ty)?,
|
||||
});
|
||||
Some(())
|
||||
|
|
|
@ -43,7 +43,7 @@ pub(super) fn hints(
|
|||
Some(field_list) => name.syntax().text_range().cover(field_list.syntax().text_range()),
|
||||
None => name.syntax().text_range(),
|
||||
},
|
||||
kind: InlayKind::DiscriminantHint,
|
||||
kind: InlayKind::Discriminant,
|
||||
label: InlayHintLabel::simple(
|
||||
match &d {
|
||||
Ok(v) => format!("{}", v),
|
||||
|
|
|
@ -23,7 +23,7 @@ pub(super) fn hints(
|
|||
|
||||
let mk_lt_hint = |t: SyntaxToken, label: String| InlayHint {
|
||||
range: t.text_range(),
|
||||
kind: InlayKind::LifetimeHint,
|
||||
kind: InlayKind::Lifetime,
|
||||
label: label.into(),
|
||||
};
|
||||
|
||||
|
@ -182,7 +182,7 @@ pub(super) fn hints(
|
|||
let is_empty = gpl.generic_params().next().is_none();
|
||||
acc.push(InlayHint {
|
||||
range: angle_tok.text_range(),
|
||||
kind: InlayKind::LifetimeHint,
|
||||
kind: InlayKind::Lifetime,
|
||||
label: format!(
|
||||
"{}{}",
|
||||
allocated_lifetimes.iter().format(", "),
|
||||
|
@ -193,7 +193,7 @@ pub(super) fn hints(
|
|||
}
|
||||
(None, allocated_lifetimes) => acc.push(InlayHint {
|
||||
range: func.name()?.syntax().text_range(),
|
||||
kind: InlayKind::GenericParamListHint,
|
||||
kind: InlayKind::GenericParamList,
|
||||
label: format!("<{}>", allocated_lifetimes.iter().format(", "),).into(),
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ pub(super) fn hints(
|
|||
let t = ty.amp_token()?;
|
||||
acc.push(InlayHint {
|
||||
range: t.text_range(),
|
||||
kind: InlayKind::LifetimeHint,
|
||||
kind: InlayKind::Lifetime,
|
||||
label: "'static".to_owned().into(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ pub(super) fn hints(
|
|||
|
||||
InlayHint {
|
||||
range,
|
||||
kind: InlayKind::ParameterHint,
|
||||
kind: InlayKind::Parameter,
|
||||
label: InlayHintLabel::simple(param_name, None, linked_location),
|
||||
}
|
||||
});
|
||||
|
|
|
@ -431,10 +431,10 @@ pub(crate) fn inlay_hint(
|
|||
mut inlay_hint: InlayHint,
|
||||
) -> Cancellable<lsp_types::InlayHint> {
|
||||
match inlay_hint.kind {
|
||||
InlayKind::ParameterHint if render_colons => inlay_hint.label.append_str(":"),
|
||||
InlayKind::TypeHint if render_colons => inlay_hint.label.prepend_str(": "),
|
||||
InlayKind::ClosureReturnTypeHint => inlay_hint.label.prepend_str(" -> "),
|
||||
InlayKind::DiscriminantHint => inlay_hint.label.prepend_str(" = "),
|
||||
InlayKind::Parameter if render_colons => inlay_hint.label.append_str(":"),
|
||||
InlayKind::Type if render_colons => inlay_hint.label.prepend_str(": "),
|
||||
InlayKind::ClosureReturnType => inlay_hint.label.prepend_str(" -> "),
|
||||
InlayKind::Discriminant => inlay_hint.label.prepend_str(" = "),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
@ -444,64 +444,64 @@ pub(crate) fn inlay_hint(
|
|||
position: match inlay_hint.kind {
|
||||
// before annotated thing
|
||||
InlayKind::OpeningParenthesis
|
||||
| InlayKind::ParameterHint
|
||||
| InlayKind::AdjustmentHint
|
||||
| InlayKind::BindingModeHint => position(line_index, inlay_hint.range.start()),
|
||||
| InlayKind::Parameter
|
||||
| InlayKind::Adjustment
|
||||
| InlayKind::BindingMode => position(line_index, inlay_hint.range.start()),
|
||||
// after annotated thing
|
||||
InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::TypeHint
|
||||
| InlayKind::DiscriminantHint
|
||||
| InlayKind::ChainingHint
|
||||
| InlayKind::GenericParamListHint
|
||||
InlayKind::ClosureReturnType
|
||||
| InlayKind::Type
|
||||
| InlayKind::Discriminant
|
||||
| InlayKind::Chaining
|
||||
| InlayKind::GenericParamList
|
||||
| InlayKind::ClosingParenthesis
|
||||
| InlayKind::AdjustmentHintPostfix
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::ClosingBraceHint => position(line_index, inlay_hint.range.end()),
|
||||
| InlayKind::AdjustmentPostfix
|
||||
| InlayKind::Lifetime
|
||||
| InlayKind::ClosingBrace => position(line_index, inlay_hint.range.end()),
|
||||
},
|
||||
padding_left: Some(match inlay_hint.kind {
|
||||
InlayKind::TypeHint => !render_colons,
|
||||
InlayKind::ChainingHint | InlayKind::ClosingBraceHint => true,
|
||||
InlayKind::Type => !render_colons,
|
||||
InlayKind::Chaining | InlayKind::ClosingBrace => true,
|
||||
InlayKind::ClosingParenthesis
|
||||
| InlayKind::DiscriminantHint
|
||||
| InlayKind::Discriminant
|
||||
| InlayKind::OpeningParenthesis
|
||||
| InlayKind::BindingModeHint
|
||||
| InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::AdjustmentHint
|
||||
| InlayKind::AdjustmentHintPostfix
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::ParameterHint => false,
|
||||
| InlayKind::BindingMode
|
||||
| InlayKind::ClosureReturnType
|
||||
| InlayKind::GenericParamList
|
||||
| InlayKind::Adjustment
|
||||
| InlayKind::AdjustmentPostfix
|
||||
| InlayKind::Lifetime
|
||||
| InlayKind::Parameter => false,
|
||||
}),
|
||||
padding_right: Some(match inlay_hint.kind {
|
||||
InlayKind::ClosingParenthesis
|
||||
| InlayKind::OpeningParenthesis
|
||||
| InlayKind::ChainingHint
|
||||
| InlayKind::ClosureReturnTypeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::AdjustmentHint
|
||||
| InlayKind::AdjustmentHintPostfix
|
||||
| InlayKind::TypeHint
|
||||
| InlayKind::DiscriminantHint
|
||||
| InlayKind::ClosingBraceHint => false,
|
||||
InlayKind::BindingModeHint => {
|
||||
| InlayKind::Chaining
|
||||
| InlayKind::ClosureReturnType
|
||||
| InlayKind::GenericParamList
|
||||
| InlayKind::Adjustment
|
||||
| InlayKind::AdjustmentPostfix
|
||||
| InlayKind::Type
|
||||
| InlayKind::Discriminant
|
||||
| InlayKind::ClosingBrace => false,
|
||||
InlayKind::BindingMode => {
|
||||
matches!(&label, lsp_types::InlayHintLabel::String(s) if s != "&")
|
||||
}
|
||||
InlayKind::ParameterHint | InlayKind::LifetimeHint => true,
|
||||
InlayKind::Parameter | InlayKind::Lifetime => true,
|
||||
}),
|
||||
kind: match inlay_hint.kind {
|
||||
InlayKind::ParameterHint => Some(lsp_types::InlayHintKind::PARAMETER),
|
||||
InlayKind::ClosureReturnTypeHint | InlayKind::TypeHint | InlayKind::ChainingHint => {
|
||||
InlayKind::Parameter => Some(lsp_types::InlayHintKind::PARAMETER),
|
||||
InlayKind::ClosureReturnType | InlayKind::Type | InlayKind::Chaining => {
|
||||
Some(lsp_types::InlayHintKind::TYPE)
|
||||
}
|
||||
InlayKind::ClosingParenthesis
|
||||
| InlayKind::DiscriminantHint
|
||||
| InlayKind::Discriminant
|
||||
| InlayKind::OpeningParenthesis
|
||||
| InlayKind::BindingModeHint
|
||||
| InlayKind::GenericParamListHint
|
||||
| InlayKind::LifetimeHint
|
||||
| InlayKind::AdjustmentHint
|
||||
| InlayKind::AdjustmentHintPostfix
|
||||
| InlayKind::ClosingBraceHint => None,
|
||||
| InlayKind::BindingMode
|
||||
| InlayKind::GenericParamList
|
||||
| InlayKind::Lifetime
|
||||
| InlayKind::Adjustment
|
||||
| InlayKind::AdjustmentPostfix
|
||||
| InlayKind::ClosingBrace => None,
|
||||
},
|
||||
text_edits: None,
|
||||
data: None,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!---
|
||||
lsp_ext.rs hash: 45bd7985265725c5
|
||||
lsp_ext.rs hash: d296ce1226e3568d
|
||||
|
||||
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:
|
||||
|
|
Loading…
Reference in a new issue