diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-14 20:55:18 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-14 20:55:18 +0100 |
commit | e1a2649aff0a9387fb14646a56cb652061bc42ec (patch) | |
tree | b8275843aa56b922b6325b50be2aae063234cc2a /crates/ra_hir/src/source_binder.rs | |
parent | 88be6f32172813f53dae60d73c9f5deb0c3fb29f (diff) | |
parent | 4f8a49f43cad086a656626c43062ff89b46f505a (diff) |
Merge #1144
1144: Refactor method candidate generation a bit r=flodiebold a=flodiebold
This fixes the order in which candidates are chosen a bit (not completely though, as the ignored test demonstrates), and makes autoderef work with trait methods.
As a side effect, this also makes completion of trait methods work :)
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index bd035ced9..f1bb13bc6 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -18,7 +18,7 @@ use ra_syntax::{ | |||
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, | 20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, |
21 | AsName, Module, HirFileId, Crate, Trait, Resolver, | 21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, |
22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, | 22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, |
23 | ids::LocationCtx, | 23 | ids::LocationCtx, |
24 | expr, AstId | 24 | expr, AstId |
@@ -343,6 +343,16 @@ impl SourceAnalyzer { | |||
343 | .collect() | 343 | .collect() |
344 | } | 344 | } |
345 | 345 | ||
346 | pub fn iterate_method_candidates<T>( | ||
347 | &self, | ||
348 | db: &impl HirDatabase, | ||
349 | ty: Ty, | ||
350 | name: Option<&Name>, | ||
351 | callback: impl FnMut(&Ty, Function) -> Option<T>, | ||
352 | ) -> Option<T> { | ||
353 | ty.iterate_method_candidates(db, &self.resolver, name, callback) | ||
354 | } | ||
355 | |||
346 | #[cfg(test)] | 356 | #[cfg(test)] |
347 | pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> { | 357 | pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> { |
348 | self.body_source_map.clone().unwrap() | 358 | self.body_source_map.clone().unwrap() |