aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/fill_match_arms.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/fill_match_arms.rs')
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs
index 69b535a27..d8e40b4b7 100644
--- a/crates/ra_assists/src/fill_match_arms.rs
+++ b/crates/ra_assists/src/fill_match_arms.rs
@@ -8,7 +8,7 @@ use ra_syntax::ast::{self, AstNode};
8 8
9use crate::{AssistCtx, Assist}; 9use crate::{AssistCtx, Assist};
10 10
11pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 11pub(crate) fn fill_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
12 let match_expr = ctx.node_at_offset::<ast::MatchExpr>()?; 12 let match_expr = ctx.node_at_offset::<ast::MatchExpr>()?;
13 13
14 // We already have some match arms, so we don't provide any assists. 14 // We already have some match arms, so we don't provide any assists.
@@ -33,7 +33,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
33 let enum_name = enum_def.name(ctx.db)?; 33 let enum_name = enum_def.name(ctx.db)?;
34 let db = ctx.db; 34 let db = ctx.db;
35 35
36 ctx.build("fill match arms", |edit| { 36 ctx.add_action("fill match arms", |edit| {
37 let mut buf = format!("match {} {{\n", expr.syntax().text().to_string()); 37 let mut buf = format!("match {} {{\n", expr.syntax().text().to_string());
38 let variants = enum_def.variants(db); 38 let variants = enum_def.variants(db);
39 for variant in variants { 39 for variant in variants {
@@ -68,7 +68,9 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
68 edit.target(match_expr.syntax().range()); 68 edit.target(match_expr.syntax().range());
69 edit.set_cursor(expr.syntax().range().start()); 69 edit.set_cursor(expr.syntax().range().start());
70 edit.replace_node_and_indent(match_expr.syntax(), buf); 70 edit.replace_node_and_indent(match_expr.syntax(), buf);
71 }) 71 });
72
73 ctx.build()
72} 74}
73 75
74#[cfg(test)] 76#[cfg(test)]