diff options
Diffstat (limited to 'crates/ra_ide_api/src/references/search_scope.rs')
-rw-r--r-- | crates/ra_ide_api/src/references/search_scope.rs | 16 |
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 | |||
1 | use hir::{DefWithBody, HasSource, ModuleSource}; | 3 | use hir::{DefWithBody, HasSource, ModuleSource}; |
2 | use ra_db::{FileId, SourceDatabase}; | 4 | use ra_db::{FileId, SourceDatabase}; |
3 | use ra_syntax::{AstNode, TextRange}; | 5 | use ra_syntax::{AstNode, TextRange}; |
@@ -7,21 +9,21 @@ use crate::db::RootDatabase; | |||
7 | use super::{NameDefinition, NameKind}; | 9 | use super::{NameDefinition, NameKind}; |
8 | 10 | ||
9 | pub(crate) struct SearchScope { | 11 | pub(crate) struct SearchScope { |
10 | pub scope: Vec<(FileId, Option<TextRange>)>, | 12 | pub files: Vec<(FileId, Option<TextRange>)>, |
11 | } | 13 | } |
12 | 14 | ||
13 | impl NameDefinition { | 15 | impl 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 | } |