aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references/search_scope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/references/search_scope.rs')
-rw-r--r--crates/ra_ide_api/src/references/search_scope.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs
index 680988a21..d2c966b4f 100644
--- a/crates/ra_ide_api/src/references/search_scope.rs
+++ b/crates/ra_ide_api/src/references/search_scope.rs
@@ -1,5 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::collections::HashSet;
4
3use hir::{DefWithBody, HasSource, ModuleSource}; 5use hir::{DefWithBody, HasSource, ModuleSource};
4use ra_db::{FileId, SourceDatabase, SourceDatabaseExt}; 6use ra_db::{FileId, SourceDatabase, SourceDatabaseExt};
5use ra_syntax::{AstNode, TextRange}; 7use ra_syntax::{AstNode, TextRange};
@@ -9,7 +11,7 @@ use crate::db::RootDatabase;
9use super::{NameDefinition, NameKind}; 11use super::{NameDefinition, NameKind};
10 12
11impl NameDefinition { 13impl NameDefinition {
12 pub(crate) fn search_scope(&self, db: &RootDatabase) -> Vec<(FileId, Option<TextRange>)> { 14 pub(crate) fn search_scope(&self, db: &RootDatabase) -> HashSet<(FileId, Option<TextRange>)> {
13 let module_src = self.container.definition_source(db); 15 let module_src = self.container.definition_source(db);
14 let file_id = module_src.file_id.original_file(db); 16 let file_id = module_src.file_id.original_file(db);
15 17
@@ -19,13 +21,13 @@ impl NameDefinition {
19 DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), 21 DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(),
20 DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), 22 DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(),
21 }; 23 };
22 return vec![(file_id, Some(range))]; 24 return [(file_id, Some(range))].iter().cloned().collect();
23 } 25 }
24 26
25 if let Some(ref vis) = self.visibility { 27 if let Some(ref vis) = self.visibility {
26 let source_root_id = db.file_source_root(file_id); 28 let source_root_id = db.file_source_root(file_id);
27 let source_root = db.source_root(source_root_id); 29 let source_root = db.source_root(source_root_id);
28 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>(); 30 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<HashSet<_>>();
29 31
30 if vis.syntax().to_string().as_str() == "pub(crate)" { 32 if vis.syntax().to_string().as_str() == "pub(crate)" {
31 return files; 33 return files;
@@ -54,6 +56,6 @@ impl NameDefinition {
54 ModuleSource::Module(m) => Some(m.syntax().text_range()), 56 ModuleSource::Module(m) => Some(m.syntax().text_range()),
55 ModuleSource::SourceFile(_) => None, 57 ModuleSource::SourceFile(_) => None,
56 }; 58 };
57 vec![(file_id, range)] 59 [(file_id, range)].iter().cloned().collect()
58 } 60 }
59} 61}