This repository was archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
fix(rome_js_analyze): fix the removal of nodes from syntax lists in batch mutations #2980
Merged
Conversation
This file contains 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
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
xunilrj
reviewed
Aug 1, 2022
I suppose we will need to be able to insert nodes in the future. Right? |
xunilrj
approved these changes
Aug 1, 2022
At the moment it's possible to get around it by first creating a mutated copy of the parent list with the new node inserted, then adding a replacement operation for that list node to the batch mutation (this is what |
MichaReiser
approved these changes
Aug 2, 2022
ematipico
reviewed
Aug 2, 2022
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/tools
that referenced
this pull request
Aug 22, 2022
…atch mutations (rome#2980) * fix(rome_js_analyze): fix the removal of nodes from syntax lists in batch mutations * address PR review * run the configuration codegen
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR fixes #2966 by changing the behavior of the
remove_node
batch mutation method in syntax lists, making it actually remove the corresponding slot from the list instead of replacing the previous node with an empty slot.In order to make this work the batch mutation now has to track the number of removed slots in a node to adjust the indices of other modifications being applied to the same node, in turn this means I had to change the ordering semantics of mutation changes slightly so that modifications that apply to the same node are sorted in increasing order by the index of the slot they are modifying.
Test Plan
To test this change and protect from future regressions I modified the analyzer tests to perform additional checks on the syntax tree emitted by code actions. These checks include:
as_text_edits
and printing the syntax tree returned bycommit
result in the same source codeIncidentally these new checks required changes in a few existing tests that had syntax errors in the input file