ide_completion/completions/attribute/
feature.rs1use ide_db::{
3 SymbolKind,
4 documentation::Documentation,
5 generated::lints::{FEATURES, Lint},
6};
7use syntax::ast;
8
9use crate::{Completions, context::CompletionContext, item::CompletionItem};
10
11pub(super) fn complete_feature(
12 acc: &mut Completions,
13 ctx: &CompletionContext<'_, '_>,
14 existing_features: &[ast::Path],
15) {
16 for &Lint { label, description, .. } in FEATURES {
17 let feature_already_annotated = existing_features
18 .iter()
19 .filter_map(|p| p.as_single_name_ref())
20 .any(|n| n.text() == label);
21 if feature_already_annotated {
22 continue;
23 }
24
25 let mut item =
26 CompletionItem::new(SymbolKind::Attribute, ctx.source_range(), label, ctx.edition);
27 item.documentation(Documentation::new_borrowed(description));
28 item.add_to(acc, ctx.db)
29 }
30}