aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_keyword.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_keyword.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_keyword.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs
index 3fbf36313..006b20076 100644
--- a/crates/ra_ide_api/src/completion/complete_keyword.rs
+++ b/crates/ra_ide_api/src/completion/complete_keyword.rs
@@ -9,25 +9,26 @@ use crate::completion::{CompletionContext, CompletionItem, Completions, Completi
9 9
10pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { 10pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
11 // complete keyword "crate" in use stmt 11 // complete keyword "crate" in use stmt
12 let leaf_range = ctx.leaf_range();
12 match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { 13 match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) {
13 (Some(_), None) => { 14 (Some(_), None) => {
14 CompletionItem::new(CompletionKind::Keyword, ctx, "crate") 15 CompletionItem::new(CompletionKind::Keyword, leaf_range, "crate")
15 .kind(CompletionItemKind::Keyword) 16 .kind(CompletionItemKind::Keyword)
16 .insert_text("crate::") 17 .insert_text("crate::")
17 .add_to(acc); 18 .add_to(acc);
18 CompletionItem::new(CompletionKind::Keyword, ctx, "self") 19 CompletionItem::new(CompletionKind::Keyword, leaf_range, "self")
19 .kind(CompletionItemKind::Keyword) 20 .kind(CompletionItemKind::Keyword)
20 .add_to(acc); 21 .add_to(acc);
21 CompletionItem::new(CompletionKind::Keyword, ctx, "super") 22 CompletionItem::new(CompletionKind::Keyword, leaf_range, "super")
22 .kind(CompletionItemKind::Keyword) 23 .kind(CompletionItemKind::Keyword)
23 .insert_text("super::") 24 .insert_text("super::")
24 .add_to(acc); 25 .add_to(acc);
25 } 26 }
26 (Some(_), Some(_)) => { 27 (Some(_), Some(_)) => {
27 CompletionItem::new(CompletionKind::Keyword, ctx, "self") 28 CompletionItem::new(CompletionKind::Keyword, leaf_range, "self")
28 .kind(CompletionItemKind::Keyword) 29 .kind(CompletionItemKind::Keyword)
29 .add_to(acc); 30 .add_to(acc);
30 CompletionItem::new(CompletionKind::Keyword, ctx, "super") 31 CompletionItem::new(CompletionKind::Keyword, leaf_range, "super")
31 .kind(CompletionItemKind::Keyword) 32 .kind(CompletionItemKind::Keyword)
32 .insert_text("super::") 33 .insert_text("super::")
33 .add_to(acc); 34 .add_to(acc);
@@ -37,7 +38,7 @@ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionC
37} 38}
38 39
39fn keyword(ctx: &CompletionContext, kw: &str, snippet: &str) -> CompletionItem { 40fn keyword(ctx: &CompletionContext, kw: &str, snippet: &str) -> CompletionItem {
40 CompletionItem::new(CompletionKind::Keyword, ctx, kw) 41 CompletionItem::new(CompletionKind::Keyword, ctx.leaf_range(), kw)
41 .kind(CompletionItemKind::Keyword) 42 .kind(CompletionItemKind::Keyword)
42 .snippet(snippet) 43 .snippet(snippet)
43 .build() 44 .build()