Migrate merge imports to editor#22351
Open
Shourya742 wants to merge 7 commits into
Open
Conversation
24ab4f9 to
d144bca
Compare
d144bca to
935f981
Compare
ChayimFriedman2
requested changes
May 24, 2026
| } | ||
| } | ||
|
|
||
| /// Editor variant of `split_prefix` |
Contributor
There was a problem hiding this comment.
Suggested change
| /// Editor variant of `split_prefix` | |
| /// Splits off the given prefix, making it the path component of the use tree, | |
| /// appending the rest of the path to all UseTreeList items. | |
| /// | |
| /// # Examples | |
| /// | |
| /// `prefix$0::suffix` -> `prefix::{suffix}` | |
| /// | |
| /// `prefix$0` -> `prefix::{self}` | |
| /// | |
| /// `prefix$0::*` -> `prefix::{*}```` |
Comment on lines
+39
to
+41
| let parent_node = use_item.syntax().parent()?; | ||
| let (editor, _) = | ||
| SyntaxEditor::new(parent_node.ancestors().last().unwrap_or(parent_node.clone())); |
Contributor
There was a problem hiding this comment.
Suggested change
| let parent_node = use_item.syntax().parent()?; | |
| let (editor, _) = | |
| SyntaxEditor::new(parent_node.ancestors().last().unwrap_or(parent_node.clone())); | |
| let (editor, _) = | |
| SyntaxEditor::new(use_item.syntax().ancestors().last().unwrap()); |
| let first_selected = selected_nodes.next()?; | ||
| let edits = match_ast! { | ||
| let (editor, _) = | ||
| SyntaxEditor::new(parent_node.ancestors().last().unwrap_or(parent_node.clone())); |
Contributor
There was a problem hiding this comment.
Suggested change
| SyntaxEditor::new(parent_node.ancestors().last().unwrap_or(parent_node.clone())); | |
| SyntaxEditor::new(parent_node.ancestors().last().unwrap()); |
| } | ||
|
|
||
| fn use_tree_list_style(use_tree_list: &ast::UseTreeList) -> Option<(String, String, bool)> { | ||
| let text = use_tree_list.syntax().text().to_string(); |
Contributor
There was a problem hiding this comment.
I really dislike this text manipulation. Please do this with proper AST.
| .map(|tree| merge.is_tree_allowed(&tree).then_some(tree)) | ||
| .collect::<Option<_>>()?; | ||
| .map(|(idx, tree)| merge.is_tree_allowed(tree).then_some(idx)) | ||
| .collect::<Option<Vec<_>>>()?; |
Contributor
There was a problem hiding this comment.
Why did you change this to be a second Vec of indices? The previous setup was clearer IMO.
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 #15710 and #18285