Use match_ast! in FnCallNode::with_node
This commit is contained in:
parent
7ad55e976c
commit
4d17658940
@ -4,7 +4,7 @@
|
|||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
algo::ancestors_at_offset,
|
algo::ancestors_at_offset,
|
||||||
ast::{self, ArgListOwner},
|
ast::{self, ArgListOwner},
|
||||||
AstNode, SyntaxNode, TextUnit,
|
match_ast, AstNode, SyntaxNode, TextUnit,
|
||||||
};
|
};
|
||||||
use test_utils::tested_by;
|
use test_utils::tested_by;
|
||||||
|
|
||||||
@ -91,14 +91,13 @@ enum FnCallNode {
|
|||||||
impl FnCallNode {
|
impl FnCallNode {
|
||||||
fn with_node(syntax: &SyntaxNode, offset: TextUnit) -> Option<FnCallNode> {
|
fn with_node(syntax: &SyntaxNode, offset: TextUnit) -> Option<FnCallNode> {
|
||||||
ancestors_at_offset(syntax, offset).find_map(|node| {
|
ancestors_at_offset(syntax, offset).find_map(|node| {
|
||||||
if let Some(expr) = ast::CallExpr::cast(node.clone()) {
|
match_ast! {
|
||||||
Some(FnCallNode::CallExpr(expr))
|
match node {
|
||||||
} else if let Some(expr) = ast::MethodCallExpr::cast(node.clone()) {
|
ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) },
|
||||||
Some(FnCallNode::MethodCallExpr(expr))
|
ast::MethodCallExpr(it) => { Some(FnCallNode::MethodCallExpr(it)) },
|
||||||
} else if let Some(expr) = ast::MacroCall::cast(node) {
|
ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) },
|
||||||
Some(FnCallNode::MacroCallExpr(expr))
|
_ => { None },
|
||||||
} else {
|
}
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user