aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-19 21:57:13 +0000
committerAleksey Kladov <[email protected]>2018-12-20 09:15:38 +0000
commit2caac99ef3731b39c484a23cdab00af94de7b645 (patch)
tree48a03c5fe30915e82045962d5ea22e1800693b4a
parent590bd5f849cf257f499f6c7aa8da3dc4ffc7578f (diff)
resolve paths across crates
-rw-r--r--crates/ra_hir/src/module/nameres.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/ra_hir/src/module/nameres.rs b/crates/ra_hir/src/module/nameres.rs
index dc05c7112..4161442b2 100644
--- a/crates/ra_hir/src/module/nameres.rs
+++ b/crates/ra_hir/src/module/nameres.rs
@@ -32,7 +32,7 @@ use crate::{
32 SourceItemId, SourceFileItemId, SourceFileItems, 32 SourceItemId, SourceFileItemId, SourceFileItems,
33 Path, PathKind, 33 Path, PathKind,
34 HirDatabase, Crate, 34 HirDatabase, Crate,
35 module::{ModuleId, ModuleTree}, 35 module::{Module, ModuleId, ModuleTree},
36}; 36};
37 37
38/// Item map is the result of the name resolution. Item map contains, for each 38/// Item map is the result of the name resolution. Item map contains, for each
@@ -357,14 +357,27 @@ where
357 curr = match def_id.loc(self.db) { 357 curr = match def_id.loc(self.db) {
358 DefLoc { 358 DefLoc {
359 kind: DefKind::Module, 359 kind: DefKind::Module,
360 module_id, 360 module_id: target_module_id,
361 source_root_id, 361 source_root_id,
362 .. 362 ..
363 } => { 363 } => {
364 if source_root_id == self.source_root { 364 if source_root_id == self.source_root {
365 module_id 365 target_module_id
366 } else { 366 } else {
367 // FIXME: across crates resolve 367 let module = Module::new(self.db, source_root_id, target_module_id)?;
368 let path = Path {
369 segments: import.path.segments[i + 1..].iter().cloned().collect(),
370 kind: PathKind::Crate,
371 };
372 if let Some(def_id) = module.resolve_path(self.db, path)? {
373 self.update(module_id, |items| {
374 let res = Resolution {
375 def_id: Some(def_id),
376 import: Some(ptr),
377 };
378 items.items.insert(name.clone(), res);
379 })
380 }
368 return Ok(()); 381 return Ok(());
369 } 382 }
370 } 383 }