aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r--crates/ide_completion/src/completions/attribute.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/ide_completion/src/completions/attribute.rs b/crates/ide_completion/src/completions/attribute.rs
index f80d7eec3..d3392100d 100644
--- a/crates/ide_completion/src/completions/attribute.rs
+++ b/crates/ide_completion/src/completions/attribute.rs
@@ -3,6 +3,7 @@
3//! This module uses a bit of static metadata to provide completions 3//! This module uses a bit of static metadata to provide completions
4//! for built-in attributes. 4//! for built-in attributes.
5 5
6use hir::HasAttrs;
6use ide_db::helpers::generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES}; 7use ide_db::helpers::generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES};
7use once_cell::sync::Lazy; 8use once_cell::sync::Lazy;
8use rustc_hash::{FxHashMap, FxHashSet}; 9use rustc_hash::{FxHashMap, FxHashSet};
@@ -81,6 +82,24 @@ fn complete_new_attribute(acc: &mut Completions, ctx: &CompletionContext, attrib
81 None if is_inner => ATTRIBUTES.iter().for_each(add_completion), 82 None if is_inner => ATTRIBUTES.iter().for_each(add_completion),
82 None => ATTRIBUTES.iter().filter(|compl| !compl.prefer_inner).for_each(add_completion), 83 None => ATTRIBUTES.iter().filter(|compl| !compl.prefer_inner).for_each(add_completion),
83 } 84 }
85
86 // FIXME: write a test for this when we can
87 ctx.scope.process_all_names(&mut |name, scope_def| {
88 if let hir::ScopeDef::MacroDef(mac) = scope_def {
89 if mac.kind() == hir::MacroKind::Attr {
90 let mut item = CompletionItem::new(
91 CompletionKind::Attribute,
92 ctx.source_range(),
93 name.to_string(),
94 );
95 item.kind(CompletionItemKind::Attribute);
96 if let Some(docs) = mac.docs(ctx.sema.db) {
97 item.documentation(docs);
98 }
99 acc.add(item.build());
100 }
101 }
102 });
84} 103}
85 104
86struct AttrCompletion { 105struct AttrCompletion {