1 //! Completion of paths and keywords at item list position.
4 completions::module_or_fn_macro,
5 context::{PathCompletionCtx, PathKind, PathQualifierCtx},
6 CompletionContext, Completions,
9 pub(crate) fn complete_item_list(acc: &mut Completions, ctx: &CompletionContext) {
10 let _p = profile::span("complete_item_list");
11 if ctx.is_path_disallowed() || ctx.has_unfinished_impl_or_trait_prev_sibling() {
15 let (&is_absolute_path, qualifier) = match ctx.path_context() {
16 Some(PathCompletionCtx {
17 kind: PathKind::Item { .. },
21 }) => (is_absolute_path, qualifier),
26 Some(PathQualifierCtx { resolution, is_super_chain, .. }) => {
27 if let Some(hir::PathResolution::Def(hir::ModuleDef::Module(module))) = resolution {
28 for (name, def) in module.scope(ctx.db, Some(ctx.module)) {
29 if let Some(def) = module_or_fn_macro(ctx.db, def) {
30 acc.add_resolution(ctx, name, def);
36 acc.add_keyword(ctx, "super::");
39 None if is_absolute_path => {
40 acc.add_crate_roots(ctx);
43 ctx.process_all_names(&mut |name, def| {
44 if let Some(def) = module_or_fn_macro(ctx.db, def) {
45 acc.add_resolution(ctx, name, def);
48 acc.add_nameref_keywords_with_colon(ctx);