Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/context.rs')
| -rw-r--r-- | crates/ide-completion/src/context.rs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs index 4ed083a524..6af24f8748 100644 --- a/crates/ide-completion/src/context.rs +++ b/crates/ide-completion/src/context.rs @@ -64,6 +64,8 @@ pub(crate) struct PathCompletionCtx { pub(super) kind: PathKind, /// Whether the path segment has type args or not. pub(super) has_type_args: bool, + /// Whether the qualifier comes from a use tree parent or not + pub(crate) use_tree_parent: bool, } impl PathCompletionCtx { @@ -101,7 +103,9 @@ pub(super) enum PathKind { kind: AttrKind, annotated_item_kind: Option<SyntaxKind>, }, - Derive, + Derive { + existing_derives: FxHashSet<hir::Macro>, + }, /// Path in item position, that is inside an (Assoc)ItemList Item { kind: ItemListKind, @@ -147,24 +151,18 @@ pub(super) enum ItemListKind { #[derive(Debug)] pub(super) enum Qualified { No, - With(PathQualifierCtx), + With { + path: ast::Path, + resolution: Option<PathResolution>, + /// Whether this path consists solely of `super` segments + is_super_chain: bool, + }, + /// <_>:: + Infer, /// Whether the path is an absolute path Absolute, } -/// The path qualifier state of the path we are completing. -#[derive(Debug)] -pub(crate) struct PathQualifierCtx { - pub(crate) path: ast::Path, - pub(crate) resolution: Option<PathResolution>, - /// Whether this path consists solely of `super` segments - pub(crate) is_super_chain: bool, - /// Whether the qualifier comes from a use tree parent or not - pub(crate) use_tree_parent: bool, - /// <_> - pub(crate) is_infer_qualifier: bool, -} - /// The state of the pattern we are completing. #[derive(Debug)] pub(super) struct PatternContext { @@ -318,13 +316,16 @@ pub(crate) struct CompletionContext<'a> { pub(super) expected_type: Option<Type>, /// The parent function of the cursor position if it exists. + // FIXME: This probably doesn't belong here pub(super) function_def: Option<ast::Fn>, /// The parent impl of the cursor position if it exists. + // FIXME: This probably doesn't belong here pub(super) impl_def: Option<ast::Impl>, /// Are we completing inside a let statement with a missing semicolon? // FIXME: This should be part of PathKind::Expr pub(super) incomplete_let: bool, + // FIXME: This shouldn't exist pub(super) previous_token: Option<SyntaxToken>, pub(super) ident_ctx: IdentContext, @@ -332,8 +333,6 @@ pub(crate) struct CompletionContext<'a> { pub(super) pattern_ctx: Option<PatternContext>, pub(super) qualifier_ctx: QualifierCtx, - pub(super) existing_derives: FxHashSet<hir::Macro>, - pub(super) locals: FxHashMap<Name, Local>, } @@ -354,6 +353,7 @@ impl<'a> CompletionContext<'a> { } } + // FIXME: This shouldn't exist pub(crate) fn previous_token_is(&self, kind: SyntaxKind) -> bool { self.previous_token.as_ref().map_or(false, |tok| tok.kind() == kind) } @@ -406,7 +406,7 @@ impl<'a> CompletionContext<'a> { pub(crate) fn path_qual(&self) -> Option<&ast::Path> { self.path_context().and_then(|it| match &it.qualified { - Qualified::With(it) => Some(&it.path), + Qualified::With { path, .. } => Some(path), _ => None, }) } @@ -556,7 +556,6 @@ impl<'a> CompletionContext<'a> { ident_ctx: IdentContext::UnexpandedAttrTT { fake_attribute_under_caret: None }, pattern_ctx: None, qualifier_ctx: Default::default(), - existing_derives: Default::default(), locals, }; ctx.expand_and_fill( |