diff options
-rw-r--r-- | crates/ra_ide/src/call_hierarchy.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 75658c20b..1cb712e32 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs | |||
@@ -16,21 +16,6 @@ use crate::{ | |||
16 | goto_definition, references, FilePosition, NavigationTarget, RangeInfo, | 16 | goto_definition, references, FilePosition, NavigationTarget, RangeInfo, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | #[derive(Default)] | ||
20 | struct CallLocations { | ||
21 | funcs: IndexMap<NavigationTarget, Vec<TextRange>>, | ||
22 | } | ||
23 | |||
24 | impl CallLocations { | ||
25 | pub fn add(&mut self, target: &NavigationTarget, range: TextRange) { | ||
26 | self.funcs.entry(target.clone()).or_default().push(range); | ||
27 | } | ||
28 | |||
29 | pub fn into_items(self) -> Vec<CallItem> { | ||
30 | self.funcs.into_iter().map(|(target, ranges)| CallItem { target, ranges }).collect() | ||
31 | } | ||
32 | } | ||
33 | |||
34 | #[derive(Debug, Clone)] | 19 | #[derive(Debug, Clone)] |
35 | pub struct CallItem { | 20 | pub struct CallItem { |
36 | pub target: NavigationTarget, | 21 | pub target: NavigationTarget, |
@@ -146,6 +131,21 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio | |||
146 | Some(calls.into_items()) | 131 | Some(calls.into_items()) |
147 | } | 132 | } |
148 | 133 | ||
134 | #[derive(Default)] | ||
135 | struct CallLocations { | ||
136 | funcs: IndexMap<NavigationTarget, Vec<TextRange>>, | ||
137 | } | ||
138 | |||
139 | impl CallLocations { | ||
140 | fn add(&mut self, target: &NavigationTarget, range: TextRange) { | ||
141 | self.funcs.entry(target.clone()).or_default().push(range); | ||
142 | } | ||
143 | |||
144 | fn into_items(self) -> Vec<CallItem> { | ||
145 | self.funcs.into_iter().map(|(target, ranges)| CallItem { target, ranges }).collect() | ||
146 | } | ||
147 | } | ||
148 | |||
149 | #[cfg(test)] | 149 | #[cfg(test)] |
150 | mod tests { | 150 | mod tests { |
151 | use ra_db::FilePosition; | 151 | use ra_db::FilePosition; |