aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/complete_qualified_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/complete_qualified_path.rs')
-rw-r--r--crates/ra_ide/src/completion/complete_qualified_path.rs46
1 files changed, 39 insertions, 7 deletions
diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs
index d98523406..5a5139e14 100644
--- a/crates/ra_ide/src/completion/complete_qualified_path.rs
+++ b/crates/ra_ide/src/completion/complete_qualified_path.rs
@@ -57,9 +57,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
57 } 57 }
58 match item { 58 match item {
59 hir::AssocItem::Function(func) => { 59 hir::AssocItem::Function(func) => {
60 if !func.has_self_param(ctx.db) { 60 acc.add_function(ctx, func, None);
61 acc.add_function(ctx, func, None);
62 }
63 } 61 }
64 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct), 62 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
65 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), 63 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
@@ -86,9 +84,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
86 } 84 }
87 match item { 85 match item {
88 hir::AssocItem::Function(func) => { 86 hir::AssocItem::Function(func) => {
89 if !func.has_self_param(ctx.db) { 87 acc.add_function(ctx, func, None);
90 acc.add_function(ctx, func, None);
91 }
92 } 88 }
93 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct), 89 hir::AssocItem::Const(ct) => acc.add_const(ctx, ct),
94 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), 90 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
@@ -483,6 +479,42 @@ mod tests {
483 } 479 }
484 480
485 #[test] 481 #[test]
482 fn completes_struct_associated_method_with_self() {
483 assert_debug_snapshot!(
484 do_reference_completion(
485 "
486 //- /lib.rs
487 /// A Struct
488 struct S;
489
490 impl S {
491 /// An associated method
492 fn m(&self) { }
493 }
494
495 fn foo() { let _ = S::<|> }
496 "
497 ),
498 @r###"
499 [
500 CompletionItem {
501 label: "m()",
502 source_range: [105; 105),
503 delete: [105; 105),
504 insert: "m()$0",
505 kind: Method,
506 lookup: "m",
507 detail: "fn m(&self)",
508 documentation: Documentation(
509 "An associated method",
510 ),
511 },
512 ]
513 "###
514 );
515 }
516
517 #[test]
486 fn completes_struct_associated_const() { 518 fn completes_struct_associated_const() {
487 assert_debug_snapshot!( 519 assert_debug_snapshot!(
488 do_reference_completion( 520 do_reference_completion(
@@ -869,7 +901,7 @@ mod tests {
869 @r###" 901 @r###"
870 [ 902 [
871 CompletionItem { 903 CompletionItem {
872 label: "foo!", 904 label: "foo!(…)",
873 source_range: [179; 179), 905 source_range: [179; 179),
874 delete: [179; 179), 906 delete: [179; 179),
875 insert: "foo!($0)", 907 insert: "foo!($0)",