diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/references.rs | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 6999dacee..e8737dcfa 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -14,7 +14,6 @@ pub(crate) mod rename; | |||
14 | use either::Either; | 14 | use either::Either; |
15 | use hir::Semantics; | 15 | use hir::Semantics; |
16 | use ide_db::{ | 16 | use ide_db::{ |
17 | base_db::FileId, | ||
18 | defs::{Definition, NameClass, NameRefClass}, | 17 | defs::{Definition, NameClass, NameRefClass}, |
19 | search::{FileReference, ReferenceAccess, ReferenceKind, SearchScope, UsageSearchResult}, | 18 | search::{FileReference, ReferenceAccess, ReferenceKind, SearchScope, UsageSearchResult}, |
20 | RootDatabase, | 19 | RootDatabase, |
@@ -35,14 +34,14 @@ pub struct ReferenceSearchResult { | |||
35 | 34 | ||
36 | #[derive(Debug, Clone)] | 35 | #[derive(Debug, Clone)] |
37 | pub struct Declaration { | 36 | pub struct Declaration { |
38 | pub nav: NavigationTarget, | 37 | nav: NavigationTarget, |
39 | pub kind: ReferenceKind, | 38 | kind: ReferenceKind, |
40 | pub access: Option<ReferenceAccess>, | 39 | access: Option<ReferenceAccess>, |
41 | } | 40 | } |
42 | 41 | ||
43 | impl ReferenceSearchResult { | 42 | impl ReferenceSearchResult { |
44 | pub fn references(&self) -> &UsageSearchResult { | 43 | pub fn references(self) -> UsageSearchResult { |
45 | &self.references | 44 | self.references |
46 | } | 45 | } |
47 | 46 | ||
48 | pub fn references_with_declaration(mut self) -> UsageSearchResult { | 47 | pub fn references_with_declaration(mut self) -> UsageSearchResult { |
@@ -55,24 +54,6 @@ impl ReferenceSearchResult { | |||
55 | self.references.references.entry(file_id).or_default().push(decl_ref); | 54 | self.references.references.entry(file_id).or_default().push(decl_ref); |
56 | self.references | 55 | self.references |
57 | } | 56 | } |
58 | |||
59 | /// Total number of references | ||
60 | /// At least 1 since all valid references should | ||
61 | /// Have a declaration | ||
62 | pub fn len(&self) -> usize { | ||
63 | self.references.len() + 1 | ||
64 | } | ||
65 | } | ||
66 | |||
67 | // allow turning ReferenceSearchResult into an iterator | ||
68 | // over References | ||
69 | impl IntoIterator for ReferenceSearchResult { | ||
70 | type Item = (FileId, Vec<FileReference>); | ||
71 | type IntoIter = std::collections::hash_map::IntoIter<FileId, Vec<FileReference>>; | ||
72 | |||
73 | fn into_iter(self) -> Self::IntoIter { | ||
74 | self.references_with_declaration().into_iter() | ||
75 | } | ||
76 | } | 57 | } |
77 | 58 | ||
78 | pub(crate) fn find_all_refs( | 59 | pub(crate) fn find_all_refs( |