diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 940858342..2aec8eb26 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -82,6 +82,20 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
82 | }); | 82 | }); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | hir::ModuleDef::Trait(t) => { | ||
86 | for item in t.items(ctx.db) { | ||
87 | match item { | ||
88 | hir::AssocItem::Function(func) => { | ||
89 | let data = func.data(ctx.db); | ||
90 | if !data.has_self_param() { | ||
91 | acc.add_function(ctx, func); | ||
92 | } | ||
93 | } | ||
94 | hir::AssocItem::Const(ct) => acc.add_const(ctx, ct), | ||
95 | hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), | ||
96 | } | ||
97 | } | ||
98 | } | ||
85 | _ => {} | 99 | _ => {} |
86 | }; | 100 | }; |
87 | } | 101 | } |
@@ -587,7 +601,22 @@ mod tests { | |||
587 | fn foo() { let _ = Trait::<|> } | 601 | fn foo() { let _ = Trait::<|> } |
588 | " | 602 | " |
589 | ), | 603 | ), |
590 | @"[]" | 604 | @r###" |
605 | [ | ||
606 | CompletionItem { | ||
607 | label: "m()", | ||
608 | source_range: [73; 73), | ||
609 | delete: [73; 73), | ||
610 | insert: "m()$0", | ||
611 | kind: Function, | ||
612 | lookup: "m", | ||
613 | detail: "fn m()", | ||
614 | documentation: Documentation( | ||
615 | "A trait method", | ||
616 | ), | ||
617 | }, | ||
618 | ] | ||
619 | "### | ||
591 | ); | 620 | ); |
592 | } | 621 | } |
593 | 622 | ||
@@ -644,7 +673,22 @@ mod tests { | |||
644 | fn foo() { let _ = <S as Trait>::<|> } | 673 | fn foo() { let _ = <S as Trait>::<|> } |
645 | " | 674 | " |
646 | ), | 675 | ), |
647 | @"[]" | 676 | @r###" |
677 | [ | ||
678 | CompletionItem { | ||
679 | label: "m()", | ||
680 | source_range: [110; 110), | ||
681 | delete: [110; 110), | ||
682 | insert: "m()$0", | ||
683 | kind: Function, | ||
684 | lookup: "m", | ||
685 | detail: "fn m()", | ||
686 | documentation: Documentation( | ||
687 | "A trait method", | ||
688 | ), | ||
689 | }, | ||
690 | ] | ||
691 | "### | ||
648 | ); | 692 | ); |
649 | } | 693 | } |
650 | 694 | ||