aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion
diff options
context:
space:
mode:
authorgfreezy <[email protected]>2019-01-01 13:55:27 +0000
committergfreezy <[email protected]>2019-01-01 13:55:27 +0000
commitfc2d7d1e1f03faa4566dea8b60eca860bcf9eb04 (patch)
tree16dab87abb9fb73e6f7fd96b7ac884c4e6b849e0 /crates/ra_analysis/src/completion
parent6f4c9303e41b5973830ae8d80b2b6d206f2e9a57 (diff)
complete crate in use stmt
Diffstat (limited to 'crates/ra_analysis/src/completion')
-rw-r--r--crates/ra_analysis/src/completion/complete_keyword.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs
index d70fdaada..f51d77f27 100644
--- a/crates/ra_analysis/src/completion/complete_keyword.rs
+++ b/crates/ra_analysis/src/completion/complete_keyword.rs
@@ -18,6 +18,16 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
18 if !ctx.is_trivial_path { 18 if !ctx.is_trivial_path {
19 return; 19 return;
20 } 20 }
21
22 // complete keyword "crate" in use stmt
23 if let (Some(use_item), None) = (&ctx.use_item_syntax, &ctx.path_prefix) {
24 if use_item.use_tree().is_none() {
25 CompletionItem::new(CompletionKind::Keyword, "crate")
26 .kind(CompletionItemKind::Keyword)
27 .add_to(acc);
28 }
29 }
30
21 let fn_def = match ctx.function_syntax { 31 let fn_def = match ctx.function_syntax {
22 Some(it) => it, 32 Some(it) => it,
23 None => return, 33 None => return,
@@ -269,4 +279,23 @@ mod tests {
269 "#, 279 "#,
270 ) 280 )
271 } 281 }
282
283 fn completes_crate_in_use_stmt() {
284 check_keyword_completion(
285 r"
286 use <|>
287 ",
288 r#"
289 crate
290 "#,
291 );
292 // No completion: lambda isolates control flow
293 check_keyword_completion(
294 r"
295 use a<|>
296 ",
297 r#"
298 "#,
299 );
300 }
272} 301}