mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
move to method
This commit is contained in:
parent
cc8163439f
commit
aab71bff8e
1 changed files with 30 additions and 33 deletions
|
@ -209,9 +209,9 @@ impl ModuleItem {
|
||||||
|
|
||||||
struct Resolver<'a, DB> {
|
struct Resolver<'a, DB> {
|
||||||
db: &'a DB,
|
db: &'a DB,
|
||||||
|
input: &'a FxHashMap<ModuleId, InputModuleItems>,
|
||||||
source_root: SourceRootId,
|
source_root: SourceRootId,
|
||||||
module_tree: Arc<ModuleTree>,
|
module_tree: Arc<ModuleTree>,
|
||||||
input: FxHashMap<ModuleId, InputModuleItems>,
|
|
||||||
result: ItemMap,
|
result: ItemMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,27 +221,19 @@ where
|
||||||
{
|
{
|
||||||
fn resolve(&mut self) {
|
fn resolve(&mut self) {
|
||||||
for (&module_id, items) in self.input.iter() {
|
for (&module_id, items) in self.input.iter() {
|
||||||
populate_module(
|
self.populate_module(
|
||||||
self.db,
|
|
||||||
self.source_root,
|
|
||||||
&*self.module_tree,
|
|
||||||
&mut self.result,
|
|
||||||
module_id,
|
module_id,
|
||||||
items,
|
items,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn populate_module(
|
fn populate_module(
|
||||||
db: &impl DescriptorDatabase,
|
&mut self,
|
||||||
source_root: SourceRootId,
|
|
||||||
module_tree: &ModuleTree,
|
|
||||||
item_map: &mut ItemMap,
|
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
input: &InputModuleItems,
|
input: &InputModuleItems,
|
||||||
) {
|
) {
|
||||||
let file_id = module_id.source(module_tree).file_id();
|
let file_id = module_id.source(&self.module_tree).file_id();
|
||||||
|
|
||||||
let mut module_items = ModuleItems::default();
|
let mut module_items = ModuleItems::default();
|
||||||
|
|
||||||
|
@ -252,16 +244,21 @@ fn populate_module(
|
||||||
}
|
}
|
||||||
let ptr = item.ptr.into_global(file_id);
|
let ptr = item.ptr.into_global(file_id);
|
||||||
let def_loc = DefLoc::Item { ptr };
|
let def_loc = DefLoc::Item { ptr };
|
||||||
let def_id = db.id_maps().def_id(def_loc);
|
let def_id = self.db.id_maps().def_id(def_loc);
|
||||||
module_items.items.insert(item.name.clone(), def_id);
|
module_items.items.insert(item.name.clone(), def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (name, mod_id) in module_id.children(module_tree) {
|
for (name, mod_id) in module_id.children(&self.module_tree) {
|
||||||
let def_loc = DefLoc::Module {
|
let def_loc = DefLoc::Module {
|
||||||
id: mod_id,
|
id: mod_id,
|
||||||
source_root,
|
source_root: self.source_root,
|
||||||
};
|
};
|
||||||
|
let def_id = self.db.id_maps().def_id(def_loc);
|
||||||
|
module_items.items.insert(name, def_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
item_map.per_module.insert(module_id, module_items);
|
self.result.per_module.insert(module_id, module_items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue