-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Migrate convert_tuple_struct_to_named_struct
assist to use SyntaxEditor
#20311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate convert_tuple_struct_to_named_struct
assist to use SyntaxEditor
#20311
Conversation
3025fab
to
a74d6ec
Compare
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Hayashi Mikihiro <[email protected]>
…` to SyntaxEditor Signed-off-by: Hayashi Mikihiro <[email protected]>
…ditor' Signed-off-by: Hayashi Mikihiro <[email protected]>
cd07345
to
475ebb8
Compare
let tuple_fields_text_range = tuple_fields.syntax().text_range(); | ||
|
||
edit.edit_file(ctx.vfs_file_id()); | ||
let record_fields = ast::make::record_field_list(record_fields).clone_for_update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to use
pub fn record_field_list( |
especially when we need .clone_for_update()
here. Though it still calls clone_for_update()
in its body, at least we can gather them up in one place and bulk-fix later.
@@ -245,7 +275,7 @@ fn generate_names(fields: impl Iterator<Item = ast::TupleField>) -> Vec<ast::Nam | |||
.enumerate() | |||
.map(|(i, _)| { | |||
let idx = i + 1; | |||
ast::make::name(&format!("field{idx}")) | |||
ast::make::name(&format!("field{idx}")).clone_for_update() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the above, with
pub fn name(&self, name: &str) -> ast::Name { |
Everything else looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
part of #15710 and #18285