Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/expand_rest_pattern.rs')
-rw-r--r--crates/ide-assists/src/handlers/expand_rest_pattern.rs31
1 files changed, 11 insertions, 20 deletions
diff --git a/crates/ide-assists/src/handlers/expand_rest_pattern.rs b/crates/ide-assists/src/handlers/expand_rest_pattern.rs
index a7e78dfc9c..dc4976e8c2 100644
--- a/crates/ide-assists/src/handlers/expand_rest_pattern.rs
+++ b/crates/ide-assists/src/handlers/expand_rest_pattern.rs
@@ -51,8 +51,8 @@ fn expand_record_rest_pattern(
"Fill struct fields",
rest_pat.syntax().text_range(),
|builder| {
- let make = SyntaxFactory::with_mappings();
- let mut editor = builder.make_editor(rest_pat.syntax());
+ let editor = builder.make_editor(rest_pat.syntax());
+ let make = editor.make();
let new_fields = old_field_list.fields().chain(matched_fields.iter().map(|(f, _)| {
make.record_pat_field_shorthand(
make.ident_pat(
@@ -66,8 +66,6 @@ fn expand_record_rest_pattern(
let new_field_list = make.record_pat_field_list(new_fields, None);
editor.replace(old_field_list.syntax(), new_field_list.syntax());
-
- editor.add_mappings(make.finish_with_mappings());
builder.add_file_edits(ctx.vfs_file_id(), editor);
},
)
@@ -130,8 +128,8 @@ fn expand_tuple_struct_rest_pattern(
"Fill tuple struct fields",
rest_pat.syntax().text_range(),
|builder| {
- let make = SyntaxFactory::with_mappings();
- let mut editor = builder.make_editor(rest_pat.syntax());
+ let editor = builder.make_editor(rest_pat.syntax());
+ let make = editor.make();
let mut name_gen = NameGenerator::new_from_scope_locals(ctx.sema.scope(pat.syntax()));
let new_pat = make.tuple_struct_pat(
@@ -141,7 +139,7 @@ fn expand_tuple_struct_rest_pattern(
.chain(fields[prefix_count..fields.len() - suffix_count].iter().map(|f| {
gen_unnamed_pat(
ctx,
- &make,
+ make,
&mut name_gen,
&f.ty(ctx.db()).to_type(ctx.sema.db),
f.index(),
@@ -151,8 +149,6 @@ fn expand_tuple_struct_rest_pattern(
);
editor.replace(pat.syntax(), new_pat.syntax());
-
- editor.add_mappings(make.finish_with_mappings());
builder.add_file_edits(ctx.vfs_file_id(), editor);
},
)
@@ -200,24 +196,21 @@ fn expand_tuple_rest_pattern(
"Fill tuple fields",
rest_pat.syntax().text_range(),
|builder| {
- let make = SyntaxFactory::with_mappings();
- let mut editor = builder.make_editor(rest_pat.syntax());
-
+ let editor = builder.make_editor(rest_pat.syntax());
+ let make = editor.make();
let mut name_gen = NameGenerator::new_from_scope_locals(ctx.sema.scope(pat.syntax()));
let new_pat = make.tuple_pat(
pat.fields()
.take(prefix_count)
.chain(fields[prefix_count..len - suffix_count].iter().enumerate().map(
|(index, ty)| {
- gen_unnamed_pat(ctx, &make, &mut name_gen, ty, prefix_count + index)
+ gen_unnamed_pat(ctx, make, &mut name_gen, ty, prefix_count + index)
},
))
.chain(pat.fields().skip(prefix_count + 1)),
);
editor.replace(pat.syntax(), new_pat.syntax());
-
- editor.add_mappings(make.finish_with_mappings());
builder.add_file_edits(ctx.vfs_file_id(), editor);
},
)
@@ -264,8 +257,8 @@ fn expand_slice_rest_pattern(
"Fill slice fields",
rest_pat.syntax().text_range(),
|builder| {
- let make = SyntaxFactory::with_mappings();
- let mut editor = builder.make_editor(rest_pat.syntax());
+ let editor = builder.make_editor(rest_pat.syntax());
+ let make = editor.make();
let mut name_gen = NameGenerator::new_from_scope_locals(ctx.sema.scope(pat.syntax()));
let new_pat = make.slice_pat(
@@ -273,14 +266,12 @@ fn expand_slice_rest_pattern(
.take(prefix_count)
.chain(
(prefix_count..len - suffix_count)
- .map(|index| gen_unnamed_pat(ctx, &make, &mut name_gen, &ty, index)),
+ .map(|index| gen_unnamed_pat(ctx, make, &mut name_gen, &ty, index)),
)
.chain(pat.pats().skip(prefix_count + 1)),
);
editor.replace(pat.syntax(), new_pat.syntax());
-
- editor.add_mappings(make.finish_with_mappings());
builder.add_file_edits(ctx.vfs_file_id(), editor);
},
)