diff options
Diffstat (limited to 'crates/ra_ide/src/completion/complete_dot.rs')
-rw-r--r-- | crates/ra_ide/src/completion/complete_dot.rs | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index f275305e2..f07611d88 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs | |||
@@ -70,7 +70,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T | |||
70 | 70 | ||
71 | #[cfg(test)] | 71 | #[cfg(test)] |
72 | mod tests { | 72 | mod tests { |
73 | use crate::completion::{do_completion, CompletionItem, CompletionKind}; | 73 | use crate::completion::{test_utils::do_completion, CompletionItem, CompletionKind}; |
74 | use insta::assert_debug_snapshot; | 74 | use insta::assert_debug_snapshot; |
75 | 75 | ||
76 | fn do_ref_completion(code: &str) -> Vec<CompletionItem> { | 76 | fn do_ref_completion(code: &str) -> Vec<CompletionItem> { |
@@ -402,6 +402,38 @@ mod tests { | |||
402 | } | 402 | } |
403 | 403 | ||
404 | #[test] | 404 | #[test] |
405 | fn completes_trait_method_from_other_module() { | ||
406 | assert_debug_snapshot!( | ||
407 | do_ref_completion( | ||
408 | r" | ||
409 | struct A {} | ||
410 | mod m { | ||
411 | pub trait Trait { fn the_method(&self); } | ||
412 | } | ||
413 | use m::Trait; | ||
414 | impl Trait for A {} | ||
415 | fn foo(a: A) { | ||
416 | a.<|> | ||
417 | } | ||
418 | ", | ||
419 | ), | ||
420 | @r###" | ||
421 | [ | ||
422 | CompletionItem { | ||
423 | label: "the_method()", | ||
424 | source_range: [219; 219), | ||
425 | delete: [219; 219), | ||
426 | insert: "the_method()$0", | ||
427 | kind: Method, | ||
428 | lookup: "the_method", | ||
429 | detail: "fn the_method(&self)", | ||
430 | }, | ||
431 | ] | ||
432 | "### | ||
433 | ); | ||
434 | } | ||
435 | |||
436 | #[test] | ||
405 | fn test_no_non_self_method() { | 437 | fn test_no_non_self_method() { |
406 | assert_debug_snapshot!( | 438 | assert_debug_snapshot!( |
407 | do_ref_completion( | 439 | do_ref_completion( |
@@ -718,4 +750,35 @@ mod tests { | |||
718 | "### | 750 | "### |
719 | ); | 751 | ); |
720 | } | 752 | } |
753 | |||
754 | #[test] | ||
755 | fn test_method_completion_3547() { | ||
756 | assert_debug_snapshot!( | ||
757 | do_ref_completion( | ||
758 | r" | ||
759 | struct HashSet<T> {} | ||
760 | impl<T> HashSet<T> { | ||
761 | pub fn the_method(&self) {} | ||
762 | } | ||
763 | fn foo() { | ||
764 | let s: HashSet<_>; | ||
765 | s.<|> | ||
766 | } | ||
767 | ", | ||
768 | ), | ||
769 | @r###" | ||
770 | [ | ||
771 | CompletionItem { | ||
772 | label: "the_method()", | ||
773 | source_range: [201; 201), | ||
774 | delete: [201; 201), | ||
775 | insert: "the_method()$0", | ||
776 | kind: Method, | ||
777 | lookup: "the_method", | ||
778 | detail: "pub fn the_method(&self)", | ||
779 | }, | ||
780 | ] | ||
781 | "### | ||
782 | ); | ||
783 | } | ||
721 | } | 784 | } |