diff options
author | Jonas Schievink <[email protected]> | 2020-04-24 20:46:18 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-04-24 20:46:18 +0100 |
commit | 7b9553a7039a5307b8c436d4128e08b74f75c55b (patch) | |
tree | d45970bbfa388a83dfef0fb63f3257d5b7a0ca77 /crates/ra_ide/src | |
parent | 5d97667f8dd467e7382885fcae40bcdbac63ae4f (diff) |
Don't omit methods with self from path completion
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/completion/complete_qualified_path.rs | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index 9f795e441..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( |