diff options
author | Florian Diebold <[email protected]> | 2019-01-07 12:44:54 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-01-12 14:01:19 +0000 |
commit | 082ef52bcb15d779c6aff78d9860d328bf7df9b2 (patch) | |
tree | a4a123ad491e15c8d17bdc815675d43bb33811b5 /crates/ra_hir/src/code_model_impl/module.rs | |
parent | e9e397e705ad0bec9775067b10109e35ebefc493 (diff) |
Implement basic inherent method resolution
Diffstat (limited to 'crates/ra_hir/src/code_model_impl/module.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/module.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs index e9ff06dc8..775dd6709 100644 --- a/crates/ra_hir/src/code_model_impl/module.rs +++ b/crates/ra_hir/src/code_model_impl/module.rs | |||
@@ -95,6 +95,21 @@ impl Module { | |||
95 | Module::from_module_id(db, loc.source_root_id, child_id).map(Some) | 95 | Module::from_module_id(db, loc.source_root_id, child_id).map(Some) |
96 | } | 96 | } |
97 | 97 | ||
98 | /// Iterates over all child modules. | ||
99 | pub fn children_impl(&self, db: &impl HirDatabase) -> Cancelable<impl Iterator<Item = Module>> { | ||
100 | // FIXME this should be implementable without collecting into a vec, but | ||
101 | // it's kind of hard since the iterator needs to keep a reference to the | ||
102 | // module tree. | ||
103 | let loc = self.def_id.loc(db); | ||
104 | let module_tree = db.module_tree(loc.source_root_id)?; | ||
105 | let children = loc | ||
106 | .module_id | ||
107 | .children(&module_tree) | ||
108 | .map(|(_, module_id)| Module::from_module_id(db, loc.source_root_id, module_id)) | ||
109 | .collect::<Cancelable<Vec<_>>>()?; | ||
110 | Ok(children.into_iter()) | ||
111 | } | ||
112 | |||
98 | pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> { | 113 | pub fn parent_impl(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> { |
99 | let loc = self.def_id.loc(db); | 114 | let loc = self.def_id.loc(db); |
100 | let module_tree = db.module_tree(loc.source_root_id)?; | 115 | let module_tree = db.module_tree(loc.source_root_id)?; |