Skip to content

Migrate missing fields to syntax editor#22261

Merged
ChayimFriedman2 merged 6 commits intorust-lang:masterfrom
Shourya742:2026-05-03-migrate-missing-fields-to-syntax-editor
May 5, 2026
Merged

Migrate missing fields to syntax editor#22261
ChayimFriedman2 merged 6 commits intorust-lang:masterfrom
Shourya742:2026-05-03-migrate-missing-fields-to-syntax-editor

Conversation

@Shourya742
Copy link
Copy Markdown
Member

part of #15710 and #18285

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

This comment has been minimized.

@Shourya742 Shourya742 force-pushed the 2026-05-03-migrate-missing-fields-to-syntax-editor branch from 4f84c19 to dc702ae Compare May 3, 2026 15:12
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 3, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Shourya742 Shourya742 force-pushed the 2026-05-03-migrate-missing-fields-to-syntax-editor branch from dc702ae to 82c6405 Compare May 3, 2026 15:15
@Shourya742 Shourya742 requested a review from ChayimFriedman2 May 3, 2026 16:03
let edit = editor.finish();
edit.new_root()
.descendants()
.find(|it| it.kind() == kind && it.text_range().start() == old_range.start())
Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 May 4, 2026

Choose a reason for hiding this comment

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

Can't we have a for the range since the editor roots things?

Also it's worth considering whether we should generalize the process of finding the mapped node to a method in the editor.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't get the first suggestion.

We can opt for range based finding on new root.

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.

What I was saying is that since the editor clone_subtree()s its node, the ranges won't be equal.

Copy link
Copy Markdown
Member Author

@Shourya742 Shourya742 May 4, 2026

Choose a reason for hiding this comment

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

We don't really need this, considering we are inserting only the new fields, it should be present in changed_elements in final edit, which we can directly use that. Added here: 8a83ee6. Tests are failing with this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added find_element in syntax_edit, which respects the relative positioning of the element.

@Shourya742 Shourya742 force-pushed the 2026-05-03-migrate-missing-fields-to-syntax-editor branch from 8a83ee6 to 82c6405 Compare May 4, 2026 04:44
@Shourya742 Shourya742 requested a review from ChayimFriedman2 May 4, 2026 12:52
Comment thread crates/syntax/src/syntax_editor/edits.rs
@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue May 5, 2026
Merged via the queue into rust-lang:master with commit 06aba0c May 5, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 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