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 653
feat(rome_analyze): refactor code actions to use batch mutations #2915
Merged
Conversation
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
!bench_analyzer |
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
Analyzer Benchmark Results
|
63ad55b
to
d46f232
Compare
Deploying with
|
Latest commit: |
ec50d8d
|
Status: | ✅ Deploy successful! |
Preview URL: | https://e1db45c2.tools-8rn.pages.dev |
Branch Preview URL: | https://feature-code-action-batch-mu.tools-8rn.pages.dev |
xunilrj
reviewed
Jul 22, 2022
crates/rome_analyze/src/signals.rs
Outdated
fn from(action: AnalyzerAction<L>) -> Self { | ||
let indels = action.as_indels(); | ||
|
||
let range = indels.iter().fold(None, |state, indel| match state { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to move this closer to the BatchMutation
?
I can see this being helpful when renaming inside the LSP, for example.
Today I return the whole file, instead of the snippets that changed.
ematipico
approved these changes
Jul 22, 2022
5c1bfc1
to
ec50d8d
Compare
IWANABETHATGUY
pushed a commit
to IWANABETHATGUY/tools
that referenced
this pull request
Aug 22, 2022
…e#2915) * feat(rome_analyze): refactor code actions to use batch mutations * refactor the text edit generation from batch mutation to be used in renaming operations
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 refactors the
RuleAction
andAnalyzerAction
to have lint rules provide code actions in the form ofBatchMutation
objects instead of returning a mutated syntax tree. In addition to possible improvements to performances unlocked by batching the mutations, this change allows the set of changes to be inspected in order to efficiently generate smaller text diffs that directly represent the mutation operations that were executed on the syntax tree usingrome_text_edit
(in fact for most use-cases code actions can directly be turned into a text-based diff operation without having to go through the mutation commit operation to build the mutated syntax tree)In order to support this I had to extend the
BatchMutation
to support additional mutation operations that were used by existing lint rules, as well as replicating the "automatic trivia transfer" feature of thereplace_node
andreplace_token
method of theAstNode
mutation extensionsTest Plan
The lint rules test suite has been adapted to the new internal representation of code actions with no changes to the content of snapshots, from a user perspective all rules continue to emit the exact same code actions as before the change