Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/attribute/feature.rs')
-rw-r--r--crates/ide-completion/src/completions/attribute/feature.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/crates/ide-completion/src/completions/attribute/feature.rs b/crates/ide-completion/src/completions/attribute/feature.rs
new file mode 100644
index 0000000000..1e6baca864
--- /dev/null
+++ b/crates/ide-completion/src/completions/attribute/feature.rs
@@ -0,0 +1,30 @@
+//! Completion for features
+use ide_db::{
+ SymbolKind,
+ documentation::Documentation,
+ generated::lints::{FEATURES, Lint},
+};
+use syntax::ast;
+
+use crate::{Completions, context::CompletionContext, item::CompletionItem};
+
+pub(super) fn complete_feature(
+ acc: &mut Completions,
+ ctx: &CompletionContext<'_>,
+ existing_features: &[ast::Path],
+) {
+ for &Lint { label, description, .. } in FEATURES {
+ let feature_already_annotated = existing_features
+ .iter()
+ .filter_map(|p| p.as_single_name_ref())
+ .any(|n| n.text() == label);
+ if feature_already_annotated {
+ continue;
+ }
+
+ let mut item =
+ CompletionItem::new(SymbolKind::Attribute, ctx.source_range(), label, ctx.edition);
+ item.documentation(Documentation::new_borrowed(description));
+ item.add_to(acc, ctx.db)
+ }
+}