diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 4a111aba5..e34ddf24a 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -37,7 +37,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
37 | } | 37 | } |
38 | 38 | ||
39 | fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { | 39 | fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { |
40 | receiver.iterate_methods(ctx.db, |_ty, func| { | 40 | ctx.analyzer.iterate_method_candidates(ctx.db, receiver, None, |_ty, func| { |
41 | let sig = func.signature(ctx.db); | 41 | let sig = func.signature(ctx.db); |
42 | if sig.has_self_param() { | 42 | if sig.has_self_param() { |
43 | acc.add_function(ctx, func); | 43 | acc.add_function(ctx, func); |
@@ -196,6 +196,32 @@ mod tests { | |||
196 | } | 196 | } |
197 | 197 | ||
198 | #[test] | 198 | #[test] |
199 | fn test_trait_method_completion() { | ||
200 | assert_debug_snapshot_matches!( | ||
201 | do_ref_completion( | ||
202 | r" | ||
203 | struct A {} | ||
204 | trait Trait { fn the_method(&self); } | ||
205 | impl Trait for A {} | ||
206 | fn foo(a: A) { | ||
207 | a.<|> | ||
208 | } | ||
209 | ", | ||
210 | ), | ||
211 | @r###"[ | ||
212 | CompletionItem { | ||
213 | label: "the_method", | ||
214 | source_range: [151; 151), | ||
215 | delete: [151; 151), | ||
216 | insert: "the_method()$0", | ||
217 | kind: Method, | ||
218 | detail: "fn the_method(&self)" | ||
219 | } | ||
220 | ]"### | ||
221 | ); | ||
222 | } | ||
223 | |||
224 | #[test] | ||
199 | fn test_no_non_self_method() { | 225 | fn test_no_non_self_method() { |
200 | assert_debug_snapshot_matches!( | 226 | assert_debug_snapshot_matches!( |
201 | do_ref_completion( | 227 | do_ref_completion( |