aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/module
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/module')
-rw-r--r--crates/ra_hir/src/module/mod.rs17
-rw-r--r--crates/ra_hir/src/module/nameres.rs23
2 files changed, 28 insertions, 12 deletions
diff --git a/crates/ra_hir/src/module/mod.rs b/crates/ra_hir/src/module/mod.rs
index fa9ee94eb..08ce7c8d1 100644
--- a/crates/ra_hir/src/module/mod.rs
+++ b/crates/ra_hir/src/module/mod.rs
@@ -14,7 +14,7 @@ use ra_db::{SourceRootId, FileId, FilePosition, Cancelable};
14use relative_path::RelativePathBuf; 14use relative_path::RelativePathBuf;
15 15
16use crate::{ 16use crate::{
17 DefLoc, DefId, Path, PathKind, HirDatabase, SourceItemId, SourceFileItemId, 17 DefKind, DefLoc, DefId, Path, PathKind, HirDatabase, SourceItemId, SourceFileItemId,
18 arena::{Arena, Id}, 18 arena::{Arena, Id},
19}; 19};
20 20
@@ -127,9 +127,11 @@ impl Module {
127 } 127 }
128 128
129 pub fn def_id(&self, db: &impl HirDatabase) -> DefId { 129 pub fn def_id(&self, db: &impl HirDatabase) -> DefId {
130 let def_loc = DefLoc::Module { 130 let def_loc = DefLoc {
131 id: self.module_id, 131 kind: DefKind::Module,
132 source_root: self.source_root_id, 132 source_root_id: self.source_root_id,
133 module_id: self.module_id,
134 source_item_id: self.module_id.source(&self.tree).0,
133 }; 135 };
134 def_loc.id(db) 136 def_loc.id(db)
135 } 137 }
@@ -161,7 +163,12 @@ impl Module {
161 let segments = path.segments; 163 let segments = path.segments;
162 for name in segments.iter() { 164 for name in segments.iter() {
163 let module = match curr.loc(db) { 165 let module = match curr.loc(db) {
164 DefLoc::Module { id, source_root } => Module::new(db, source_root, id)?, 166 DefLoc {
167 kind: DefKind::Module,
168 source_root_id,
169 module_id,
170 ..
171 } => Module::new(db, source_root_id, module_id)?,
165 _ => return Ok(None), 172 _ => return Ok(None),
166 }; 173 };
167 let scope = module.scope(db)?; 174 let scope = module.scope(db)?;
diff --git a/crates/ra_hir/src/module/nameres.rs b/crates/ra_hir/src/module/nameres.rs
index 8529e16b3..c2b380a80 100644
--- a/crates/ra_hir/src/module/nameres.rs
+++ b/crates/ra_hir/src/module/nameres.rs
@@ -28,7 +28,7 @@ use ra_db::SourceRootId;
28 28
29use crate::{ 29use crate::{
30 Cancelable, FileId, 30 Cancelable, FileId,
31 DefId, DefLoc, 31 DefId, DefLoc, DefKind,
32 SourceItemId, SourceFileItemId, SourceFileItems, 32 SourceItemId, SourceFileItemId, SourceFileItems,
33 Path, PathKind, 33 Path, PathKind,
34 HirDatabase, 34 HirDatabase,
@@ -247,7 +247,10 @@ where
247 // handle submodules separatelly 247 // handle submodules separatelly
248 continue; 248 continue;
249 } 249 }
250 let def_loc = DefLoc::Item { 250 let def_loc = DefLoc {
251 kind: DefKind::Item,
252 source_root_id: self.source_root,
253 module_id,
251 source_item_id: SourceItemId { 254 source_item_id: SourceItemId {
252 file_id, 255 file_id,
253 item_id: item.id, 256 item_id: item.id,
@@ -261,10 +264,12 @@ where
261 module_items.items.insert(item.name.clone(), resolution); 264 module_items.items.insert(item.name.clone(), resolution);
262 } 265 }
263 266
264 for (name, mod_id) in module_id.children(&self.module_tree) { 267 for (name, module_id) in module_id.children(&self.module_tree) {
265 let def_loc = DefLoc::Module { 268 let def_loc = DefLoc {
266 id: mod_id, 269 kind: DefKind::Module,
267 source_root: self.source_root, 270 source_root_id: self.source_root,
271 module_id,
272 source_item_id: module_id.source(&self.module_tree).0,
268 }; 273 };
269 let def_id = def_loc.id(self.db); 274 let def_id = def_loc.id(self.db);
270 let resolution = Resolution { 275 let resolution = Resolution {
@@ -316,7 +321,11 @@ where
316 321
317 if !is_last { 322 if !is_last {
318 curr = match def_id.loc(self.db) { 323 curr = match def_id.loc(self.db) {
319 DefLoc::Module { id, .. } => id, 324 DefLoc {
325 kind: DefKind::Module,
326 module_id,
327 ..
328 } => module_id,
320 _ => return, 329 _ => return,
321 } 330 }
322 } else { 331 } else {