aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-01-07 21:48:54 +0000
committerLukas Wirth <[email protected]>2021-01-07 21:48:54 +0000
commitca6db58762dcd0ee9b7d5fb91c85486c0b90ef4b (patch)
treefe787a45f154951019c9cf49ab80793024b6f3b3 /crates/completion/src
parent5722d2b7b88cf04365037b0769316916e486de48 (diff)
Tidy up attribute completion match
Diffstat (limited to 'crates/completion/src')
-rw-r--r--crates/completion/src/completions/attribute.rs30
1 files changed, 11 insertions, 19 deletions
diff --git a/crates/completion/src/completions/attribute.rs b/crates/completion/src/completions/attribute.rs
index 10739750c..3a29b5203 100644
--- a/crates/completion/src/completions/attribute.rs
+++ b/crates/completion/src/completions/attribute.rs
@@ -21,20 +21,15 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
21 21
22 let attribute = ctx.attribute_under_caret.as_ref()?; 22 let attribute = ctx.attribute_under_caret.as_ref()?;
23 match (attribute.path(), attribute.token_tree()) { 23 match (attribute.path(), attribute.token_tree()) {
24 (Some(path), Some(token_tree)) if path.to_string() == "derive" => { 24 (Some(path), Some(token_tree)) => match path.to_string().as_str() {
25 complete_derive(acc, ctx, token_tree) 25 "derive" => complete_derive(acc, ctx, token_tree),
26 } 26 "feature" => complete_lint(acc, ctx, token_tree, FEATURES),
27 (Some(path), Some(token_tree)) if path.to_string() == "feature" => { 27 "allow" | "warn" | "deny" | "forbid" => {
28 complete_lint(acc, ctx, token_tree, FEATURES); 28 complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
29 } 29 complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
30 (Some(path), Some(token_tree)) 30 }
31 if ["allow", "warn", "deny", "forbid"] 31 _ => {}
32 .iter() 32 },
33 .any(|lint_level| lint_level == &path.to_string()) =>
34 {
35 complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
36 complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
37 }
38 (_, Some(_token_tree)) => {} 33 (_, Some(_token_tree)) => {}
39 _ => complete_attribute_start(acc, ctx, attribute), 34 _ => complete_attribute_start(acc, ctx, attribute),
40 } 35 }
@@ -54,11 +49,8 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr
54 item = item.lookup_by(lookup); 49 item = item.lookup_by(lookup);
55 } 50 }
56 51
57 match (attr_completion.snippet, ctx.config.snippet_cap) { 52 if let Some((snippet, cap)) = attr_completion.snippet.zip(ctx.config.snippet_cap) {
58 (Some(snippet), Some(cap)) => { 53 item = item.insert_snippet(cap, snippet);
59 item = item.insert_snippet(cap, snippet);
60 }
61 _ => {}
62 } 54 }
63 55
64 if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner { 56 if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner {