Restructure InlayHint, no longer derive properties from its kind

This commit is contained in:
Lukas Wirth 2023-05-13 10:42:26 +02:00
parent 4c5fd19ee5
commit 730286b523
15 changed files with 417 additions and 349 deletions

View file

@ -7,7 +7,7 @@ use ide_db::RootDatabase;
use syntax::ast::{self, AstNode};
use crate::{InlayHint, InlayHintsConfig, InlayKind};
use crate::{InlayHint, InlayHintPosition, InlayHintsConfig, InlayKind};
pub(super) fn hints(
acc: &mut Vec<InlayHint>,
@ -54,6 +54,9 @@ pub(super) fn hints(
kind: InlayKind::BindingMode,
label: r.to_string().into(),
text_edit: None,
position: InlayHintPosition::Before,
pad_left: false,
pad_right: mut_reference,
});
});
match pat {
@ -69,11 +72,20 @@ pub(super) fn hints(
kind: InlayKind::BindingMode,
label: bm.to_string().into(),
text_edit: None,
position: InlayHintPosition::Before,
pad_left: false,
pad_right: true,
});
}
ast::Pat::OrPat(pat) if !pattern_adjustments.is_empty() && outer_paren_pat.is_none() => {
acc.push(InlayHint::opening_paren(pat.syntax().text_range()));
acc.push(InlayHint::closing_paren(pat.syntax().text_range()));
acc.push(InlayHint::opening_paren_before(
InlayKind::BindingMode,
pat.syntax().text_range(),
));
acc.push(InlayHint::closing_paren_after(
InlayKind::BindingMode,
pat.syntax().text_range(),
));
}
_ => (),
}