Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/use_.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/use_.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ide-completion/src/completions/use_.rs b/crates/ide-completion/src/completions/use_.rs index a8d301da17..f1beeb454c 100644 --- a/crates/ide-completion/src/completions/use_.rs +++ b/crates/ide-completion/src/completions/use_.rs @@ -5,16 +5,19 @@ use ide_db::FxHashSet; use syntax::{ast, AstNode}; use crate::{ - context::{CompletionContext, PathCompletionCtx, PathKind, PathQualifierCtx}, + context::{CompletionContext, NameRefContext, PathCompletionCtx, PathKind, PathQualifierCtx}, item::Builder, CompletionRelevance, Completions, }; pub(crate) fn complete_use_tree(acc: &mut Completions, ctx: &CompletionContext) { - let (&is_absolute_path, qualifier) = match &ctx.path_context { - Some(PathCompletionCtx { kind: PathKind::Use, is_absolute_path, qualifier, .. }) => { - (is_absolute_path, qualifier) - } + let (&is_absolute_path, qualifier, name_ref) = match ctx.nameref_ctx() { + Some(NameRefContext { + path_ctx: + Some(PathCompletionCtx { kind: PathKind::Use, is_absolute_path, qualifier, .. }), + nameref, + .. + }) => (is_absolute_path, qualifier, nameref), _ => return, }; @@ -55,7 +58,7 @@ pub(crate) fn complete_use_tree(acc: &mut Completions, ctx: &CompletionContext) let module_scope = module.scope(ctx.db, Some(ctx.module)); let unknown_is_current = |name: &hir::Name| { matches!( - ctx.name_ref(), + name_ref, Some(name_ref) if name_ref.syntax().text() == name.to_smol_str().as_str() ) }; |