aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/call_hierarchy.rs30
1 files changed, 8 insertions, 22 deletions
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs
index 4d8983cb2..b29d1fef9 100644
--- a/crates/ide/src/call_hierarchy.rs
+++ b/crates/ide/src/call_hierarchy.rs
@@ -5,7 +5,7 @@ use indexmap::IndexMap;
5use hir::Semantics; 5use hir::Semantics;
6use ide_db::call_info::FnCallNode; 6use ide_db::call_info::FnCallNode;
7use ide_db::RootDatabase; 7use ide_db::RootDatabase;
8use syntax::{ast, match_ast, AstNode, TextRange}; 8use syntax::{ast, AstNode, TextRange};
9 9
10use crate::{ 10use crate::{
11 display::TryToNav, goto_definition, references, FilePosition, NavigationTarget, RangeInfo, 11 display::TryToNav, goto_definition, references, FilePosition, NavigationTarget, RangeInfo,
@@ -57,15 +57,9 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
57 57
58 // This target is the containing function 58 // This target is the containing function
59 if let Some(nav) = syntax.ancestors().find_map(|node| { 59 if let Some(nav) = syntax.ancestors().find_map(|node| {
60 match_ast! { 60 let fn_ = ast::Fn::cast(node)?;
61 match node { 61 let def = sema.to_def(&fn_)?;
62 ast::Fn(it) => { 62 def.try_to_nav(sema.db)
63 let def = sema.to_def(&it)?;
64 def.try_to_nav(sema.db)
65 },
66 _ => None,
67 }
68 }
69 }) { 63 }) {
70 let relative_range = reference.file_range.range; 64 let relative_range = reference.file_range.range;
71 calls.add(&nav, relative_range); 65 calls.add(&nav, relative_range);
@@ -91,17 +85,12 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio
91 .filter_map(|node| FnCallNode::with_node_exact(&node)) 85 .filter_map(|node| FnCallNode::with_node_exact(&node))
92 .filter_map(|call_node| { 86 .filter_map(|call_node| {
93 let name_ref = call_node.name_ref()?; 87 let name_ref = call_node.name_ref()?;
94 88 let func_target = match call_node {
95 if let Some(func_target) = match &call_node {
96 FnCallNode::CallExpr(expr) => { 89 FnCallNode::CallExpr(expr) => {
97 //FIXME: Type::as_callable is broken 90 //FIXME: Type::as_callable is broken
98 let callable = sema.type_of_expr(&expr.expr()?)?.as_callable(db)?; 91 let callable = sema.type_of_expr(&expr.expr()?)?.as_callable(db)?;
99 match callable.kind() { 92 match callable.kind() {
100 hir::CallableKind::Function(it) => { 93 hir::CallableKind::Function(it) => it.try_to_nav(db),
101 let fn_def: hir::Function = it.into();
102 let nav = fn_def.try_to_nav(db)?;
103 Some(nav)
104 }
105 _ => None, 94 _ => None,
106 } 95 }
107 } 96 }
@@ -109,11 +98,8 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio
109 let function = sema.resolve_method_call(&expr)?; 98 let function = sema.resolve_method_call(&expr)?;
110 function.try_to_nav(db) 99 function.try_to_nav(db)
111 } 100 }
112 } { 101 }?;
113 Some((func_target, name_ref.syntax().text_range())) 102 Some((func_target, name_ref.syntax().text_range()))
114 } else {
115 None
116 }
117 }) 103 })
118 .for_each(|(nav, range)| calls.add(&nav, range)); 104 .for_each(|(nav, range)| calls.add(&nav, range));
119 105