mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Tidy up attribute completion match
This commit is contained in:
parent
5722d2b7b8
commit
ca6db58762
1 changed files with 11 additions and 19 deletions
|
@ -21,20 +21,15 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
|
|
||||||
let attribute = ctx.attribute_under_caret.as_ref()?;
|
let attribute = ctx.attribute_under_caret.as_ref()?;
|
||||||
match (attribute.path(), attribute.token_tree()) {
|
match (attribute.path(), attribute.token_tree()) {
|
||||||
(Some(path), Some(token_tree)) if path.to_string() == "derive" => {
|
(Some(path), Some(token_tree)) => match path.to_string().as_str() {
|
||||||
complete_derive(acc, ctx, token_tree)
|
"derive" => complete_derive(acc, ctx, token_tree),
|
||||||
}
|
"feature" => complete_lint(acc, ctx, token_tree, FEATURES),
|
||||||
(Some(path), Some(token_tree)) if path.to_string() == "feature" => {
|
"allow" | "warn" | "deny" | "forbid" => {
|
||||||
complete_lint(acc, ctx, token_tree, FEATURES);
|
complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
|
||||||
}
|
complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
|
||||||
(Some(path), Some(token_tree))
|
}
|
||||||
if ["allow", "warn", "deny", "forbid"]
|
_ => {}
|
||||||
.iter()
|
},
|
||||||
.any(|lint_level| lint_level == &path.to_string()) =>
|
|
||||||
{
|
|
||||||
complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
|
|
||||||
complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
|
|
||||||
}
|
|
||||||
(_, Some(_token_tree)) => {}
|
(_, Some(_token_tree)) => {}
|
||||||
_ => complete_attribute_start(acc, ctx, attribute),
|
_ => complete_attribute_start(acc, ctx, attribute),
|
||||||
}
|
}
|
||||||
|
@ -54,11 +49,8 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr
|
||||||
item = item.lookup_by(lookup);
|
item = item.lookup_by(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
match (attr_completion.snippet, ctx.config.snippet_cap) {
|
if let Some((snippet, cap)) = attr_completion.snippet.zip(ctx.config.snippet_cap) {
|
||||||
(Some(snippet), Some(cap)) => {
|
item = item.insert_snippet(cap, snippet);
|
||||||
item = item.insert_snippet(cap, snippet);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner {
|
if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue