diff options
author | Laurențiu Nicola <[email protected]> | 2019-02-12 08:33:23 +0000 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2019-02-12 10:51:01 +0000 |
commit | 7e8527f74831b37c5757ea6b25e40bcbb61bb6d4 (patch) | |
tree | e7bddef556f430d31903a54fced0df760673a0e8 /crates/ra_hir | |
parent | 37148000dcd43e5ccba4737a3e379f1ae6861893 (diff) |
Implement completion for associated items
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index b8e911b88..e81bd3e06 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -174,4 +174,24 @@ impl Ty { | |||
174 | } | 174 | } |
175 | None | 175 | None |
176 | } | 176 | } |
177 | |||
178 | // This would be nicer if it just returned an iterator, but that runs into | ||
179 | // lifetime problems, because we need to borrow temp `CrateImplBlocks`. | ||
180 | pub fn iterate_impl_items<T>( | ||
181 | self, | ||
182 | db: &impl HirDatabase, | ||
183 | mut callback: impl FnMut(ImplItem) -> Option<T>, | ||
184 | ) -> Option<T> { | ||
185 | let krate = def_crate(db, &self)?; | ||
186 | let impls = db.impls_in_crate(krate); | ||
187 | |||
188 | for (_, impl_block) in impls.lookup_impl_blocks(db, &self) { | ||
189 | for item in impl_block.items() { | ||
190 | if let Some(result) = callback(*item) { | ||
191 | return Some(result); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | None | ||
196 | } | ||
177 | } | 197 | } |