-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analyzer: Convert applyOptions extension method into AnalysisOptionsB…
…uilder builder. Previously, the fields in an AnalysisOptionsImpl were primarily arranged by an extension method, declared externally, called `applyOptions`. It seemed very odd that this wasn't just a method on AnalysisOptionsImpl; the "Impl" class is already private. But it turns out that an AnalysisOptionsImpl is _mostly_ not mutated in practice; the class wants to be immutable, with final fields. In this change, I make AnalysisOptionsImpl mostly immutable, and convert the `applyOptions` extension method, and all of its helper code, into a builder class, AnalysisOptionsBuilder. While we don't use a lot of builders in analyzer packages, this is a much more common and idiomatic pattern for setting up complicated data, multiple values, and then finalizing it all into an object that will not be changed again during it's lifetime. One big benefit of this refactoring is that most fields in AnalysisOptionsImpl are now final: * sourceLanguageConstraint * errorProcessors * excludePatterns * file * strictCasts * strictInference * strictRawTypes * chromeOsManifestChecks * codeStyleOptions * formatterOptions * unignorableNames Whereas before, they _all_ had to be mutable, as `applyOptions`, the primary mechanism for setting up an AnalysisOptionsImpl, had to able to write any field. Other changes: * Flip the instantiation of AnalysisOptionsImpl and CodeStyleOptions; now CodeStyleOptions is instatiated first, and AnalysisOptionsImpl sets itself as `codeStyleOptions.options`. * Remove the private, deprecated, `applyToAnalysisOptions` function. Change-Id: I6595d88aa5721e4f9a8b2b987482f9f43d27efd1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390660 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
- Loading branch information
Showing
18 changed files
with
614 additions
and
542 deletions.
There are no files selected for viewing
255 changes: 0 additions & 255 deletions
255
pkg/analyzer/lib/src/analysis_options/apply_options.dart
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.