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.rs44
1 files changed, 41 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/references/search_scope.rs b/crates/ra_ide_api/src/references/search_scope.rs
index d2c966b4f..8495a92a5 100644
--- a/crates/ra_ide_api/src/references/search_scope.rs
+++ b/crates/ra_ide_api/src/references/search_scope.rs
@@ -25,14 +25,53 @@ impl NameDefinition {
25 } 25 }
26 26
27 if let Some(ref vis) = self.visibility { 27 if let Some(ref vis) = self.visibility {
28 let vis = vis.syntax().to_string();
29
30 // FIXME: add "pub(in path)"
31
32 if vis.as_str() == "pub(super)" {
33 if let Some(parent_module) = self.container.parent(db) {
34 let mut files = HashSet::new();
35
36 let parent_src = parent_module.definition_source(db);
37 let file_id = parent_src.file_id.original_file(db);
38
39 match parent_src.ast {
40 ModuleSource::Module(m) => {
41 let range = Some(m.syntax().text_range());
42 files.insert((file_id, range));
43 }
44 ModuleSource::SourceFile(_) => {
45 files.insert((file_id, None));
46 files.extend(
47 parent_module
48 .children(db)
49 .map(|m| {
50 let src = m.definition_source(db);
51 (src.file_id.original_file(db), None)
52 })
53 .collect::<HashSet<_>>(),
54 );
55 }
56 }
57 return files;
58 } else {
59 let range = match module_src.ast {
60 ModuleSource::Module(m) => Some(m.syntax().text_range()),
61 ModuleSource::SourceFile(_) => None,
62 };
63 return [(file_id, range)].iter().cloned().collect();
64 }
65 }
66
28 let source_root_id = db.file_source_root(file_id); 67 let source_root_id = db.file_source_root(file_id);
29 let source_root = db.source_root(source_root_id); 68 let source_root = db.source_root(source_root_id);
30 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<HashSet<_>>(); 69 let mut files = source_root.walk().map(|id| (id.into(), None)).collect::<HashSet<_>>();
31 70
32 if vis.syntax().to_string().as_str() == "pub(crate)" { 71 if vis.as_str() == "pub(crate)" {
33 return files; 72 return files;
34 } 73 }
35 if vis.syntax().to_string().as_str() == "pub" { 74 if vis.as_str() == "pub" {
36 let krate = self.container.krate(db).unwrap(); 75 let krate = self.container.krate(db).unwrap();
37 let crate_graph = db.crate_graph(); 76 let crate_graph = db.crate_graph();
38 77
@@ -49,7 +88,6 @@ impl NameDefinition {
49 88
50 return files; 89 return files;
51 } 90 }
52 // FIXME: "pub(super)", "pub(in path)"
53 } 91 }
54 92
55 let range = match module_src.ast { 93 let range = match module_src.ast {