diff options
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r-- | crates/ra_analysis/src/completion/complete_keyword.rs | 29 |
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 | } |