From b2a6c1736295a5fffa5ac0d0fee835cdc719ada3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Mar 2019 13:14:54 +0300 Subject: remove lower module --- crates/ra_hir/src/nameres/crate_def_map/collector.rs | 9 ++++++++- crates/ra_hir/src/nameres/crate_def_map/raw.rs | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/nameres/crate_def_map') diff --git a/crates/ra_hir/src/nameres/crate_def_map/collector.rs b/crates/ra_hir/src/nameres/crate_def_map/collector.rs index 8b727e2c9..0f500ce42 100644 --- a/crates/ra_hir/src/nameres/crate_def_map/collector.rs +++ b/crates/ra_hir/src/nameres/crate_def_map/collector.rs @@ -224,7 +224,7 @@ where } } let resolution = Resolution { def, import: Some(import_id) }; - self.update(module_id, None, &[(name, resolution)]); + self.update(module_id, Some(import_id), &[(name, resolution)]); } } @@ -262,6 +262,13 @@ where existing.import = import.or(res.import); changed = true; } + if existing.def.is_none() + && res.def.is_none() + && existing.import.is_none() + && res.import.is_some() + { + existing.import = res.import; + } } if !changed { return; diff --git a/crates/ra_hir/src/nameres/crate_def_map/raw.rs b/crates/ra_hir/src/nameres/crate_def_map/raw.rs index f064f722c..dca86e394 100644 --- a/crates/ra_hir/src/nameres/crate_def_map/raw.rs +++ b/crates/ra_hir/src/nameres/crate_def_map/raw.rs @@ -14,6 +14,7 @@ use ra_syntax::{ use crate::{ PersistentHirDatabase, Name, AsName, Path, HirFileId, ids::{SourceFileItemId, SourceFileItems}, + nameres::lower::ImportSourceMap, }; #[derive(Debug, Default, PartialEq, Eq)] @@ -31,13 +32,21 @@ impl RawItems { db: &impl PersistentHirDatabase, file_id: FileId, ) -> Arc { + db.raw_items_with_source_map(file_id).0 + } + + pub(crate) fn raw_items_with_source_map_query( + db: &impl PersistentHirDatabase, + file_id: FileId, + ) -> (Arc, Arc) { let mut collector = RawItemsCollector { raw_items: RawItems::default(), source_file_items: db.file_items(file_id.into()), + source_map: ImportSourceMap::default(), }; let source_file = db.parse(file_id); collector.process_module(None, &*source_file); - Arc::new(collector.raw_items) + (Arc::new(collector.raw_items), Arc::new(collector.source_map)) } pub(crate) fn items(&self) -> &[RawItem] { @@ -51,6 +60,7 @@ impl RawItems { let mut collector = RawItemsCollector { raw_items: RawItems::default(), source_file_items: Arc::new(source_file_items), + source_map: ImportSourceMap::default(), }; collector.process_module(None, &*source_file); collector.raw_items @@ -144,6 +154,7 @@ pub(crate) struct MacroData { struct RawItemsCollector { raw_items: RawItems, source_file_items: Arc, + source_map: ImportSourceMap, } impl RawItemsCollector { @@ -227,6 +238,9 @@ impl RawItemsCollector { is_prelude, is_extern_crate: false, }); + if let Some(segment) = segment { + self.source_map.insert(import, segment) + } self.push_item(current_module, RawItem::Import(import)) }) } -- cgit v1.2.3