Skip to content

Commit ddb2f87

Browse files
committed
typo fix
1 parent 69ffbe2 commit ddb2f87

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

crates/ide-assists/src/handlers/add_braces.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,9 @@ use syntax::{
55

66
use crate::{AssistContext, AssistId, AssistKind, Assists};
77

8-
enum ParentType {
9-
MatchArmExpr,
10-
ClosureExpr,
11-
}
12-
13-
fn get_replacement_node(ctx: &AssistContext<'_>) -> Option<(ParentType, ast::Expr)> {
14-
if let Some(match_arm) = ctx.find_node_at_offset::<ast::MatchArm>() {
15-
let match_arm_expr = match_arm.syntax().children().find_map(ast::Expr::cast)?;
16-
17-
if matches!(match_arm_expr, ast::Expr::BlockExpr(_)) {
18-
return None;
19-
}
20-
21-
return Some((ParentType::MatchArmExpr, match_arm_expr));
22-
} else if let Some(closure_expr) = ctx.find_node_at_offset::<ast::ClosureExpr>() {
23-
let body = closure_expr.body()?;
24-
25-
if matches!(body, ast::Expr::BlockExpr(_)) {
26-
return None;
27-
}
28-
29-
return Some((ParentType::ClosureExpr, body));
30-
}
31-
32-
None
33-
}
34-
358
// Assist: add_braces
369
//
37-
// Adds braces to lamda and match arm expressions
10+
// Adds braces to lambda and match arm expressions.
3811
//
3912
// ```
4013
// fn foo(n: i32) -> i32 {
@@ -61,7 +34,7 @@ pub(crate) fn add_braces(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<(
6134
acc.add(
6235
AssistId("wrap_with_braces", AssistKind::RefactorRewrite),
6336
match expr_type {
64-
ParentType::ClosureExpr => "Add braces to lamda expression",
37+
ParentType::ClosureExpr => "Add braces to lambda expression",
6538
ParentType::MatchArmExpr => "Add braces to arm expression",
6639
},
6740
expr.syntax().text_range(),
@@ -78,6 +51,33 @@ pub(crate) fn add_braces(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<(
7851
Some(())
7952
}
8053

54+
enum ParentType {
55+
MatchArmExpr,
56+
ClosureExpr,
57+
}
58+
59+
fn get_replacement_node(ctx: &AssistContext<'_>) -> Option<(ParentType, ast::Expr)> {
60+
if let Some(match_arm) = ctx.find_node_at_offset::<ast::MatchArm>() {
61+
let match_arm_expr = match_arm.syntax().children().find_map(ast::Expr::cast)?;
62+
63+
if matches!(match_arm_expr, ast::Expr::BlockExpr(_)) {
64+
return None;
65+
}
66+
67+
return Some((ParentType::MatchArmExpr, match_arm_expr));
68+
} else if let Some(closure_expr) = ctx.find_node_at_offset::<ast::ClosureExpr>() {
69+
let body = closure_expr.body()?;
70+
71+
if matches!(body, ast::Expr::BlockExpr(_)) {
72+
return None;
73+
}
74+
75+
return Some((ParentType::ClosureExpr, body));
76+
}
77+
78+
None
79+
}
80+
8181
#[cfg(test)]
8282
mod tests {
8383
use crate::tests::{check_assist, check_assist_not_applicable};

0 commit comments

Comments
 (0)