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.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs
index 346815d31..aae9db13b 100644
--- a/crates/ra_ide_api/src/references/search_scope.rs
+++ b/crates/ra_ide_api/src/references/search_scope.rs
@@ -1,3 +1,5 @@
1//! FIXME: write short doc here
2
1use hir::{DefWithBody, HasSource, ModuleSource}; 3use hir::{DefWithBody, HasSource, ModuleSource};
2use ra_db::{FileId, SourceDatabase}; 4use ra_db::{FileId, SourceDatabase};
3use ra_syntax::{AstNode, TextRange}; 5use ra_syntax::{AstNode, TextRange};
@@ -7,21 +9,21 @@ use crate::db::RootDatabase;
7use super::{NameDefinition, NameKind}; 9use super::{NameDefinition, NameKind};
8 10
9pub(crate) struct SearchScope { 11pub(crate) struct SearchScope {
10 pub scope: Vec<(FileId, Option<TextRange>)>, 12 pub files: Vec<(FileId, Option<TextRange>)>,
11} 13}
12 14
13impl NameDefinition { 15impl NameDefinition {
14 pub fn scope(&self, db: &RootDatabase) -> SearchScope { 16 pub(crate) fn scope(&self, db: &RootDatabase) -> SearchScope {
15 let module_src = self.container.definition_source(db); 17 let module_src = self.container.definition_source(db);
16 let file_id = module_src.file_id.original_file(db); 18 let file_id = module_src.file_id.original_file(db);
17 19
18 if let NameKind::Pat((def, _)) = self.item { 20 if let NameKind::Pat((def, _)) = self.kind {
19 let range = match def { 21 let range = match def {
20 DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(), 22 DefWithBody::Function(f) => f.source(db).ast.syntax().text_range(),
21 DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), 23 DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(),
22 DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), 24 DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(),
23 }; 25 };
24 return SearchScope { scope: vec![(file_id, Some(range))] }; 26 return SearchScope { files: vec![(file_id, Some(range))] };
25 } 27 }
26 28
27 if let Some(ref vis) = self.visibility { 29 if let Some(ref vis) = self.visibility {
@@ -30,7 +32,7 @@ impl NameDefinition {
30 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>(); 32 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>();
31 33
32 if vis.syntax().to_string().as_str() == "pub(crate)" { 34 if vis.syntax().to_string().as_str() == "pub(crate)" {
33 return SearchScope { scope: files }; 35 return SearchScope { files };
34 } 36 }
35 if vis.syntax().to_string().as_str() == "pub" { 37 if vis.syntax().to_string().as_str() == "pub" {
36 let krate = self.container.krate(db).unwrap(); 38 let krate = self.container.krate(db).unwrap();
@@ -47,7 +49,7 @@ impl NameDefinition {
47 } 49 }
48 } 50 }
49 51
50 return SearchScope { scope: files }; 52 return SearchScope { files };
51 } 53 }
52 // FIXME: "pub(super)", "pub(in path)" 54 // FIXME: "pub(super)", "pub(in path)"
53 } 55 }
@@ -56,6 +58,6 @@ impl NameDefinition {
56 ModuleSource::Module(m) => Some(m.syntax().text_range()), 58 ModuleSource::Module(m) => Some(m.syntax().text_range()),
57 ModuleSource::SourceFile(_) => None, 59 ModuleSource::SourceFile(_) => None,
58 }; 60 };
59 SearchScope { scope: vec![(file_id, range)] } 61 SearchScope { files: vec![(file_id, range)] }
60 } 62 }
61} 63}