diff options
author | Aleksey Kladov <[email protected]> | 2019-12-21 16:34:28 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-21 16:34:28 +0000 |
commit | 1a8f2aa024c6f1a5e9704c9cbd2e5a020debe2c2 (patch) | |
tree | 2d432efaf61acd53adc8cf0f78f4ed60f1fa758c /crates/ra_hir_def/src/nameres | |
parent | 02f79e37ca1c4a617a46b85bf897dffbf4abed9e (diff) |
Move LocalImportId
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/raw.rs | 16 |
2 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index c2db5472b..2b194f488 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -26,8 +26,7 @@ use crate::{ | |||
26 | path::{ModPath, PathKind}, | 26 | path::{ModPath, PathKind}, |
27 | per_ns::PerNs, | 27 | per_ns::PerNs, |
28 | AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, | 28 | AdtId, AstId, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, |
29 | LocalImportId, LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, | 29 | LocalModuleId, ModuleDefId, ModuleId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, |
30 | TypeAliasLoc, UnionLoc, | ||
31 | }; | 30 | }; |
32 | 31 | ||
33 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 32 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -93,7 +92,7 @@ impl PartialResolvedImport { | |||
93 | #[derive(Clone, Debug, Eq, PartialEq)] | 92 | #[derive(Clone, Debug, Eq, PartialEq)] |
94 | struct ImportDirective { | 93 | struct ImportDirective { |
95 | module_id: LocalModuleId, | 94 | module_id: LocalModuleId, |
96 | import_id: LocalImportId, | 95 | import_id: raw::Import, |
97 | import: raw::ImportData, | 96 | import: raw::ImportData, |
98 | status: PartialResolvedImport, | 97 | status: PartialResolvedImport, |
99 | } | 98 | } |
@@ -110,7 +109,7 @@ struct MacroDirective { | |||
110 | struct DefCollector<'a, DB> { | 109 | struct DefCollector<'a, DB> { |
111 | db: &'a DB, | 110 | db: &'a DB, |
112 | def_map: CrateDefMap, | 111 | def_map: CrateDefMap, |
113 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, LocalImportId)>>, | 112 | glob_imports: FxHashMap<LocalModuleId, Vec<(LocalModuleId, raw::Import)>>, |
114 | unresolved_imports: Vec<ImportDirective>, | 113 | unresolved_imports: Vec<ImportDirective>, |
115 | resolved_imports: Vec<ImportDirective>, | 114 | resolved_imports: Vec<ImportDirective>, |
116 | unexpanded_macros: Vec<MacroDirective>, | 115 | unexpanded_macros: Vec<MacroDirective>, |
@@ -442,7 +441,7 @@ where | |||
442 | fn update( | 441 | fn update( |
443 | &mut self, | 442 | &mut self, |
444 | module_id: LocalModuleId, | 443 | module_id: LocalModuleId, |
445 | import: Option<LocalImportId>, | 444 | import: Option<raw::Import>, |
446 | resolutions: &[(Name, Resolution)], | 445 | resolutions: &[(Name, Resolution)], |
447 | ) { | 446 | ) { |
448 | self.update_recursive(module_id, import, resolutions, 0) | 447 | self.update_recursive(module_id, import, resolutions, 0) |
@@ -451,7 +450,7 @@ where | |||
451 | fn update_recursive( | 450 | fn update_recursive( |
452 | &mut self, | 451 | &mut self, |
453 | module_id: LocalModuleId, | 452 | module_id: LocalModuleId, |
454 | import: Option<LocalImportId>, | 453 | import: Option<raw::Import>, |
455 | resolutions: &[(Name, Resolution)], | 454 | resolutions: &[(Name, Resolution)], |
456 | depth: usize, | 455 | depth: usize, |
457 | ) { | 456 | ) { |
@@ -462,7 +461,7 @@ where | |||
462 | let scope = &mut self.def_map.modules[module_id].scope; | 461 | let scope = &mut self.def_map.modules[module_id].scope; |
463 | let mut changed = false; | 462 | let mut changed = false; |
464 | for (name, res) in resolutions { | 463 | for (name, res) in resolutions { |
465 | changed |= scope.push_res(name.clone(), res, import); | 464 | changed |= scope.push_res(name.clone(), res, import.is_some()); |
466 | } | 465 | } |
467 | 466 | ||
468 | if !changed { | 467 | if !changed { |
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 73e57f1e5..1b83b2247 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs | |||
@@ -20,9 +20,7 @@ use ra_syntax::{ | |||
20 | }; | 20 | }; |
21 | use test_utils::tested_by; | 21 | use test_utils::tested_by; |
22 | 22 | ||
23 | use crate::{ | 23 | use crate::{attr::Attrs, db::DefDatabase, path::ModPath, FileAstId, HirFileId, InFile}; |
24 | attr::Attrs, db::DefDatabase, path::ModPath, FileAstId, HirFileId, InFile, LocalImportId, | ||
25 | }; | ||
26 | 24 | ||
27 | /// `RawItems` is a set of top-level items in a file (except for impls). | 25 | /// `RawItems` is a set of top-level items in a file (except for impls). |
28 | /// | 26 | /// |
@@ -31,7 +29,7 @@ use crate::{ | |||
31 | #[derive(Debug, Default, PartialEq, Eq)] | 29 | #[derive(Debug, Default, PartialEq, Eq)] |
32 | pub struct RawItems { | 30 | pub struct RawItems { |
33 | modules: Arena<Module, ModuleData>, | 31 | modules: Arena<Module, ModuleData>, |
34 | imports: Arena<LocalImportId, ImportData>, | 32 | imports: Arena<Import, ImportData>, |
35 | defs: Arena<Def, DefData>, | 33 | defs: Arena<Def, DefData>, |
36 | macros: Arena<Macro, MacroData>, | 34 | macros: Arena<Macro, MacroData>, |
37 | impls: Arena<Impl, ImplData>, | 35 | impls: Arena<Impl, ImplData>, |
@@ -73,9 +71,9 @@ impl Index<Module> for RawItems { | |||
73 | } | 71 | } |
74 | } | 72 | } |
75 | 73 | ||
76 | impl Index<LocalImportId> for RawItems { | 74 | impl Index<Import> for RawItems { |
77 | type Output = ImportData; | 75 | type Output = ImportData; |
78 | fn index(&self, idx: LocalImportId) -> &ImportData { | 76 | fn index(&self, idx: Import) -> &ImportData { |
79 | &self.imports[idx] | 77 | &self.imports[idx] |
80 | } | 78 | } |
81 | } | 79 | } |
@@ -110,7 +108,7 @@ pub(super) struct RawItem { | |||
110 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 108 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
111 | pub(super) enum RawItemKind { | 109 | pub(super) enum RawItemKind { |
112 | Module(Module), | 110 | Module(Module), |
113 | Import(LocalImportId), | 111 | Import(Import), |
114 | Def(Def), | 112 | Def(Def), |
115 | Macro(Macro), | 113 | Macro(Macro), |
116 | Impl(Impl), | 114 | Impl(Impl), |
@@ -126,6 +124,10 @@ pub(super) enum ModuleData { | |||
126 | Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, | 124 | Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, |
127 | } | 125 | } |
128 | 126 | ||
127 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
128 | pub(crate) struct Import(RawId); | ||
129 | impl_arena_id!(Import); | ||
130 | |||
129 | #[derive(Debug, Clone, PartialEq, Eq)] | 131 | #[derive(Debug, Clone, PartialEq, Eq)] |
130 | pub struct ImportData { | 132 | pub struct ImportData { |
131 | pub(super) path: ModPath, | 133 | pub(super) path: ModPath, |