mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add hover for closure
This commit is contained in:
parent
370b72c7dd
commit
5df545b3f0
7 changed files with 249 additions and 7 deletions
|
@ -119,8 +119,8 @@ fn hover_simple(
|
|||
| T![crate]
|
||||
| T![Self]
|
||||
| T![_] => 4,
|
||||
// index and prefix ops
|
||||
T!['['] | T![']'] | T![?] | T![*] | T![-] | T![!] => 3,
|
||||
// index and prefix ops and closure pipe
|
||||
T!['['] | T![']'] | T![?] | T![*] | T![-] | T![!] | T![|] => 3,
|
||||
kind if kind.is_keyword() => 2,
|
||||
T!['('] | T![')'] => 2,
|
||||
kind if kind.is_trivia() => 0,
|
||||
|
@ -219,6 +219,16 @@ fn hover_simple(
|
|||
};
|
||||
render::type_info_of(sema, config, &Either::Left(call_expr))
|
||||
})
|
||||
})
|
||||
// try closure
|
||||
.or_else(|| {
|
||||
descended().find_map(|token| {
|
||||
if token.kind() != T![|] {
|
||||
return None;
|
||||
}
|
||||
let c = token.parent().and_then(|x| x.parent()).and_then(ast::ClosureExpr::cast)?;
|
||||
render::closure_expr(sema, c)
|
||||
})
|
||||
});
|
||||
|
||||
result.map(|mut res: HoverResult| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue