aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 9a3b353a9..d43ff2eec 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -9,23 +9,27 @@ use rustc_hash::FxHashSet;
9 9
10/// Complete dot accesses, i.e. fields or methods (and .await syntax). 10/// Complete dot accesses, i.e. fields or methods (and .await syntax).
11pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { 11pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
12 if let Some(dot_receiver) = &ctx.dot_receiver { 12 let dot_receiver = match &ctx.dot_receiver {
13 let receiver_ty = ctx.analyzer.type_of(ctx.db, &dot_receiver); 13 Some(expr) => expr,
14 _ => return,
15 };
14 16
15 if let Some(receiver_ty) = receiver_ty { 17 let receiver_ty = match ctx.analyzer.type_of(ctx.db, &dot_receiver) {
16 if !ctx.is_call { 18 Some(ty) => ty,
17 complete_fields(acc, ctx, receiver_ty.clone()); 19 _ => return,
18 } 20 };
19 complete_methods(acc, ctx, receiver_ty.clone());
20 21
21 // Suggest .await syntax for types that implement Future trait 22 if !ctx.is_call {
22 if ctx.analyzer.impls_future(ctx.db, receiver_ty) { 23 complete_fields(acc, ctx, receiver_ty.clone());
23 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await") 24 }
24 .detail("expr.await") 25 complete_methods(acc, ctx, receiver_ty.clone());
25 .insert_text("await") 26
26 .add_to(acc); 27 // Suggest .await syntax for types that implement Future trait
27 } 28 if ctx.analyzer.impls_future(ctx.db, receiver_ty) {
28 } 29 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await")
30 .detail("expr.await")
31 .insert_text("await")
32 .add_to(acc);
29 } 33 }
30} 34}
31 35