Skip to content

Move syntax factory inside syntax editor#22049

Merged
ChayimFriedman2 merged 5 commits into
rust-lang:masterfrom
Shourya742:2026-04-15-move-syntax-factory-inside-syntax-editor
Apr 15, 2026
Merged

Move syntax factory inside syntax editor#22049
ChayimFriedman2 merged 5 commits into
rust-lang:masterfrom
Shourya742:2026-04-15-move-syntax-factory-inside-syntax-editor

Conversation

@Shourya742

@Shourya742 Shourya742 commented Apr 15, 2026

Copy link
Copy Markdown
Member

This PR moves SyntaxFactory inside SyntaxEditor and migrates all of its with_mapping usages to SyntaxEditor’s make variant. Some remnants of SyntaxFactory::without_mapping still remain; addressing them may require additional work, as most are tied to the broader migration to SyntaxEditor and can be handled later.

  • The first commit introduces changes to SyntaxEditor, including the integration of SyntaxFactory.
  • The second commit fixes constructor mapping issues encountered during the refactor.
  • The third commit migrates assists. Although large, the changes are straightforward and intuitive.

part of #15710 and #18285

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 15, 2026

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

While I am generally against interior mutability, this time I support it to make SyntaxEditor not require a mutable reference to allow storing editor.make() in a variable, which is more pleasant to the eyes IMO. I'll leave it to you, though, if you want to do that or merge this as-is.

View changes since this review

@Shourya742

Shourya742 commented Apr 15, 2026

Copy link
Copy Markdown
Member Author

LGTM.

While I am generally against interior mutability, this time I support it to make SyntaxEditor not require a mutable reference to allow storing editor.make() in a variable, which is more pleasant to the eyes IMO. I'll leave it to you, though, if you want to do that or merge this as-is.

View changes since this review

Adapted, introducing RefCell in SyntaxEditor, it’s now more pleasant to read, with an explicit variable for editor.make().

@Shourya742 Shourya742 force-pushed the 2026-04-15-move-syntax-factory-inside-syntax-editor branch from 4c84ff6 to 745286d Compare April 15, 2026 18:48

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// tree traversal. Thus all paths in the tree are collected into a vec
// so that such operation is safe.
let (mut editor, item) = SyntaxEditor::new(self.transform_path(item));
let (editor, item) = SyntaxEditor::new(self.transform_path(item));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nodes are going to carry a lifetime, this won't compile. It will need to accept an editor from the outside. Fine for this PR, though.

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Apr 15, 2026
Merged via the queue into rust-lang:master with commit 94c2f68 Apr 15, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants