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.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/crates/ide-completion/src/completions/expr.rs b/crates/ide-completion/src/completions/expr.rs
index 2133291b1d..a7df0ab386 100644
--- a/crates/ide-completion/src/completions/expr.rs
+++ b/crates/ide-completion/src/completions/expr.rs
@@ -61,6 +61,8 @@ pub(crate) fn complete_expr_path(
after_if_expr,
in_condition,
incomplete_let,
+ after_incomplete_let,
+ in_value,
ref ref_expr_parent,
after_amp,
ref is_func_update,
@@ -139,9 +141,8 @@ pub(crate) fn complete_expr_path(
Qualified::With { resolution: None, .. } => {}
Qualified::With { resolution: Some(resolution), .. } => {
// Add associated types on type parameters and `Self`.
- ctx.scope.assoc_type_shorthand_candidates(resolution, |_, alias| {
+ ctx.scope.assoc_type_shorthand_candidates(resolution, |alias| {
acc.add_type_alias(ctx, alias);
- None::<()>
});
match resolution {
hir::PathResolution::Def(hir::ModuleDef::Module(module)) => {
@@ -254,7 +255,7 @@ pub(crate) fn complete_expr_path(
.find_path(
ctx.db,
hir::ModuleDef::from(strukt),
- ctx.config.import_path_config(ctx.is_nightly),
+ ctx.config.find_path_config(ctx.is_nightly),
)
.filter(|it| it.len() > 1);
@@ -276,7 +277,7 @@ pub(crate) fn complete_expr_path(
.find_path(
ctx.db,
hir::ModuleDef::from(un),
- ctx.config.import_path_config(ctx.is_nightly),
+ ctx.config.find_path_config(ctx.is_nightly),
)
.filter(|it| it.len() > 1);
@@ -361,10 +362,16 @@ pub(crate) fn complete_expr_path(
add_keyword("loop", "loop {\n $0\n}");
if in_match_guard {
add_keyword("if", "if $0");
+ } else if in_value {
+ add_keyword("if", "if $1 {\n $2\n} else {\n $0\n}");
} else {
add_keyword("if", "if $1 {\n $0\n}");
}
- add_keyword("if let", "if let $1 = $2 {\n $0\n}");
+ if in_value {
+ add_keyword("if let", "if let $1 = $2 {\n $3\n} else {\n $0\n}");
+ } else {
+ add_keyword("if let", "if let $1 = $2 {\n $0\n}");
+ }
add_keyword("for", "for $1 in $2 {\n $0\n}");
add_keyword("true", "true");
add_keyword("false", "false");
@@ -379,8 +386,11 @@ pub(crate) fn complete_expr_path(
add_keyword("let", "let $1 = $0;");
}
- if after_if_expr {
+ if after_if_expr || after_incomplete_let {
add_keyword("else", "else {\n $0\n}");
+ }
+
+ if after_if_expr {
add_keyword("else if", "else if $1 {\n $0\n}");
}