This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
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
I finally had a breakthrough! It took me a bit to arrive there, but I finally managed to breakdown the logic of the files and re-use it when needed.
There were two significant issues:
I created a new wrapper called
SharedTraversalOptions
. This tiny struct is used to make the compiler happy and tell it that "ctx
is just borrowed, and it won't escape the boundaries of the lifetimes".I created a new
WorkspaceFile
, another tiny wrapper meant to coordinate the writing of a new file. For example, when applying fixes to a file, we need to:This must be done because when we pass to the formatting pass, we need to apply the format, we need to have the new content of the file at end, even for the diagnostics.
I will look into it later if it's possible to optimize this part. Unfortunately, we need to keep a
String
around (it was like this before too).This is a BREAKING CHANGE because now formatting diagnostics are always shown when running
rome check
. If you noticed, many snapshots were updated, offering more diagnostics. This is the intended feature of therome check
command.Test Plan
I updated the existing tests and made sure that the emitted messages are correct.