Commit e29aa0c
analyzer: Convert applyOptions extension method into AnalysisOptionsBuilder 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]>1 parent 640ad14 commit e29aa0c
File tree
18 files changed
+614
-542
lines changed- pkg
- analyzer_cli
- lib/src
- test
- analyzer_plugin/test/utilities
- analyzer
- lib/src
- analysis_options
- dart
- analysis
- micro
- generated
- lint
- task
- test
- source
- src
- dart/analysis
- lint
- options
18 files changed
+614
-542
lines changedLines changed: 0 additions & 255 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
136 | 134 | | |
137 | 135 | | |
138 | 136 | | |
| |||
204 | 202 | | |
205 | 203 | | |
206 | 204 | | |
207 | | - | |
208 | | - | |
209 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
| |||
300 | 298 | | |
301 | 299 | | |
302 | 300 | | |
303 | | - | |
| 301 | + | |
304 | 302 | | |
305 | 303 | | |
306 | 304 | | |
307 | 305 | | |
308 | | - | |
309 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
312 | 312 | | |
313 | 313 | | |
| 314 | + | |
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
543 | 542 | | |
544 | 543 | | |
545 | 544 | | |
546 | | - | |
547 | | - | |
548 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| |||
0 commit comments