mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
resolve paths across crates
This commit is contained in:
parent
590bd5f849
commit
2caac99ef3
1 changed files with 17 additions and 4 deletions
|
@ -32,7 +32,7 @@ use crate::{
|
||||||
SourceItemId, SourceFileItemId, SourceFileItems,
|
SourceItemId, SourceFileItemId, SourceFileItems,
|
||||||
Path, PathKind,
|
Path, PathKind,
|
||||||
HirDatabase, Crate,
|
HirDatabase, Crate,
|
||||||
module::{ModuleId, ModuleTree},
|
module::{Module, ModuleId, ModuleTree},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Item map is the result of the name resolution. Item map contains, for each
|
/// Item map is the result of the name resolution. Item map contains, for each
|
||||||
|
@ -357,14 +357,27 @@ where
|
||||||
curr = match def_id.loc(self.db) {
|
curr = match def_id.loc(self.db) {
|
||||||
DefLoc {
|
DefLoc {
|
||||||
kind: DefKind::Module,
|
kind: DefKind::Module,
|
||||||
module_id,
|
module_id: target_module_id,
|
||||||
source_root_id,
|
source_root_id,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if source_root_id == self.source_root {
|
if source_root_id == self.source_root {
|
||||||
module_id
|
target_module_id
|
||||||
} else {
|
} else {
|
||||||
// FIXME: across crates resolve
|
let module = Module::new(self.db, source_root_id, target_module_id)?;
|
||||||
|
let path = Path {
|
||||||
|
segments: import.path.segments[i + 1..].iter().cloned().collect(),
|
||||||
|
kind: PathKind::Crate,
|
||||||
|
};
|
||||||
|
if let Some(def_id) = module.resolve_path(self.db, path)? {
|
||||||
|
self.update(module_id, |items| {
|
||||||
|
let res = Resolution {
|
||||||
|
def_id: Some(def_id),
|
||||||
|
import: Some(ptr),
|
||||||
|
};
|
||||||
|
items.items.insert(name.clone(), res);
|
||||||
|
})
|
||||||
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue