aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorkjeremy <[email protected]>2019-10-30 18:39:05 +0000
committerkjeremy <[email protected]>2019-10-30 18:39:05 +0000
commit4d17658940ec73554dfef799b22e8829ab5ad61a (patch)
tree77df94684e42ff4f508d14d4ad2dbe388d26535b /crates
parent7ad55e976c3f88e92075379c8a4c1f413665b458 (diff)
Use match_ast! in FnCallNode::with_node
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/call_info.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index e494f5620..3572825b5 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -4,7 +4,7 @@ use ra_db::SourceDatabase;
4use ra_syntax::{ 4use ra_syntax::{
5 algo::ancestors_at_offset, 5 algo::ancestors_at_offset,
6 ast::{self, ArgListOwner}, 6 ast::{self, ArgListOwner},
7 AstNode, SyntaxNode, TextUnit, 7 match_ast, AstNode, SyntaxNode, TextUnit,
8}; 8};
9use test_utils::tested_by; 9use test_utils::tested_by;
10 10
@@ -91,14 +91,13 @@ enum FnCallNode {
91impl FnCallNode { 91impl FnCallNode {
92 fn with_node(syntax: &SyntaxNode, offset: TextUnit) -> Option<FnCallNode> { 92 fn with_node(syntax: &SyntaxNode, offset: TextUnit) -> Option<FnCallNode> {
93 ancestors_at_offset(syntax, offset).find_map(|node| { 93 ancestors_at_offset(syntax, offset).find_map(|node| {
94 if let Some(expr) = ast::CallExpr::cast(node.clone()) { 94 match_ast! {
95 Some(FnCallNode::CallExpr(expr)) 95 match node {
96 } else if let Some(expr) = ast::MethodCallExpr::cast(node.clone()) { 96 ast::CallExpr(it) => { Some(FnCallNode::CallExpr(it)) },
97 Some(FnCallNode::MethodCallExpr(expr)) 97 ast::MethodCallExpr(it) => { Some(FnCallNode::MethodCallExpr(it)) },
98 } else if let Some(expr) = ast::MacroCall::cast(node) { 98 ast::MacroCall(it) => { Some(FnCallNode::MacroCallExpr(it)) },
99 Some(FnCallNode::MacroCallExpr(expr)) 99 _ => { None },
100 } else { 100 }
101 None
102 } 101 }
103 }) 102 })
104 } 103 }