Improve inlay hint resolution reliability

This commit is contained in:
Lukas Wirth 2024-08-30 15:45:12 +02:00
parent 13ac53e73d
commit 5ca5d52697
20 changed files with 282 additions and 216 deletions

View file

@ -2,17 +2,19 @@
//! ```no_run
//! let /* & */ (/* ref */ x,) = &(0,);
//! ```
use hir::{Mutability, Semantics};
use ide_db::RootDatabase;
use hir::Mutability;
use ide_db::famous_defs::FamousDefs;
use span::EditionedFileId;
use syntax::ast::{self, AstNode};
use crate::{InlayHint, InlayHintPosition, InlayHintsConfig, InlayKind};
pub(super) fn hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<'_, RootDatabase>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
_file_id: EditionedFileId,
pat: &ast::Pat,
) -> Option<()> {
if !config.binding_mode_hints {
@ -57,6 +59,7 @@ pub(super) fn hints(
position: InlayHintPosition::Before,
pad_left: false,
pad_right: mut_reference,
resolve_parent: Some(pat.syntax().text_range()),
});
});
match pat {
@ -75,6 +78,7 @@ pub(super) fn hints(
position: InlayHintPosition::Before,
pad_left: false,
pad_right: true,
resolve_parent: Some(pat.syntax().text_range()),
});
}
ast::Pat::OrPat(pat) if !pattern_adjustments.is_empty() && outer_paren_pat.is_none() => {