diff options
Diffstat (limited to 'crates/ra_ide/src/call_hierarchy.rs')
-rw-r--r-- | crates/ra_ide/src/call_hierarchy.rs | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 1e3a31602..884353808 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs | |||
@@ -39,10 +39,11 @@ pub(crate) fn call_hierarchy( | |||
39 | 39 | ||
40 | pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Option<Vec<CallItem>> { | 40 | pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Option<Vec<CallItem>> { |
41 | let sema = Semantics::new(db); | 41 | let sema = Semantics::new(db); |
42 | |||
42 | // 1. Find all refs | 43 | // 1. Find all refs |
43 | // 2. Loop through refs and determine unique fndef. This will become our `from: CallHierarchyItem,` in the reply. | 44 | // 2. Loop through refs and determine unique fndef. This will become our `from: CallHierarchyItem,` in the reply. |
44 | // 3. Add ranges relative to the start of the fndef. | 45 | // 3. Add ranges relative to the start of the fndef. |
45 | let refs = references::find_all_refs(db, position, None)?; | 46 | let refs = references::find_all_refs(&sema, position, None)?; |
46 | 47 | ||
47 | let mut calls = CallLocations::default(); | 48 | let mut calls = CallLocations::default(); |
48 | 49 | ||
@@ -355,4 +356,41 @@ fn caller3() { | |||
355 | &["caller3 FN_DEF FileId(1) 66..83 69..76 : [52..59]"], | 356 | &["caller3 FN_DEF FileId(1) 66..83 69..76 : [52..59]"], |
356 | ); | 357 | ); |
357 | } | 358 | } |
359 | |||
360 | #[test] | ||
361 | fn test_call_hierarchy_issue_5103() { | ||
362 | check_hierarchy( | ||
363 | r#" | ||
364 | fn a() { | ||
365 | b() | ||
366 | } | ||
367 | |||
368 | fn b() {} | ||
369 | |||
370 | fn main() { | ||
371 | a<|>() | ||
372 | } | ||
373 | "#, | ||
374 | "a FN_DEF FileId(1) 0..18 3..4", | ||
375 | &["main FN_DEF FileId(1) 31..52 34..38 : [47..48]"], | ||
376 | &["b FN_DEF FileId(1) 20..29 23..24 : [13..14]"], | ||
377 | ); | ||
378 | |||
379 | check_hierarchy( | ||
380 | r#" | ||
381 | fn a() { | ||
382 | b<|>() | ||
383 | } | ||
384 | |||
385 | fn b() {} | ||
386 | |||
387 | fn main() { | ||
388 | a() | ||
389 | } | ||
390 | "#, | ||
391 | "b FN_DEF FileId(1) 20..29 23..24", | ||
392 | &["a FN_DEF FileId(1) 0..18 3..4 : [13..14]"], | ||
393 | &[], | ||
394 | ); | ||
395 | } | ||
358 | } | 396 | } |