aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-04-14 15:08:10 +0100
committerFlorian Diebold <[email protected]>2019-04-14 20:53:35 +0100
commit4f8a49f43cad086a656626c43062ff89b46f505a (patch)
treeb8275843aa56b922b6325b50be2aae063234cc2a /crates/ra_hir/src/source_binder.rs
parent88be6f32172813f53dae60d73c9f5deb0c3fb29f (diff)
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 :)
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs12
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
19use crate::{ 19use 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()