mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Move CrateDefMap to hir_def
This commit is contained in:
parent
f9f1effd01
commit
ba2efca2bb
23 changed files with 824 additions and 731 deletions
|
@ -149,14 +149,20 @@ impl Module {
|
|||
ModuleSource::SourceFile(_) => None,
|
||||
};
|
||||
|
||||
db.relevant_crates(src.file_id.original_file(db))
|
||||
.iter()
|
||||
.map(|&crate_id| Crate { crate_id })
|
||||
.find_map(|krate| {
|
||||
let def_map = db.crate_def_map(krate);
|
||||
let module_id = def_map.find_module_by_source(src.file_id, decl_id)?;
|
||||
Some(Module::new(krate, module_id))
|
||||
})
|
||||
db.relevant_crates(src.file_id.original_file(db)).iter().find_map(|&crate_id| {
|
||||
let def_map = db.crate_def_map(crate_id);
|
||||
|
||||
let (module_id, _module_data) =
|
||||
def_map.modules.iter().find(|(_module_id, module_data)| {
|
||||
if decl_id.is_some() {
|
||||
module_data.declaration == decl_id
|
||||
} else {
|
||||
module_data.definition.map(|it| it.into()) == Some(src.file_id)
|
||||
}
|
||||
})?;
|
||||
|
||||
Some(Module::new(Crate { crate_id }, module_id))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue