-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cli): traversal #3563
refactor(cli): traversal #3563
Conversation
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.
Looks good to me. I left some remarks and suggestions.
@@ -483,11 +505,16 @@ pub(crate) struct TraversalOptions<'ctx, 'app> { | |||
/// The approximate number of diagnostics the console will print before | |||
/// folding the rest into the "skipped diagnostics" counter | |||
pub(crate) remaining_diagnostics: &'ctx AtomicU32, | |||
|
|||
/// List of paths that should be processed | |||
pub(crate) evaluated_paths: RwLock<FxHashSet<EvaluatedPath>>, |
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.
Just to be sure: why do we need a RWLock
here? Have we several processes that “evaluate” files? Or it is just for toggling if a file was fixed? In this last case, we could use an atomic bool?
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.
TraversalOptions
is sent as a reference across multiple threads. So we need RwLock
for two reasons:
- enable interior mutability when having a
&self
- lock the resource when multiple threads want to update the list
crates/biome_cli/tests/snapshots/main_cases_diagnostics/max_diagnostics_verbose.snap
Outdated
Show resolved
Hide resolved
crates/biome_cli/tests/snapshots/main_cases_diagnostics/max_diagnostics_verbose.snap
Outdated
Show resolved
Hide resolved
.map(|pattern| pattern as &dyn Display) | ||
.collect(); | ||
|
||
visitor.record_list(&pattern_list) |
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.
In another PR we could certainly accept an impl Iterator
in order to avoid the allocation of a Vec
.
Summary
Part of #3307
The PR breaks down the traversal into two parts:
The logic of the evaluation is pretty much the same we have today, and at the end instead of calling
handle_path
, we can a new function calledstore_path
.Once the evaluation finishes, we call
traversal
again, but we can a new function calledhandle
, which essentially calls the existing functionprocess_file
.Now that we have this new information, I took the opportunity to add two new verbose diagnostics that show the evaluated paths, and the paths that were changed.
Test Plan
Updated the current snapshosts.