From d853e9b1ef54be586d8e5b0c43519b5f74e090ef Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 23 Jan 2019 17:52:26 +0300 Subject: better names --- crates/ra_hir/src/module_tree.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs index 47c14af35..c9a15967c 100644 --- a/crates/ra_hir/src/module_tree.rs +++ b/crates/ra_hir/src/module_tree.rs @@ -131,6 +131,17 @@ impl ModuleTree { let (res, _) = self.mods.iter().find(|(_, m)| m.source == source)?; Some(res) } + + fn alloc_mod(&mut self, data: ModuleData) -> ModuleId { + self.mods.alloc(data) + } + + fn alloc_link(&mut self, data: LinkData) -> LinkId { + let owner = data.owner; + let id = self.links.alloc(data); + self.mods[owner].children.push(id); + id + } } impl ModuleId { @@ -198,18 +209,6 @@ impl LinkId { } } -impl ModuleTree { - fn push_mod(&mut self, data: ModuleData) -> ModuleId { - self.mods.alloc(data) - } - fn push_link(&mut self, data: LinkData) -> LinkId { - let owner = data.owner; - let id = self.links.alloc(data); - self.mods[owner].children.push(id); - id - } -} - fn modules(root: &impl ast::ModuleItemOwner) -> impl Iterator { root.items() .filter_map(|item| match item.kind() { @@ -266,13 +265,13 @@ fn build_subtree( source: SourceItemId, ) -> ModuleId { visited.insert(source); - let id = tree.push_mod(ModuleData { + let id = tree.alloc_mod(ModuleData { source, parent, children: Vec::new(), }); for sub in db.submodules(source).iter() { - let link = tree.push_link(LinkData { + let link = tree.alloc_link(LinkData { source: sub.source, name: sub.name.clone(), owner: id, -- cgit v1.2.3