Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/attribute.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/attribute.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/crates/ide-completion/src/completions/attribute.rs b/crates/ide-completion/src/completions/attribute.rs index 712163d81d..37e042a160 100644 --- a/crates/ide-completion/src/completions/attribute.rs +++ b/crates/ide-completion/src/completions/attribute.rs @@ -17,7 +17,6 @@ use syntax::{ }; use crate::{ - completions::module_or_attr, context::{AttrCtx, CompletionContext, PathCompletionCtx, Qualified}, item::CompletionItem, Completions, @@ -28,7 +27,7 @@ mod derive; mod lint; mod repr; -pub(crate) use self::derive::complete_derive; +pub(crate) use self::derive::complete_derive_path; /// Complete inputs to known builtin attributes as well as derive attributes pub(crate) fn complete_known_attribute_input( @@ -69,7 +68,7 @@ pub(crate) fn complete_known_attribute_input( Some(()) } -pub(crate) fn complete_attribute( +pub(crate) fn complete_attribute_path( acc: &mut Completions, ctx: &CompletionContext, PathCompletionCtx { qualified, .. }: &PathCompletionCtx, @@ -88,8 +87,14 @@ pub(crate) fn complete_attribute( } for (name, def) in module.scope(ctx.db, Some(ctx.module)) { - if let Some(def) = module_or_attr(ctx.db, def) { - acc.add_resolution(ctx, name, def); + match def { + hir::ScopeDef::ModuleDef(hir::ModuleDef::Macro(m)) if m.is_attr(ctx.db) => { + acc.add_macro(ctx, m, name) + } + hir::ScopeDef::ModuleDef(hir::ModuleDef::Module(m)) => { + acc.add_module(ctx, m, name) + } + _ => (), } } return; @@ -98,10 +103,12 @@ pub(crate) fn complete_attribute( Qualified::Absolute => acc.add_crate_roots(ctx), // only show modules in a fresh UseTree Qualified::No => { - ctx.process_all_names(&mut |name, def| { - if let Some(def) = module_or_attr(ctx.db, def) { - acc.add_resolution(ctx, name, def); + ctx.process_all_names(&mut |name, def| match def { + hir::ScopeDef::ModuleDef(hir::ModuleDef::Macro(m)) if m.is_attr(ctx.db) => { + acc.add_macro(ctx, m, name) } + hir::ScopeDef::ModuleDef(hir::ModuleDef::Module(m)) => acc.add_module(ctx, m, name), + _ => (), }); acc.add_nameref_keywords_with_colon(ctx); } |