aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/descriptors/module
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-20 20:36:53 +0000
committerAleksey Kladov <[email protected]>2018-11-20 20:36:53 +0000
commitaab71bff8eb89fb65f4aba8e90df2ae586ecb0a6 (patch)
tree3056841cd667b971942c57be6b8822c4c1ce89e6 /crates/ra_analysis/src/descriptors/module
parentcc8163439f65138c0945c37d6bddc64ced2d2143 (diff)
move to method
Diffstat (limited to 'crates/ra_analysis/src/descriptors/module')
-rw-r--r--crates/ra_analysis/src/descriptors/module/nameres.rs63
1 files changed, 30 insertions, 33 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs
index 6ff8e61f5..44059e5c3 100644
--- a/crates/ra_analysis/src/descriptors/module/nameres.rs
+++ b/crates/ra_analysis/src/descriptors/module/nameres.rs
@@ -209,9 +209,9 @@ impl ModuleItem {
209 209
210struct Resolver<'a, DB> { 210struct Resolver<'a, DB> {
211 db: &'a DB, 211 db: &'a DB,
212 input: &'a FxHashMap<ModuleId, InputModuleItems>,
212 source_root: SourceRootId, 213 source_root: SourceRootId,
213 module_tree: Arc<ModuleTree>, 214 module_tree: Arc<ModuleTree>,
214 input: FxHashMap<ModuleId, InputModuleItems>,
215 result: ItemMap, 215 result: ItemMap,
216} 216}
217 217
@@ -221,47 +221,44 @@ where
221{ 221{
222 fn resolve(&mut self) { 222 fn resolve(&mut self) {
223 for (&module_id, items) in self.input.iter() { 223 for (&module_id, items) in self.input.iter() {
224 populate_module( 224 self.populate_module(
225 self.db,
226 self.source_root,
227 &*self.module_tree,
228 &mut self.result,
229 module_id, 225 module_id,
230 items, 226 items,
231 ) 227 )
232 } 228 }
233 } 229 }
234}
235 230
236fn populate_module( 231 fn populate_module(
237 db: &impl DescriptorDatabase, 232 &mut self,
238 source_root: SourceRootId, 233 module_id: ModuleId,
239 module_tree: &ModuleTree, 234 input: &InputModuleItems,
240 item_map: &mut ItemMap, 235 ) {
241 module_id: ModuleId, 236 let file_id = module_id.source(&self.module_tree).file_id();
242 input: &InputModuleItems,
243) {
244 let file_id = module_id.source(module_tree).file_id();
245 237
246 let mut module_items = ModuleItems::default(); 238 let mut module_items = ModuleItems::default();
247 239
248 for item in input.items.iter() { 240 for item in input.items.iter() {
249 if item.kind == MODULE { 241 if item.kind == MODULE {
250 // handle submodules separatelly 242 // handle submodules separatelly
251 continue; 243 continue;
244 }
245 let ptr = item.ptr.into_global(file_id);
246 let def_loc = DefLoc::Item { ptr };
247 let def_id = self.db.id_maps().def_id(def_loc);
248 module_items.items.insert(item.name.clone(), def_id);
252 } 249 }
253 let ptr = item.ptr.into_global(file_id);
254 let def_loc = DefLoc::Item { ptr };
255 let def_id = db.id_maps().def_id(def_loc);
256 module_items.items.insert(item.name.clone(), def_id);
257 }
258 250
259 for (name, mod_id) in module_id.children(module_tree) { 251 for (name, mod_id) in module_id.children(&self.module_tree) {
260 let def_loc = DefLoc::Module { 252 let def_loc = DefLoc::Module {
261 id: mod_id, 253 id: mod_id,
262 source_root, 254 source_root: self.source_root,
263 }; 255 };
264 } 256 let def_id = self.db.id_maps().def_id(def_loc);
257 module_items.items.insert(name, def_id);
258 }
265 259
266 item_map.per_module.insert(module_id, module_items); 260 self.result.per_module.insert(module_id, module_items);
261 }
267} 262}
263
264