Skip to content
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 merge_imports Assist to Use SyntaxFactory #18484

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tareknaser
Copy link
Contributor

This PR is part of #15710 and #18285.

Changes Made

  • Followed the steps in Migrate assists to SyntaxEditor #18285 for migration.
  • Removed the edits_mut vector from crates/ide-assists/src/handlers/merge_imports.rs
  • Added a new SyntaxFactory method whitespace
    • There are no mappings needed as far as I am concerned
    • Currently named whitespace as it mirrors make::tokens::whitespace but tokens_whitespace might be a more fitting name.
  • Replaced the edit_in_place::Removable trait with edit_in_place::EditorRemovable (Relevant conversation here)
    • This trait requires a SyntaxEditor instance in the remove method to use instead of ted.
    • Implemented for ast::Use and ast::UseTree
    • Most implementations remain the same, except that I used SyntaxEditor::delete instead of ted::remove and ted::remove_all_iter. Since SyntaxEditor::remove doesn’t exist, I assumed delete would perform the same function—though this might be causing issues.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2024
@tareknaser
Copy link
Contributor Author

Marking this as a draft for now since I’m running into an error.

---- handlers::merge_imports::tests::test_merge_with_synonymous_imports_1 stdout ----

thread 'handlers::merge_imports::tests::test_merge_with_synonymous_imports_1' panicked at crates/syntax/src/syntax_editor/edit_algo.rs:79:8:

some replace change ranges intersect: [Replace(Token([email protected] "\n\n"), Some(Token([email protected] "\n\n"))), Replace(Node([email protected]), None), Replace(Token([email protected] "\n"), None), Replace(Node([email protected]), Some(Node([email protected])))]

  

---- handlers::merge_imports::tests::test_merge_with_synonymous_imports_2 stdout ----

thread 'handlers::merge_imports::tests::test_merge_with_synonymous_imports_2' panicked at crates/syntax/src/syntax_editor/edit_algo.rs:79:8:

some replace change ranges intersect: [Replace(Token([email protected] "\n\n"), Some(Token([email protected] "\n\n"))), Replace(Node([email protected]), None), Replace(Token([email protected] "\n"), None), Replace(Node([email protected]), Some(Node([email protected])))]

  

---- tests::generated::doctest_merge_imports stdout ----

thread 'tests::generated::doctest_merge_imports' panicked at crates/syntax/src/syntax_editor/edit_algo.rs:79:8:

some replace change ranges intersect: [Replace(Node([email protected]), Some(Node([email protected]))), Replace(Token([email protected] "\n"), Some(Token([email protected] "\n"))), Replace(Node([email protected]), None), Replace(Token([email protected] "\n"), None)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants