mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Obtain ModuleId
's DefMap
through a method
This commit is contained in:
parent
a5322e3d5b
commit
ce29730bc7
14 changed files with 43 additions and 32 deletions
|
@ -31,6 +31,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
|
||||
let _p = profile::span("SourceBinder::to_module_def");
|
||||
let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
|
||||
// FIXME: inner items
|
||||
let crate_def_map = self.db.crate_def_map(crate_id);
|
||||
let local_id = crate_def_map.modules_for_file(file).next()?;
|
||||
Some((crate_id, local_id))
|
||||
|
@ -60,7 +61,7 @@ impl SourceToDefCtx<'_, '_> {
|
|||
}?;
|
||||
|
||||
let child_name = src.value.name()?.as_name();
|
||||
let def_map = self.db.crate_def_map(parent_module.krate);
|
||||
let def_map = parent_module.def_map(self.db.upcast());
|
||||
let child_id = *def_map[parent_module.local_id].children.get(&child_name)?;
|
||||
Some(ModuleId { krate: parent_module.krate, local_id: child_id })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue