aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/module.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-31 14:15:34 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-31 14:15:34 +0000
commit2a65020442142b68b32c0a97672faeeba5ff399e (patch)
tree32791da6860ea906017a8d30157baedc08bee484 /crates/ra_hir/src/module.rs
parent700b334a28b73133a25416319475eafe3ec11f90 (diff)
parent05daa86634b41aa3f311a1ac0b02bf7fed7ed569 (diff)
Merge #165
165: Make modules with tests runnable r=farodin91 a=farodin91 Fixes #154 I having problems to traverse the path to module. The main problem is that module_tree only supports `FileId` and not `Module` in files. Any idea? I need to clean up the code a bit later. Co-authored-by: Jan Jansen <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/module.rs')
-rw-r--r--crates/ra_hir/src/module.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/crates/ra_hir/src/module.rs b/crates/ra_hir/src/module.rs
index 24c346984..87e30191f 100644
--- a/crates/ra_hir/src/module.rs
+++ b/crates/ra_hir/src/module.rs
@@ -75,6 +75,11 @@ impl Module {
75 Some(Crate::new(crate_id)) 75 Some(Crate::new(crate_id))
76 } 76 }
77 77
78 /// Returns the all modulkes on the way to the root.
79 pub fn path_to_root(&self) -> Vec<Module> {
80 generate(Some(self.clone()), move |it| it.parent()).collect::<Vec<Module>>()
81 }
82
78 /// The root of the tree this module is part of 83 /// The root of the tree this module is part of
79 pub fn crate_root(&self) -> Module { 84 pub fn crate_root(&self) -> Module {
80 let root_id = self.module_id.crate_root(&self.tree); 85 let root_id = self.module_id.crate_root(&self.tree);