From 4f8a49f43cad086a656626c43062ff89b46f505a Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 14 Apr 2019 16:08:10 +0200 Subject: Refactor method candidate generation a bit 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 :) --- crates/ra_hir/src/source_binder.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/source_binder.rs') 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::{ use crate::{ HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, - AsName, Module, HirFileId, Crate, Trait, Resolver, + AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, ids::LocationCtx, expr, AstId @@ -343,6 +343,16 @@ impl SourceAnalyzer { .collect() } + pub fn iterate_method_candidates( + &self, + db: &impl HirDatabase, + ty: Ty, + name: Option<&Name>, + callback: impl FnMut(&Ty, Function) -> Option, + ) -> Option { + ty.iterate_method_candidates(db, &self.resolver, name, callback) + } + #[cfg(test)] pub(crate) fn body_source_map(&self) -> Arc { self.body_source_map.clone().unwrap() -- cgit v1.2.3