diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/references/search_scope.rs | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 3d282d48a..0f1ac57fc 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -99,7 +99,7 @@ fn find_name<'a>( | |||
99 | 99 | ||
100 | fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> Vec<FileRange> { | 100 | fn process_definition(db: &RootDatabase, def: NameDefinition, name: String) -> Vec<FileRange> { |
101 | let pat = name.as_str(); | 101 | let pat = name.as_str(); |
102 | let scope = def.scope(db).files; | 102 | let scope = def.search_scope(db); |
103 | let mut refs = vec![]; | 103 | let mut refs = vec![]; |
104 | 104 | ||
105 | let is_match = |file_id: FileId, name_ref: &ast::NameRef| -> bool { | 105 | let is_match = |file_id: FileId, name_ref: &ast::NameRef| -> bool { |
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs index aae9db13b..dfea18a19 100644 --- a/crates/ra_ide_api/src/references/search_scope.rs +++ b/crates/ra_ide_api/src/references/search_scope.rs | |||
@@ -8,12 +8,8 @@ use crate::db::RootDatabase; | |||
8 | 8 | ||
9 | use super::{NameDefinition, NameKind}; | 9 | use super::{NameDefinition, NameKind}; |
10 | 10 | ||
11 | pub(crate) struct SearchScope { | ||
12 | pub files: Vec<(FileId, Option<TextRange>)>, | ||
13 | } | ||
14 | |||
15 | impl NameDefinition { | 11 | impl NameDefinition { |
16 | pub(crate) fn scope(&self, db: &RootDatabase) -> SearchScope { | 12 | pub(crate) fn search_scope(&self, db: &RootDatabase) -> Vec<(FileId, Option<TextRange>)> { |
17 | let module_src = self.container.definition_source(db); | 13 | let module_src = self.container.definition_source(db); |
18 | let file_id = module_src.file_id.original_file(db); | 14 | let file_id = module_src.file_id.original_file(db); |
19 | 15 | ||
@@ -23,7 +19,7 @@ impl NameDefinition { | |||
23 | DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), | 19 | DefWithBody::Const(c) => c.source(db).ast.syntax().text_range(), |
24 | DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), | 20 | DefWithBody::Static(s) => s.source(db).ast.syntax().text_range(), |
25 | }; | 21 | }; |
26 | return SearchScope { files: vec![(file_id, Some(range))] }; | 22 | return vec![(file_id, Some(range))]; |
27 | } | 23 | } |
28 | 24 | ||
29 | if let Some(ref vis) = self.visibility { | 25 | if let Some(ref vis) = self.visibility { |
@@ -32,7 +28,7 @@ impl NameDefinition { | |||
32 | let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>(); | 28 | let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<Vec<_>>(); |
33 | 29 | ||
34 | if vis.syntax().to_string().as_str() == "pub(crate)" { | 30 | if vis.syntax().to_string().as_str() == "pub(crate)" { |
35 | return SearchScope { files }; | 31 | return files; |
36 | } | 32 | } |
37 | if vis.syntax().to_string().as_str() == "pub" { | 33 | if vis.syntax().to_string().as_str() == "pub" { |
38 | let krate = self.container.krate(db).unwrap(); | 34 | let krate = self.container.krate(db).unwrap(); |
@@ -49,7 +45,7 @@ impl NameDefinition { | |||
49 | } | 45 | } |
50 | } | 46 | } |
51 | 47 | ||
52 | return SearchScope { files }; | 48 | return files; |
53 | } | 49 | } |
54 | // FIXME: "pub(super)", "pub(in path)" | 50 | // FIXME: "pub(super)", "pub(in path)" |
55 | } | 51 | } |
@@ -58,6 +54,6 @@ impl NameDefinition { | |||
58 | ModuleSource::Module(m) => Some(m.syntax().text_range()), | 54 | ModuleSource::Module(m) => Some(m.syntax().text_range()), |
59 | ModuleSource::SourceFile(_) => None, | 55 | ModuleSource::SourceFile(_) => None, |
60 | }; | 56 | }; |
61 | SearchScope { files: vec![(file_id, range)] } | 57 | vec![(file_id, range)] |
62 | } | 58 | } |
63 | } | 59 | } |