mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
fix: Fix highlighting hack for self-params
This commit is contained in:
parent
989c06b25d
commit
087122ad1a
1 changed files with 6 additions and 4 deletions
|
@ -712,11 +712,13 @@ fn parent_matches<N: AstNode>(token: &SyntaxToken) -> bool {
|
||||||
token.parent().map_or(false, |it| N::can_cast(it.kind()))
|
token.parent().map_or(false, |it| N::can_cast(it.kind()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_in_fn_with_self_param<N: AstNode>(node: &N) -> bool {
|
fn is_in_fn_with_self_param(node: &ast::NameRef) -> bool {
|
||||||
node.syntax()
|
node.syntax()
|
||||||
.ancestors()
|
.ancestors()
|
||||||
.take_while(|node| ast::Expr::can_cast(node.kind()) || ast::Fn::can_cast(node.kind()))
|
.find_map(ast::Item::cast)
|
||||||
.find_map(ast::Fn::cast)
|
.and_then(|item| match item {
|
||||||
.and_then(|s| s.param_list()?.self_param())
|
ast::Item::Fn(fn_) => fn_.param_list()?.self_param(),
|
||||||
|
_ => None,
|
||||||
|
})
|
||||||
.is_some()
|
.is_some()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue