internal: migrate extract_module to SyntaxEditor#21868
Open
itang06 wants to merge 5 commits intorust-lang:masterfrom
Open
internal: migrate extract_module to SyntaxEditor#21868itang06 wants to merge 5 commits intorust-lang:masterfrom
itang06 wants to merge 5 commits intorust-lang:masterfrom
Conversation
Member
There was a problem hiding this comment.
Please migrate remaining make::* usages to SyntaxFactory APIs
| continue; | ||
| } | ||
|
|
||
| let mut editor = SyntaxEditor::new(body_item.syntax().clone()); |
Member
There was a problem hiding this comment.
Is this new SyntaxEditor instance and .finish() call on it necessary? Couldn't it be done by passing the mutable reference of existing one from the assist entrance function as a parameter of this function instead?
| }) | ||
| .collect(); | ||
| if !replacements.is_empty() { | ||
| let mut editor = SyntaxEditor::new(entry.syntax().clone()); |
Shourya742
reviewed
Mar 25, 2026
| @@ -18,8 +18,10 @@ use syntax::{ | |||
| self, HasVisibility, | |||
| edit::{AstNodeEdit, IndentLevel}, | |||
| make, | |||
Member
There was a problem hiding this comment.
Kindly replace use of make with SyntaxFactory
| let assoc_item_list = make::assoc_item_list(Some(assoc_items)).clone_for_update(); | ||
| let impl_ = impl_.reset_indent(); | ||
| ted::replace(impl_.get_or_create_assoc_item_list().syntax(), assoc_item_list.syntax()); | ||
| let impl_detached = ast::Impl::cast(impl_.syntax().clone_subtree()).unwrap(); |
|
|
||
| let (mut replacements, record_field_parents, impls) = | ||
| get_replacements_for_visibility_change(&mut self.body_items, false); | ||
| get_replacements_for_visibility_change(&mut self.body_items, true); |
|
|
||
| let mut editor = SyntaxEditor::new(body_item.syntax().clone()); | ||
| for target in insert_targets { | ||
| let pub_crate_vis = make::visibility_pub_crate().clone_for_update(); |
| Some(( | ||
| seg.syntax().parent()?, | ||
| make::path_from_text(&format!("{mod_name}::{seg}")) | ||
| .clone_for_update(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #18285
Migrates all
ted::calls incrates/ide-assists/src/handlers/extract_module.rsto the newSyntaxEditor/SyntaxFactoryabstractionChanges:
generate_module_def: replacedted::withSyntaxEditor/SyntaxFactoryexpand_and_group_usages_file_wise: replacedted::replacewithSyntaxEditorchange_visibility: replacedted::insert(viaadd_change_vishelper) withSyntaxEditor::insert_all; removes theadd_change_visfunction entirelyAI assistance was used for this contribution