]> git.lizzy.rs Git - rust.git/commitdiff
Rename FileReferences -> UsageSearchResult
authorLukas Wirth <lukastw97@gmail.com>
Tue, 12 Jan 2021 14:56:24 +0000 (15:56 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Tue, 12 Jan 2021 14:56:24 +0000 (15:56 +0100)
crates/ide/src/references.rs
crates/ide_db/src/search.rs
crates/ssr/src/search.rs

index c7943dc95ef87212e842d498f58644fa1ffcab1c..7d4757e02523e817e807fc965c49aaeb1d23d7f5 100644 (file)
@@ -15,7 +15,7 @@
 use ide_db::{
     base_db::FileId,
     defs::{Definition, NameClass, NameRefClass},
-    search::{FileReference, FileReferences, ReferenceAccess, ReferenceKind, SearchScope},
+    search::{FileReference, ReferenceAccess, ReferenceKind, SearchScope, UsageSearchResult},
     RootDatabase,
 };
 use syntax::{
@@ -29,7 +29,7 @@
 #[derive(Debug, Clone)]
 pub struct ReferenceSearchResult {
     declaration: Declaration,
-    references: FileReferences,
+    references: UsageSearchResult,
 }
 
 #[derive(Debug, Clone)]
@@ -48,11 +48,11 @@ pub fn decl_target(&self) -> &NavigationTarget {
         &self.declaration.nav
     }
 
-    pub fn references(&self) -> &FileReferences {
+    pub fn references(&self) -> &UsageSearchResult {
         &self.references
     }
 
-    pub fn references_with_declaration(mut self) -> FileReferences {
+    pub fn references_with_declaration(mut self) -> UsageSearchResult {
         let decl_ref = FileReference {
             range: self.declaration.nav.focus_or_full_range(),
             kind: self.declaration.kind,
@@ -315,7 +315,7 @@ fn try_find_self_references(
                 .collect()
         })
         .unwrap_or_default();
-    let mut references = FileReferences::default();
+    let mut references = UsageSearchResult::default();
     references.references.insert(file_id, refs);
 
     Some(RangeInfo::new(
index 89a313e9b5b6e275880c63c00ed517c27ef4374b..b5fa466427aaa2521653baa8962d1f61f0666e2e 100644 (file)
 };
 
 #[derive(Debug, Default, Clone)]
-pub struct FileReferences {
+pub struct UsageSearchResult {
     pub references: FxHashMap<FileId, Vec<FileReference>>,
 }
 
-impl FileReferences {
+impl UsageSearchResult {
     pub fn is_empty(&self) -> bool {
         self.references.is_empty()
     }
@@ -43,7 +43,7 @@ pub fn file_ranges(&self) -> impl Iterator<Item = FileRange> + '_ {
     }
 }
 
-impl IntoIterator for FileReferences {
+impl IntoIterator for UsageSearchResult {
     type Item = (FileId, Vec<FileReference>);
     type IntoIter = <FxHashMap<FileId, Vec<FileReference>> as IntoIterator>::IntoIter;
 
@@ -293,9 +293,8 @@ pub fn at_least_one(self) -> bool {
         found
     }
 
-    /// The [`FileReferences`] returned always have unique [`FileId`]s.
-    pub fn all(self) -> FileReferences {
-        let mut res = FileReferences::default();
+    pub fn all(self) -> UsageSearchResult {
+        let mut res = UsageSearchResult::default();
         self.search(&mut |file_id, reference| {
             res.references.entry(file_id).or_default().push(reference);
             false
index a3eb2e800d24a5719dab51f5b262d59ee4f39321..836eb94b2e22797f2ddb235a6d67bc137d5a2571 100644 (file)
@@ -8,7 +8,7 @@
 use ide_db::{
     base_db::{FileId, FileRange},
     defs::Definition,
-    search::{FileReferences, SearchScope},
+    search::{SearchScope, UsageSearchResult},
 };
 use rustc_hash::FxHashSet;
 use syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
@@ -20,7 +20,7 @@
 /// them more than once.
 #[derive(Default)]
 pub(crate) struct UsageCache {
-    usages: Vec<(Definition, FileReferences)>,
+    usages: Vec<(Definition, UsageSearchResult)>,
 }
 
 impl<'db> MatchFinder<'db> {
@@ -108,7 +108,7 @@ fn find_usages<'a>(
         &self,
         usage_cache: &'a mut UsageCache,
         definition: Definition,
-    ) -> &'a FileReferences {
+    ) -> &'a UsageSearchResult {
         // Logically if a lookup succeeds we should just return it. Unfortunately returning it would
         // extend the lifetime of the borrow, then we wouldn't be able to do the insertion on a
         // cache miss. This is a limitation of NLL and is fixed with Polonius. For now we do two
@@ -250,7 +250,7 @@ fn is_search_permitted(node: &SyntaxNode) -> bool {
 }
 
 impl UsageCache {
-    fn find(&mut self, definition: &Definition) -> Option<&FileReferences> {
+    fn find(&mut self, definition: &Definition) -> Option<&UsageSearchResult> {
         // We expect a very small number of cache entries (generally 1), so a linear scan should be
         // fast enough and avoids the need to implement Hash for Definition.
         for (d, refs) in &self.usages {