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.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs
index cfd7f80d40..2f166b7184 100644
--- a/crates/ide-completion/src/context.rs
+++ b/crates/ide-completion/src/context.rs
@@ -15,6 +15,7 @@ use ide_db::{
FilePosition, FxHashMap, FxHashSet, RootDatabase, famous_defs::FamousDefs,
helpers::is_editable_crate,
};
+use itertools::Either;
use syntax::{
AstNode, Edition, SmolStr,
SyntaxKind::{self, *},
@@ -142,17 +143,21 @@ pub(crate) struct AttrCtx {
#[derive(Debug, PartialEq, Eq)]
pub(crate) struct PathExprCtx<'db> {
pub(crate) in_block_expr: bool,
- pub(crate) in_breakable: BreakableKind,
+ pub(crate) in_breakable: Option<BreakableKind>,
pub(crate) after_if_expr: bool,
+ pub(crate) before_else_kw: bool,
/// Whether this expression is the direct condition of an if or while expression
pub(crate) in_condition: bool,
pub(crate) incomplete_let: bool,
+ pub(crate) after_incomplete_let: bool,
+ pub(crate) in_value: bool,
pub(crate) ref_expr_parent: Option<ast::RefExpr>,
pub(crate) after_amp: bool,
/// The surrounding RecordExpression we are completing a functional update
pub(crate) is_func_update: Option<ast::RecordExpr>,
pub(crate) self_param: Option<hir::SelfParam>,
pub(crate) innermost_ret_ty: Option<hir::Type<'db>>,
+ pub(crate) innermost_breakable_ty: Option<hir::Type<'db>>,
pub(crate) impl_: Option<ast::Impl>,
/// Whether this expression occurs in match arm guard position: before the
/// fat arrow token
@@ -274,12 +279,13 @@ pub(crate) struct PatternContext {
pub(crate) param_ctx: Option<ParamContext>,
pub(crate) has_type_ascription: bool,
pub(crate) should_suggest_name: bool,
+ pub(crate) after_if_expr: bool,
pub(crate) parent_pat: Option<ast::Pat>,
pub(crate) ref_token: Option<SyntaxToken>,
pub(crate) mut_token: Option<SyntaxToken>,
/// The record pattern this name or ref is a field of
pub(crate) record_pat: Option<ast::RecordPat>,
- pub(crate) impl_: Option<ast::Impl>,
+ pub(crate) impl_or_trait: Option<Either<ast::Impl, ast::Trait>>,
/// List of missing variants in a match expr
pub(crate) missing_variants: Vec<hir::Variant>,
}
@@ -400,20 +406,17 @@ pub(crate) enum DotAccessKind {
/// like `0.$0`
receiver_is_ambiguous_float_literal: bool,
},
- Method {
- has_parens: bool,
- },
+ Method,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct DotAccessExprCtx {
pub(crate) in_block_expr: bool,
- pub(crate) in_breakable: BreakableKind,
+ pub(crate) in_breakable: Option<BreakableKind>,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub(crate) enum BreakableKind {
- None,
Loop,
For,
While,
@@ -436,6 +439,7 @@ pub(crate) struct CompletionContext<'a> {
pub(crate) config: &'a CompletionConfig<'a>,
pub(crate) position: FilePosition,
+ pub(crate) trigger_character: Option<char>,
/// The token before the cursor, in the original file.
pub(crate) original_token: SyntaxToken,
/// The token before the cursor, in the macro-expanded file.
@@ -525,7 +529,6 @@ impl CompletionContext<'_> {
hir::ModuleDef::Const(it) => self.is_visible(it),
hir::ModuleDef::Static(it) => self.is_visible(it),
hir::ModuleDef::Trait(it) => self.is_visible(it),
- hir::ModuleDef::TraitAlias(it) => self.is_visible(it),
hir::ModuleDef::TypeAlias(it) => self.is_visible(it),
hir::ModuleDef::Macro(it) => self.is_visible(it),
hir::ModuleDef::BuiltinType(_) => Visible::Yes,
@@ -700,6 +703,7 @@ impl<'db> CompletionContext<'db> {
db: &'db RootDatabase,
position @ FilePosition { file_id, offset }: FilePosition,
config: &'db CompletionConfig<'db>,
+ trigger_character: Option<char>,
) -> Option<(CompletionContext<'db>, CompletionAnalysis<'db>)> {
let _p = tracing::info_span!("CompletionContext::new").entered();
let sema = Semantics::new(db);
@@ -868,6 +872,7 @@ impl<'db> CompletionContext<'db> {
db,
config,
position,
+ trigger_character,
original_token,
token,
krate,