mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 14:33:29 +00:00
Enable linked locations for closure param inlay hints
This commit is contained in:
parent
ff79903cf6
commit
0de904d539
1 changed files with 5 additions and 10 deletions
|
@ -30,28 +30,23 @@ pub(super) fn hints(
|
||||||
.filter_map(|(p, arg)| {
|
.filter_map(|(p, arg)| {
|
||||||
// Only annotate hints for expressions that exist in the original file
|
// Only annotate hints for expressions that exist in the original file
|
||||||
let range = sema.original_range_opt(arg.syntax())?;
|
let range = sema.original_range_opt(arg.syntax())?;
|
||||||
let (param_name, name_syntax) = match p.source(sema.db)?.value.as_ref() {
|
let source = p.source(sema.db)?;
|
||||||
|
let (param_name, name_syntax) = match source.value.as_ref() {
|
||||||
Either::Left(pat) => (pat.name()?, pat.name()),
|
Either::Left(pat) => (pat.name()?, pat.name()),
|
||||||
Either::Right(param) => match param.pat()? {
|
Either::Right(param) => match param.pat()? {
|
||||||
ast::Pat::IdentPat(it) => (it.name()?, it.name()),
|
ast::Pat::IdentPat(it) => (it.name()?, it.name()),
|
||||||
_ => return None,
|
_ => return None,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// make sure the file is cached so we can map out of macros
|
||||||
|
sema.parse_or_expand(source.file_id);
|
||||||
Some((name_syntax, param_name, arg, range))
|
Some((name_syntax, param_name, arg, range))
|
||||||
})
|
})
|
||||||
.filter(|(_, param_name, arg, _)| {
|
.filter(|(_, param_name, arg, _)| {
|
||||||
!should_hide_param_name_hint(sema, &callable, ¶m_name.text(), arg)
|
!should_hide_param_name_hint(sema, &callable, ¶m_name.text(), arg)
|
||||||
})
|
})
|
||||||
.map(|(param, param_name, _, FileRange { range, .. })| {
|
.map(|(param, param_name, _, FileRange { range, .. })| {
|
||||||
let mut linked_location = None;
|
let linked_location = param.and_then(|name| sema.original_range_opt(name.syntax()));
|
||||||
if let Some(name) = param {
|
|
||||||
if let hir::CallableKind::Function(f) = callable.kind() {
|
|
||||||
// assert the file is cached so we can map out of macros
|
|
||||||
if sema.source(f).is_some() {
|
|
||||||
linked_location = sema.original_range_opt(name.syntax());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let colon = if config.render_colons { ":" } else { "" };
|
let colon = if config.render_colons { ":" } else { "" };
|
||||||
let label =
|
let label =
|
||||||
|
|
Loading…
Reference in a new issue