Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/completions/unqualified_path.rs')
| -rw-r--r-- | crates/ide_completion/src/completions/unqualified_path.rs | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index 7e06b074ce..cca2785e2d 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs @@ -4,8 +4,8 @@ use hir::ScopeDef; use syntax::{ast, AstNode}; use crate::{ - completions::{module_or_attr, module_or_fn_macro}, - context::{PathCompletionContext, PathKind}, + completions::module_or_fn_macro, + context::{PathCompletionCtx, PathKind}, patterns::ImmediateLocation, CompletionContext, Completions, }; @@ -15,37 +15,22 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC if ctx.is_path_disallowed() || ctx.has_impl_or_trait_prev_sibling() { return; } - let kind = match ctx.path_context { - Some(PathCompletionContext { is_trivial_path: true, kind, .. }) => kind, + match ctx.path_context { + Some(PathCompletionCtx { + kind: + Some( + PathKind::Vis { .. } + | PathKind::Attr { .. } + | PathKind::Use { .. } + | PathKind::Pat, + ), + .. + }) => return, + Some(PathCompletionCtx { is_absolute_path: false, qualifier: None, .. }) => (), _ => return, - }; - - if let Some(PathKind::Use) = kind { - // only show modules in a fresh UseTree - cov_mark::hit!(unqualified_path_only_modules_in_import); - ctx.process_all_names(&mut |name, res| { - if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = res { - acc.add_resolution(ctx, name, res); - } - }); - - ["self::", "super::", "crate::"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw)); - return; } - ["self", "super", "crate"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw)); - match kind { - Some(PathKind::Vis { .. }) => return, - Some(PathKind::Attr) => { - ctx.process_all_names(&mut |name, def| { - if let Some(def) = module_or_attr(def) { - acc.add_resolution(ctx, name, def); - } - }); - return; - } - _ => (), - } + ["self", "super", "crate"].into_iter().for_each(|kw| acc.add_keyword(ctx, kw)); match &ctx.completion_location { Some(ImmediateLocation::ItemList | ImmediateLocation::Trait | ImmediateLocation::Impl) => { |