Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/completions/expr.rs')
| -rw-r--r-- | crates/ide-completion/src/completions/expr.rs | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs index 891717285d..9708f9c526 100644 --- a/crates/ide-completion/src/completions/expr.rs +++ b/crates/ide-completion/src/completions/expr.rs @@ -329,11 +329,8 @@ pub(crate) fn complete_expr_path( } } -pub(crate) fn complete_expr( - acc: &mut Completions, - ctx: &CompletionContext<'_>, -) { - let _p = profile::span("complete_expr"); +pub(crate) fn complete_expr(acc: &mut Completions, ctx: &CompletionContext<'_>) { + let _p = tracing::span!(tracing::Level::INFO, "complete_expr").entered(); if !ctx.qualifier_ctx.none() { return; } @@ -351,12 +348,34 @@ pub(crate) fn complete_expr( config: hir::term_search::TermSearchConfig { enable_borrowcheck: false, many_alternatives_threshold: 1, - depth: 2, + depth: 6, }, }; - let exprs = hir::term_search::term_search(term_search_ctx); + let exprs = hir::term_search::term_search(&term_search_ctx); for expr in exprs { - acc.add_expr(ctx, &expr); + // Expand method calls + match expr { + hir::term_search::Expr::Method { func, generics, target, params } + if target.is_many() => + { + let target_ty = target.ty(ctx.db); + let term_search_ctx = + hir::term_search::TermSearchCtx { goal: target_ty, ..term_search_ctx }; + let target_exprs = hir::term_search::term_search(&term_search_ctx); + + for expr in target_exprs { + let expanded_expr = hir::term_search::Expr::Method { + func, + generics: generics.clone(), + target: Box::new(expr), + params: params.clone(), + }; + + acc.add_expr(ctx, &expanded_expr) + } + } + _ => acc.add_expr(ctx, &expr), + } } } } |