@@ -158,7 +158,7 @@ class AnalysisDriver {
158158 final DeclaredVariables declaredVariables;
159159
160160 /// The analysis context that created this driver / session.
161- DriverBasedAnalysisContext ? analysisContext;
161+ final DriverBasedAnalysisContext ? analysisContext;
162162
163163 /// The salt to mix into all hashes used as keys for unlinked data.
164164 Uint32List _saltForUnlinked = Uint32List (0 );
@@ -236,7 +236,7 @@ class AnalysisDriver {
236236
237237 final AnalysisDriverTestView ? testView;
238238
239- late FileSystemState _fsState;
239+ late final FileSystemState _fsState;
240240
241241 /// The [FileTracker] used by this driver.
242242 late FileTracker _fileTracker;
@@ -265,7 +265,7 @@ class AnalysisDriver {
265265 bool _disposed = false ;
266266
267267 /// A map that associates files to corresponding analysis options.
268- late final AnalysisOptionsMap analysisOptionsMap;
268+ final AnalysisOptionsMap analysisOptionsMap;
269269
270270 /// Whether timing data should be gathered during lint rule execution.
271271 final bool _enableLintRuleTiming;
@@ -311,25 +311,21 @@ class AnalysisDriver {
311311 _externalSummaries = externalSummaries,
312312 declaredVariables = declaredVariables ?? DeclaredVariables (),
313313 testingData = retainDataForTesting ? TestingData () : null ,
314- _enableLintRuleTiming = enableLintRuleTiming {
314+ _enableLintRuleTiming = enableLintRuleTiming,
315+ // This extra work is temporary and will get simplified when the
316+ // deprecated support for passing in an `analysisOptions` is removed.
317+ assert (
318+ analysisOptionsMap == null || analysisOptions == null ,
319+ 'An analysisOptionsMap or analysisOptions can be specified, but not both' ,
320+ ),
321+ // This '!' is temporary. The analysisOptionsMap is effectively
322+ // required but can't be until Google3 is updated.
323+ analysisOptionsMap = analysisOptions == null
324+ ? analysisOptionsMap!
325+ : AnalysisOptionsMap .forSharedOptions (analysisOptions) {
315326 analysisContext? .driver = this ;
316327 testView? .driver = this ;
317328
318- // Setup the options map.
319- // This extra work is temporary and will get simplified when the deprecated support for
320- // passing in a single analysisOptions is removed.
321- if (analysisOptionsMap != null && analysisOptions != null ) {
322- throw AssertionError (
323- 'An analysisOptionsMap or analysisOptions can be specified, but not both' );
324- }
325- if (analysisOptions != null ) {
326- this .analysisOptionsMap =
327- AnalysisOptionsMap .forSharedOptions (analysisOptions);
328- } else {
329- // This '!' is temporary. The analysisOptionsMap is effectively required but can't be until Google3 is updated.
330- this .analysisOptionsMap = analysisOptionsMap! ;
331- }
332-
333329 _fileContentStrategy = StoredFileContentStrategy (_fileContentCache);
334330
335331 _createFileTracker ();
@@ -973,14 +969,11 @@ class AnalysisDriver {
973969 /// Return a [ParsedLibraryResult] for the library with the given [uri] .
974970 SomeParsedLibraryResult getParsedLibraryByUri (Uri uri) {
975971 var fileOr = _fsState.getFileForUri (uri);
976- switch (fileOr) {
977- case null :
978- return CannotResolveUriResult ();
979- case UriResolutionFile (: var file):
980- return getParsedLibrary (file.path);
981- case UriResolutionExternalLibrary ():
982- return UriOfExternalLibraryResult ();
983- }
972+ return switch (fileOr) {
973+ null => CannotResolveUriResult (),
974+ UriResolutionFile (: var file) => getParsedLibrary (file.path),
975+ UriResolutionExternalLibrary () => UriOfExternalLibraryResult (),
976+ };
984977 }
985978
986979 /// Return a [Future] that completes with a [ResolvedLibraryResult] for the
@@ -1168,7 +1161,7 @@ class AnalysisDriver {
11681161 return InvalidPathResult ();
11691162 }
11701163
1171- FileState file = _fsState.getFileForPath (path);
1164+ var file = _fsState.getFileForPath (path);
11721165 RecordingErrorListener listener = RecordingErrorListener ();
11731166 CompilationUnit unit = file.parse (
11741167 errorListener: listener,
@@ -1596,8 +1589,7 @@ class AnalysisDriver {
15961589
15971590 /// Creates new [FileSystemState] and [FileTracker] objects.
15981591 ///
1599- /// This is used both on initial construction and whenever the configuration
1600- /// changes.
1592+ /// This is used on initial construction.
16011593 void _createFileTracker () {
16021594 _fillSalt ();
16031595
@@ -1864,7 +1856,7 @@ class AnalysisDriver {
18641856 await scheduler.accumulatedPerformance.runAsync (
18651857 'getUnitElement' ,
18661858 (performance) async {
1867- FileState file = _fsState.getFileForPath (path);
1859+ var file = _fsState.getFileForPath (path);
18681860
18691861 // Prepare the library - the file itself, or the known library.
18701862 var kind = file.kind;
0 commit comments