aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/completions/keyword.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ide_completion/src/completions/keyword.rs b/crates/ide_completion/src/completions/keyword.rs
index b635e0ca3..61b667104 100644
--- a/crates/ide_completion/src/completions/keyword.rs
+++ b/crates/ide_completion/src/completions/keyword.rs
@@ -9,22 +9,21 @@ use crate::{CompletionContext, CompletionItem, CompletionItemKind, CompletionKin
9pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { 9pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
10 // complete keyword "crate" in use stmt 10 // complete keyword "crate" in use stmt
11 let source_range = ctx.source_range(); 11 let source_range = ctx.source_range();
12 let kw_completion = move |text: &str| {
13 let mut item = CompletionItem::new(CompletionKind::Keyword, source_range, text);
14 item.kind(CompletionItemKind::Keyword).insert_text(text);
15 item
16 };
12 17
13 if ctx.use_item_syntax.is_some() { 18 if ctx.use_item_syntax.is_some() {
14 if ctx.path_qual.is_none() { 19 if ctx.path_qual.is_none() {
15 let mut item = CompletionItem::new(CompletionKind::Keyword, source_range, "crate::"); 20 kw_completion("crate::").add_to(acc);
16 item.kind(CompletionItemKind::Keyword).insert_text("crate::");
17 item.add_to(acc);
18 } 21 }
19 let mut item = CompletionItem::new(CompletionKind::Keyword, source_range, "self"); 22 kw_completion("self").add_to(acc);
20 item.kind(CompletionItemKind::Keyword);
21 item.add_to(acc);
22 if iter::successors(ctx.path_qual.clone(), |p| p.qualifier()) 23 if iter::successors(ctx.path_qual.clone(), |p| p.qualifier())
23 .all(|p| p.segment().and_then(|s| s.super_token()).is_some()) 24 .all(|p| p.segment().and_then(|s| s.super_token()).is_some())
24 { 25 {
25 let mut item = CompletionItem::new(CompletionKind::Keyword, source_range, "super::"); 26 kw_completion("super::").add_to(acc);
26 item.kind(CompletionItemKind::Keyword).insert_text("super::");
27 item.add_to(acc);
28 } 27 }
29 } 28 }
30 29
@@ -32,9 +31,8 @@ pub(crate) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
32 if let Some(receiver) = &ctx.dot_receiver { 31 if let Some(receiver) = &ctx.dot_receiver {
33 if let Some(ty) = ctx.sema.type_of_expr(receiver) { 32 if let Some(ty) = ctx.sema.type_of_expr(receiver) {
34 if ty.impls_future(ctx.db) { 33 if ty.impls_future(ctx.db) {
35 let mut item = 34 let mut item = kw_completion("await");
36 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await"); 35 item.detail("expr.await");
37 item.kind(CompletionItemKind::Keyword).detail("expr.await").insert_text("await");
38 item.add_to(acc); 36 item.add_to(acc);
39 } 37 }
40 }; 38 };