aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs38
1 files changed, 34 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index b471787eb..940858342 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -50,9 +50,12 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
50 hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db), 50 hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
51 _ => unreachable!(), 51 _ => unreachable!(),
52 }; 52 };
53 let krate = ctx.module.map(|m| m.krate()); 53 ctx.analyzer.iterate_method_candidates(
54 if let Some(krate) = krate { 54 ctx.db,
55 ty.iterate_impl_items(ctx.db, krate, |item| { 55 ty.clone(),
56 None,
57 hir::LookupMode::Path,
58 |_ty, item| {
56 match item { 59 match item {
57 hir::AssocItem::Function(func) => { 60 hir::AssocItem::Function(func) => {
58 let data = func.data(ctx.db); 61 let data = func.data(ctx.db);
@@ -64,6 +67,18 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
64 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), 67 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
65 } 68 }
66 None::<()> 69 None::<()>
70 },
71 );
72 // Iterate assoc types separately
73 // FIXME: complete T::AssocType
74 let krate = ctx.module.map(|m| m.krate());
75 if let Some(krate) = krate {
76 ty.iterate_impl_items(ctx.db, krate, |item| {
77 match item {
78 hir::AssocItem::Function(_) | hir::AssocItem::Const(_) => {}
79 hir::AssocItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty),
80 }
81 None::<()>
67 }); 82 });
68 } 83 }
69 } 84 }
@@ -593,7 +608,22 @@ mod tests {
593 fn foo() { let _ = S::<|> } 608 fn foo() { let _ = S::<|> }
594 " 609 "
595 ), 610 ),
596 @"[]" 611 @r###"
612 [
613 CompletionItem {
614 label: "m()",
615 source_range: [99; 99),
616 delete: [99; 99),
617 insert: "m()$0",
618 kind: Function,
619 lookup: "m",
620 detail: "fn m()",
621 documentation: Documentation(
622 "A trait method",
623 ),
624 },
625 ]
626 "###
597 ); 627 );
598 } 628 }
599 629