Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/attribute/diagnostic.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/attribute/diagnostic.rs | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/crates/ide-completion/src/completions/attribute/diagnostic.rs b/crates/ide-completion/src/completions/attribute/diagnostic.rs index 8adc974239..0899bbff14 100644 --- a/crates/ide-completion/src/completions/attribute/diagnostic.rs +++ b/crates/ide-completion/src/completions/attribute/diagnostic.rs @@ -10,46 +10,44 @@ use super::AttrCompletion; pub(super) fn complete_on_unimplemented( acc: &mut Completions, ctx: &CompletionContext<'_>, - input: ast::TokenTree, + existing_keys: &[ast::Expr], ) { - if let Some(existing_keys) = super::parse_comma_sep_expr(input) { - for attr in ATTRIBUTE_ARGS { - let already_annotated = existing_keys - .iter() - .filter_map(|expr| match expr { - ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(), - ast::Expr::BinExpr(bin) - if bin.op_kind() == Some(ast::BinaryOp::Assignment { op: None }) => - { - match bin.lhs()? { - ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(), - _ => None, - } + for attr in ATTRIBUTE_ARGS { + let already_annotated = existing_keys + .iter() + .filter_map(|expr| match expr { + ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(), + ast::Expr::BinExpr(bin) + if bin.op_kind() == Some(ast::BinaryOp::Assignment { op: None }) => + { + match bin.lhs()? { + ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(), + _ => None, } - _ => None, - }) - .any(|it| { - let text = it.text(); - attr.key() == text && text != "note" - }); - if already_annotated { - continue; - } + } + _ => None, + }) + .any(|it| { + let text = it.text(); + attr.key() == text && text != "note" + }); + if already_annotated { + continue; + } - let mut item = CompletionItem::new( - SymbolKind::BuiltinAttr, - ctx.source_range(), - attr.label, - ctx.edition, - ); - if let Some(lookup) = attr.lookup { - item.lookup_by(lookup); - } - if let Some((snippet, cap)) = attr.snippet.zip(ctx.config.snippet_cap) { - item.insert_snippet(cap, snippet); - } - item.add_to(acc, ctx.db); + let mut item = CompletionItem::new( + SymbolKind::BuiltinAttr, + ctx.source_range(), + attr.label, + ctx.edition, + ); + if let Some(lookup) = attr.lookup { + item.lookup_by(lookup); + } + if let Some((snippet, cap)) = attr.snippet.zip(ctx.config.snippet_cap) { + item.insert_snippet(cap, snippet); } + item.add_to(acc, ctx.db); } } |