diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 51df44d2f..a80c4f8e9 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -677,9 +677,13 @@ where | |||
677 | let is_macro_use = attrs.by_key("macro_use").exists(); | 677 | let is_macro_use = attrs.by_key("macro_use").exists(); |
678 | match module { | 678 | match module { |
679 | // inline module, just recurse | 679 | // inline module, just recurse |
680 | raw::ModuleData::Definition { name, items, ast_id } => { | 680 | raw::ModuleData::Definition { name, visibility, items, ast_id } => { |
681 | let module_id = | 681 | let module_id = self.push_child_module( |
682 | self.push_child_module(name.clone(), AstId::new(self.file_id, *ast_id), None); | 682 | name.clone(), |
683 | AstId::new(self.file_id, *ast_id), | ||
684 | None, | ||
685 | &visibility, | ||
686 | ); | ||
683 | 687 | ||
684 | ModCollector { | 688 | ModCollector { |
685 | def_collector: &mut *self.def_collector, | 689 | def_collector: &mut *self.def_collector, |
@@ -694,7 +698,7 @@ where | |||
694 | } | 698 | } |
695 | } | 699 | } |
696 | // out of line module, resolve, parse and recurse | 700 | // out of line module, resolve, parse and recurse |
697 | raw::ModuleData::Declaration { name, ast_id } => { | 701 | raw::ModuleData::Declaration { name, visibility, ast_id } => { |
698 | let ast_id = AstId::new(self.file_id, *ast_id); | 702 | let ast_id = AstId::new(self.file_id, *ast_id); |
699 | match self.mod_dir.resolve_declaration( | 703 | match self.mod_dir.resolve_declaration( |
700 | self.def_collector.db, | 704 | self.def_collector.db, |
@@ -703,7 +707,12 @@ where | |||
703 | path_attr, | 707 | path_attr, |
704 | ) { | 708 | ) { |
705 | Ok((file_id, mod_dir)) => { | 709 | Ok((file_id, mod_dir)) => { |
706 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); | 710 | let module_id = self.push_child_module( |
711 | name.clone(), | ||
712 | ast_id, | ||
713 | Some(file_id), | ||
714 | &visibility, | ||
715 | ); | ||
707 | let raw_items = self.def_collector.db.raw_items(file_id.into()); | 716 | let raw_items = self.def_collector.db.raw_items(file_id.into()); |
708 | ModCollector { | 717 | ModCollector { |
709 | def_collector: &mut *self.def_collector, | 718 | def_collector: &mut *self.def_collector, |
@@ -734,7 +743,13 @@ where | |||
734 | name: Name, | 743 | name: Name, |
735 | declaration: AstId<ast::Module>, | 744 | declaration: AstId<ast::Module>, |
736 | definition: Option<FileId>, | 745 | definition: Option<FileId>, |
746 | visibility: &crate::visibility::Visibility, | ||
737 | ) -> LocalModuleId { | 747 | ) -> LocalModuleId { |
748 | let vis = self | ||
749 | .def_collector | ||
750 | .def_map | ||
751 | .resolve_visibility(self.def_collector.db, self.module_id, visibility) | ||
752 | .unwrap_or(ResolvedVisibility::Public); | ||
738 | let modules = &mut self.def_collector.def_map.modules; | 753 | let modules = &mut self.def_collector.def_map.modules; |
739 | let res = modules.alloc(ModuleData::default()); | 754 | let res = modules.alloc(ModuleData::default()); |
740 | modules[res].parent = Some(self.module_id); | 755 | modules[res].parent = Some(self.module_id); |
@@ -745,7 +760,6 @@ where | |||
745 | modules[self.module_id].children.insert(name.clone(), res); | 760 | modules[self.module_id].children.insert(name.clone(), res); |
746 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; | 761 | let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res }; |
747 | let def: ModuleDefId = module.into(); | 762 | let def: ModuleDefId = module.into(); |
748 | let vis = ResolvedVisibility::Public; // TODO handle module visibility | ||
749 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); | 763 | self.def_collector.def_map.modules[self.module_id].scope.define_def(def); |
750 | self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis); | 764 | self.def_collector.update(self.module_id, &[(name, PerNs::from_def(def, vis))], vis); |
751 | res | 765 | res |