Version 2.17.0-206.0.dev

Merge commit '935faa6c8a860125a4762296ebca5ff7b4174281' into 'dev'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6bf63c92..be5981de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -101,6 +101,23 @@
           [web]                  A web app that uses only core Dart libraries.
 ```
 
+#### Linter
+
+Updated the Linter to `1.19.2`, which includes changes that
+
+- adds new lint: `use_super_initializers`.
+- adds new lint: `use_enums`.
+- adds new lint: `use_colored_box`.
+- improves performance for `sort_constructors`.
+- improves docs for `always_use_package_imports`,
+  `avoid_print`, and `avoid_relative_lib_imports` .
+- updates `avoid_void_async` to skip `main` functions.
+- updates `prefer_final_parameters` to not super on super params.
+- updates lints for enhanced-enums and super-initializer language
+  features.
+- updates `unnecessary_late` to report on variable names.
+- marks `null_check_on_nullable_type_parameter` stable.
+
 ## 2.16.1 - 2022-02-09
 
 This is a patch release that fixes an AOT precompiler crash when building some
@@ -183,20 +200,8 @@
 
 #### Linter
 
-Updated the Linter to `1.19.2`, which includes changes that
+Updated the Linter to `1.18.0`, which includes changes that
 
-- adds new lint: `use_super_initializers`.
-- adds new lint: `use_enums`.
-- adds new lint: `use_colored_box`.
-- improves performance for `sort_constructors`.
-- improves docs for `always_use_package_imports`,
-  `avoid_print`, and `avoid_relative_lib_imports` .
-- updates `avoid_void_async` to skip `main` functions.
-- updates `prefer_final_parameters` to not super on super params.
-- updates lints for enhanced-enums and super-initializer language
-  features.
-- updates `unnecessary_late` to report on variable names.
-- marks `null_check_on_nullable_type_parameter` stable.
 - extends `camel_case_types` to cover enums.
 - fixes `no_leading_underscores_for_local_identifiers` to not
   mis-flag field formal parameters with default values.
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 12ae415..b4c545a 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -47,6 +47,7 @@
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/exception/exception.dart';
 import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/file_system/overlay_file_system.dart';
 import 'package:analyzer/instrumentation/instrumentation.dart';
 import 'package:analyzer/src/dart/analysis/driver.dart' as analysis;
 import 'package:analyzer/src/dart/analysis/status.dart' as analysis;
@@ -123,6 +124,34 @@
   final StreamController _onAnalysisSetChangedController =
       StreamController.broadcast(sync: true);
 
+  /// Key: a file path for which removing of the overlay was requested.
+  /// Value: a timer that will remove the overlay, or cancelled.
+  ///
+  /// This helps for analysis server running remotely, with slow remote file
+  /// systems, in the following scenario:
+  /// 1. User edits file, IDE sends "add overlay".
+  /// 2. User saves file, IDE saves file locally, sends "remove overlay".
+  /// 3. The remove server reads the file on "remove overlay". But the content
+  ///    of the file on the remove machine is not the same as it is locally,
+  ///    and not what the user looks in the IDE. So, analysis results, such
+  ///    as semantic highlighting, are inconsistent with the local file content.
+  /// 4. (after a few seconds) The file is synced to the remove machine,
+  ///    the watch event happens, server reads the file, sends analysis
+  ///    results that are consistent with the local file content.
+  ///
+  /// We try to prevent the inconsistency between moments (3) and (4).
+  /// It is not wrong, we are still in the eventual consistency, but we
+  /// want to keep the inconsistency time shorter.
+  ///
+  /// To do this we keep the last overlay content on "remove overlay",
+  /// and wait for the next watch event in (4). But there might be race
+  /// condition, and when it happens, we still want to get to the eventual
+  /// consistency, so on timer we remove the overlay anyway.
+  final Map<String, Timer> _pendingFilesToRemoveOverlay = {};
+
+  @visibleForTesting
+  Duration pendingFilesRemoveOverlayDelay = const Duration(seconds: 10);
+
   final DetachableFileSystemManager? detachableFileSystemManager;
 
   /// The broadcast stream of requests that were discarded because there
@@ -231,6 +260,12 @@
     cancellationTokens[id]?.cancel();
   }
 
+  Future<void> dispose() async {
+    for (var timer in _pendingFilesToRemoveOverlay.values) {
+      timer.cancel();
+    }
+  }
+
   /// The socket from which requests are being read has been closed.
   void done() {}
 
@@ -511,7 +546,7 @@
       } catch (_) {}
 
       // Prepare the new contents.
-      String? newContents;
+      String newContents;
       if (change is AddContentOverlay) {
         newContents = change.content;
       } else if (change is ChangeContentOverlay) {
@@ -530,25 +565,28 @@
                   'Invalid overlay change')));
         }
       } else if (change is RemoveContentOverlay) {
-        newContents = null;
+        _pendingFilesToRemoveOverlay[file]?.cancel();
+        _pendingFilesToRemoveOverlay[file] = Timer(
+          pendingFilesRemoveOverlayDelay,
+          () {
+            resourceProvider.removeOverlay(file);
+            _changeFileInDrivers(file);
+          },
+        );
+        return;
       } else {
         // Protocol parsing should have ensured that we never get here.
         throw AnalysisException('Illegal change type');
       }
 
-      if (newContents != null) {
-        resourceProvider.setOverlay(
-          file,
-          content: newContents,
-          modificationStamp: overlayModificationStamp++,
-        );
-      } else {
-        resourceProvider.removeOverlay(file);
-      }
+      _pendingFilesToRemoveOverlay[file]?.cancel();
+      resourceProvider.setOverlay(
+        file,
+        content: newContents,
+        modificationStamp: overlayModificationStamp++,
+      );
 
-      driverMap.values.forEach((driver) {
-        driver.changeFile(file);
-      });
+      _changeFileInDrivers(file);
 
       // If the file did not exist, and is "overlay only", it still should be
       // analyzed. Add it to driver to which it should have been added.
@@ -586,6 +624,12 @@
 //    });
   }
 
+  void _changeFileInDrivers(String path) {
+    for (var driver in driverMap.values) {
+      driver.changeFile(path);
+    }
+  }
+
   /// Returns `true` if there is a subscription for the given [service] and
   /// [file].
   bool _hasAnalysisServiceSubscription(AnalysisService service, String file) {
@@ -671,7 +715,7 @@
   final AnalysisServer analysisServer;
 
   /// The [ResourceProvider] by which paths are converted into [Resource]s.
-  final ResourceProvider resourceProvider;
+  final OverlayResourceProvider resourceProvider;
 
   /// The set of files for which notifications were sent.
   final Set<String> filesToFlush = {};
@@ -698,6 +742,15 @@
 
   @override
   void afterWatchEvent(WatchEvent event) {
+    var path = event.path;
+
+    var pendingTimer = analysisServer._pendingFilesToRemoveOverlay.remove(path);
+    if (pendingTimer != null) {
+      pendingTimer.cancel();
+      resourceProvider.removeOverlay(path);
+      analysisServer._changeFileInDrivers(path);
+    }
+
     analysisServer._onAnalysisSetChangedController.add(null);
   }
 
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index d4ce078..65f35a6 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -417,8 +417,12 @@
       return null;
     }
 
-    var result = await session.getParsedUnit2(path);
-    return result is ParsedUnitResult ? result : null;
+    try {
+      var result = await session.getParsedUnit2(path);
+      return result is ParsedUnitResult ? result : null;
+    } on InconsistentAnalysisException {
+      return null;
+    }
   }
 
   /// Return the resolved unit for the file with the given [path]. The file is
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart
index 0e0b1c9..2dbdf85 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -201,10 +201,10 @@
     30,
     'Convert to a spread',
   );
-  static const CONVERT_TO_SUPER_INITIALIZING_PARAMETER = AssistKind(
-    'dart.assist.convert.toSuperInitializingParameter',
+  static const CONVERT_TO_SUPER_PARAMETERS = AssistKind(
+    'dart.assist.convert.toSuperParameters',
     30,
-    'Convert to a super initializing parameter',
+    'Convert to using super parameters',
   );
   static const ENCAPSULATE_FIELD = AssistKind(
     'dart.assist.encapsulateField',
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index 70835d5..c63b5e7 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -39,7 +39,7 @@
 import 'package:analysis_server/src/services/correction/dart/convert_to_package_import.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_to_relative_import.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_to_set_literal.dart';
-import 'package:analysis_server/src/services/correction/dart/convert_to_super_initializing_parameter.dart';
+import 'package:analysis_server/src/services/correction/dart/convert_to_super_parameters.dart';
 import 'package:analysis_server/src/services/correction/dart/encapsulate_field.dart';
 import 'package:analysis_server/src/services/correction/dart/exchange_operands.dart';
 import 'package:analysis_server/src/services/correction/dart/flutter_convert_to_children.dart';
@@ -120,7 +120,7 @@
     ConvertToRelativeImport.newInstance,
     ConvertToSetLiteral.newInstance,
     ConvertToSingleQuotes.newInstance,
-    ConvertToSuperInitializingParameter.newInstance,
+    ConvertToSuperParameters.newInstance,
     EncapsulateField.newInstance,
     ExchangeOperands.newInstance,
     FlutterConvertToChildren.newInstance,
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
index 9530b09..61cf3f9 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_enum.dart
@@ -4,6 +4,7 @@
 
 import 'package:analysis_server/src/services/correction/assist.dart';
 import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/correction/util.dart';
 import 'package:analysis_server/src/utilities/extensions/range_factory.dart';
 import 'package:analyzer/dart/analysis/features.dart';
@@ -16,6 +17,7 @@
 import 'package:analyzer_plugin/utilities/assist/assist.dart';
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:analyzer_plugin/utilities/range_factory.dart';
 import 'package:collection/collection.dart';
 
@@ -24,6 +26,18 @@
   AssistKind get assistKind => DartAssistKind.CONVERT_CLASS_TO_ENUM;
 
   @override
+  bool get canBeAppliedInBulk => true;
+
+  @override
+  bool get canBeAppliedToFile => true;
+
+  @override
+  FixKind get fixKind => DartFixKind.CONVERT_CLASS_TO_ENUM;
+
+  @override
+  FixKind get multiFixKind => DartFixKind.CONVERT_CLASS_TO_ENUM_MULTI;
+
+  @override
   Future<void> compute(ChangeBuilder builder) async {
     if (!libraryElement.featureSet.isEnabled(Feature.enhanced_enums)) {
       // If the library doesn't support enhanced_enums then the class can't be
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_initializing_parameter.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_initializing_parameter.dart
deleted file mode 100644
index b26d127..0000000
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_initializing_parameter.dart
+++ /dev/null
@@ -1,360 +0,0 @@
-// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analysis_server/src/services/correction/assist.dart';
-import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
-import 'package:analyzer/dart/analysis/features.dart';
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/source/source_range.dart';
-import 'package:analyzer_plugin/utilities/assist/assist.dart';
-import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
-import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
-import 'package:analyzer_plugin/utilities/range_factory.dart';
-
-class ConvertToSuperInitializingParameter extends CorrectionProducer {
-  @override
-  AssistKind get assistKind =>
-      DartAssistKind.CONVERT_TO_SUPER_INITIALIZING_PARAMETER;
-
-  /// If the selected node is the name of either a simple formal parameter or a
-  /// function-typed formal parameter, either with or without a default value,
-  /// then return the formal parameter. Otherwise return `null`.
-  FormalParameter? get _formalParameter {
-    final node = this.node;
-    if (node is SimpleIdentifier) {
-      var parent = node.parent;
-      if (parent is NormalFormalParameter &&
-          (parent is SimpleFormalParameter ||
-              parent is FunctionTypedFormalParameter) &&
-          parent.identifier == node) {
-        var grandparent = parent.parent;
-        if (grandparent is DefaultFormalParameter) {
-          return grandparent;
-        }
-        return parent;
-      }
-    }
-    return null;
-  }
-
-  @override
-  Future<void> compute(ChangeBuilder builder) async {
-    if (!libraryElement.featureSet.isEnabled(Feature.super_parameters)) {
-      // If the library doesn't support super_parameters then the change isn't
-      // appropriate.
-      return;
-    }
-    var parameter = _formalParameter;
-    if (parameter == null) {
-      // If the user hasn't selected a formal parameter to convert then there
-      // is nothing to change.
-      return;
-    }
-    var parameterList = parameter.parent;
-    if (parameterList is! FormalParameterList) {
-      // This is here to safely cast the parent. This branch should never be
-      // reached.
-      return;
-    }
-    var constructor = parameterList.parent;
-    if (constructor is! ConstructorDeclaration) {
-      // If this isn't a parameter in a constructor declaration then the change
-      // isn't appropriate.
-      return;
-    }
-    var superInvocation = _superInvocation(constructor);
-    if (superInvocation == null) {
-      // If there isn't an explicit invocation of the super constructor then the
-      // change isn't appropriate.
-      return;
-    }
-    var superConstructor = superInvocation.staticElement;
-    if (superConstructor == null) {
-      // If the super constructor wasn't resolved then we can't apply the
-      // change.
-      return;
-    }
-    var thisParameter = parameter.declaredElement;
-    if (thisParameter == null) {
-      return;
-    }
-
-    _ParameterData? data;
-    if (parameter.isPositional) {
-      data = _dataForPositionalParameter(
-          parameter, thisParameter, superConstructor, superInvocation);
-    } else if (parameter.isNamed) {
-      data = _dataForNamedParameter(
-          parameter, thisParameter, superConstructor, superInvocation);
-    }
-    if (data == null) {
-      return;
-    }
-
-    final parameterData = data;
-    await builder.addDartFileEdit(file, (builder) {
-      var typeToDelete = parameterData.typeToDelete;
-      if (typeToDelete == null) {
-        builder.addSimpleInsertion(parameter.identifier!.offset, 'super.');
-      } else {
-        var primaryRange = typeToDelete.primaryRange;
-        if (primaryRange == null) {
-          builder.addSimpleInsertion(parameter.identifier!.offset, 'super.');
-        } else {
-          builder.addSimpleReplacement(primaryRange, 'super.');
-        }
-        var parameterRange = typeToDelete.parameterRange;
-        if (parameterRange != null) {
-          builder.addDeletion(parameterRange);
-        }
-      }
-      parameterData.argumentUpdate.addDeletion(builder);
-      var defaultValueRange = parameterData.defaultValueRange;
-      if (defaultValueRange != null) {
-        builder.addDeletion(defaultValueRange);
-      }
-    });
-  }
-
-  ParameterElement? _correspondingNamedParameter(
-      ConstructorElement superConstructor, ParameterElement thisParameter) {
-    for (var superParameter in superConstructor.parameters) {
-      if (superParameter.isNamed && superParameter.name == thisParameter.name) {
-        return superParameter;
-      }
-    }
-    return null;
-  }
-
-  /// Return `true` if the named [parameter] can be converted into a super
-  /// initializing formal parameter.
-  _ParameterData? _dataForNamedParameter(
-      FormalParameter parameter,
-      ParameterElement thisParameter,
-      ConstructorElement superConstructor,
-      SuperConstructorInvocation superInvocation) {
-    var superParameter =
-        _correspondingNamedParameter(superConstructor, thisParameter);
-    if (superParameter == null) {
-      return null;
-    }
-    // Validate that the parameter is used in the super constructor invocation.
-    _ArgumentUpdate? argumentUpdate;
-    var arguments = superInvocation.argumentList.arguments;
-    for (var argument in arguments) {
-      if (argument is NamedExpression &&
-          argument.name.label.name == thisParameter.name) {
-        var expression = argument.expression;
-        if (expression is SimpleIdentifier &&
-            expression.staticElement == thisParameter) {
-          argumentUpdate = _RemoveArgument(argument);
-          break;
-        }
-      }
-    }
-    if (argumentUpdate == null) {
-      // If the selected parameter isn't being passed to the super constructor,
-      // then the change isn't appropriate.
-      return null;
-    } else if (arguments.length == 1) {
-      // If the selected parameter is the only parameter being passed to the
-      // super constructor then we no longer need to invoke the super
-      // constructor.
-      argumentUpdate = _RemoveInvocation(superInvocation);
-    }
-    // Compare the types.
-    var superType = superParameter.type;
-    var thisType = thisParameter.type;
-    if (!typeSystem.isAssignableTo(superType, thisType)) {
-      // If the type of the selected parameter can't be assigned to the super
-      // parameter, the the change isn't appropriate.
-      return null;
-    }
-    // Return the data.
-    return _ParameterData(
-      argumentUpdate: argumentUpdate,
-      defaultValueRange:
-          _defaultValueRange(parameter, superParameter, thisParameter),
-      typeToDelete: superType == thisType ? _type(parameter) : null,
-    );
-  }
-
-  /// Return `true` if the positional [parameter] can be converted into a super
-  /// initializing formal parameter.
-  _ParameterData? _dataForPositionalParameter(
-      FormalParameter parameter,
-      ParameterElement thisParameter,
-      ConstructorElement superConstructor,
-      SuperConstructorInvocation superInvocation) {
-    var positionalArguments = _positionalArguments(superInvocation);
-    if (positionalArguments.length != 1) {
-      // If there's more than one positional parameter then they would all need
-      // to be converted at the same time. If there's less than one, the the
-      // selected parameter isn't being passed to the super constructor.
-      return null;
-    }
-    var argument = positionalArguments[0];
-    if (argument is! SimpleIdentifier ||
-        argument.staticElement != parameter.declaredElement) {
-      // If the selected parameter isn't the one being passed to the super
-      // constructor then the change isn't appropriate.
-      return null;
-    }
-    var positionalParameters = superConstructor.parameters
-        .where((param) => param.isPositional)
-        .toList();
-    if (positionalParameters.isEmpty) {
-      return null;
-    }
-    var superParameter = positionalParameters[0];
-    _ArgumentUpdate? argumentUpdate;
-    if (superInvocation.argumentList.arguments.length == 1) {
-      argumentUpdate = _RemoveInvocation(superInvocation);
-    } else {
-      argumentUpdate = _RemoveArgument(argument);
-    }
-    // Compare the types.
-    var superType = superParameter.type;
-    var thisType = thisParameter.type;
-    if (!typeSystem.isSubtypeOf(thisType, superType)) {
-      // If the type of the selected parameter can't be assigned to the super
-      // parameter, the the change isn't appropriate.
-      return null;
-    }
-    // Return the data.
-    return _ParameterData(
-      argumentUpdate: argumentUpdate,
-      defaultValueRange:
-          _defaultValueRange(parameter, superParameter, thisParameter),
-      typeToDelete: superType == thisType ? _type(parameter) : null,
-    );
-  }
-
-  /// Return the range of the default value associated with the [parameter], or
-  /// `null` if the parameter doesn't have a default value or if the default
-  /// value is not the same as the default value in the super constructor.
-  SourceRange? _defaultValueRange(FormalParameter parameter,
-      ParameterElement superParameter, ParameterElement thisParameter) {
-    if (parameter is DefaultFormalParameter) {
-      var defaultValue = parameter.defaultValue;
-      if (defaultValue != null) {
-        var superDefault = superParameter.computeConstantValue();
-        var thisDefault = thisParameter.computeConstantValue();
-        if (superDefault != null && superDefault == thisDefault) {
-          return range.endEnd(parameter.identifier!, defaultValue);
-        }
-      }
-    }
-    return null;
-  }
-
-  List<Expression> _positionalArguments(SuperConstructorInvocation invocation) {
-    return invocation.argumentList.arguments
-        .where((argument) => argument is! NamedExpression)
-        .toList();
-  }
-
-  SuperConstructorInvocation? _superInvocation(
-      ConstructorDeclaration constructor) {
-    var initializers = constructor.initializers;
-    // Search all of the initializers in case the code is invalid, but start
-    // from the end because the code will usually be correct.
-    for (var i = initializers.length - 1; i >= 0; i--) {
-      var initializer = initializers[i];
-      if (initializer is SuperConstructorInvocation) {
-        return initializer;
-      }
-    }
-    return null;
-  }
-
-  _TypeData? _type(FormalParameter parameter) {
-    if (parameter is DefaultFormalParameter) {
-      return _type(parameter.parameter);
-    } else if (parameter is SimpleFormalParameter) {
-      var typeAnnotation = parameter.type;
-      if (typeAnnotation != null) {
-        return _TypeData(
-            primaryRange:
-                range.startStart(typeAnnotation, parameter.identifier!));
-      }
-    } else if (parameter is FunctionTypedFormalParameter) {
-      var returnType = parameter.returnType;
-      return _TypeData(
-          primaryRange: returnType != null
-              ? range.startStart(returnType, parameter.identifier)
-              : null,
-          parameterRange: range.node(parameter.parameters));
-    }
-    return null;
-  }
-
-  /// Return an instance of this class. Used as a tear-off in `AssistProcessor`.
-  static ConvertToSuperInitializingParameter newInstance() =>
-      ConvertToSuperInitializingParameter();
-}
-
-abstract class _ArgumentUpdate {
-  void addDeletion(DartFileEditBuilder builder);
-}
-
-class _ParameterData {
-  /// Information used to remove the argument from the super constructor
-  /// invocation.
-  final _ArgumentUpdate argumentUpdate;
-
-  /// Information about the type annotation that should be deleted, or `null` if
-  /// there is no type annotation to delete or if the type should not be
-  /// deleted.
-  final _TypeData? typeToDelete;
-
-  /// The range of the default value that is to be deleted, or `null` if there
-  /// is no default value, the default value isn't to be deleted.
-  final SourceRange? defaultValueRange;
-
-  /// Initialize a newly create data object.
-  _ParameterData(
-      {required this.argumentUpdate,
-      required this.typeToDelete,
-      required this.defaultValueRange});
-}
-
-class _RemoveArgument extends _ArgumentUpdate {
-  final Expression argument;
-
-  _RemoveArgument(this.argument);
-
-  @override
-  void addDeletion(DartFileEditBuilder builder) {
-    var argumentList = argument.parent as ArgumentList;
-    var index = argumentList.arguments.indexOf(argument);
-    builder.addDeletion(range.argumentRange(argumentList, index, index, true));
-  }
-}
-
-class _RemoveInvocation extends _ArgumentUpdate {
-  final SuperConstructorInvocation invocation;
-
-  _RemoveInvocation(this.invocation);
-
-  @override
-  void addDeletion(DartFileEditBuilder builder) {
-    var declaration = invocation.parent as ConstructorDeclaration;
-    var initializerList = declaration.initializers;
-    if (initializerList.length == 1) {
-      builder.addDeletion(range.endEnd(declaration.parameters, invocation));
-    } else {
-      builder.addDeletion(range.nodeInList(initializerList, invocation));
-    }
-  }
-}
-
-class _TypeData {
-  SourceRange? primaryRange;
-
-  SourceRange? parameterRange;
-
-  _TypeData({required this.primaryRange, this.parameterRange});
-}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart
new file mode 100644
index 0000000..dc3eb6f
--- /dev/null
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_super_parameters.dart
@@ -0,0 +1,381 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/correction/assist.dart';
+import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/utilities/extensions/range_factory.dart';
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/source/source_range.dart';
+import 'package:analyzer_plugin/utilities/assist/assist.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+import 'package:analyzer_plugin/utilities/range_factory.dart';
+
+class ConvertToSuperParameters extends CorrectionProducer {
+  @override
+  AssistKind get assistKind => DartAssistKind.CONVERT_TO_SUPER_PARAMETERS;
+
+  @override
+  Future<void> compute(ChangeBuilder builder) async {
+    if (!libraryElement.featureSet.isEnabled(Feature.super_parameters)) {
+      // If the library doesn't support super_parameters then the change isn't
+      // appropriate.
+      return;
+    }
+    var constructor = _findConstructor();
+    if (constructor == null) {
+      // If this isn't a constructor declaration then the change isn't
+      // appropriate.
+      return;
+    }
+    var superInvocation = _superInvocation(constructor);
+    if (superInvocation == null) {
+      // If there isn't an explicit invocation of a super constructor then the
+      // change isn't appropriate. Note that this also rules out factory
+      // constructors because factory constructors can't have initializers.
+      return;
+    }
+    var superConstructor = superInvocation.staticElement;
+    if (superConstructor == null) {
+      // If the super constructor wasn't resolved then we can't apply the
+      // change.
+      return;
+    }
+    // Find the arguments that can be converted. Named arguments are added to
+    // [named]. Positional arguments are added to [positional], but the list is
+    // set to `null` if a positional argument is found that can't be converted
+    // because either all of the positional parameters must be converted or none
+    // of them can be converted.
+    var parameterMap = _parameterMap(constructor.parameters);
+    List<_ParameterData>? positional = [];
+    var named = <_ParameterData>[];
+    var arguments = superInvocation.argumentList.arguments;
+    for (var argumentIndex = 0;
+        argumentIndex < arguments.length;
+        argumentIndex++) {
+      var argument = arguments[argumentIndex];
+      if (argument is NamedExpression) {
+        var parameterAndElement =
+            _parameterFor(parameterMap, argument.expression);
+        if (parameterAndElement != null && parameterAndElement.isNamed) {
+          var data = _dataForParameter(
+            parameterAndElement.parameter,
+            parameterAndElement.element,
+            argumentIndex,
+            argument.staticParameterElement,
+          );
+          if (data != null) {
+            named.add(data);
+          }
+        }
+      } else if (positional != null) {
+        var parameterAndElement = _parameterFor(parameterMap, argument);
+        if (parameterAndElement == null || !parameterAndElement.isPositional) {
+          positional = null;
+        } else {
+          var data = _dataForParameter(
+            parameterAndElement.parameter,
+            parameterAndElement.element,
+            argumentIndex,
+            argument.staticParameterElement,
+          );
+          if (data == null) {
+            positional = null;
+          } else {
+            positional.add(data);
+          }
+        }
+      }
+    }
+    if (positional != null && !_inOrder(positional)) {
+      positional = null;
+    }
+    // At this point:
+    // 1. `positional` will be `null` if
+    //    - there is at least one positional argument that can't be converted,
+    //      which implies that there are no positional arguments that can be
+    //      converted, or
+    //    - if the order of the positional parameters doesn't match the order of
+    //      the positional arguments.
+    // 2. `positional` will be empty if there are no positional arguments at
+    //    all.
+    // 3. `named` will be empty if there are no named arguments that can be
+    //    converted.
+    if ((positional == null || positional.isEmpty) && named.isEmpty) {
+      // There are no parameters that can be converted.
+      return;
+    }
+
+    var allParameters = <_ParameterData>[...?positional, ...named];
+
+    var argumentsToDelete =
+        allParameters.map((data) => data.argumentIndex).toList();
+    argumentsToDelete.sort();
+
+    await builder.addDartFileEdit(file, (builder) {
+      // Convert the parameters.
+      for (var parameterData in allParameters) {
+        var typeToDelete = parameterData.typeToDelete;
+        if (typeToDelete == null) {
+          builder.addSimpleInsertion(parameterData.nameOffset, 'super.');
+        } else {
+          var primaryRange = typeToDelete.primaryRange;
+          if (primaryRange == null) {
+            builder.addSimpleInsertion(parameterData.nameOffset, 'super.');
+          } else {
+            builder.addSimpleReplacement(primaryRange, 'super.');
+          }
+          var parameterRange = typeToDelete.parameterRange;
+          if (parameterRange != null) {
+            builder.addDeletion(parameterRange);
+          }
+        }
+        var defaultValueRange = parameterData.defaultValueRange;
+        if (defaultValueRange != null) {
+          builder.addDeletion(defaultValueRange);
+        }
+      }
+
+      // Remove the corresponding arguments.
+      if (argumentsToDelete.length == arguments.length) {
+        var initializers = constructor.initializers;
+        SourceRange initializerRange;
+        if (initializers.length == 1) {
+          initializerRange =
+              range.endEnd(constructor.parameters, superInvocation);
+        } else {
+          initializerRange = range.nodeInList(initializers, superInvocation);
+        }
+        builder.addDeletion(initializerRange);
+      } else {
+        var ranges = range.nodesInList(arguments, argumentsToDelete);
+        for (var range in ranges) {
+          builder.addDeletion(range);
+        }
+      }
+    });
+  }
+
+  /// If the [parameter] can be converted into a super initializing formal
+  /// parameter then return the data needed to do so.
+  _ParameterData? _dataForParameter(
+      _Parameter parameter,
+      ParameterElement thisParameter,
+      int argumentIndex,
+      ParameterElement? superParameter) {
+    if (superParameter == null) {
+      return null;
+    }
+    // If the type of the `thisParameter` isn't a subtype of the type of the
+    // super parameter, then the change isn't appropriate.
+    var superType = superParameter.type;
+    var thisType = thisParameter.type;
+    if (!typeSystem.isSubtypeOf(thisType, superType)) {
+      return null;
+    }
+    var identifier = parameter.parameter.identifier;
+    if (identifier == null) {
+      // This condition should never occur, but the test is here to promote the
+      // type.
+      return null;
+    }
+    // Return the data.
+    return _ParameterData(
+      argumentIndex: argumentIndex,
+      defaultValueRange: _defaultValueRange(
+          parameter.parameter, superParameter, thisParameter),
+      nameOffset: identifier.offset,
+      parameterIndex: parameter.index,
+      typeToDelete: superType == thisType ? _type(parameter.parameter) : null,
+    );
+  }
+
+  /// Return the range of the default value associated with the [parameter], or
+  /// `null` if the parameter doesn't have a default value or if the default
+  /// value is not the same as the default value in the super constructor.
+  SourceRange? _defaultValueRange(FormalParameter parameter,
+      ParameterElement superParameter, ParameterElement thisParameter) {
+    if (parameter is DefaultFormalParameter) {
+      var defaultValue = parameter.defaultValue;
+      if (defaultValue != null) {
+        var superDefault = superParameter.computeConstantValue();
+        var thisDefault = thisParameter.computeConstantValue();
+        if (superDefault != null && superDefault == thisDefault) {
+          return range.endEnd(parameter.identifier!, defaultValue);
+        }
+      }
+    }
+    return null;
+  }
+
+  /// Return the constructor to be converted, or `null` if the cursor is not on
+  /// the name of a constructor.
+  ConstructorDeclaration? _findConstructor() {
+    final node = this.node;
+    if (node is SimpleIdentifier) {
+      var parent = node.parent;
+      if (parent is ConstructorDeclaration) {
+        return parent;
+      } else if (parent is ConstructorName) {
+        var grandparent = parent.parent;
+        if (grandparent is ConstructorDeclaration) {
+          return grandparent;
+        }
+      }
+    }
+    return null;
+  }
+
+  /// Return `true` if the given list of [parameterData] is in order by the
+  /// index of the parameters. The list is known to be in order by the argument
+  /// positions, so this test is used to ensure that the order won't be changed
+  /// if the parameters are converted.
+  bool _inOrder(List<_ParameterData> parameterData) {
+    var previousIndex = -1;
+    for (var data in parameterData) {
+      var index = data.parameterIndex;
+      if (index < previousIndex) {
+        return false;
+      }
+      previousIndex = index;
+    }
+    return true;
+  }
+
+  /// Return the parameter element corresponding to the [expression], or `null`
+  /// if the expression isn't a simple reference to one of the parameters in the
+  /// constructor being converted.
+  _ParameterAndElement? _parameterFor(
+      Map<ParameterElement, _Parameter> parameterMap, Expression expression) {
+    if (expression is SimpleIdentifier) {
+      var element = expression.staticElement;
+      var parameter = parameterMap[element];
+      if (element is ParameterElement && parameter != null) {
+        return _ParameterAndElement(element, parameter);
+      }
+    }
+    return null;
+  }
+
+  /// Return a map from parameter elements to the parameters that define those
+  /// elements.
+  Map<ParameterElement, _Parameter> _parameterMap(
+      FormalParameterList parameterList) {
+    var map = <ParameterElement, _Parameter>{};
+    var parameters = parameterList.parameters;
+    for (var i = 0; i < parameters.length; i++) {
+      var parameter = parameters[i];
+      var element = parameter.declaredElement;
+      if (element != null) {
+        map[element] = _Parameter(parameter, i);
+      }
+    }
+    return map;
+  }
+
+  /// Return the invocation of the super constructor.
+  SuperConstructorInvocation? _superInvocation(
+      ConstructorDeclaration constructor) {
+    var initializers = constructor.initializers;
+    // Search all of the initializers in case the code is invalid, but start
+    // from the end because the code will usually be correct.
+    for (var i = initializers.length - 1; i >= 0; i--) {
+      var initializer = initializers[i];
+      if (initializer is SuperConstructorInvocation) {
+        return initializer;
+      }
+    }
+    return null;
+  }
+
+  /// Return data about the type annotation on the [parameter]. This is the
+  /// information about the ranges of text that need to be removed in order to
+  /// remove the type annotation.
+  _TypeData? _type(FormalParameter parameter) {
+    if (parameter is DefaultFormalParameter) {
+      return _type(parameter.parameter);
+    } else if (parameter is SimpleFormalParameter) {
+      var typeAnnotation = parameter.type;
+      if (typeAnnotation != null) {
+        return _TypeData(
+            primaryRange:
+                range.startStart(typeAnnotation, parameter.identifier!));
+      }
+    } else if (parameter is FunctionTypedFormalParameter) {
+      var returnType = parameter.returnType;
+      return _TypeData(
+          primaryRange: returnType != null
+              ? range.startStart(returnType, parameter.identifier)
+              : null,
+          parameterRange: range.node(parameter.parameters));
+    }
+    return null;
+  }
+
+  /// Return an instance of this class. Used as a tear-off in `AssistProcessor`.
+  static ConvertToSuperParameters newInstance() => ConvertToSuperParameters();
+}
+
+/// Information about a single parameter.
+class _Parameter {
+  final FormalParameter parameter;
+
+  final int index;
+
+  _Parameter(this.parameter, this.index);
+}
+
+/// A data class used to avoid a null check.
+class _ParameterAndElement {
+  final ParameterElement element;
+
+  final _Parameter parameter;
+
+  _ParameterAndElement(this.element, this.parameter);
+
+  bool get isNamed => element.isNamed;
+
+  bool get isPositional => element.isPositional;
+}
+
+/// Information used to convert a single parameter.
+class _ParameterData {
+  /// The type annotation that should be deleted from the parameter list, or
+  /// `null` if there is no type annotation to delete or if the type should not
+  /// be deleted.
+  final _TypeData? typeToDelete;
+
+  /// The offset of the name.
+  final int nameOffset;
+
+  /// The range of the default value that is to be deleted from the parameter
+  /// list, or `null` if there is no default value, the default value isn't to
+  /// be deleted.
+  final SourceRange? defaultValueRange;
+
+  /// The index of the parameter to be updated.
+  final int parameterIndex;
+
+  /// The index of the argument to be deleted.
+  final int argumentIndex;
+
+  /// Initialize a newly create data object.
+  _ParameterData(
+      {required this.typeToDelete,
+      required this.nameOffset,
+      required this.defaultValueRange,
+      required this.parameterIndex,
+      required this.argumentIndex});
+}
+
+/// Information about the ranges of text that need to be removed in order to
+/// remove a type annotation.
+class _TypeData {
+  SourceRange? primaryRange;
+
+  SourceRange? parameterRange;
+
+  _TypeData({required this.primaryRange, this.parameterRange});
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_assignment.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_assignment.dart
new file mode 100644
index 0000000..8f95178
--- /dev/null
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_assignment.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/source/source_range.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:analyzer_plugin/utilities/range_factory.dart';
+
+class RemoveAssignment extends CorrectionProducer {
+  @override
+  bool get canBeAppliedInBulk => true;
+
+  @override
+  bool get canBeAppliedToFile => true;
+
+  @override
+  FixKind get fixKind => DartFixKind.REMOVE_ASSIGNMENT;
+
+  @override
+  FixKind get multiFixKind => DartFixKind.REMOVE_ASSIGNMENT_MULTI;
+
+  @override
+  Future<void> compute(ChangeBuilder builder) async {
+    var expression = node;
+    if (expression is! AssignmentExpression) {
+      return;
+    }
+
+    SourceRange sourceRange;
+    var parent = expression.parent;
+    while (parent is ParenthesizedExpression) {
+      parent = parent.parent;
+    }
+    if (parent is ExpressionStatement) {
+      sourceRange = utils.getLinesRange(range.node(parent));
+    } else {
+      sourceRange = range.endEnd(
+          expression.leftHandSide.endToken, expression.rightHandSide.endToken);
+    }
+
+    await builder.addDartFileEdit(file, (builder) {
+      builder.addDeletion(sourceRange);
+    });
+  }
+
+  /// Return an instance of this class. Used as a tear-off in `FixProcessor`.
+  static RemoveAssignment newInstance() => RemoveAssignment();
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
index 0a88729..a2be51b 100644
--- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
+++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
@@ -1783,7 +1783,7 @@
 LintCode.unnecessary_new:
   status: hasFix
 LintCode.unnecessary_null_aware_assignments:
-  status: needsFix
+  status: hasFix
 LintCode.unnecessary_null_checks:
   status: needsEvaluation
 LintCode.unnecessary_null_in_if_null_operators:
@@ -1819,7 +1819,7 @@
 LintCode.use_decorated_box:
   status: needsEvaluation
 LintCode.use_enums:
-    status: needsFix
+    status: hasFix
 LintCode.use_full_hex_values_for_flutter_colors:
   status: hasFix
 LintCode.use_function_type_syntax_for_parameters:
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index d3411f7..d5879e9 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -308,6 +308,16 @@
     DartFixKindPriority.DEFAULT,
     "Change '{0}' to '{1}' type annotation",
   );
+  static const CONVERT_CLASS_TO_ENUM = FixKind(
+    'dart.fix.convert.classToEnum',
+    DartFixKindPriority.DEFAULT,
+    'Convert class to an enum',
+  );
+  static const CONVERT_CLASS_TO_ENUM_MULTI = FixKind(
+    'dart.fix.convert.classToEnum.multi',
+    DartFixKindPriority.DEFAULT,
+    'Convert classes to enums in file',
+  );
   static const CONVERT_FLUTTER_CHILD = FixKind(
     'dart.fix.flutter.convert.childToChildren',
     DartFixKindPriority.DEFAULT,
@@ -819,6 +829,16 @@
     DartFixKindPriority.IN_FILE,
     'Remove arguments in file',
   );
+  static const REMOVE_ASSIGNMENT = FixKind(
+    'dart.fix.remove.assignment',
+    DartFixKindPriority.DEFAULT,
+    'Remove assignment',
+  );
+  static const REMOVE_ASSIGNMENT_MULTI = FixKind(
+    'dart.fix.remove.assignment.multi',
+    DartFixKindPriority.IN_FILE,
+    'Remove unnecessary assignments everywhere in file',
+  );
   static const REMOVE_AWAIT = FixKind(
     'dart.fix.remove.await',
     DartFixKindPriority.DEFAULT,
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 11db925..50e70815 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -39,6 +39,7 @@
 import 'package:analysis_server/src/services/correction/dart/change_to_static_access.dart';
 import 'package:analysis_server/src/services/correction/dart/change_type_annotation.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_add_all_to_spread.dart';
+import 'package:analysis_server/src/services/correction/dart/convert_class_to_enum.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_conditional_expression_to_if_element.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_documentation_into_line.dart';
 import 'package:analysis_server/src/services/correction/dart/convert_flutter_child.dart';
@@ -103,6 +104,7 @@
 import 'package:analysis_server/src/services/correction/dart/remove_abstract.dart';
 import 'package:analysis_server/src/services/correction/dart/remove_annotation.dart';
 import 'package:analysis_server/src/services/correction/dart/remove_argument.dart';
+import 'package:analysis_server/src/services/correction/dart/remove_assignment.dart';
 import 'package:analysis_server/src/services/correction/dart/remove_await.dart';
 import 'package:analysis_server/src/services/correction/dart/remove_comparison.dart';
 import 'package:analysis_server/src/services/correction/dart/remove_const.dart';
@@ -627,6 +629,9 @@
     LintNames.unnecessary_new: [
       RemoveUnnecessaryNew.newInstance,
     ],
+    LintNames.unnecessary_null_aware_assignments: [
+      RemoveAssignment.newInstance,
+    ],
     LintNames.unnecessary_null_in_if_null_operators: [
       RemoveIfNullOperator.newInstance,
     ],
@@ -651,6 +656,9 @@
     LintNames.unnecessary_this: [
       RemoveThisExpression.newInstance,
     ],
+    LintNames.use_enums: [
+      ConvertClassToEnum.newInstance,
+    ],
     LintNames.use_full_hex_values_for_flutter_colors: [
       ReplaceWithEightDigitHex.newInstance,
     ],
diff --git a/pkg/analysis_server/lib/src/services/linter/lint_names.dart b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
index 472ddf8..108dde5 100644
--- a/pkg/analysis_server/lib/src/services/linter/lint_names.dart
+++ b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
@@ -136,6 +136,8 @@
   static const String unnecessary_lambdas = 'unnecessary_lambdas';
   static const String unnecessary_late = 'unnecessary_late';
   static const String unnecessary_new = 'unnecessary_new';
+  static const String unnecessary_null_aware_assignments =
+      'unnecessary_null_aware_assignments';
   static const String unnecessary_null_in_if_null_operators =
       'unnecessary_null_in_if_null_operators';
   static const String unnecessary_nullable_for_final_variable_declarations =
@@ -147,6 +149,7 @@
   static const String unnecessary_string_interpolations =
       'unnecessary_string_interpolations';
   static const String unnecessary_this = 'unnecessary_this';
+  static const String use_enums = 'use_enums';
   static const String use_full_hex_values_for_flutter_colors =
       'use_full_hex_values_for_flutter_colors';
   static const String use_function_type_syntax_for_parameters =
diff --git a/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart b/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
index 8a49420..016b2f7 100644
--- a/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
+++ b/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
@@ -10,6 +10,43 @@
 import 'package:analyzer/src/lint/linter.dart' show LinterContextImpl;
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
 
+/// Produces a [Snippet] that creates a Class definition.
+class DartClassSnippetProducer extends DartSnippetProducer {
+  static const prefix = 'class';
+  static const label = 'class';
+
+  DartClassSnippetProducer._(DartSnippetRequest request) : super(request);
+
+  @override
+  Future<Snippet> compute() async {
+    final builder = ChangeBuilder(session: request.analysisSession);
+    final indent = utils.getLinePrefix(request.offset);
+
+    await builder.addDartFileEdit(request.filePath, (builder) {
+      builder.addReplacement(request.replacementRange, (builder) {
+        void writeIndented(String string) => builder.write('$indent$string');
+        builder.write('class ');
+        builder.addEmptyLinkedEdit('className');
+        builder.writeln(' {');
+        writeIndented('  ');
+        builder.selectHere();
+        builder.writeln();
+        writeIndented('}');
+      });
+    });
+
+    return Snippet(
+      prefix,
+      label,
+      'Insert a class definition.',
+      builder.sourceChange,
+    );
+  }
+
+  static DartClassSnippetProducer newInstance(DartSnippetRequest request) =>
+      DartClassSnippetProducer._(request);
+}
+
 /// Produces a [Snippet] that creates a `do while` loop.
 class DartDoWhileLoopSnippetProducer extends DartSnippetProducer {
   static const prefix = 'do';
@@ -219,11 +256,7 @@
   /// function.
   ///
   /// The parameter is suppressed for any known test directories.
-  bool get _insertArgsParameter {
-    final path = request.unit.path;
-    return !LinterContextImpl.testDirectories
-        .any((testDir) => path.contains(testDir));
-  }
+  bool get _insertArgsParameter => !isInTestDirectory;
 
   @override
   Future<Snippet> compute() async {
@@ -273,6 +306,12 @@
         utils = CorrectionUtils(request.unit),
         super(request);
 
+  bool get isInTestDirectory {
+    final path = request.unit.path;
+    return LinterContextImpl.testDirectories
+        .any((testDir) => path.contains(testDir));
+  }
+
   bool isLintEnabled(String name) {
     var analysisOptions = sessionHelper.session.analysisContext.analysisOptions;
     return analysisOptions.isLintEnabled(name);
@@ -323,6 +362,100 @@
       DartSwitchSnippetProducer._(request);
 }
 
+/// Produces a [Snippet] that creates a `test()` block.
+class DartTestBlockSnippetProducer extends DartSnippetProducer {
+  static const prefix = 'test';
+  static const label = 'test';
+
+  DartTestBlockSnippetProducer._(DartSnippetRequest request) : super(request);
+
+  @override
+  Future<Snippet> compute() async {
+    final builder = ChangeBuilder(session: request.analysisSession);
+    final indent = utils.getLinePrefix(request.offset);
+
+    await builder.addDartFileEdit(request.filePath, (builder) {
+      builder.addReplacement(request.replacementRange, (builder) {
+        void writeIndented(String string) => builder.write('$indent$string');
+        builder.write("test('");
+        builder.addEmptyLinkedEdit('testName');
+        builder.writeln("', () {");
+        writeIndented('  ');
+        builder.selectHere();
+        builder.writeln();
+        writeIndented('});');
+      });
+    });
+
+    return Snippet(
+      prefix,
+      label,
+      'Insert a test block.',
+      builder.sourceChange,
+    );
+  }
+
+  @override
+  Future<bool> isValid() async {
+    if (!await super.isValid()) {
+      return false;
+    }
+
+    return isInTestDirectory;
+  }
+
+  static DartTestBlockSnippetProducer newInstance(DartSnippetRequest request) =>
+      DartTestBlockSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates a `test()` block.
+class DartTestGroupBlockSnippetProducer extends DartSnippetProducer {
+  static const prefix = 'group';
+  static const label = 'group';
+
+  DartTestGroupBlockSnippetProducer._(DartSnippetRequest request)
+      : super(request);
+
+  @override
+  Future<Snippet> compute() async {
+    final builder = ChangeBuilder(session: request.analysisSession);
+    final indent = utils.getLinePrefix(request.offset);
+
+    await builder.addDartFileEdit(request.filePath, (builder) {
+      builder.addReplacement(request.replacementRange, (builder) {
+        void writeIndented(String string) => builder.write('$indent$string');
+        builder.write("group('");
+        builder.addEmptyLinkedEdit('groupName');
+        builder.writeln("', () {");
+        writeIndented('  ');
+        builder.selectHere();
+        builder.writeln();
+        writeIndented('});');
+      });
+    });
+
+    return Snippet(
+      prefix,
+      label,
+      'Insert a test group block.',
+      builder.sourceChange,
+    );
+  }
+
+  @override
+  Future<bool> isValid() async {
+    if (!await super.isValid()) {
+      return false;
+    }
+
+    return isInTestDirectory;
+  }
+
+  static DartTestGroupBlockSnippetProducer newInstance(
+          DartSnippetRequest request) =>
+      DartTestGroupBlockSnippetProducer._(request);
+}
+
 /// Produces a [Snippet] that creates a try/catch statement.
 class DartTryCatchSnippetProducer extends DartSnippetProducer {
   static const prefix = 'try';
diff --git a/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart b/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
index 4972b2d..914de9f 100644
--- a/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
+++ b/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
@@ -28,6 +28,7 @@
       FlutterStatefulWidgetSnippetProducer.newInstance,
       FlutterStatefulWidgetWithAnimationControllerSnippetProducer.newInstance,
       FlutterStatelessWidgetSnippetProducer.newInstance,
+      DartClassSnippetProducer.newInstance,
     ],
     SnippetContext.inBlock: [
       DartDoWhileLoopSnippetProducer.newInstance,
@@ -38,6 +39,8 @@
       DartSwitchSnippetProducer.newInstance,
       DartTryCatchSnippetProducer.newInstance,
       DartWhileLoopSnippetProducer.newInstance,
+      DartTestBlockSnippetProducer.newInstance,
+      DartTestGroupBlockSnippetProducer.newInstance,
     ],
   };
 
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index 2d8b06f..ab5be7e 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -81,7 +81,7 @@
   String get workspaceRootPath => '/home';
 
   void addSource(String path, String content) {
-    newFile(path, content: content);
+    newFile2(path, content);
   }
 
   Future<void> analyzeTestPackageFiles() async {
@@ -134,7 +134,7 @@
       }
     }
 
-    newFile(analysisOptionsPath, content: buffer.toString());
+    newFile2(analysisOptionsPath, buffer.toString());
   }
 
   AnalysisDriver driverFor(String path) {
@@ -158,14 +158,14 @@
   }
 
   @override
-  File newFile(String path, {String content = ''}) {
+  File newFile2(String path, String content) {
     if (_analysisContextCollection != null && !path.endsWith('.dart')) {
       throw StateError('Only dart files can be changed after analysis.');
     }
 
     path = convertPath(path);
     _addAnalyzedFileToDrivers(path);
-    return super.newFile(path, content: content);
+    return super.newFile2(path, content);
   }
 
   Future<ResolvedUnitResult> resolveFile(String path) async {
@@ -209,13 +209,13 @@
 
   /// Update `pubspec.yaml` and create the driver.
   void updateTestPubspecFile(String content) {
-    newFile(testPubspecPath, content: content);
+    newFile2(testPubspecPath, content);
   }
 
   void verifyCreatedCollection() {}
 
   void writePackageConfig(String path, PackageConfigFileBuilder config) {
-    newFile(path, content: config.toContent(toUriStr: toUriStr));
+    newFile2(path, config.toContent(toUriStr: toUriStr));
   }
 
   void writeTestPackageConfig({
diff --git a/pkg/analysis_server/test/abstract_single_unit.dart b/pkg/analysis_server/test/abstract_single_unit.dart
index 4def5df..3dd0ad3 100644
--- a/pkg/analysis_server/test/abstract_single_unit.dart
+++ b/pkg/analysis_server/test/abstract_single_unit.dart
@@ -57,11 +57,11 @@
   }
 
   @override
-  File newFile(String path, {String content = ''}) {
+  File newFile2(String path, String content) {
     if (useLineEndingsForPlatform) {
       content = normalizeNewlinesForPlatform(content);
     }
-    return super.newFile(path, content: content);
+    return super.newFile2(path, content);
   }
 
   Future<void> resolveFile2(String path) async {
diff --git a/pkg/analysis_server/test/analysis/get_errors_test.dart b/pkg/analysis_server/test/analysis/get_errors_test.dart
index baca9b0..8310a89 100644
--- a/pkg/analysis_server/test/analysis/get_errors_test.dart
+++ b/pkg/analysis_server/test/analysis/get_errors_test.dart
@@ -45,12 +45,12 @@
   Future<void> test_errorInPart() async {
     var libPath = join(testFolder, 'main.dart');
     var partPath = join(testFolder, 'main_part.dart');
-    newFile(libPath, content: r'''
+    newFile2(libPath, r'''
 library main;
 part 'main_part.dart';
 class A {}
 ''');
-    newFile(partPath, content: r'''
+    newFile2(partPath, r'''
 part of main;
 class A {}
 ''');
@@ -69,7 +69,7 @@
   Future<void> test_fileWithoutContext() async {
     // Broken under the new driver.
     var file = convertPath('/outside.dart');
-    newFile(file, content: '''
+    newFile2(file, '''
 main() {
   print(42);
 }
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index 440b1b4..96b7f7f 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -20,13 +20,13 @@
 @reflectiveTest
 class AnalysisHoverBazelTest extends AbstractAnalysisTest {
   Future<void> test_bazel_notOwnedUri() async {
-    newFile('/workspace/WORKSPACE');
+    newFile2('/workspace/WORKSPACE', '');
     projectPath = newFolder('/workspace').path;
     testFile = convertPath('/workspace/dart/my/lib/test.dart');
 
-    newFile(
+    newFile2(
       '/workspace/bazel-genfiles/dart/my/lib/test.dart',
-      content: '// generated',
+      '// generated',
     );
 
     await createProject();
diff --git a/pkg/analysis_server/test/analysis/get_navigation_test.dart b/pkg/analysis_server/test/analysis/get_navigation_test.dart
index 793dad6..3450000 100644
--- a/pkg/analysis_server/test/analysis/get_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/get_navigation_test.dart
@@ -68,7 +68,7 @@
 
   Future<void> test_comment_toolSeeCodeComment() async {
     var examplePath = 'examples/api/foo.dart';
-    newFile(convertPath('$testFolder/$examplePath'), content: '');
+    newFile2(convertPath('$testFolder/$examplePath'), '');
     addTestFile('''
 /// {@tool dartpad}
 /// ** See code in $examplePath **
@@ -191,8 +191,8 @@
   }
 
   Future<void> test_importUri_configurations() async {
-    final ioFile = newFile(join(testFolder, 'io.dart'));
-    final htmlFile = newFile(join(testFolder, 'html.dart'));
+    final ioFile = newFile2(join(testFolder, 'io.dart'), '');
+    final htmlFile = newFile2(join(testFolder, 'html.dart'), '');
     addTestFile('''
 import 'foo.dart'
   if (dart.library.io) 'io.dart'
diff --git a/pkg/analysis_server/test/analysis/get_signature_test.dart b/pkg/analysis_server/test/analysis/get_signature_test.dart
index d213962..ba5a920 100644
--- a/pkg/analysis_server/test/analysis/get_signature_test.dart
+++ b/pkg/analysis_server/test/analysis/get_signature_test.dart
@@ -177,7 +177,7 @@
   }
 
   Future<void> test_function_from_other_file() async {
-    newFile('/project/bin/other.dart', content: '''
+    newFile2('/project/bin/other.dart', '''
 /// one doc
 one(String name, int length) {}
 main() {
diff --git a/pkg/analysis_server/test/analysis/notification_analysis_options_test.dart b/pkg/analysis_server/test/analysis/notification_analysis_options_test.dart
index 6116340..b82f567 100644
--- a/pkg/analysis_server/test/analysis/notification_analysis_options_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_analysis_options_test.dart
@@ -40,7 +40,7 @@
   List<AnalysisError> get testFileErrors => filesErrors[testFile]!;
 
   void addOptionsFile(String contents) {
-    newFile(optionsFilePath, content: contents);
+    newFile2(optionsFilePath, contents);
   }
 
   @override
diff --git a/pkg/analysis_server/test/analysis/notification_analyzed_files_test.dart b/pkg/analysis_server/test/analysis/notification_analyzed_files_test.dart
index 93cb4ac..e2fce2f 100644
--- a/pkg/analysis_server/test/analysis/notification_analyzed_files_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_analyzed_files_test.dart
@@ -111,7 +111,7 @@
     // Making a change that *does* affect the set of reachable files should
     // trigger the notification to be re-sent.
     addTestFile('class A {}');
-    newFile('/foo.dart', content: 'library foo;');
+    newFile2('/foo.dart', 'library foo;');
     await prepareAnalyzedFiles();
     expect(analyzedFilesReceived, isTrue);
 
diff --git a/pkg/analysis_server/test/analysis/notification_errors_test.dart b/pkg/analysis_server/test/analysis/notification_errors_test.dart
index a85cfaefb..ab0e04d 100644
--- a/pkg/analysis_server/test/analysis/notification_errors_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_errors_test.dart
@@ -45,6 +45,7 @@
   void setUp() {
     registerLintRules();
     super.setUp();
+    server.pendingFilesRemoveOverlayDelay = const Duration(milliseconds: 10);
     server.handlers = [
       AnalysisDomainHandler(server),
     ];
@@ -53,7 +54,7 @@
 
   Future<void> test_analysisOptionsFile() async {
     var filePath = join(projectPath, 'analysis_options.yaml');
-    var analysisOptionsFile = newFile(filePath, content: '''
+    var analysisOptionsFile = newFile2(filePath, '''
 linter:
   rules:
     - invalid_lint_rule_name
@@ -75,7 +76,7 @@
 
   Future<void> test_analysisOptionsFile_packageInclude() async {
     var filePath = join(projectPath, 'analysis_options.yaml');
-    var analysisOptionsFile = newFile(filePath, content: '''
+    var analysisOptionsFile = newFile2(filePath, '''
 include: package:pedantic/analysis_options.yaml
 ''').path;
 
@@ -94,7 +95,7 @@
     // Write a package file that allows resolving the include.
     newPackageConfigJsonFile(
       projectPath,
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'pedantic', rootPath: pedanticFolder.parent.path))
           .toContent(toUriStr: toUriStr),
     );
@@ -108,14 +109,14 @@
 
   Future<void> test_androidManifestFile() async {
     var filePath = join(projectPath, 'android', 'AndroidManifest.xml');
-    var manifestFile = newFile(filePath, content: '''
+    var manifestFile = newFile2(filePath, '''
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android">
     <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
     <uses-feature android:name="android.software.home_screen" />
 </manifest>
 ''').path;
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
@@ -137,14 +138,14 @@
 
   Future<void> test_androidManifestFile_dotDirectoryIgnored() async {
     var filePath = join(projectPath, 'ios', '.symlinks', 'AndroidManifest.xml');
-    var manifestFile = newFile(filePath, content: '''
+    var manifestFile = newFile2(filePath, '''
 <manifest
     xmlns:android="http://schemas.android.com/apk/res/android">
     <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
     <uses-feature android:name="android.software.home_screen" />
 </manifest>
 ''').path;
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
@@ -171,10 +172,10 @@
     // Add the generated project into package_config.json.
     final config = PackageConfigFileBuilder();
     config.add(name: 'foo', rootPath: generatedProject);
-    newFile(configPath, content: config.toContent(toUriStr: toUriStr));
+    newFile2(configPath, config.toContent(toUriStr: toUriStr));
 
     // Set up project that references the class prior to initial analysis.
-    newFile(generatedFile, content: 'class A {}');
+    newFile2(generatedFile, 'class A {}');
     addTestFile('''
 import 'package:foo/foo.dart';
 A? a;
@@ -196,7 +197,7 @@
 
   Future<void> test_dataFile() async {
     var filePath = join(projectPath, 'lib', 'fix_data.yaml');
-    var dataFile = newFile(filePath, content: '''
+    var dataFile = newFile2(filePath, '''
 version: 1
 transforms:
 ''').path;
@@ -222,8 +223,7 @@
     await createProject();
     addTestFile('');
     var brokenFile =
-        newFile(join(projectPath, '.dart_tool/broken.dart'), content: 'err')
-            .path;
+        newFile2(join(projectPath, '.dart_tool/broken.dart'), 'err').path;
 
     await waitForTasksFinished();
     await pumpEventQueue(times: 5000);
@@ -247,8 +247,7 @@
     await createProject();
     addTestFile('');
     var brokenFile =
-        newFile(join(projectPath, '.dart_tool/broken.dart'), content: 'err')
-            .path;
+        newFile2(join(projectPath, '.dart_tool/broken.dart'), 'err').path;
 
     await waitForTasksFinished();
     await pumpEventQueue(times: 5000);
@@ -264,14 +263,14 @@
   }
 
   Future<void> test_excludedFolder() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   exclude:
     - excluded/**
 ''');
     await createProject();
     var excludedFile =
-        newFile(join(projectPath, 'excluded/broken.dart'), content: 'err').path;
+        newFile2(join(projectPath, 'excluded/broken.dart'), 'err').path;
 
     // There should be no errors initially.
     await waitForTasksFinished();
@@ -313,7 +312,7 @@
   Future<void> test_lintError() async {
     var camelCaseTypesLintName = 'camel_case_types';
 
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - $camelCaseTypesLintName
@@ -344,7 +343,7 @@
 
   Future<void> test_notInAnalysisRoot() async {
     await createProject();
-    var otherFile = newFile('/other.dart', content: 'UnknownType V;').path;
+    var otherFile = newFile2('/other.dart', 'UnknownType V;').path;
     addTestFile('''
 import '/other.dart';
 main() {
@@ -361,8 +360,7 @@
     await createProject();
     addTestFile('');
     var brokenFile =
-        newFile(join(projectPath, '.dart_tool/broken.dart'), content: 'err')
-            .path;
+        newFile2(join(projectPath, '.dart_tool/broken.dart'), 'err').path;
 
     await waitForTasksFinished();
     await pumpEventQueue(times: 5000);
@@ -408,6 +406,10 @@
         brokenFile: RemoveContentOverlay(),
       }).toRequest('1'),
     );
+
+    // Wait for the timer to remove the overlay to fire.
+    await Future.delayed(server.pendingFilesRemoveOverlayDelay);
+
     await waitForTasksFinished();
     await pumpEventQueue(times: 5000);
 
@@ -439,7 +441,7 @@
     expect(filesErrors[brokenFile], hasLength(greaterThan(0)));
 
     // Write the file to disk.
-    newFile(brokenFile, content: 'err');
+    newFile2(brokenFile, 'err');
     await waitForTasksFinished();
     await pumpEventQueue(times: 5000);
 
@@ -505,7 +507,7 @@
   }
 
   Future<void> test_pubspecFile_lint() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - sort_pub_dependencies
diff --git a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
index 3048a8c..f74517f 100644
--- a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
@@ -328,7 +328,7 @@
 void f() {
   var part = 42;
 }''');
-    newFile('/project/bin/my_part.dart', content: 'part of lib;');
+    newFile2('/project/bin/my_part.dart', 'part of lib;');
     await prepareHighlights();
     assertHasRegion(HighlightRegionType.BUILT_IN, 'part "my_');
     assertNoRegion(HighlightRegionType.BUILT_IN, 'part = 42');
@@ -1677,7 +1677,7 @@
   }
 
   void _addLibraryForTestPart() {
-    newFile(join(testFolder, 'my_lib.dart'), content: '''
+    newFile2(join(testFolder, 'my_lib.dart'), '''
 library lib;
 part 'test.dart';
     ''');
diff --git a/pkg/analysis_server/test/analysis/notification_implemented_test.dart b/pkg/analysis_server/test/analysis/notification_implemented_test.dart
index a9db25d..c7e6989 100644
--- a/pkg/analysis_server/test/analysis/notification_implemented_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_implemented_test.dart
@@ -365,7 +365,7 @@
   }
 
   Future<void> test_method_withMethod_private_differentLib() async {
-    newFile(join(testFolder, 'lib.dart'), content: r'''
+    newFile2(join(testFolder, 'lib.dart'), r'''
 import 'test.dart';
 class B extends A {
   void _m() {}
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
index 506df55..fc40e2d 100644
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
@@ -274,7 +274,7 @@
   }
 
   Future<void> test_annotationConstructor_importPrefix() async {
-    newFile(join(testFolder, 'my_annotation.dart'), content: r'''
+    newFile2(join(testFolder, 'my_annotation.dart'), r'''
 library an;
 class MyAnnotation {
   const MyAnnotation();
@@ -349,7 +349,7 @@
   }
 
   Future<void> test_annotationField_importPrefix() async {
-    newFile(join(testFolder, 'mayn.dart'), content: r'''
+    newFile2(join(testFolder, 'mayn.dart'), r'''
 library an;
 const myan = new Object();
 ''');
@@ -821,7 +821,7 @@
   }
 
   Future<void> test_functionReference_importPrefix_function() async {
-    newFile(join(testFolder, 'a.dart'), content: r'''
+    newFile2(join(testFolder, 'a.dart'), r'''
 void foo<T>() {}
 ''');
     addTestFile('''
@@ -1070,8 +1070,8 @@
   }
 
   Future<void> test_multiplyDefinedElement() async {
-    newFile('$projectPath/bin/libA.dart', content: 'library A; int TEST = 1;');
-    newFile('$projectPath/bin/libB.dart', content: 'library B; int TEST = 2;');
+    newFile2('$projectPath/bin/libA.dart', 'library A; int TEST = 1;');
+    newFile2('$projectPath/bin/libB.dart', 'library B; int TEST = 2;');
     addTestFile('''
 import 'libA.dart';
 import 'libB.dart';
@@ -1162,7 +1162,7 @@
 
   Future<void> test_partOf() async {
     var libCode = 'library lib; part "test.dart";';
-    var libFile = newFile('$projectPath/bin/lib.dart', content: libCode).path;
+    var libFile = newFile2('$projectPath/bin/lib.dart', libCode).path;
     addTestFile('part of lib;');
     await prepareNavigation();
     assertHasRegionString('lib');
@@ -1221,8 +1221,8 @@
   }
 
   Future<void> test_string_configuration() async {
-    newFile('$projectPath/bin/lib.dart', content: '').path;
-    var lib2File = newFile('$projectPath/bin/lib2.dart', content: '').path;
+    newFile2('$projectPath/bin/lib.dart', '').path;
+    var lib2File = newFile2('$projectPath/bin/lib2.dart', '').path;
     addTestFile('import "lib.dart" if (dart.library.html) "lib2.dart";');
     await prepareNavigation();
     assertHasRegionString('"lib2.dart"');
@@ -1231,7 +1231,7 @@
 
   Future<void> test_string_export() async {
     var libCode = 'library lib;';
-    var libFile = newFile('$projectPath/bin/lib.dart', content: libCode).path;
+    var libFile = newFile2('$projectPath/bin/lib.dart', libCode).path;
     addTestFile('export "lib.dart";');
     await prepareNavigation();
     assertHasRegionString('"lib.dart"');
@@ -1246,7 +1246,7 @@
 
   Future<void> test_string_import() async {
     var libCode = 'library lib;';
-    var libFile = newFile('$projectPath/bin/lib.dart', content: libCode).path;
+    var libFile = newFile2('$projectPath/bin/lib.dart', libCode).path;
     addTestFile('import "lib.dart";');
     await prepareNavigation();
     assertHasRegionString('"lib.dart"');
@@ -1267,8 +1267,7 @@
 
   Future<void> test_string_part() async {
     var unitCode = 'part of lib;  f() {}';
-    var unitFile =
-        newFile('$projectPath/bin/test_unit.dart', content: unitCode).path;
+    var unitFile = newFile2('$projectPath/bin/test_unit.dart', unitCode).path;
     addTestFile('''
 library lib;
 part "test_unit.dart";
diff --git a/pkg/analysis_server/test/analysis/notification_overrides_test.dart b/pkg/analysis_server/test/analysis/notification_overrides_test.dart
index 3ce1928..2e10b24 100644
--- a/pkg/analysis_server/test/analysis/notification_overrides_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_overrides_test.dart
@@ -221,7 +221,7 @@
   }
 
   Future<void> test_class_BAD_privateByPrivate_inDifferentLib() async {
-    newFile(join(testFolder, 'lib.dart'), content: r'''
+    newFile2(join(testFolder, 'lib.dart'), r'''
 class A {
   void _m() {}
 }
diff --git a/pkg/analysis_server/test/analysis/reanalyze_test.dart b/pkg/analysis_server/test/analysis/reanalyze_test.dart
index 4fc723b..84aea11 100644
--- a/pkg/analysis_server/test/analysis/reanalyze_test.dart
+++ b/pkg/analysis_server/test/analysis/reanalyze_test.dart
@@ -32,7 +32,7 @@
   Future<void> test_reanalyze() async {
     var b = convertPath('/other/b.dart');
 
-    newFile(testFile, content: r'''
+    newFile2(testFile, r'''
 import '../../other/b.dart';
 
 var b = B();
@@ -47,7 +47,7 @@
     filesErrors.clear();
 
     // Create b.dart, reanalyzing should fix the error.
-    newFile(b, content: 'class B {}');
+    newFile2(b, 'class B {}');
 
     // Reanalyze.
     await server.reanalyze();
diff --git a/pkg/analysis_server/test/analysis/set_priority_files_test.dart b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
index 9d3c505..16b93d0 100644
--- a/pkg/analysis_server/test/analysis/set_priority_files_test.dart
+++ b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
@@ -46,7 +46,7 @@
 
   Future<void> test_fileInAnalysisRootAddedLater() async {
     var path = convertPath('/other/file.dart');
-    newFile(path);
+    newFile2(path, '');
     await _setPriorityFile(path);
     await _setAnalysisRoots('/other');
     _verifyPriorityFiles(path);
@@ -64,50 +64,49 @@
 
   Future<void> test_fileNotInAnalysisRoot() async {
     var path = convertPath('/other/file.dart');
-    newFile(path);
+    newFile2(path, '');
     await _setPriorityFile(path);
     _verifyPriorityFiles(path);
   }
 
   Future<void> test_ignoredInAnalysisOptions() async {
     var sampleFile = convertPath('$projectPath/samples/sample.dart');
-    newFile('$projectPath/${file_paths.analysisOptionsYaml}', content: r'''
+    newFile2('$projectPath/${file_paths.analysisOptionsYaml}', r'''
 analyzer:
   exclude:
     - 'samples/**'
 ''');
-    newFile(sampleFile);
+    newFile2(sampleFile, '');
     // attempt to set priority file
     await _setPriorityFile(sampleFile);
     _verifyPriorityFiles(sampleFile);
   }
 
   Future<void> test_ignoredInAnalysisOptions_inChildContext() async {
-    newPackageConfigJsonFile(projectPath);
-    newPackageConfigJsonFile('$projectPath/child');
+    newPackageConfigJsonFile(projectPath, '');
+    newPackageConfigJsonFile('$projectPath/child', '');
     var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
-    newFile('$projectPath/child/${file_paths.analysisOptionsYaml}',
-        content: r'''
+    newFile2('$projectPath/child/${file_paths.analysisOptionsYaml}', r'''
 analyzer:
   exclude:
     - 'samples/**'
 ''');
-    newFile(sampleFile);
+    newFile2(sampleFile, '');
     // attempt to set priority file
     await _setPriorityFile(sampleFile);
     _verifyPriorityFiles(sampleFile);
   }
 
   Future<void> test_ignoredInAnalysisOptions_inRootContext() async {
-    newPackageConfigJsonFile(projectPath);
-    newPackageConfigJsonFile('$projectPath/child');
+    newPackageConfigJsonFile(projectPath, '');
+    newPackageConfigJsonFile('$projectPath/child', '');
     var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
-    newFile('$projectPath/${file_paths.analysisOptionsYaml}', content: r'''
+    newFile2('$projectPath/${file_paths.analysisOptionsYaml}', r'''
 analyzer:
   exclude:
     - 'child/samples/**'
 ''');
-    newFile(sampleFile);
+    newFile2(sampleFile, '');
     // attempt to set priority file
     await _setPriorityFile(sampleFile);
     _verifyPriorityFiles(sampleFile);
diff --git a/pkg/analysis_server/test/analysis/update_content_test.dart b/pkg/analysis_server/test/analysis/update_content_test.dart
index 0f1313f..b5213d9 100644
--- a/pkg/analysis_server/test/analysis/update_content_test.dart
+++ b/pkg/analysis_server/test/analysis/update_content_test.dart
@@ -83,15 +83,15 @@
   Future<void> test_multiple_contexts() async {
     var project1path = convertPath('/project1');
     var project2path = convertPath('/project2');
-    var fooPath = newFile('/project1/foo.dart', content: '''
+    var fooPath = newFile2('/project1/foo.dart', '''
 library foo;
 import '../project2/baz.dart';
 main() { f(); }''').path;
-    var barPath = newFile('/project2/bar.dart', content: '''
+    var barPath = newFile2('/project2/bar.dart', '''
 library bar;
 import 'baz.dart';
 main() { f(); }''').path;
-    var bazPath = newFile('/project2/baz.dart', content: '''
+    var bazPath = newFile2('/project2/baz.dart', '''
 library baz;
 f(int i) {}
 ''').path;
diff --git a/pkg/analysis_server/test/analysis_abstract.dart b/pkg/analysis_server/test/analysis_abstract.dart
index df45776..b6014a5 100644
--- a/pkg/analysis_server/test/analysis_abstract.dart
+++ b/pkg/analysis_server/test/analysis_abstract.dart
@@ -85,7 +85,7 @@
   }
 
   String addTestFile(String content) {
-    newFile(testFile, content: content);
+    newFile2(testFile, content);
     testCode = content;
     return testFile;
   }
diff --git a/pkg/analysis_server/test/analysis_server_test.dart b/pkg/analysis_server/test/analysis_server_test.dart
index 4b83983f..58ac7dd 100644
--- a/pkg/analysis_server/test/analysis_server_test.dart
+++ b/pkg/analysis_server/test/analysis_server_test.dart
@@ -46,8 +46,8 @@
     server.serverServices = {ServerService.STATUS};
     newFolder('/foo');
     newFolder('/bar');
-    newFile('/foo/foo.dart', content: 'import "../bar/bar.dart";');
-    var bar = newFile('/bar/bar.dart', content: 'library bar;');
+    newFile2('/foo/foo.dart', 'import "../bar/bar.dart";');
+    var bar = newFile2('/bar/bar.dart', 'library bar;');
     await server.setAnalysisRoots('0', ['/foo', '/bar'], []);
     var subscriptions = <AnalysisService, Set<String>>{};
     for (var service in AnalysisService.VALUES) {
@@ -119,9 +119,9 @@
     // Create a file that references two packages, which will we write to
     // package_config.json individually.
     newFolder(projectRoot);
-    newFile(
+    newFile2(
       projectTestFile,
-      content: r'''
+      r'''
       import "package:foo/foo.dart";'
       import "package:bar/bar.dart";'
       ''',
@@ -183,7 +183,7 @@
   Future test_serverStatusNotifications_hasFile() async {
     server.serverServices.add(ServerService.STATUS);
 
-    newFile('/test/lib/a.dart', content: r'''
+    newFile2('/test/lib/a.dart', r'''
 class A {}
 ''');
     await server.setAnalysisRoots('0', [convertPath('/test')], []);
@@ -245,8 +245,8 @@
   Future<void>
       test_setAnalysisSubscriptions_fileInIgnoredFolder_newOptions() async {
     var path = convertPath('/project/samples/sample.dart');
-    newFile(path);
-    newAnalysisOptionsYamlFile('/project', content: r'''
+    newFile2(path, '');
+    newAnalysisOptionsYamlFile2('/project', r'''
 analyzer:
   exclude:
     - 'samples/**'
@@ -266,8 +266,8 @@
   Future<void>
       test_setAnalysisSubscriptions_fileInIgnoredFolder_oldOptions() async {
     var path = convertPath('/project/samples/sample.dart');
-    newFile(path);
-    newAnalysisOptionsYamlFile('/project', content: r'''
+    newFile2(path, '');
+    newAnalysisOptionsYamlFile2('/project', r'''
 analyzer:
   exclude:
     - 'samples/**'
@@ -334,7 +334,7 @@
   }
 
   void writePackageConfig(String path, PackageConfigFileBuilder config) {
-    newFile(path, content: config.toContent(toUriStr: toUriStr));
+    newFile2(path, config.toContent(toUriStr: toUriStr));
   }
 
   /// Creates a simple package named [name] with [content] in the file at
@@ -343,7 +343,7 @@
   /// Returns a [Folder] that represents the packages `lib` folder.
   Folder _addSimplePackage(String name, String content) {
     final packagePath = '/packages/$name';
-    final file = newFile('$packagePath/lib/$name.dart', content: content);
+    final file = newFile2('$packagePath/lib/$name.dart', content);
     return file.parent;
   }
 }
diff --git a/pkg/analysis_server/test/client/completion_driver_test.dart b/pkg/analysis_server/test/client/completion_driver_test.dart
index 6316a24..9cb255d 100644
--- a/pkg/analysis_server/test/client/completion_driver_test.dart
+++ b/pkg/analysis_server/test/client/completion_driver_test.dart
@@ -296,11 +296,11 @@
 
 mixin CompletionWithSuggestionsTestCases on AbstractCompletionDriverTest {
   Future<void> test_project_filterImports_defaultConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -324,13 +324,13 @@
 
   /// See: https://github.com/dart-lang/sdk/issues/40620
   Future<void> test_project_filterImports_enumValues() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum E {
   e,
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -353,13 +353,13 @@
 
   /// See: https://github.com/dart-lang/sdk/issues/40620
   Future<void> test_project_filterImports_namedConstructors() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A.a();
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -382,11 +382,11 @@
   }
 
   Future<void> test_project_filterMultipleImports() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -410,7 +410,7 @@
   }
 
   Future<void> test_project_lib() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 enum E {
   e,
@@ -467,7 +467,7 @@
   }
 
   Future<void> test_project_lib_fields_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int f = 0;
 }
@@ -487,7 +487,7 @@
   }
 
   Future<void> test_project_lib_fields_static() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int f = 0;
 }
@@ -510,7 +510,7 @@
   }
 
   Future<void> test_project_lib_getters_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get g => 0;
 }
@@ -530,7 +530,7 @@
   }
 
   Future<void> test_project_lib_getters_static() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int get g => 0;
 }
@@ -554,7 +554,7 @@
 
   /// See: https://github.com/dart-lang/sdk/issues/40626
   Future<void> test_project_lib_getters_topLevel() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int get g => 0;
 ''');
 
@@ -575,7 +575,7 @@
   }
 
   Future<void> test_project_lib_methods_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo() => 0;
 }
@@ -595,7 +595,7 @@
   }
 
   Future<void> test_project_lib_methods_static() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static void foo() => 0;
 }
@@ -615,11 +615,11 @@
   }
 
   Future<void> test_project_lib_multipleExports() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -642,7 +642,7 @@
   }
 
   Future<void> test_project_lib_setters_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   set s(int s) {}
 }
@@ -662,7 +662,7 @@
   }
 
   Future<void> test_project_lib_setters_static() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static set g(int g) {}
 }
@@ -683,7 +683,7 @@
 
   /// See: https://github.com/dart-lang/sdk/issues/40626
   Future<void> test_project_lib_setters_topLevel() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 set s(int s) {}
 ''');
 
@@ -706,7 +706,7 @@
   @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/38739')
   Future<void>
       test_project_suggestionRelevance_constructorParameterType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'b.dart';
 
 class A {
@@ -714,7 +714,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 class O { }
 ''');
 
@@ -745,7 +745,7 @@
   }
 
   Future<void> test_project_suggestionRelevance_constructorsAndTypes() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A { }
 ''');
 
@@ -777,7 +777,7 @@
 
   /// See: https://github.com/dart-lang/sdk/issues/35529
   Future<void> test_project_suggestMixins() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin M { }
 class A { }
 ''');
diff --git a/pkg/analysis_server/test/client/impl/completion_driver.dart b/pkg/analysis_server/test/client/impl/completion_driver.dart
index c57c328..3383e6c 100644
--- a/pkg/analysis_server/test/client/impl/completion_driver.dart
+++ b/pkg/analysis_server/test/client/impl/completion_driver.dart
@@ -92,14 +92,16 @@
     if (offset != null) {
       expect(completionOffset, -1, reason: 'cannot supply offset and ^');
       completionOffset = offset;
-      server.newFile(server.testFilePath, content: content);
+      server.newFile2(server.testFilePath, content);
     } else {
       expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
       var nextOffset = content.indexOf('^', completionOffset + 1);
       expect(nextOffset, equals(-1), reason: 'too many ^');
-      server.newFile(server.testFilePath,
-          content: content.substring(0, completionOffset) +
-              content.substring(completionOffset + 1));
+      server.newFile2(
+        server.testFilePath,
+        content.substring(0, completionOffset) +
+            content.substring(completionOffset + 1),
+      );
     }
   }
 
diff --git a/pkg/analysis_server/test/completion_test_support.dart b/pkg/analysis_server/test/completion_test_support.dart
index 35f61fd..de59784 100644
--- a/pkg/analysis_server/test/completion_test_support.dart
+++ b/pkg/analysis_server/test/completion_test_support.dart
@@ -83,12 +83,12 @@
     await super.setUp();
     return Future(() {
       var content = spec.source;
-      newFile(testFile, content: content);
+      newFile2(testFile, content);
       testCode = content;
       completionOffset = spec.testLocation;
       if (extraFiles != null) {
         extraFiles.forEach((String fileName, String content) {
-          newFile(fileName, content: content);
+          newFile2(fileName, content);
         });
       }
     }).then((_) => getSuggestions()).then((_) {
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index 229f1ca..776c72d 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -36,14 +36,14 @@
   @override
   void setUp() {
     super.setUp();
-    newFile('$workspaceRootPath/WORKSPACE');
+    newFile2('$workspaceRootPath/WORKSPACE', '');
   }
 
   Future<void> test_fileSystem_changeFile_buildFile() async {
     // This BUILD file does not enable null safety.
     newBazelBuildFile(myPackageRootPath, '');
 
-    newFile(myPackageTestFilePath, content: '''
+    newFile2(myPackageTestFilePath, '''
 void f(int? a) {}
 ''');
 
@@ -85,7 +85,7 @@
     );
 
     // Write the options file that excludes b.dart
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, r'''
 analyzer:
   exclude:
     - lib/b.dart
@@ -107,7 +107,7 @@
     var a_path = '$testPackageLibPath/a.dart';
     var options_path = '$testPackageRootPath/analysis_options.yaml';
 
-    newFile(a_path, content: 'error');
+    newFile2(a_path, 'error');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
     await server.onAnalysisComplete;
@@ -119,7 +119,7 @@
     );
 
     // Add 'analysis_options.yaml' that has an error.
-    newFile(options_path, content: '''
+    newFile2(options_path, '''
 analyzer:
   error:
 ''');
@@ -136,9 +136,9 @@
   Future<void> test_fileSystem_addFile_androidManifestXml() async {
     var path = '$testPackageRootPath/AndroidManifest.xml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
@@ -146,7 +146,7 @@
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
-    newFile(path, content: '<manifest/>');
+    newFile2(path, '<manifest/>');
     await pumpEventQueue();
     await server.onAnalysisComplete;
 
@@ -178,7 +178,7 @@
     var a_path = '$testPackageLibPath/.foo/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import '.foo/a.dart';
 void f(A a) {}
 ''');
@@ -189,7 +189,7 @@
     // We don't have a.dart, so the import cannot be resolved.
     assertHasErrors(b_path);
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A {}
 ''');
     await pumpEventQueue();
@@ -206,13 +206,13 @@
     var a_path = '$testPackageLibPath/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, r'''
 analyzer:
   exclude:
     - "**/a.dart"
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import 'a.dart';
 void f(A a) {}
 ''');
@@ -223,7 +223,7 @@
     // We don't have a.dart, so the import cannot be resolved.
     assertHasErrors(b_path);
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A {}
 ''');
     await pumpEventQueue();
@@ -239,7 +239,7 @@
   Future<void> test_fileSystem_addFile_fixDataYaml() async {
     var path = '$testPackageLibPath/fix_data.yaml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -247,7 +247,7 @@
     assertNoErrorsNotification(path);
 
     // Create it, will be analyzed.
-    newFile(path, content: '0: 1');
+    newFile2(path, '0: 1');
     await pumpEventQueue();
     await server.onAnalysisComplete;
 
@@ -262,11 +262,11 @@
     var aaaRootPath = '/packages/aaa';
     var a_path = '$aaaRootPath/lib/a.dart';
 
-    newFile(a_path, content: '''
+    newFile2(a_path, '''
 class A {}
 ''');
 
-    newFile(testFilePath, content: '''
+    newFile2(testFilePath, '''
 import 'package:aaa/a.dart';
 void f(A a) {}
 ''');
@@ -297,11 +297,11 @@
     var a_path = '$testPackageLibPath/a.dart';
     var pubspec_path = '$testPackageRootPath/pubspec.yaml';
 
-    newFile(a_path, content: 'error');
+    newFile2(a_path, 'error');
 
     // Write an empty file to force a new analysis context.
     // We look for `pubspec.yaml` files only in analysis context roots.
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '');
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
     await server.onAnalysisComplete;
@@ -313,7 +313,7 @@
     );
 
     // Add a non-Dart file that we know how to analyze.
-    newFile(pubspec_path, content: '''
+    newFile2(pubspec_path, '''
 name: sample
 dependencies: true
 ''');
@@ -331,7 +331,7 @@
     var a_path = '$testPackageLibPath/a.dart';
     var unrelated_path = '$testPackageRootPath/unrelated.txt';
 
-    newFile(a_path, content: 'error');
+    newFile2(a_path, 'error');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
     await server.onAnalysisComplete;
@@ -343,7 +343,7 @@
     );
 
     // Add an unrelated file, no analysis.
-    newFile(unrelated_path, content: 'anything');
+    newFile2(unrelated_path, 'anything');
     await pumpEventQueue();
     await server.onAnalysisComplete;
 
@@ -361,7 +361,7 @@
     _createFilesWithErrors([a_path, b_path, c_path]);
 
     // Exclude b.dart from analysis.
-    newFile(options_path, content: r'''
+    newFile2(options_path, r'''
 analyzer:
   exclude:
     - lib/b.dart
@@ -377,7 +377,7 @@
     );
 
     // Exclude c.dart from analysis.
-    newFile(options_path, content: r'''
+    newFile2(options_path, r'''
 analyzer:
   exclude:
     - lib/c.dart
@@ -398,12 +398,12 @@
   Future<void> test_fileSystem_changeFile_androidManifestXml() async {
     var path = '$testPackageRootPath/AndroidManifest.xml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
     // Has an error - no touch screen.
-    newFile(path, content: '<manifest/>');
+    newFile2(path, '<manifest/>');
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
@@ -416,7 +416,7 @@
     assertNoErrorsNotification(path);
 
     // Update the file, so analyze it.
-    newFile(path, content: '<manifest/>');
+    newFile2(path, '<manifest/>');
     await pumpEventQueue();
     await server.onAnalysisComplete;
 
@@ -428,11 +428,11 @@
     var a_path = '$testPackageLibPath/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A2 {}
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import 'a.dart';
 void f(A a) {}
 ''');
@@ -445,7 +445,7 @@
     forgetReceivedErrors();
 
     // Update a.dart so that b.dart has no error.
-    newFile(a_path, content: 'class A {}');
+    newFile2(a_path, 'class A {}');
     await pumpEventQueue();
     await server.onAnalysisComplete;
 
@@ -458,11 +458,11 @@
     var a_path = '$testPackageLibPath/.foo/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class B {}
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import '.foo/a.dart';
 void f(A a) {}
 ''');
@@ -477,7 +477,7 @@
     // We have `B`, not `A`, in a.dart, so has errors.
     assertHasErrors(b_path);
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A {}
 ''');
     await pumpEventQueue();
@@ -494,17 +494,17 @@
     var a_path = '$testPackageLibPath/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, r'''
 analyzer:
   exclude:
     - "**/a.dart"
 ''');
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class B {}
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import 'a.dart';
 void f(A a) {}
 ''');
@@ -519,7 +519,7 @@
     // We have `B`, not `A`, in a.dart, so has errors.
     assertHasErrors(b_path);
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A {}
 ''');
     await pumpEventQueue();
@@ -532,10 +532,10 @@
   Future<void> test_fileSystem_changeFile_fixDataYaml() async {
     var path = '$testPackageLibPath/fix_data.yaml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
     // This file has an error.
-    newFile(path, content: '0: 1');
+    newFile2(path, '0: 1');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -543,7 +543,7 @@
     assertHasErrors(path);
 
     // Replace with the context that does not have errors.
-    newFile(path, content: r'''
+    newFile2(path, r'''
 version: 1
 transforms: []
 ''');
@@ -558,7 +558,7 @@
   }
 
   Future<void> test_fileSystem_changeFile_hasOverlay_removeOverlay() async {
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     // Add an overlay without errors.
     await handleSuccessfulRequest(
@@ -569,8 +569,8 @@
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
-    // The test file is analyzed, no errors.
-    await server.onAnalysisComplete;
+    // The test file (overlay) is analyzed, no errors.
+    await _waitAnalysisComplete();
     _assertAnalyzedFiles(
       hasErrors: [],
       noErrors: [testFilePathPlatform],
@@ -578,24 +578,87 @@
     );
 
     // Change the file, has errors.
-    newFile(testFilePath, content: 'error');
+    newFile2(testFilePath, 'error');
 
     // But the overlay is still present, so the file is not analyzed.
-    await server.onAnalysisComplete;
+    await _waitAnalysisComplete();
     _assertAnalyzedFiles(
       hasErrors: [],
       notAnalyzed: [testFilePathPlatform],
     );
 
-    // Remove the overlay, now the file will be read.
+    // Ask to remove the overlay, still active, start a timer.
     await handleSuccessfulRequest(
       AnalysisUpdateContentParams({
         testFilePathPlatform: RemoveContentOverlay(),
       }).toRequest('0'),
     );
 
+    // Wait for the timer to remove the overlay to fire.
+    await Future.delayed(server.pendingFilesRemoveOverlayDelay);
+
     // The file has errors.
-    await server.onAnalysisComplete;
+    await _waitAnalysisComplete();
+    _assertAnalyzedFiles(
+      hasErrors: [testFilePathPlatform],
+      noErrors: [],
+      notAnalyzed: [],
+    );
+  }
+
+  Future<void>
+      test_fileSystem_changeFile_hasOverlay_removeOverlay_delayed() async {
+    // Use long delay, so that it does not happen.
+    server.pendingFilesRemoveOverlayDelay = const Duration(seconds: 300);
+
+    newFile2(testFilePath, '');
+
+    // Add an overlay without errors.
+    await handleSuccessfulRequest(
+      AnalysisUpdateContentParams({
+        testFilePathPlatform: AddContentOverlay(''),
+      }).toRequest('0'),
+    );
+
+    await setRoots(included: [workspaceRootPath], excluded: []);
+
+    // The test file (overlay) is analyzed, no errors.
+    await _waitAnalysisComplete();
+    _assertAnalyzedFiles(
+      hasErrors: [],
+      noErrors: [testFilePathPlatform],
+      notAnalyzed: [],
+    );
+
+    // Change the file, has errors.
+    modifyFile(testFilePath, 'error');
+
+    // But the overlay is still present, so the file is not analyzed.
+    await _waitAnalysisComplete();
+    _assertAnalyzedFiles(
+      hasErrors: [],
+      notAnalyzed: [testFilePathPlatform],
+    );
+
+    // Ask to remove the overlay, still active, start a timer.
+    await handleSuccessfulRequest(
+      AnalysisUpdateContentParams({
+        testFilePathPlatform: RemoveContentOverlay(),
+      }).toRequest('0'),
+    );
+
+    // Long timer, so still not analyzed.
+    await _waitAnalysisComplete();
+    _assertAnalyzedFiles(
+      hasErrors: [],
+      notAnalyzed: [testFilePathPlatform],
+    );
+
+    // Change the file again, has errors.
+    newFile2(testFilePath, 'error');
+
+    // The timer cancelled on the watch event, and the file analyzed.
+    await _waitAnalysisComplete();
     _assertAnalyzedFiles(
       hasErrors: [testFilePathPlatform],
       noErrors: [],
@@ -607,11 +670,11 @@
     var aaaRootPath = '/packages/aaa';
     var a_path = '$aaaRootPath/lib/a.dart';
 
-    newFile(a_path, content: '''
+    newFile2(a_path, '''
 class A {}
 ''');
 
-    newFile(testFilePath, content: '''
+    newFile2(testFilePath, '''
 import 'package:aaa/a.dart';
 void f(A a) {}
 ''');
@@ -647,7 +710,7 @@
     _createFilesWithErrors([a_path, b_path]);
 
     // Exclude b.dart from analysis.
-    newFile(options_path, content: r'''
+    newFile2(options_path, r'''
 analyzer:
   exclude:
     - lib/b.dart
@@ -679,12 +742,12 @@
   Future<void> test_fileSystem_deleteFile_androidManifestXml() async {
     var path = '$testPackageRootPath/AndroidManifest.xml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
     // Has an error - no touch screen.
-    newFile(path, content: '<manifest/>');
+    newFile2(path, '<manifest/>');
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
@@ -727,17 +790,17 @@
     var a_path = '$testPackageLibPath/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: r'''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, r'''
 analyzer:
   exclude:
     - "**/a.dart"
 ''');
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 class A {}
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 import 'a.dart';
 void f(A a) {}
 ''');
@@ -763,10 +826,10 @@
   Future<void> test_fileSystem_deleteFile_fixDataYaml() async {
     var path = '$testPackageLibPath/fix_data.yaml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
     // This file has an error.
-    newFile(path, content: '0: 1');
+    newFile2(path, '0: 1');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -785,7 +848,7 @@
     var aaaRootPath = '/packages/aaa';
     var a_path = '$aaaRootPath/lib/a.dart';
 
-    newFile(a_path, content: '''
+    newFile2(a_path, '''
 class A {}
 ''');
 
@@ -795,7 +858,7 @@
         ..add(name: 'aaa', rootPath: aaaRootPath),
     );
 
-    newFile(testFilePath, content: '''
+    newFile2(testFilePath, '''
 import 'package:aaa/a.dart';
 void f(A a) {}
 ''');
@@ -1024,7 +1087,7 @@
     var a_path = '$testPackageLibPath/a.dart';
     var b_path = '$testPackageLibPath/b.dart';
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '''
 analyzer:
   exclude:
     - "**/b.dart"
@@ -1107,15 +1170,15 @@
   Future<void> test_setRoots_notDartFile_androidManifestXml() async {
     var path = '$testPackageRootPath/AndroidManifest.xml';
 
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
-    newAnalysisOptionsYamlFile(testPackageRootPath, content: '''
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '''
 analyzer:
   optional-checks:
     chrome-os-manifest-checks: true
 ''');
 
-    newFile(path, content: '<manifest/>');
+    newFile2(path, '<manifest/>');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -1127,7 +1190,7 @@
     var path = '$testPackageLibPath/fix_data.yaml';
 
     // `lib/fix_data.yaml` will be analyzed.
-    newFile(path, content: '0: 1');
+    newFile2(path, '0: 1');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -1138,7 +1201,7 @@
     var aaaRootPath = '/packages/aaa';
     var a_path = '$aaaRootPath/lib/a.dart';
 
-    newFile(a_path, content: '''
+    newFile2(a_path, '''
 class A {}
 ''');
 
@@ -1147,7 +1210,7 @@
         ..add(name: 'aaa', rootPath: aaaRootPath),
     );
 
-    newFile(testFilePath, content: '''
+    newFile2(testFilePath, '''
 import 'package:aaa/a.dart';
 void f(A a) {}
 ''');
@@ -1164,7 +1227,7 @@
   }
 
   Future<void> test_updateContent_addOverlay() async {
-    newFile('$testFilePath', content: 'error');
+    newFile2('$testFilePath', 'error');
 
     await setRoots(included: [workspaceRootPath], excluded: []);
 
@@ -1193,7 +1256,7 @@
   }
 
   Future<void> test_updateContent_changeOverlay() async {
-    newFile('$testFilePath', content: '');
+    newFile2('$testFilePath', '');
 
     // Add the content with an error.
     await handleSuccessfulRequest(
@@ -1255,7 +1318,7 @@
     String initialContent,
     SourceEdit edit,
   ) async {
-    newFile('$testFilePath', content: initialContent);
+    newFile2('$testFilePath', initialContent);
 
     await setRoots(included: [workspaceRootPath], excluded: []);
     await server.onAnalysisComplete;
@@ -1280,6 +1343,16 @@
       ),
     );
   }
+
+  /// Pump the event queue, so that watch events are processed.
+  /// Wait for analysis to complete.
+  /// Repeat a few times, eventually there will be no work to do.
+  Future<void> _waitAnalysisComplete() async {
+    for (var i = 0; i < 128; i++) {
+      pumpEventQueue();
+      await server.onAnalysisComplete;
+    }
+  }
 }
 
 @reflectiveTest
@@ -1325,13 +1398,13 @@
   }
 
   Future<void> test_afterAnalysis_packageFile_external() async {
-    var pkgFile = newFile('/packages/pkgA/lib/libA.dart', content: '''
+    var pkgFile = newFile2('/packages/pkgA/lib/libA.dart', '''
 library lib_a;
 class A {}
 ''').path;
     newPackageConfigJsonFile(
       '/project',
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
           .toContent(toUriStr: toUriStr),
     );
@@ -1356,11 +1429,11 @@
   Future<void> test_afterAnalysis_packageFile_inRoot() async {
     var pkgA = convertPath('/pkgA');
     var pkgB = convertPath('/pkgA');
-    var pkgFileA = newFile('$pkgA/lib/libA.dart', content: '''
+    var pkgFileA = newFile2('$pkgA/lib/libA.dart', '''
 library lib_a;
 class A {}
 ''').path;
-    newFile('$pkgA/lib/libB.dart', content: '''
+    newFile2('$pkgA/lib/libB.dart', '''
 import 'package:pkgA/libA.dart';
 main() {
   new A();
@@ -1380,13 +1453,13 @@
   }
 
   Future<void> test_afterAnalysis_packageFile_notUsed() async {
-    var pkgFile = newFile('/packages/pkgA/lib/libA.dart', content: '''
+    var pkgFile = newFile2('/packages/pkgA/lib/libA.dart', '''
 library lib_a;
 class A {}
 ''').path;
     newPackageConfigJsonFile(
       '/project',
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
           .toContent(toUriStr: toUriStr),
     );
@@ -1514,7 +1587,7 @@
   /// So, when analyzed, these files will satisfy [assertHasErrors].
   void _createFilesWithErrors(List<String> paths) {
     for (var path in paths) {
-      newFile(path, content: 'error');
+      newFile2(path, 'error');
     }
   }
 }
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index 3618cc0..ad469f1 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -133,7 +133,7 @@
 ''');
 
     var aaaRoot = getFolder('$workspaceRootPath/packages/aaa');
-    newFile('${aaaRoot.path}/lib/f.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/f.dart', '''
 class Test {}
 ''');
 
@@ -164,7 +164,7 @@
   }
 
   Future<void> test_import_package_this() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class Test {}
 ''');
 
@@ -224,8 +224,9 @@
     var nextOffset = content.indexOf('^', completionOffset + 1);
     expect(nextOffset, equals(-1), reason: 'too many ^');
 
-    newFile(path,
-        content: content.substring(0, completionOffset) +
+    newFile2(
+        path,
+        content.substring(0, completionOffset) +
             content.substring(completionOffset + 1));
 
     return await _getDetails(
@@ -282,7 +283,7 @@
       abortedIdSet.add(request.id);
     });
 
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     await _configureWithWorkspaceRoot();
 
@@ -320,7 +321,7 @@
       abortedIdSet.add(request.id);
     });
 
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     await _configureWithWorkspaceRoot();
 
@@ -344,13 +345,13 @@
   }
 
   Future<void> test_isNotImportedFeature_prefixed_classInstanceMethod() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void foo01() {}
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 
 class B extends A {
@@ -424,13 +425,13 @@
   }
 
   Future<void> test_notImported_lowerRelevance_enumConstant() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 enum E1 {
   foo01
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 enum E2 {
   foo02
 }
@@ -464,13 +465,13 @@
   Future<void> test_notImported_lowerRelevance_extension_getter() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   int get foo01 => 0;
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 extension E2 on int {
   int get foo02 => 0;
 }
@@ -502,13 +503,13 @@
   Future<void> test_notImported_lowerRelevance_extension_method() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   void foo01() {}
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 extension E2 on int {
   void foo02() {}
 }
@@ -540,13 +541,13 @@
   Future<void> test_notImported_lowerRelevance_extension_setter() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   set foo01(int _) {}
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 extension E2 on int {
   set foo02(int _) {}
 }
@@ -576,11 +577,11 @@
   }
 
   Future<void> test_notImported_lowerRelevance_topLevel_class() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class A02 {}
 ''');
 
@@ -610,11 +611,11 @@
   }
 
   Future<void> test_notImported_lowerRelevance_topLevel_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 int get foo01 => 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 int get foo02 => 0;
 ''');
 
@@ -644,11 +645,11 @@
   }
 
   Future<void> test_notImported_lowerRelevance_topLevel_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 set foo01(int _) {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 set foo02(int _) {}
 ''');
 
@@ -678,11 +679,11 @@
   }
 
   Future<void> test_notImported_lowerRelevance_topLevel_variable() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var foo01 = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var foo02 = 0;
 ''');
 
@@ -721,18 +722,18 @@
 ''');
 
     var aaaRoot = getFolder('$workspaceRootPath/packages/aaa');
-    newFile('${aaaRoot.path}/lib/f.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/f.dart', '''
 class A01 {}
 ''');
-    newFile('${aaaRoot.path}/lib/src/f.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/src/f.dart', '''
 class A02 {}
 ''');
 
     var bbbRoot = getFolder('$workspaceRootPath/packages/bbb');
-    newFile('${bbbRoot.path}/lib/f.dart', content: '''
+    newFile2('${bbbRoot.path}/lib/f.dart', '''
 class A03 {}
 ''');
-    newFile('${bbbRoot.path}/lib/src/f.dart', content: '''
+    newFile2('${bbbRoot.path}/lib/src/f.dart', '''
 class A04 {}
 ''');
 
@@ -771,18 +772,18 @@
 ''');
 
     var aaaRoot = getFolder('$workspaceRootPath/packages/aaa');
-    newFile('${aaaRoot.path}/lib/f.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/f.dart', '''
 class A01 {}
 ''');
-    newFile('${aaaRoot.path}/lib/src/f.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/src/f.dart', '''
 class A02 {}
 ''');
 
     var bbbRoot = getFolder('$workspaceRootPath/packages/bbb');
-    newFile('${bbbRoot.path}/lib/f.dart', content: '''
+    newFile2('${bbbRoot.path}/lib/f.dart', '''
 class A03 {}
 ''');
-    newFile('${bbbRoot.path}/lib/src/f.dart', content: '''
+    newFile2('${bbbRoot.path}/lib/src/f.dart', '''
 class A04 {}
 ''');
 
@@ -819,11 +820,11 @@
   }
 
   Future<void> test_notImported_pub_this() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class A02 {}
 ''');
 
@@ -850,12 +851,12 @@
   }
 
   Future<void> test_notImported_pub_this_hasImport() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 class A02 {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class A03 {}
 ''');
 
@@ -887,12 +888,12 @@
   }
 
   Future<void> test_notImported_pub_this_hasImport_hasShow() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 class A02 {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class A03 {}
 ''');
 
@@ -932,11 +933,11 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageTestPath/b.dart', content: '''
+    newFile2('$testPackageTestPath/b.dart', '''
 class A02 {}
 ''');
 
@@ -964,11 +965,11 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/f.dart', content: '''
+    newFile2('$testPackageLibPath/f.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageLibPath/src/f.dart', content: '''
+    newFile2('$testPackageLibPath/src/f.dart', '''
 class A02 {}
 ''');
 
@@ -999,11 +1000,11 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 ''');
 
-    var b = newFile('$testPackageTestPath/b.dart', content: '''
+    var b = newFile2('$testPackageTestPath/b.dart', '''
 class A02 {}
 ''');
     var b_uriStr = toUriStr(b.path);
@@ -1039,11 +1040,11 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/f.dart', content: '''
+    newFile2('$testPackageLibPath/f.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageLibPath/src/f.dart', content: '''
+    newFile2('$testPackageLibPath/src/f.dart', '''
 class A02 {}
 ''');
 
@@ -1132,7 +1133,7 @@
   Future<void> test_numResults_topLevelVariables_imported_withPrefix() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var foo01 = 0;
 var foo02 = 0;
 var foo03 = 0;
@@ -1312,7 +1313,7 @@
   Future<void> test_prefixed_expression_extensionGetters_notImported() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   int get foo01 => 0;
   int get bar => 0;
@@ -1353,7 +1354,7 @@
       test_prefixed_expression_extensionGetters_notImported_private() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   int get foo01 => 0;
 }
@@ -1421,7 +1422,7 @@
   Future<void> test_prefixed_expression_extensionMethods_notImported() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   void foo01() {}
   void bar() {}
@@ -1494,7 +1495,7 @@
   Future<void> test_prefixed_expression_extensionSetters_notImported() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   set foo01(int _) {}
   set bar(int _) {}
@@ -1535,7 +1536,7 @@
       test_prefixed_expression_extensionSetters_notImported_private() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   set foo01(int _) {}
 }
@@ -1570,7 +1571,7 @@
   Future<void> test_prefixed_extensionGetters_imported() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E1 on int {
   int get foo01 => 0;
   int get foo02 => 0;
@@ -1714,11 +1715,11 @@
   Future<void> test_unprefixed_imported_class() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A01 {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class A02 {}
 ''');
 
@@ -1752,11 +1753,11 @@
   Future<void> test_unprefixed_imported_topLevelVariable() async {
     await _configureWithWorkspaceRoot();
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var foo01 = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var foo02 = 0;
 ''');
 
@@ -1951,9 +1952,11 @@
     var nextOffset = content.indexOf('^', completionOffset + 1);
     expect(nextOffset, equals(-1), reason: 'too many ^');
 
-    newFile(path,
-        content: content.substring(0, completionOffset) +
-            content.substring(completionOffset + 1));
+    newFile2(
+      path,
+      content.substring(0, completionOffset) +
+          content.substring(completionOffset + 1),
+    );
 
     return await _getSuggestions(
       path: path,
@@ -2281,7 +2284,7 @@
   Future<void> test_import_uri_with_trailing() {
     final filePath = '/project/bin/testA.dart';
     final incompleteImportText = toUriStr('/project/bin/t');
-    newFile(filePath, content: 'library libA;');
+    newFile2(filePath, 'library libA;');
     addTestFile('''
     import "$incompleteImportText^.dart";
     void f() {}''');
@@ -2578,7 +2581,7 @@
   }
 
   Future<void> test_inDartDoc_reference1() async {
-    newFile('/testA.dart', content: '''
+    newFile2('/testA.dart', '''
   part of libA;
   foo(bar) => 0;''');
     addTestFile('''
@@ -2731,7 +2734,7 @@
   }
 
   Future<void> test_local_override() {
-    newFile('/project/bin/a.dart', content: 'class A {m() {}}');
+    newFile2('/project/bin/a.dart', 'class A {m() {}}');
     addTestFile('''
 import 'a.dart';
 class B extends A {
@@ -2796,7 +2799,7 @@
   }
 
   Future<void> test_overrides() {
-    newFile('/project/bin/a.dart', content: 'class A {m() {}}');
+    newFile2('/project/bin/a.dart', 'class A {m() {}}');
     addTestFile('''
 import 'a.dart';
 class B extends A {m() {^}}
@@ -2809,7 +2812,7 @@
   }
 
   Future<void> test_partFile() {
-    newFile('/project/bin/a.dart', content: '''
+    newFile2('/project/bin/a.dart', '''
       library libA;
       import 'dart:html';
       part 'test.dart';
@@ -2832,7 +2835,7 @@
   }
 
   Future<void> test_partFile2() {
-    newFile('/project/bin/a.dart', content: '''
+    newFile2('/project/bin/a.dart', '''
       part of libA;
       class A { }''');
     addTestFile('''
@@ -3016,20 +3019,25 @@
       InstrumentationService.NULL_SERVICE,
     );
 
+    server.pendingFilesRemoveOverlayDelay = const Duration(milliseconds: 10);
     completionDomain.budgetDuration = const Duration(seconds: 30);
   }
 
+  Future<void> tearDown() async {
+    await server.dispose();
+  }
+
   void writePackageConfig(Folder root, PackageConfigFileBuilder config) {
     newPackageConfigJsonFile(
       root.path,
-      content: config.toContent(toUriStr: toUriStr),
+      config.toContent(toUriStr: toUriStr),
     );
   }
 
   void writeTestPackageAnalysisOptionsFile(AnalysisOptionsFileConfig config) {
-    newAnalysisOptionsYamlFile(
+    newAnalysisOptionsYamlFile2(
       testPackageRootPath,
-      content: config.toContent(),
+      config.toContent(),
     );
   }
 
diff --git a/pkg/analysis_server/test/domain_diagnostic_test.dart b/pkg/analysis_server/test/domain_diagnostic_test.dart
index 2a354f2..e19b27d 100644
--- a/pkg/analysis_server/test/domain_diagnostic_test.dart
+++ b/pkg/analysis_server/test/domain_diagnostic_test.dart
@@ -27,7 +27,7 @@
 
   Future<void> test_getDiagnostics() async {
     newPubspecYamlFile('/project', 'name: project');
-    newFile('/project/bin/test.dart', content: 'main() {}');
+    newFile2('/project/bin/test.dart', 'main() {}');
 
     await server.setAnalysisRoots('0', [convertPath('/project')], []);
 
diff --git a/pkg/analysis_server/test/domain_execution_test.dart b/pkg/analysis_server/test/domain_execution_test.dart
index d3945a8..3bfafaf 100644
--- a/pkg/analysis_server/test/domain_execution_test.dart
+++ b/pkg/analysis_server/test/domain_execution_test.dart
@@ -188,8 +188,8 @@
 }
 ''';
 
-    var path = newFile('/test.dart').path;
-    newFile(path, content: code);
+    var path = newFile2('/test.dart', '').path;
+    newFile2(path, code);
 
     var request = ExecutionGetSuggestionsParams(
         'a.',
@@ -213,7 +213,7 @@
   }
 
   void test_mapUri_file() {
-    var path = newFile('/a/b.dart').path;
+    var path = newFile2('/a/b.dart', '').path;
     // map the file
     var result = _mapUri(file: path);
     expect(result.file, isNull);
@@ -229,7 +229,7 @@
   }
 
   void test_mapUri_uri() {
-    var path = newFile('/a/b.dart').path;
+    var path = newFile2('/a/b.dart', '').path;
     // map the uri
     var result = _mapUri(uri: Uri.file(path).toString());
     expect(result.file, convertPath('/a/b.dart'));
diff --git a/pkg/analysis_server/test/edit/bulk_fixes_test.dart b/pkg/analysis_server/test/edit/bulk_fixes_test.dart
index b746b44..4928226 100644
--- a/pkg/analysis_server/test/edit/bulk_fixes_test.dart
+++ b/pkg/analysis_server/test/edit/bulk_fixes_test.dart
@@ -60,7 +60,7 @@
   }
 
   Future<void> test_annotateOverrides_excludedFile() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   exclude:
     - test/**
@@ -69,7 +69,7 @@
     - annotate_overrides
 ''');
 
-    newFile('$projectPath/test/test.dart', content: '''
+    newFile2('$projectPath/test/test.dart', '''
 class A {
   void f() {}
 }
@@ -83,7 +83,7 @@
 
   Future<void> test_annotateOverrides_excludedSubProject() async {
     // Root project.
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   exclude:
     - test/data/**
@@ -91,7 +91,7 @@
 
     // Sub-project.
     var subprojectRoot = '$projectPath/test/data/subproject';
-    newAnalysisOptionsYamlFile(subprojectRoot, content: '''
+    newAnalysisOptionsYamlFile2(subprojectRoot, '''
 linter:
   rules:
     - annotate_overrides
@@ -101,7 +101,7 @@
 name: subproject
 ''');
 
-    newFile('$subprojectRoot/test.dart', content: '''
+    newFile2('$subprojectRoot/test.dart', '''
 class A {
   void f() {}
 }
@@ -115,7 +115,7 @@
 
   Future<void> test_annotateOverrides_subProject() async {
     var subprojectRoot = '$projectPath/test/data/subproject';
-    newAnalysisOptionsYamlFile(subprojectRoot, content: '''
+    newAnalysisOptionsYamlFile2(subprojectRoot, '''
 linter:
   rules:
     - annotate_overrides
@@ -147,7 +147,7 @@
   }
 
   Future<void> test_details() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - annotate_overrides
@@ -155,7 +155,7 @@
 ''');
 
     var fileA = convertPath('$projectPath/a.dart');
-    newFile(fileA, content: '''
+    newFile2(fileA, '''
 class A {
   A f() => new A();
 }
@@ -181,7 +181,7 @@
   }
 
   Future<void> test_unnecessaryNew() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - unnecessary_new
@@ -205,7 +205,7 @@
     if (Platform.isWindows) {
       fail('Should not be passing on Windows, but it does');
     }
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - prefer_collection_literals
@@ -228,7 +228,7 @@
   }
 
   Future<void> test_unnecessaryNew_ignoredInOptions() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   errors:
     unnecessary_new: ignore
@@ -244,7 +244,7 @@
   }
 
   Future<void> test_unnecessaryNew_ignoredInSource() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 linter:
   rules:
     - unnecessary_new
diff --git a/pkg/analysis_server/test/edit/fixes_test.dart b/pkg/analysis_server/test/edit/fixes_test.dart
index b84a06c..ba507ba 100644
--- a/pkg/analysis_server/test/edit/fixes_test.dart
+++ b/pkg/analysis_server/test/edit/fixes_test.dart
@@ -33,7 +33,7 @@
 
   Future<void> test_fileOutsideRoot() async {
     final outsideFile = '/foo/test.dart';
-    newFile(outsideFile, content: 'bad code to create error');
+    newFile2(outsideFile, 'bad code to create error');
 
     // Set up the original project, as the code fix code won't run at all
     // if there are no contexts.
@@ -152,7 +152,7 @@
   Future<void> test_suggestImportFromDifferentAnalysisRoot() async {
     newPackageConfigJsonFile(
       '/aaa',
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'aaa', rootPath: '/aaa')
             ..add(name: 'bbb', rootPath: '/bbb'))
           .toContent(toUriStr: toUriStr),
@@ -164,12 +164,12 @@
 
     newPackageConfigJsonFile(
       '/bbb',
-      content: (PackageConfigFileBuilder()..add(name: 'bbb', rootPath: '/bbb'))
+      (PackageConfigFileBuilder()..add(name: 'bbb', rootPath: '/bbb'))
           .toContent(toUriStr: toUriStr),
     );
-    newFile('/bbb/lib/target.dart', content: 'class Foo() {}');
-    newFile('/bbb/lib/target.generated.dart', content: 'class Foo() {}');
-    newFile('/bbb/lib/target.template.dart', content: 'class Foo() {}');
+    newFile2('/bbb/lib/target.dart', 'class Foo() {}');
+    newFile2('/bbb/lib/target.generated.dart', 'class Foo() {}');
+    newFile2('/bbb/lib/target.template.dart', 'class Foo() {}');
 
     await setRoots(
         included: [convertPath('/aaa'), convertPath('/bbb')], excluded: []);
diff --git a/pkg/analysis_server/test/edit/refactoring_test.dart b/pkg/analysis_server/test/edit/refactoring_test.dart
index 74507b0..fe52d9d 100644
--- a/pkg/analysis_server/test/edit/refactoring_test.dart
+++ b/pkg/analysis_server/test/edit/refactoring_test.dart
@@ -269,7 +269,7 @@
 
   Future<void> test_analysis_onlyOneFile() async {
     shouldWaitForFullAnalysis = false;
-    newFile(join(testFolder, 'other.dart'), content: r'''
+    newFile2(join(testFolder, 'other.dart'), r'''
 foo(int myName) {}
 ''');
     addTestFile('''
@@ -468,7 +468,7 @@
 
   Future<void> test_resetOnAnalysisSetChanged_watch_otherFile() async {
     var otherFile = join(testFolder, 'other.dart');
-    newFile(otherFile, content: '// other 1');
+    newFile2(otherFile, '// other 1');
     addTestFile('''
 void f() {
   foo(1 + 2);
@@ -488,7 +488,7 @@
     // The refactoring is reset, even though it's a different file. It is up to
     // analyzer to track dependencies and provide resolved units fast when
     // possible.
-    newFile(otherFile, content: '// other 2');
+    newFile2(otherFile, '// other 2');
     await pumpEventQueue();
     expect(test_resetCount, initialResetCount + 1);
   }
@@ -843,7 +843,7 @@
   void addFlutterPackage() {
     var libFolder = MockPackages.instance.addFlutter(resourceProvider);
     // Create .packages in the project.
-    newFile(join(projectPath, '.packages'), content: '''
+    newFile2(join(projectPath, '.packages'), '''
 flutter:${libFolder.toUri()}
 ''');
   }
@@ -1088,7 +1088,7 @@
   Future<void> test_analysis_onlyOneFile() async {
     shouldWaitForFullAnalysis = false;
     var otherFile = join(testFolder, 'other.dart');
-    newFile(otherFile, content: r'''
+    newFile2(otherFile, r'''
 foo(int p) {}
 ''');
     addTestFile('''
@@ -1156,7 +1156,7 @@
   }
 
   Future<void> test_resetOnAnalysisSetChanged() async {
-    newFile(join(testFolder, 'other.dart'), content: '// other 1');
+    newFile2(join(testFolder, 'other.dart'), '// other 1');
     addTestFile('''
 void f() {
   int res = 1 + 2;
@@ -1318,7 +1318,7 @@
   late MoveFileOptions options;
 
   Future<void> test_file_OK() {
-    newFile('/project/bin/lib.dart');
+    newFile2('/project/bin/lib.dart', '');
     addTestFile('''
 import 'dart:math';
 import 'lib.dart';
@@ -1333,7 +1333,7 @@
   }
 
   Future<void> test_folder_cancel() {
-    newFile('/project/bin/original_folder/file.dart');
+    newFile2('/project/bin/original_folder/file.dart', '');
     addTestFile('''
 import 'dart:math';
 import 'original_folder/file.dart';
@@ -1346,7 +1346,7 @@
   }
 
   Future<void> test_folder_OK() {
-    newFile('/project/bin/original_folder/file.dart');
+    newFile2('/project/bin/original_folder/file.dart', '');
     addTestFile('''
 import 'dart:math';
 import 'original_folder/file.dart';
@@ -2129,7 +2129,7 @@
   }
 
   Future<void> test_library_partOfDirective() {
-    newFile(join(testFolder, 'my_lib.dart'), content: '''
+    newFile2(join(testFolder, 'my_lib.dart'), '''
 library aaa.bbb.ccc;
 part 'test.dart';
 ''');
diff --git a/pkg/analysis_server/test/edit/sort_members_test.dart b/pkg/analysis_server/test/edit/sort_members_test.dart
index 4c173d9..05a3cc1 100644
--- a/pkg/analysis_server/test/edit/sort_members_test.dart
+++ b/pkg/analysis_server/test/edit/sort_members_test.dart
@@ -195,7 +195,7 @@
   }
 
   Future<void> test_OK_genericFunctionType() async {
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   strong-mode: true
 ''');
diff --git a/pkg/analysis_server/test/integration/lsp_server/analyzer_status_test.dart b/pkg/analysis_server/test/integration/lsp_server/analyzer_status_test.dart
index 4889961..f7b847d 100644
--- a/pkg/analysis_server/test/integration/lsp_server/analyzer_status_test.dart
+++ b/pkg/analysis_server/test/integration/lsp_server/analyzer_status_test.dart
@@ -17,7 +17,7 @@
 class AnalyzerStatusTest extends AbstractLspAnalysisServerIntegrationTest {
   Future<void> test_afterDocumentEdits() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile(mainFilePath, initialContents);
 
     final initialAnalysis = waitForAnalysisComplete();
 
@@ -39,7 +39,7 @@
 
   Future<void> test_afterInitialize() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile(mainFilePath, initialContents);
 
     // To avoid races, set up listeners for the notifications before we initialise
     // and track which event came first to ensure they arrived in the expected
diff --git a/pkg/analysis_server/test/integration/lsp_server/diagnostic_test.dart b/pkg/analysis_server/test/integration/lsp_server/diagnostic_test.dart
index e9ed76a..ca65cbd 100644
--- a/pkg/analysis_server/test/integration/lsp_server/diagnostic_test.dart
+++ b/pkg/analysis_server/test/integration/lsp_server/diagnostic_test.dart
@@ -23,7 +23,7 @@
   print(x);
 }
 ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile(mainFilePath, withoutMarkers(content));
 
     final diagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await initialize();
@@ -45,7 +45,7 @@
   }
 
   Future<void> test_initialAnalysis() async {
-    newFile(mainFilePath, content: 'String a = 1;');
+    newFile(mainFilePath, 'String a = 1;');
 
     final diagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await initialize();
@@ -60,8 +60,8 @@
   }
 
   Future<void> test_lints() async {
-    newFile(mainFilePath, content: '''main() async => await 1;''');
-    newFile(analysisOptionsPath, content: '''
+    newFile(mainFilePath, '''main() async => await 1;''');
+    newFile(analysisOptionsPath, '''
 linter:
   rules:
     - await_only_futures
diff --git a/pkg/analysis_server/test/integration/lsp_server/integration_tests.dart b/pkg/analysis_server/test/integration/lsp_server/integration_tests.dart
index 3022431..cbf06cd 100644
--- a/pkg/analysis_server/test/integration/lsp_server/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/lsp_server/integration_tests.dart
@@ -43,8 +43,8 @@
     }
   }
 
-  void newFile(String path, {String? content}) =>
-      File(path).writeAsStringSync(content ?? '');
+  void newFile(String path, String content) =>
+      File(path).writeAsStringSync(content);
 
   void newFolder(String path) => Directory(path).createSync(recursive: true);
 
diff --git a/pkg/analysis_server/test/lsp/analyzer_status_test.dart b/pkg/analysis_server/test/lsp/analyzer_status_test.dart
index a137a95..151158d 100644
--- a/pkg/analysis_server/test/lsp/analyzer_status_test.dart
+++ b/pkg/analysis_server/test/lsp/analyzer_status_test.dart
@@ -39,7 +39,7 @@
 
   Future<void> test_afterDocumentEdits() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile2(mainFilePath, initialContents);
 
     final initialAnalysis = waitForAnalysisComplete();
 
@@ -61,7 +61,7 @@
 
   Future<void> test_afterInitialize() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile2(mainFilePath, initialContents);
 
     // To avoid races, set up listeners for the notifications before we initialise
     // and track which event came first to ensure they arrived in the expected
diff --git a/pkg/analysis_server/test/lsp/change_workspace_folders_test.dart b/pkg/analysis_server/test/lsp/change_workspace_folders_test.dart
index 14ae4a4..cddb554 100644
--- a/pkg/analysis_server/test/lsp/change_workspace_folders_test.dart
+++ b/pkg/analysis_server/test/lsp/change_workspace_folders_test.dart
@@ -74,7 +74,7 @@
         join(workspaceFolder1Path, 'nested', 'deeply', 'in', 'folders');
     final nestedFilePath = join(nestedFolderPath, 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     await initialize(allowEmptyRootUri: true);
     await openFile(nestedFileUri, '');
@@ -111,7 +111,7 @@
         join(workspaceFolder1Path, 'nested', 'deeply', 'in', 'folders');
     final nestedFilePath = join(nestedFolderPath, 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     await initialize(allowEmptyRootUri: true);
     await openFile(nestedFileUri, '');
@@ -149,7 +149,7 @@
         join(workspaceFolder1Path, 'nested', 'deeply', 'in', 'folders');
     final nestedFilePath = join(nestedFolderPath, 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     await initialize(workspaceFolders: [workspaceFolder1Uri]);
 
@@ -184,7 +184,7 @@
         join(workspaceFolder1Path, 'nested', 'deeply', 'in', 'folders');
     final nestedFilePath = join(nestedFolderPath, 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     await initialize(workspaceFolders: [workspaceFolder1Uri]);
 
@@ -220,7 +220,7 @@
         join(workspaceFolder1Path, 'nested', 'deeply', 'in', 'folders');
     final nestedFilePath = join(nestedFolderPath, 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     // Ensure no pubspecs in tree.
     deleteFile(
@@ -256,10 +256,10 @@
     // analysis driver will be used (see [AbstractAnalysisServer.getAnalysisDriver])
     // and no new root will be created.
     final workspace1FilePath = join(workspaceFolder1Path, 'test.dart');
-    newFile(workspace1FilePath);
+    newFile2(workspace1FilePath, '');
     final workspace2FilePath = join(workspaceFolder2Path, 'test.dart');
     final workspace2FileUri = Uri.file(workspace2FilePath);
-    newFile(workspace2FilePath);
+    newFile2(workspace2FilePath, '');
 
     await initialize(workspaceFolders: [workspaceFolder1Uri]);
 
@@ -309,7 +309,7 @@
 
     // Generate an error in the test project.
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
-    newFile(mainFilePath, content: 'String a = 1;');
+    newFile2(mainFilePath, 'String a = 1;');
     final initialDiagnostics = await firstDiagnosticsUpdate;
     expect(initialDiagnostics, hasLength(1));
 
diff --git a/pkg/analysis_server/test/lsp/code_actions_assists_test.dart b/pkg/analysis_server/test/lsp/code_actions_assists_test.dart
index 68652df..06d962f 100644
--- a/pkg/analysis_server/test/lsp/code_actions_assists_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_assists_test.dart
@@ -45,7 +45,7 @@
 
     Future f;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -86,7 +86,7 @@
 
     Future f;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -122,7 +122,7 @@
     // indicating this is not a valid (Dart) int.
     // https://github.com/dart-lang/sdk/issues/42786
 
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize();
 
     final request = makeRequest(
@@ -157,7 +157,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -191,7 +191,7 @@
           request is plugin.EditGetAssistsParams ? pluginResult : null,
     );
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -228,7 +228,7 @@
           request is plugin.EditGetAssistsParams ? pluginResult : null,
     );
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -285,7 +285,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -357,7 +357,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -421,7 +421,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -463,7 +463,7 @@
     build() => Contai^ner(child: Container());
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -504,7 +504,7 @@
 }
 ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
diff --git a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
index 9a541dc..3cd73f3 100644
--- a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
@@ -35,7 +35,7 @@
 
     Future foo;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -77,7 +77,7 @@
 
     Future foo;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -111,7 +111,7 @@
     final expectedCreatedFile =
         path.join(path.dirname(mainFilePath), 'newfile.dart');
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -142,7 +142,7 @@
 
     Future foo;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final ofKind = (CodeActionKind kind) => getCodeActions(
@@ -182,7 +182,7 @@
 import 'dart:convert';
 
 Future foo;''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -217,7 +217,7 @@
 import 'dart:convert';
 
 Future foo;''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -244,7 +244,7 @@
     var a = [Test, Test, Te[[]]st];
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -264,7 +264,7 @@
     var a = [Test, Test, Te[[]]st];
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -281,7 +281,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -294,7 +294,7 @@
 
   Future<void> test_organizeImportsFix_namedOrganizeImports() async {
     registerLintRules();
-    newFile(analysisOptionsPath, content: '''
+    newFile2(analysisOptionsPath, '''
 linter:
   rules:
     - directives_ordering
@@ -316,7 +316,7 @@
 Completer a;
 ProcessInfo b;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -343,7 +343,7 @@
   Future<void> test_outsideRoot() async {
     final otherFilePath = convertPath('/home/otherProject/foo.dart');
     final otherFileUri = Uri.file(otherFilePath);
-    newFile(otherFilePath, content: 'bad code to create error');
+    newFile2(otherFilePath, 'bad code to create error');
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -387,7 +387,7 @@
           request is plugin.EditGetFixesParams ? pluginResult : null,
     );
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -437,7 +437,7 @@
           request is plugin.EditGetFixesParams ? pluginResult : null,
     );
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -473,7 +473,7 @@
 var b = bar();
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -495,7 +495,7 @@
 }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -524,7 +524,7 @@
   print(a);
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
@@ -556,7 +556,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
           emptyTextDocumentClientCapabilities, [CodeActionKind.QuickFix]),
diff --git a/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart b/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart
index e8921f7..ac78b0d 100644
--- a/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart
@@ -44,7 +44,7 @@
   var b = test();
 }
 ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -76,7 +76,7 @@
   var b = test;
 }
 ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -144,7 +144,7 @@
   print('Test!');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -173,7 +173,7 @@
   print('Test!');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -241,7 +241,7 @@
   [[print('Test!');]]
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
       textDocumentCapabilities: withCodeActionKinds(
         emptyTextDocumentClientCapabilities,
@@ -301,7 +301,7 @@
 Object Container(Object text) => null;
 Object Text(Object text) => null;
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -319,7 +319,7 @@
 ^
 main() {}
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString());
@@ -345,7 +345,7 @@
   print('Test!');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
         windowCapabilities:
             withWorkDoneProgressSupport(emptyWindowClientCapabilities));
@@ -381,7 +381,7 @@
   print('Test!');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     var didGetProgressNotifications = false;
@@ -417,7 +417,7 @@
   print('Test!');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
         windowCapabilities:
             withWorkDoneProgressSupport(emptyWindowClientCapabilities));
@@ -455,7 +455,7 @@
 
 void foo(int arg) {}
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -485,7 +485,7 @@
 
 void foo(int arg) {}
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -565,7 +565,7 @@
   }
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -583,7 +583,7 @@
 ^
 main() {}
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString());
@@ -614,7 +614,7 @@
   print(1);
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -658,7 +658,7 @@
   print('test');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
@@ -693,7 +693,7 @@
   print('test');
 }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString(),
diff --git a/pkg/analysis_server/test/lsp/code_actions_source_test.dart b/pkg/analysis_server/test/lsp/code_actions_source_test.dart
index 75118f8..76fb7a9 100644
--- a/pkg/analysis_server/test/lsp/code_actions_source_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_source_test.dart
@@ -38,8 +38,8 @@
     ''';
 
     registerLintRules();
-    newFile(analysisOptionsPath, content: analysisOptionsContent);
-    newFile(mainFilePath, content: content);
+    newFile2(analysisOptionsPath, analysisOptionsContent);
+    newFile2(mainFilePath, content);
 
     await initialize(
         workspaceCapabilities:
@@ -70,7 +70,7 @@
 Completer foo;
 int minified(int x, int y) => min(x, y);
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities: withApplyEditSupport(
             withDocumentChangesSupport(emptyWorkspaceClientCapabilities)));
@@ -98,7 +98,7 @@
 Completer foo;
 int minified(int x, int y) => min(x, y);
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -110,7 +110,7 @@
   }
 
   Future<void> test_availableAsCodeActionLiteral() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.Source]),
@@ -126,7 +126,7 @@
   }
 
   Future<void> test_availableAsCommand() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -141,7 +141,7 @@
 
   Future<void> test_failsSilentlyIfFileHasErrors() async {
     final content = 'invalid dart code';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -161,7 +161,7 @@
   }
 
   Future<void> test_filtersCorrectly() async {
-    newFile(mainFilePath, content: '');
+    newFile2(mainFilePath, '');
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -187,7 +187,7 @@
 Completer foo;
 int minified(int x, int y) => min(x, y);
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -208,7 +208,7 @@
   }
 
   Future<void> test_unavailableWhenNotRequested() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -221,7 +221,7 @@
   }
 
   Future<void> test_unavailableWithoutApplyEditSupport() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString());
@@ -241,7 +241,7 @@
     String a;
     String b;
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities: withApplyEditSupport(
             withDocumentChangesSupport(emptyWorkspaceClientCapabilities)));
@@ -262,7 +262,7 @@
     String a;
     String b;
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -274,7 +274,7 @@
   }
 
   Future<void> test_availableAsCodeActionLiteral() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.Source]),
@@ -290,7 +290,7 @@
   }
 
   Future<void> test_availableAsCommand() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -308,7 +308,7 @@
     String b;
     String a;
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -341,7 +341,7 @@
 
   Future<void> test_failsIfFileHasErrors() async {
     final content = 'invalid dart code';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         workspaceCapabilities:
             withApplyEditSupport(emptyWorkspaceClientCapabilities));
@@ -361,7 +361,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.Source]),
@@ -374,7 +374,7 @@
   }
 
   Future<void> test_unavailableWhenNotRequested() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize(
         textDocumentCapabilities: withCodeActionKinds(
             emptyTextDocumentClientCapabilities, [CodeActionKind.Refactor]),
@@ -387,7 +387,7 @@
   }
 
   Future<void> test_unavailableWithoutApplyEditSupport() async {
-    newFile(mainFilePath);
+    newFile2(mainFilePath, '');
     await initialize();
 
     final codeActions = await getCodeActions(mainFileUri.toString());
diff --git a/pkg/analysis_server/test/lsp/completion_dart_test.dart b/pkg/analysis_server/test/lsp/completion_dart_test.dart
index 17744ff..4647afd 100644
--- a/pkg/analysis_server/test/lsp/completion_dart_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_dart_test.dart
@@ -459,7 +459,7 @@
       );
 
   Future<void> test_completionKinds_default() async {
-    newFile(join(projectFolderPath, 'file.dart'));
+    newFile2(join(projectFolderPath, 'file.dart'), '');
     newFolder(join(projectFolderPath, 'folder'));
 
     final content = "import '^';";
@@ -1161,7 +1161,7 @@
 
   Future<void> test_nonAnalyzedFile() async {
     final readmeFilePath = convertPath(join(projectFolderPath, 'README.md'));
-    newFile(readmeFilePath, content: '');
+    newFile2(readmeFilePath, '');
     await initialize();
 
     final res = await getCompletion(Uri.file(readmeFilePath), startOfDocPos);
@@ -1274,9 +1274,9 @@
   }
 
   Future<void> test_unimportedSymbols() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: '''
+      '''
       /// This class is in another file.
       class InOtherFile {}
       ''',
@@ -1350,21 +1350,21 @@
       test_unimportedSymbols_doesNotDuplicate_importedViaMultipleLibraries() async {
     // An item that's already imported through multiple libraries that
     // export it should not result in multiple entries.
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/source_file.dart'),
-      content: '''
+      '''
       class MyExportedClass {}
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/reexport1.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/reexport2.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
@@ -1395,21 +1395,21 @@
       test_unimportedSymbols_doesNotDuplicate_importedViaSingleLibrary() async {
     // An item that's already imported through a library that exports it
     // should not result in multiple entries.
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/source_file.dart'),
-      content: '''
+      '''
       class MyExportedClass {}
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/reexport1.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib/reexport2.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
@@ -1437,17 +1437,17 @@
 
   Future<void> test_unimportedSymbols_doesNotFilterSymbolsWithSameName() async {
     // Classes here are not re-exports, so should not be filtered out.
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file1.dart'),
-      content: 'class MyDuplicatedClass {}',
+      'class MyDuplicatedClass {}',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file2.dart'),
-      content: 'class MyDuplicatedClass {}',
+      'class MyDuplicatedClass {}',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file3.dart'),
-      content: 'class MyDuplicatedClass {}',
+      'class MyDuplicatedClass {}',
     );
 
     final content = '''
@@ -1478,9 +1478,9 @@
   }
 
   Future<void> test_unimportedSymbols_enumValues() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file.dart'),
-      content: '''
+      '''
       enum MyExportedEnum { One, Two }
       ''',
     );
@@ -1542,21 +1542,21 @@
   }
 
   Future<void> test_unimportedSymbols_enumValuesAlreadyImported() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'source_file.dart'),
-      content: '''
+      '''
       enum MyExportedEnum { One, Two }
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'reexport1.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'reexport2.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
@@ -1586,21 +1586,21 @@
   }
 
   Future<void> test_unimportedSymbols_filtersOutAlreadyImportedSymbols() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'source_file.dart'),
-      content: '''
+      '''
       class MyExportedClass {}
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'reexport1.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'reexport2.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
@@ -1629,9 +1629,9 @@
   }
 
   Future<void> test_unimportedSymbols_importsPackageUri() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'lib', 'my_class.dart'),
-      content: 'class MyClass {}',
+      'class MyClass {}',
     );
 
     final content = '''
@@ -1660,21 +1660,21 @@
 
   Future<void>
       test_unimportedSymbols_includesReexportedSymbolsForEachFile() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file.dart'),
-      content: '''
+      '''
       class MyExportedClass {}
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'reexport1.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
-    newFile(
+    newFile2(
       join(projectFolderPath, 'reexport2.dart'),
-      content: '''
+      '''
       export 'source_file.dart';
       ''',
     );
@@ -1706,9 +1706,9 @@
   }
 
   Future<void> test_unimportedSymbols_insertReplaceRanges() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: '''
+      '''
       /// This class is in another file.
       class InOtherFile {}
       ''',
@@ -1799,16 +1799,16 @@
 
   Future<void> test_unimportedSymbols_insertsIntoPartFiles() async {
     // File we'll be adding an import for.
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: 'class InOtherFile {}',
+      'class InOtherFile {}',
     );
 
     // File that will have the import added.
     final parentContent = '''part 'main.dart';''';
-    final parentFilePath = newFile(
+    final parentFilePath = newFile2(
       join(projectFolderPath, 'lib', 'parent.dart'),
-      content: parentContent,
+      parentContent,
     ).path;
 
     // File that we're invoking completion in.
@@ -1889,9 +1889,9 @@
   }
 
   Future<void> test_unimportedSymbols_members() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'source_file.dart'),
-      content: '''
+      '''
       class MyExportedClass {
         DateTime myInstanceDateTime;
         static DateTime myStaticDateTimeField;
@@ -1979,7 +1979,7 @@
     await initialAnalysis;
 
     // Start with a blank file.
-    newFile(otherFilePath, content: '');
+    newFile2(otherFilePath, '');
     await openFile(otherFileUri, '');
     await pumpEventQueue(times: 5000);
 
@@ -1997,9 +1997,9 @@
   }
 
   Future<void> test_unimportedSymbols_namedConstructors() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: '''
+      '''
       /// This class is in another file.
       class InOtherFile {
         InOtherFile.fromJson() {}
@@ -2065,7 +2065,7 @@
         join(projectFolderPath, 'lib', 'nested2', 'imported.dart');
 
     // Create a file that will be auto-imported from completion.
-    newFile(importedFilePath, content: 'class MyClass {}');
+    newFile2(importedFilePath, 'class MyClass {}');
 
     final content = '''
 void f() {
@@ -2103,7 +2103,7 @@
         join(projectFolderPath, 'lib', 'nested2', 'imported.dart');
 
     // Create a file that will be auto-imported from completion.
-    newFile(importedFilePath, content: 'class MyClass {}');
+    newFile2(importedFilePath, 'class MyClass {}');
 
     final content = '''
 void f() {
@@ -2130,9 +2130,9 @@
   }
 
   Future<void> test_unimportedSymbols_unavailableIfDisabled() async {
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: 'class InOtherFile {}',
+      'class InOtherFile {}',
     );
 
     final content = '''
@@ -2163,9 +2163,9 @@
   Future<void> test_unimportedSymbols_unavailableWithoutApplyEdit() async {
     // If client doesn't advertise support for workspace/applyEdit, we won't
     // include suggestion sets.
-    newFile(
+    newFile2(
       join(projectFolderPath, 'other_file.dart'),
-      content: 'class InOtherFile {}',
+      'class InOtherFile {}',
     );
 
     final content = '''
@@ -2198,7 +2198,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
     final res = await getCompletion(mainFileUri, positionFromMarker(content));
     expect(res.any((c) => c.label == 'abcdefghij'), isTrue);
@@ -2264,7 +2264,7 @@
   void _enableLints(List<String> lintNames) {
     registerLintRules();
     final lintsYaml = lintNames.map((name) => '    - $name\n').join();
-    newFile(analysisOptionsPath, content: '''
+    newFile2(analysisOptionsPath, '''
 linter:
   rules:
 $lintsYaml
@@ -2309,10 +2309,9 @@
 
   Future<void> test_completeFunctionCalls_requiredNamed_suggestionSet() async {
     final otherFile = join(projectFolderPath, 'lib', 'other.dart');
-    newFile(
+    newFile2(
       otherFile,
-      content:
-          "void myFunction(String a, int b, {required String c, String d = ''}) {}",
+      "void myFunction(String a, int b, {required String c, String d = ''}) {}",
     );
     final content = '''
     void f() {
@@ -2371,6 +2370,25 @@
 
 @reflectiveTest
 class DartSnippetCompletionTest extends SnippetCompletionTest {
+  Future<void> test_snippets_class() async {
+    final content = '''
+clas^
+''';
+
+    await initializeWithSnippetSupportAndPreviewFlag();
+    final updated = await expectAndApplySnippet(
+      content,
+      prefix: DartClassSnippetProducer.prefix,
+      label: DartClassSnippetProducer.label,
+    );
+
+    expect(updated, r'''
+class $1 {
+  $0
+}
+''');
+  }
+
   Future<void> test_snippets_disabled() async {
     final content = '^';
 
@@ -2590,6 +2608,56 @@
 ''');
   }
 
+  Future<void> test_snippets_testBlock() async {
+    mainFilePath = join(projectFolderPath, 'test', 'foo_test.dart');
+    mainFileUri = Uri.file(mainFilePath);
+    final content = '''
+void f() {
+  test^
+}
+''';
+
+    await initializeWithSnippetSupportAndPreviewFlag();
+    final updated = await expectAndApplySnippet(
+      content,
+      prefix: DartTestBlockSnippetProducer.prefix,
+      label: DartTestBlockSnippetProducer.label,
+    );
+
+    expect(updated, r'''
+void f() {
+  test('$1', () {
+    $0
+  });
+}
+''');
+  }
+
+  Future<void> test_snippets_testGroupBlock() async {
+    mainFilePath = join(projectFolderPath, 'test', 'foo_test.dart');
+    mainFileUri = Uri.file(mainFilePath);
+    final content = '''
+void f() {
+  group^
+}
+''';
+
+    await initializeWithSnippetSupportAndPreviewFlag();
+    final updated = await expectAndApplySnippet(
+      content,
+      prefix: DartTestGroupBlockSnippetProducer.prefix,
+      label: DartTestGroupBlockSnippetProducer.label,
+    );
+
+    expect(updated, r'''
+void f() {
+  group('$1', () {
+    $0
+  });
+}
+''');
+  }
+
   Future<void> test_snippets_tryCatch() async {
     final content = '''
 void f() {
diff --git a/pkg/analysis_server/test/lsp/completion_yaml_test.dart b/pkg/analysis_server/test/lsp/completion_yaml_test.dart
index 444b101..c1b0e04 100644
--- a/pkg/analysis_server/test/lsp/completion_yaml_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_yaml_test.dart
@@ -502,7 +502,7 @@
 dependencies:
   one: ^2.3.4''';
 
-    newFile(pubspecFilePath, content: content);
+    newFile2(pubspecFilePath, content);
     await initialize();
     await openFile(pubspecFileUri, withoutMarkers(content));
     await pumpEventQueue(times: 500);
@@ -556,7 +556,7 @@
 dependencies:
   one: ^''';
 
-    newFile(pubspecFilePath, content: content);
+    newFile2(pubspecFilePath, content);
     await initialize();
     await openFile(pubspecFileUri, withoutMarkers(content));
     await pumpEventQueue(times: 500);
diff --git a/pkg/analysis_server/test/lsp/definition_test.dart b/pkg/analysis_server/test/lsp/definition_test.dart
index f15c592..1a5e7ee 100644
--- a/pkg/analysis_server/test/lsp/definition_test.dart
+++ b/pkg/analysis_server/test/lsp/definition_test.dart
@@ -87,7 +87,7 @@
     );
     configureTestPlugin(respondWith: pluginResult);
 
-    newFile(pluginAnalyzedFilePath);
+    newFile2(pluginAnalyzedFilePath, '');
     await initialize();
     final res = await getDefinitionAsLocation(
         pluginAnalyzedFileUri, lsp.Position(line: 0, character: 0));
@@ -189,7 +189,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final res = await getDefinitionAsLocation(pubspecFileUri, startOfDocPos);
@@ -287,7 +287,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(contents));
+    newFile2(mainFilePath, withoutMarkers(contents));
     await initialize();
     final res = await getDefinitionAsLocation(
         mainFileUri, positionFromMarker(contents));
diff --git a/pkg/analysis_server/test/lsp/diagnostic_test.dart b/pkg/analysis_server/test/lsp/diagnostic_test.dart
index 2d009c7..3a7f8e0 100644
--- a/pkg/analysis_server/test/lsp/diagnostic_test.dart
+++ b/pkg/analysis_server/test/lsp/diagnostic_test.dart
@@ -21,7 +21,7 @@
   Future<void> checkPluginErrorsForFile(String pluginAnalyzedFilePath) async {
     final pluginAnalyzedUri = Uri.file(pluginAnalyzedFilePath);
 
-    newFile(pluginAnalyzedFilePath, content: '''String a = "Test";
+    newFile2(pluginAnalyzedFilePath, '''String a = "Test";
 String b = "Test";
 ''');
     await initialize();
@@ -68,7 +68,7 @@
 
   Future<void> test_afterDocumentEdits() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile2(mainFilePath, initialContents);
 
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await initialize();
@@ -84,7 +84,7 @@
   }
 
   Future<void> test_analysisOptionsFile() async {
-    newFile(analysisOptionsPath, content: '''
+    newFile2(analysisOptionsPath, '''
 linter:
   rules:
     - invalid_lint_rule_name
@@ -100,7 +100,7 @@
 
   @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/43926')
   Future<void> test_analysisOptionsFile_packageInclude() async {
-    newFile(analysisOptionsPath, content: '''
+    newFile2(analysisOptionsPath, '''
 include: package:pedantic/analysis_options.yaml
 ''');
 
@@ -125,7 +125,7 @@
   }
 
   Future<void> test_contextMessage() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
 void f() {
   x = 0;
   int x;
@@ -142,7 +142,7 @@
   }
 
   Future<void> test_correction() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
 void f() {
   x = 0;
 }
@@ -157,7 +157,7 @@
   }
 
   Future<void> test_deletedFile() async {
-    newFile(mainFilePath, content: 'String a = 1;');
+    newFile2(mainFilePath, 'String a = 1;');
 
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await initialize();
@@ -172,7 +172,7 @@
   }
 
   Future<void> test_diagnosticTag_deprecated() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
     @deprecated
     int dep;
 
@@ -191,7 +191,7 @@
   }
 
   Future<void> test_diagnosticTag_notSupported() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
     @deprecated
     int dep;
 
@@ -208,7 +208,7 @@
   }
 
   Future<void> test_diagnosticTag_unnecessary() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
     void main() {
       return;
       print('unreachable');
@@ -227,7 +227,7 @@
   }
 
   Future<void> test_documentationUrl() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
     // ignore: unused_import
     import 'dart:async' as import; // produces BUILT_IN_IDENTIFIER_IN_DECLARATION
     ''');
@@ -247,7 +247,7 @@
   }
 
   Future<void> test_documentationUrl_notSupported() async {
-    newFile(mainFilePath, content: '''
+    newFile2(mainFilePath, '''
     // ignore: unused_import
     import 'dart:async' as import; // produces BUILT_IN_IDENTIFIER_IN_DECLARATION
     ''');
@@ -266,7 +266,7 @@
         join(projectFolderPath, '.dart_tool', 'tool_file.dart');
     var dotFolderFileUri = Uri.file(dotFolderFilePath);
 
-    newFile(dotFolderFilePath, content: 'String a = 1;');
+    newFile2(dotFolderFilePath, 'String a = 1;');
 
     List<Diagnostic>? diagnostics;
     waitForDiagnostics(dotFolderFileUri).then((d) => diagnostics = d);
@@ -283,7 +283,7 @@
   Future<void> test_fixDataFile() async {
     var fixDataPath = join(projectFolderPath, 'lib', 'fix_data.yaml');
     var fixDataUri = Uri.file(fixDataPath);
-    newFile(fixDataPath, content: '''
+    newFile2(fixDataPath, '''
 version: latest
 ''').path;
 
@@ -309,7 +309,7 @@
         "A value of type 'int' can't be assigned to a variable of type 'String'";
     final pluginErrorMessage = 'Test error from plugin';
 
-    newFile(mainFilePath, content: 'String a = 1;');
+    newFile2(mainFilePath, 'String a = 1;');
     final initialDiagnosticsFuture = waitForDiagnostics(mainFileUri);
     await initialize();
     final initialDiagnostics = await initialDiagnosticsFuture;
@@ -342,7 +342,7 @@
   }
 
   Future<void> test_initialAnalysis() async {
-    newFile(mainFilePath, content: 'String a = 1;');
+    newFile2(mainFilePath, 'String a = 1;');
 
     final diagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await initialize();
@@ -385,7 +385,7 @@
     // FIXME: This
     String a = "";
     ''';
-    newFile(mainFilePath, content: contents);
+    newFile2(mainFilePath, contents);
 
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await provideConfig(
@@ -403,7 +403,7 @@
     // TODO: This
     String a = "";
     ''';
-    newFile(mainFilePath, content: contents);
+    newFile2(mainFilePath, contents);
 
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
     // TODOs are disabled by default so we don't need to send any config.
@@ -449,7 +449,7 @@
     // FIXME: This
     String a = "";
     ''';
-    newFile(mainFilePath, content: contents);
+    newFile2(mainFilePath, contents);
 
     final firstDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
     await provideConfig(
diff --git a/pkg/analysis_server/test/lsp/document_color_test.dart b/pkg/analysis_server/test/lsp/document_color_test.dart
index 755752a..ff131a3 100644
--- a/pkg/analysis_server/test/lsp/document_color_test.dart
+++ b/pkg/analysis_server/test/lsp/document_color_test.dart
@@ -40,7 +40,7 @@
     importRange = ranges[0];
     colorRange = ranges[1];
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final colorPresentations = await getColorPresentation(
@@ -60,7 +60,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final colors = await getColorPresentation(
@@ -80,7 +80,7 @@
     colorRange = rangeFromMarkers(content);
 
     final outsideRootFilePath = convertPath('/home/other/test.dart');
-    newFile(outsideRootFilePath, content: withoutMarkers(content));
+    newFile2(outsideRootFilePath, withoutMarkers(content));
     await initialize();
 
     final colorPresentations = await getColorPresentation(
@@ -102,7 +102,7 @@
     ''';
     colorRange = rangeFromMarkers(content);
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final colorPresentations = await getColorPresentation(
@@ -155,7 +155,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final colors = await getDocumentColors(pubspecFileUri.toString());
@@ -168,7 +168,7 @@
 
     const red = [[Colors.red]];
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final colors = await getDocumentColors(mainFileUri.toString());
diff --git a/pkg/analysis_server/test/lsp/document_symbols_test.dart b/pkg/analysis_server/test/lsp/document_symbols_test.dart
index 48ddc1b..c49bf01 100644
--- a/pkg/analysis_server/test/lsp/document_symbols_test.dart
+++ b/pkg/analysis_server/test/lsp/document_symbols_test.dart
@@ -24,7 +24,7 @@
       light,
     }
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize();
 
     final result = await getDocumentSymbols(mainFileUri.toString());
@@ -53,7 +53,7 @@
       light,
     }
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
       textDocumentCapabilities: withDocumentSymbolKinds(
         emptyTextDocumentClientCapabilities,
@@ -90,7 +90,7 @@
     extension StringExtensions on String {}
     extension on String {}
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize();
 
     final result = await getDocumentSymbols(mainFileUri.toString());
@@ -143,7 +143,7 @@
       myMethod() {}
     }
     ''';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(
         textDocumentCapabilities: withHierarchicalDocumentSymbolSupport(
             emptyTextDocumentClientCapabilities));
@@ -182,7 +182,7 @@
     // When there are no analysis roots and we open a file, it should be added as
     // a temporary root allowing us to service requests for it.
     const content = 'class MyClass {}';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(allowEmptyRootUri: true);
     await openFile(mainFileUri, content);
 
@@ -203,7 +203,7 @@
     // When there are no analysis roots and we receive requests for a file that
     // was not opened, we will reject the file due to not being analyzed.
     const content = 'class MyClass {}';
-    newFile(mainFilePath, content: content);
+    newFile2(mainFilePath, content);
     await initialize(allowEmptyRootUri: true);
 
     await expectLater(
@@ -213,7 +213,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final result = await getDocumentSymbols(pubspecFileUri.toString());
diff --git a/pkg/analysis_server/test/lsp/folding_test.dart b/pkg/analysis_server/test/lsp/folding_test.dart
index 9d35988..2aa3b7c 100644
--- a/pkg/analysis_server/test/lsp/folding_test.dart
+++ b/pkg/analysis_server/test/lsp/folding_test.dart
@@ -143,7 +143,7 @@
     ''';
     final ranges = rangesFromMarkers(content);
     final withoutMarkers = withoutRangeMarkers(content);
-    newFile(pluginAnalyzedFilePath);
+    newFile2(pluginAnalyzedFilePath, '');
 
     await initialize();
     await openFile(pluginAnalyzedUri, withoutMarkers);
@@ -173,7 +173,7 @@
       );
     ''';
     final withoutMarkers = withoutRangeMarkers(content);
-    newFile(pluginAnalyzedFilePath, content: withoutMarkers);
+    newFile2(pluginAnalyzedFilePath, withoutMarkers);
 
     await initialize();
     await openFile(pluginAnalyzedUri, withoutMarkers);
diff --git a/pkg/analysis_server/test/lsp/format_test.dart b/pkg/analysis_server/test/lsp/format_test.dart
index f3d24e8..ad72337 100644
--- a/pkg/analysis_server/test/lsp/format_test.dart
+++ b/pkg/analysis_server/test/lsp/format_test.dart
@@ -695,7 +695,7 @@
   print('test');
 }
 ''';
-    newFile(mainFilePath, content: contents);
+    newFile2(mainFilePath, contents);
     await initialize();
     await expectFormattedContents(mainFileUri, contents, expected);
   }
diff --git a/pkg/analysis_server/test/lsp/hover_test.dart b/pkg/analysis_server/test/lsp/hover_test.dart
index bb8423b..9ac1ce2 100644
--- a/pkg/analysis_server/test/lsp/hover_test.dart
+++ b/pkg/analysis_server/test/lsp/hover_test.dart
@@ -316,7 +316,7 @@
     String [[a^bc]];
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
     final hover = await getHover(mainFileUri, positionFromMarker(content));
     expect(hover, isNotNull);
diff --git a/pkg/analysis_server/test/lsp/implementation_test.dart b/pkg/analysis_server/test/lsp/implementation_test.dart
index 195b46b..dabf3ec 100644
--- a/pkg/analysis_server/test/lsp/implementation_test.dart
+++ b/pkg/analysis_server/test/lsp/implementation_test.dart
@@ -151,7 +151,7 @@
     ''');
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final res = await getImplementations(pubspecFileUri, startOfDocPos);
diff --git a/pkg/analysis_server/test/lsp/initialization_test.dart b/pkg/analysis_server/test/lsp/initialization_test.dart
index 6b43de8..2f693e4 100644
--- a/pkg/analysis_server/test/lsp/initialization_test.dart
+++ b/pkg/analysis_server/test/lsp/initialization_test.dart
@@ -33,15 +33,15 @@
   Future<void> test_bazelWorkspace() async {
     var workspacePath = '/home/user/ws';
     // Make it a Bazel workspace.
-    newFile(convertPath('$workspacePath/WORKSPACE'));
+    newFile2(convertPath('$workspacePath/WORKSPACE'), '');
 
     var packagePath = '$workspacePath/team/project1';
 
     // Make it a Blaze project.
-    newFile(convertPath('$packagePath/BUILD'));
+    newFile2(convertPath('$packagePath/BUILD'), '');
 
     final file1 = convertPath('$packagePath/lib/file1.dart');
-    newFile(file1);
+    newFile2(file1, '');
 
     await initialize(allowEmptyRootUri: true);
 
@@ -498,10 +498,10 @@
   Future<void> test_emptyAnalysisRoots_multipleOpenFiles() async {
     final file1 = join(projectFolderPath, 'file1.dart');
     final file1Uri = Uri.file(file1);
-    newFile(file1);
+    newFile2(file1, '');
     final file2 = join(projectFolderPath, 'file2.dart');
     final file2Uri = Uri.file(file2);
-    newFile(file2);
+    newFile2(file2, '');
     newPubspecYamlFile(projectFolderPath, '');
 
     await initialize(allowEmptyRootUri: true);
@@ -532,7 +532,7 @@
     final nestedFilePath = join(
         projectFolderPath, 'nested', 'deeply', 'in', 'folders', 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     // The project folder shouldn't be added to start with.
     await initialize(allowEmptyRootUri: true);
@@ -547,7 +547,7 @@
     final nestedFilePath = join(
         projectFolderPath, 'nested', 'deeply', 'in', 'folders', 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
     newPubspecYamlFile(projectFolderPath, '');
 
     // The project folder shouldn't be added to start with.
@@ -736,7 +736,7 @@
 
   Future<void> test_nonProjectFiles_basicWorkspace() async {
     final file1 = convertPath('/home/nonProject/file1.dart');
-    newFile(file1);
+    newFile2(file1, '');
 
     await initialize(allowEmptyRootUri: true);
 
@@ -747,10 +747,10 @@
 
   Future<void> test_nonProjectFiles_bazelWorkspace() async {
     final file1 = convertPath('/home/nonProject/file1.dart');
-    newFile(file1);
+    newFile2(file1, '');
 
     // Make /home a bazel workspace.
-    newFile(convertPath('/home/WORKSPACE'));
+    newFile2(convertPath('/home/WORKSPACE'), '');
 
     await initialize(allowEmptyRootUri: true);
 
@@ -781,10 +781,10 @@
   Future<void> test_onlyAnalyzeProjectsWithOpenFiles_multipleFiles() async {
     final file1 = join(projectFolderPath, 'file1.dart');
     final file1Uri = Uri.file(file1);
-    newFile(file1);
+    newFile2(file1, '');
     final file2 = join(projectFolderPath, 'file2.dart');
     final file2Uri = Uri.file(file2);
-    newFile(file2);
+    newFile2(file2, '');
     newPubspecYamlFile(projectFolderPath, '');
 
     await initialize(
@@ -819,7 +819,7 @@
     final nestedFilePath = join(
         projectFolderPath, 'nested', 'deeply', 'in', 'folders', 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
 
     // The project folder shouldn't be added to start with.
     await initialize(
@@ -837,7 +837,7 @@
     final nestedFilePath = join(
         projectFolderPath, 'nested', 'deeply', 'in', 'folders', 'test.dart');
     final nestedFileUri = Uri.file(nestedFilePath);
-    newFile(nestedFilePath);
+    newFile2(nestedFilePath, '');
     newPubspecYamlFile(projectFolderPath, '');
 
     // The project folder shouldn't be added to start with.
diff --git a/pkg/analysis_server/test/lsp/reanalyze_test.dart b/pkg/analysis_server/test/lsp/reanalyze_test.dart
index 69afce8..0c3e3d5 100644
--- a/pkg/analysis_server/test/lsp/reanalyze_test.dart
+++ b/pkg/analysis_server/test/lsp/reanalyze_test.dart
@@ -17,7 +17,7 @@
 class ReanalyzeTest extends AbstractLspAnalysisServerTest {
   Future<void> test_reanalyze() async {
     const initialContents = 'int a = 1;';
-    newFile(mainFilePath, content: initialContents);
+    newFile2(mainFilePath, initialContents);
 
     final initialAnalysis = waitForAnalysisComplete();
 
diff --git a/pkg/analysis_server/test/lsp/references_test.dart b/pkg/analysis_server/test/lsp/references_test.dart
index 350de59..df007e5 100644
--- a/pkg/analysis_server/test/lsp/references_test.dart
+++ b/pkg/analysis_server/test/lsp/references_test.dart
@@ -102,7 +102,7 @@
   }
 
   Future<void> test_nonDartFile() async {
-    newFile(pubspecFilePath, content: simplePubspecContent);
+    newFile2(pubspecFilePath, simplePubspecContent);
     await initialize();
 
     final res = await getReferences(pubspecFileUri, startOfDocPos);
@@ -137,7 +137,7 @@
     }
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(contents));
+    newFile2(mainFilePath, withoutMarkers(contents));
     await initialize();
     final res = await getReferences(mainFileUri, positionFromMarker(contents));
 
diff --git a/pkg/analysis_server/test/lsp/rename_test.dart b/pkg/analysis_server/test/lsp/rename_test.dart
index f62944d..ddb3df6 100644
--- a/pkg/analysis_server/test/lsp/rename_test.dart
+++ b/pkg/analysis_server/test/lsp/rename_test.dart
@@ -244,7 +244,7 @@
     ''';
     final otherFilePath = join(projectFolderPath, 'lib', 'other.dart');
     final newMainFilePath = join(projectFolderPath, 'lib', 'my_new_main.dart');
-    newFile(mainFilePath, content: withoutMarkers(mainContent));
+    newFile2(mainFilePath, withoutMarkers(mainContent));
     await pumpEventQueue(times: 5000);
     await provideConfig(
       () async {
@@ -539,7 +539,7 @@
     final a = new [[Ob^ject]]();
     ''';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final request = makeRequest(
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index 4d5a6c4..fbfbeb1 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -210,7 +210,7 @@
     newFolder(join(projectFolderPath, 'lib'));
     // Create a folder and file to aid testing that includes imports/completion.
     newFolder(join(projectFolderPath, 'lib', 'folder'));
-    newFile(join(projectFolderPath, 'lib', 'file.dart'));
+    newFile2(join(projectFolderPath, 'lib', 'file.dart'), '');
     mainFilePath = join(projectFolderPath, 'lib', 'main.dart');
     mainFileUri = Uri.file(mainFilePath);
     pubspecFilePath = join(projectFolderPath, file_paths.pubspecYaml);
@@ -610,7 +610,7 @@
 
     var path = '$projectFolderPath/.dart_tool/package_config.json';
     var content = config.toContent(toUriStr: toUriStr);
-    newFile(path, content: content);
+    newFile2(path, content);
   }
 }
 
diff --git a/pkg/analysis_server/test/lsp/signature_help_test.dart b/pkg/analysis_server/test/lsp/signature_help_test.dart
index a9de8f5..17ffa43 100644
--- a/pkg/analysis_server/test/lsp/signature_help_test.dart
+++ b/pkg/analysis_server/test/lsp/signature_help_test.dart
@@ -582,7 +582,7 @@
     final expectedLabel = 'foo(String s, int i)';
     final expectedDoc = 'Does foo.';
 
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize(
         textDocumentCapabilities: withSignatureHelpContentFormat(
             emptyTextDocumentClientCapabilities, [MarkupKind.Markdown]));
diff --git a/pkg/analysis_server/test/lsp/workspace_symbols_test.dart b/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
index f81b17a..3af1f88 100644
--- a/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
+++ b/pkg/analysis_server/test/lsp/workspace_symbols_test.dart
@@ -22,7 +22,7 @@
     extension StringExtensions on String {}
     extension on String {}
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final symbols = await getWorkspaceSymbols('S');
@@ -44,7 +44,7 @@
       myMethod() {}
     }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final symbols = await getWorkspaceSymbols('topLevel');
@@ -69,7 +69,7 @@
       myMethod() {}
     }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     // meld should match myField
@@ -118,7 +118,7 @@
       [[myMethodWithArgs(int a) {}]]
     }
     ''';
-    newFile(mainFilePath, content: withoutMarkers(content));
+    newFile2(mainFilePath, withoutMarkers(content));
     await initialize();
 
     final symbols = await getWorkspaceSymbols('my');
diff --git a/pkg/analysis_server/test/search/declarations_test.dart b/pkg/analysis_server/test/search/declarations_test.dart
index 3c0a02f..c5f71ad 100644
--- a/pkg/analysis_server/test/search/declarations_test.dart
+++ b/pkg/analysis_server/test/search/declarations_test.dart
@@ -83,11 +83,11 @@
   }
 
   Future<void> test_maxResults() async {
-    newFile(join(testFolder, 'a.dart'), content: r'''
+    newFile2(join(testFolder, 'a.dart'), r'''
 class A {}
 class B {}
 ''').path;
-    newFile(join(testFolder, 'b.dart'), content: r'''
+    newFile2(join(testFolder, 'b.dart'), r'''
 class C {}
 class D {}
 ''').path;
@@ -124,8 +124,8 @@
   }
 
   Future<void> test_multipleFiles() async {
-    var a = newFile(join(testFolder, 'a.dart'), content: 'class A {}').path;
-    var b = newFile(join(testFolder, 'b.dart'), content: 'class B {}').path;
+    var a = newFile2(join(testFolder, 'a.dart'), 'class A {}').path;
+    var b = newFile2(join(testFolder, 'b.dart'), 'class B {}').path;
 
     await _getDeclarations();
 
@@ -153,8 +153,8 @@
   }
 
   Future<void> test_onlyForFile() async {
-    var a = newFile(join(testFolder, 'a.dart'), content: 'class A {}').path;
-    newFile(join(testFolder, 'b.dart'), content: 'class B {}').path;
+    var a = newFile2(join(testFolder, 'a.dart'), 'class A {}').path;
+    newFile2(join(testFolder, 'b.dart'), 'class B {}').path;
 
     await _getDeclarations(file: a);
 
diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart
index 2b1903c..589e9a5 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -164,21 +164,21 @@
 
   Future<void> test_class_extends_fileAndPackageUris() async {
     // prepare packages
-    newFile('/packages/pkgA/lib/libA.dart', content: '''
+    newFile2('/packages/pkgA/lib/libA.dart', '''
 library lib_a;
 class A {}
 class B extends A {}
 ''');
     newPackageConfigJsonFile(
       '/packages/pkgA',
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
           .toContent(toUriStr: toUriStr),
     );
     // reference the package from a project
     newPackageConfigJsonFile(
       projectPath,
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
           .toContent(toUriStr: toUriStr),
     );
@@ -652,7 +652,7 @@
   }
 
   Future<void> test_class_member_method_private_differentLib() async {
-    newFile(join(testFolder, 'lib.dart'), content: r'''
+    newFile2(join(testFolder, 'lib.dart'), r'''
 import 'test.dart';
 class A {
   void _m() {}
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index 142d6f6..66791e5 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -732,7 +732,7 @@
     await computeAndCheck();
 
     // Annotation, imported class.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   const A$parameters;
 }
@@ -746,7 +746,7 @@
     await computeAndCheck();
 
     // Annotation, imported class, prefixed.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   const A$parameters;
 }
@@ -789,7 +789,7 @@
     await computeAndCheck();
 
     // Instance creation, imported class, generative.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   A$parameters;
 }
@@ -802,7 +802,7 @@
     await computeAndCheck();
 
     // Instance creation, imported class, factory.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   factory A$parameters => throw 0;
 }
@@ -833,7 +833,7 @@
     await computeAndCheck();
 
     // Method invocation, imported function.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void f$parameters() {}
 ''');
     addTestSource2('''
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart b/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
index e1c149a..555a28f 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_manager_test.dart
@@ -32,7 +32,7 @@
   }
 
   Future<void> test_resolveDirectives() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 library libA;
 /// My class.
 /// Short description.
@@ -40,7 +40,7 @@
 /// Longer description.
 class A {}
 ''');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 library libB;
 import "a.dart" as foo;
 part 'test.dart';
diff --git a/pkg/analysis_server/test/services/completion/dart/declaration/enum_test.dart b/pkg/analysis_server/test/services/completion/dart/declaration/enum_test.dart
index 66a1a19..e06f764 100644
--- a/pkg/analysis_server/test/services/completion/dart/declaration/enum_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/declaration/enum_test.dart
@@ -59,7 +59,7 @@
   }
 
   Future<void> test_enumConstantName_imported_withPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum MyEnum { foo01 }
 ''');
 
@@ -119,7 +119,7 @@
   }
 
   Future<void> test_enumName_imported_withPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum MyEnum { foo01 }
 ''');
 
@@ -155,7 +155,7 @@
 
   @FailingTest(reason: 'element.kind is LIBRARY')
   Future<void> test_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum MyEnum { v }
 ''');
 
@@ -189,7 +189,7 @@
   }
 
   Future<void> test_importPrefix_dot() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum MyEnum { v }
 ''');
 
@@ -246,7 +246,7 @@
   }
 
   Future<void> test_nothing_imported_withPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum MyEnum { v }
 ''');
 
@@ -304,7 +304,7 @@
 
     // imported
     {
-      newFile('$testPackageLibPath/a.dart', content: '''
+      newFile2('$testPackageLibPath/a.dart', '''
 $declaration
 ''');
       if (isProtocolVersion1) {
@@ -321,7 +321,7 @@
 
     // not imported
     {
-      newFile('$testPackageLibPath/a.dart', content: '''
+      newFile2('$testPackageLibPath/a.dart', '''
 $declaration
 ''');
       if (isProtocolVersion1) {
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index 534635b..4305c13 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -1237,7 +1237,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
 
     addTestSource('void f() { ^ }');
 
@@ -1971,7 +1971,7 @@
   }
 
   Future<void> test_ExtendsClause() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('''
 import 'a.dart';
 
@@ -1982,7 +1982,7 @@
   }
 
   Future<void> test_ExtensionDeclaration_extendedType() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('''
 import 'a.dart';
 
@@ -1994,7 +1994,7 @@
   }
 
   Future<void> test_ExtensionDeclaration_extendedType2() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('''
 import 'a.dart';
 
@@ -2006,7 +2006,7 @@
   }
 
   Future<void> test_ExtensionDeclaration_member() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('''
 import 'a.dart';
 
@@ -2697,7 +2697,7 @@
   }
 
   Future<void> test_implementsClause() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('''
 import 'a.dart';
 
@@ -4898,7 +4898,7 @@
   }
 
   Future<void> test_withClause_mixin() async {
-    newFile('$testPackageLibPath/a.dart', content: 'mixin M {}');
+    newFile2('$testPackageLibPath/a.dart', 'mixin M {}');
     addTestSource('''
 import 'a.dart';
 
diff --git a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
index d9dc05e..5f1ccc7 100644
--- a/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/library_member_contributor_test.dart
@@ -104,7 +104,7 @@
 
   Future<void> test_libraryPrefix_deferred_inPart() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         library testA;
         import "dart:async" deferred as bar;
         part "test.dart";''');
@@ -118,8 +118,8 @@
   }
 
   Future<void> test_libraryPrefix_with_exports() async {
-    newFile('$testPackageLibPath/a.dart', content: 'library libA; class A { }');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', 'library libA; class A { }');
+    newFile2('$testPackageLibPath/b.dart', '''
         library libB;
         export "a.dart";
         class B { }
@@ -194,12 +194,12 @@
 
   Future<void> test_PrefixedIdentifier_library_inPart() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         var T1;
         class X { }
         class Y { }''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         library testA;
         import "b.dart" as b;
         part "test.dart";
@@ -225,7 +225,7 @@
 
   Future<void> test_PrefixedIdentifier_library_typesOnly() async {
     // SimpleIdentifier  PrefixedIdentifier  NamedType
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         var T1;
         class X { }
@@ -258,7 +258,7 @@
 
   Future<void> test_PrefixedIdentifier_library_typesOnly2() async {
     // SimpleIdentifier  PrefixedIdentifier  NamedType
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         var T1;
         class X { }
@@ -283,7 +283,7 @@
 
   Future<void> test_PrefixedIdentifier_parameter() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         class _W {M y; var _z;}
         class X extends _W {}
@@ -297,7 +297,7 @@
 
   Future<void> test_PrefixedIdentifier_prefix() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         class A {static int bar = 10;}
         _B() {}''');
     addTestSource('''
diff --git a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
index 52c6b90..5c1dd55 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_library_contributor_test.dart
@@ -29,12 +29,12 @@
 
   Future<void> test_partFile_Constructor() async {
     // SimpleIdentifier  NamedType  ConstructorName
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         library libA;
         import "b.dart";
         part "test.dart";
@@ -64,12 +64,12 @@
 
   Future<void> test_partFile_Constructor2() async {
     // SimpleIdentifier  NamedType  ConstructorName
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         part of libA;
         class B { }''');
     addTestSource('''
@@ -97,7 +97,7 @@
   }
 
   Future<void> test_partFile_extension() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 part of libA;
 extension E on int {}
 ''');
@@ -115,12 +115,12 @@
   Future<void>
       test_partFile_InstanceCreationExpression_assignment_filter() async {
     // ConstructorName  InstanceCreationExpression  VariableDeclarationList
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         part of libA;
         class A {} class B extends A {} class C implements A {} class D {}
         ''');
@@ -162,12 +162,12 @@
   Future<void>
       test_partFile_InstanceCreationExpression_variable_declaration_filter() async {
     // ConstructorName  InstanceCreationExpression  VariableDeclarationList
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         part of libA;
         class A {} class B extends A {} class C implements A {} class D {}
         ''');
@@ -205,12 +205,12 @@
   }
 
   Future<void> test_partFile_TypeName() async {
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         library libA;
         import "b.dart";
         part "test.dart";
@@ -254,12 +254,12 @@
   }
 
   Future<void> test_partFile_TypeName2() async {
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
         part of libA;
         class B { var b1; b2(){}}
         int bf() => 0;
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index 235ed40..45e5c5d 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -1512,7 +1512,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('void f() { ^ }');
 
     await computeSuggestions();
diff --git a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
index df03716..01f664e 100644
--- a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
@@ -462,7 +462,7 @@
   }
 
   Future<void> test_private_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void foo() {}
   void _bar() {}
diff --git a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
index a5d53f4..ea54cb1 100644
--- a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
@@ -1079,7 +1079,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
     addTestSource('void f() { ^ }');
 
     await computeSuggestions();
diff --git a/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
index db354c4..e2d0297 100644
--- a/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart
@@ -75,9 +75,9 @@
   Future<void> test_export_package2() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart', content: 'library foo;');
-    newFile('$fooRootPath/lib/baz/too.dart', content: 'library too;');
-    newFile('$barRootPath/lib/bar.dart', content: 'library bar;');
+    newFile2('$fooRootPath/lib/foo.dart', 'library foo;');
+    newFile2('$fooRootPath/lib/baz/too.dart', 'library too;');
+    newFile2('$barRootPath/lib/bar.dart', 'library bar;');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -144,9 +144,9 @@
 
   Future<void> test_import_file() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "^" import');
     await computeSuggestions();
@@ -162,9 +162,9 @@
 
   Future<void> test_import_file2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "..^" import');
     await computeSuggestions();
@@ -180,9 +180,9 @@
 
   Future<void> test_import_file_child() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "foo/^" import');
     await computeSuggestions();
@@ -197,10 +197,10 @@
   }
 
   Future<void> test_import_file_outside_lib() async {
-    newFile('$testPackageLibPath/other.dart');
-    newFile('$testPackageLibPath/foo/bar.dart');
-    newFile('$testPackageRootPath/blat.dart');
-    newFile('$testPackageRootPath/bin/boo.dart');
+    newFile2('$testPackageLibPath/other.dart', '');
+    newFile2('$testPackageLibPath/foo/bar.dart', '');
+    newFile2('$testPackageRootPath/blat.dart', '');
+    newFile2('$testPackageRootPath/bin/boo.dart', '');
 
     addTestSource('import "../^" import');
     await computeSuggestions();
@@ -218,10 +218,10 @@
 
   Future<void> test_import_file_parent() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
-    newFile('$workspaceRootPath/aaa/boo.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
+    newFile2('$workspaceRootPath/aaa/boo.dart', '');
 
     addTestSource('import "../^" import');
     await computeSuggestions();
@@ -238,9 +238,9 @@
 
   Future<void> test_import_file_parent2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "../b^" import');
     await computeSuggestions();
@@ -265,8 +265,8 @@
 
   Future<void> test_import_only_dart_files() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newAnalysisOptionsYamlFile(testPackageRootPath);
+    newFile2('$testPackageRootPath/other.dart', '');
+    newAnalysisOptionsYamlFile2(testPackageRootPath, '');
 
     addTestSource('import "package:^";');
     await computeSuggestions();
@@ -276,9 +276,9 @@
   Future<void> test_import_package() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart');
-    newFile('$fooRootPath/lib/baz/too.dart');
-    newFile('$barRootPath/lib/bar.dart');
+    newFile2('$fooRootPath/lib/foo.dart', '');
+    newFile2('$fooRootPath/lib/baz/too.dart', '');
+    newFile2('$barRootPath/lib/bar.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -304,9 +304,9 @@
   Future<void> test_import_package2() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart');
-    newFile('$fooRootPath/lib/baz/too.dart');
-    newFile('$barRootPath/lib/bar.dart');
+    newFile2('$fooRootPath/lib/foo.dart', '');
+    newFile2('$fooRootPath/lib/baz/too.dart', '');
+    newFile2('$barRootPath/lib/bar.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -323,9 +323,9 @@
   Future<void> test_import_package2_raw() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart');
-    newFile('$fooRootPath/lib/baz/too.dart');
-    newFile('$barRootPath/lib/bar.dart');
+    newFile2('$fooRootPath/lib/foo.dart', '');
+    newFile2('$fooRootPath/lib/baz/too.dart', '');
+    newFile2('$barRootPath/lib/bar.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -342,9 +342,9 @@
   Future<void> test_import_package2_with_trailing() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart');
-    newFile('$fooRootPath/lib/baz/too.dart');
-    newFile('$barRootPath/lib/bar.dart');
+    newFile2('$fooRootPath/lib/foo.dart', '');
+    newFile2('$fooRootPath/lib/baz/too.dart', '');
+    newFile2('$barRootPath/lib/bar.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -379,9 +379,9 @@
   Future<void> test_import_package_raw() async {
     var fooRootPath = '$workspaceRootPath/foo';
     var barRootPath = '$workspaceRootPath/bar';
-    newFile('$fooRootPath/lib/foo.dart');
-    newFile('$fooRootPath/lib/baz/too.dart');
-    newFile('$barRootPath/lib/bar.dart');
+    newFile2('$fooRootPath/lib/foo.dart', '');
+    newFile2('$fooRootPath/lib/baz/too.dart', '');
+    newFile2('$barRootPath/lib/bar.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -479,9 +479,9 @@
 
   Future<void> test_part_file() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "^" import');
     await computeSuggestions();
@@ -497,9 +497,9 @@
 
   Future<void> test_part_file2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "..^" import');
     await computeSuggestions();
@@ -515,9 +515,9 @@
 
   Future<void> test_part_file_child() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "foo/^" import');
     await computeSuggestions();
@@ -533,9 +533,9 @@
 
   Future<void> test_part_file_parent() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "../^" import');
     await computeSuggestions();
@@ -567,9 +567,9 @@
 
   Future<void> test_import_file() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "^" import');
     await computeSuggestions();
@@ -585,9 +585,9 @@
 
   Future<void> test_import_file2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "..^" import');
     await computeSuggestions();
@@ -603,9 +603,9 @@
 
   Future<void> test_import_file_child() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "foo/^" import');
     await computeSuggestions();
@@ -621,9 +621,9 @@
 
   Future<void> test_import_file_parent() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "../^" import');
     await computeSuggestions();
@@ -639,9 +639,9 @@
 
   Future<void> test_import_file_parent2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('import "../b^" import');
     await computeSuggestions();
@@ -657,9 +657,9 @@
 
   Future<void> test_part_file() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "^" import');
     await computeSuggestions();
@@ -675,9 +675,9 @@
 
   Future<void> test_part_file2() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "..^" import');
     await computeSuggestions();
@@ -693,9 +693,9 @@
 
   Future<void> test_part_file_child() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "foo/^" import');
     await computeSuggestions();
@@ -711,9 +711,9 @@
 
   Future<void> test_part_file_parent() async {
     testFile = convertPath('$testPackageRootPath/test.dart');
-    newFile('$testPackageRootPath/other.dart');
-    newFile('$testPackageRootPath/foo/bar.dart');
-    newFile('$workspaceRootPath/blat.dart');
+    newFile2('$testPackageRootPath/other.dart', '');
+    newFile2('$testPackageRootPath/foo/bar.dart', '');
+    newFile2('$workspaceRootPath/blat.dart', '');
 
     addTestSource('library x; part "../^" import');
     await computeSuggestions();
diff --git a/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart b/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
index bc6f11e..7676492 100644
--- a/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
+++ b/pkg/analysis_server/test/services/completion/postfix/postfix_completion_test.dart
@@ -739,7 +739,7 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_into_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 String? x;
 ''');
     await _prepareCompletion('.tryon', '''
@@ -763,7 +763,7 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_into_legacy_nested() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 List<String?> x;
 ''');
     await _prepareCompletion('.tryon', '''
@@ -787,7 +787,7 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.8
 String x;
 ''');
@@ -810,7 +810,7 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_legacy_nested() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.8
 List<String> x;
 ''');
diff --git a/pkg/analysis_server/test/services/correction/util_test.dart b/pkg/analysis_server/test/services/correction/util_test.dart
index d6dc428..3269037 100644
--- a/pkg/analysis_server/test/services/correction/util_test.dart
+++ b/pkg/analysis_server/test/services/correction/util_test.dart
@@ -196,8 +196,8 @@
 
   Future<void>
       test_addLibraryImports_package_hasDart_hasPackages_insertAfter() async {
-    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
-    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
+    newFile2('$workspaceRootPath/aaa/lib/aaa.dart', '');
+    newFile2('$workspaceRootPath/bbb/lib/bbb.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -221,8 +221,8 @@
 
   Future<void>
       test_addLibraryImports_package_hasDart_hasPackages_insertBefore() async {
-    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
-    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
+    newFile2('$workspaceRootPath/aaa/lib/aaa.dart', '');
+    newFile2('$workspaceRootPath/bbb/lib/bbb.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -245,10 +245,10 @@
   }
 
   Future<void> test_addLibraryImports_package_hasImports_between() async {
-    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
-    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
-    newFile('$workspaceRootPath/ccc/lib/ccc.dart');
-    newFile('$workspaceRootPath/ddd/lib/ddd.dart');
+    newFile2('$workspaceRootPath/aaa/lib/aaa.dart', '');
+    newFile2('$workspaceRootPath/bbb/lib/bbb.dart', '');
+    newFile2('$workspaceRootPath/ccc/lib/ccc.dart', '');
+    newFile2('$workspaceRootPath/ddd/lib/ddd.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
diff --git a/pkg/analysis_server/test/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
index 7c2c008..bb098d2 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -24,10 +24,10 @@
   Future<void> test_file_containing_imports_exports_parts() async {
     final root = '/home/test/000/1111';
     testFile = convertPath('$root/test.dart');
-    newFile('/absolute/uri.dart', content: '');
-    final fileA = newFile('$root/a.dart', content: 'part of lib;');
-    final fileB = newFile('$root/b.dart', content: "import 'test.dart';");
-    final fileC = newFile('$root/22/c.dart', content: '');
+    newFile2('/absolute/uri.dart', '');
+    final fileA = newFile2('$root/a.dart', 'part of lib;');
+    final fileB = newFile2('$root/b.dart', "import 'test.dart';");
+    final fileC = newFile2('$root/22/c.dart', '');
     verifyNoTestUnitErrors = false;
     await resolveTestCode('''
 library lib;
@@ -55,7 +55,7 @@
   }
 
   Future<void> test_file_imported_with_package_uri_down() async {
-    var file = newFile('$testPackageLibPath/old_name.dart', content: '');
+    var file = newFile2('$testPackageLibPath/old_name.dart', '');
     addTestSource(r'''
 import 'package:test/old_name.dart';
 ''');
@@ -79,8 +79,7 @@
   @failingTest
   Future<void> test_file_imported_with_package_uri_lib_change() async {
     // The current testing stack does not support creating such bazel roots
-    var file =
-        newFile('/home/test0/test1/test2/lib/111/name.dart', content: '');
+    var file = newFile2('/home/test0/test1/test2/lib/111/name.dart', '');
     addTestSource(r'''
 import 'package:test0.test1.test2/111/name.dart';
 ''');
@@ -103,8 +102,7 @@
   @failingTest
   Future<void> test_file_imported_with_package_uri_lib_change_down() async {
     // The current testing stack does not support creating such bazel roots
-    var file =
-        newFile('/home/test0/test1/test2/lib/111/name.dart', content: '');
+    var file = newFile2('/home/test0/test1/test2/lib/111/name.dart', '');
     addTestSource(r'''
 import 'package:test0.test1.test2/111/name.dart';
 ''');
@@ -127,8 +125,7 @@
   @failingTest
   Future<void> test_file_imported_with_package_uri_lib_change_up() async {
     // The current testing stack does not support creating such bazel roots
-    var file =
-        newFile('/home/test0/test1/test2/lib/111/name.dart', content: '');
+    var file = newFile2('/home/test0/test1/test2/lib/111/name.dart', '');
     addTestSource(r'''
 import 'package:test0.test1.test2/111/name.dart';
 ''');
@@ -149,7 +146,7 @@
   }
 
   Future<void> test_file_imported_with_package_uri_sideways() async {
-    var file = newFile('$testPackageLibPath/111/old_name.dart', content: '');
+    var file = newFile2('$testPackageLibPath/111/old_name.dart', '');
     addTestSource(r'''
 import 'package:test/111/old_name.dart';
 ''');
@@ -171,7 +168,7 @@
   }
 
   Future<void> test_file_imported_with_package_uri_up() async {
-    var file = newFile('$testPackageLibPath/222/old_name.dart', content: '');
+    var file = newFile2('$testPackageLibPath/222/old_name.dart', '');
     addTestSource(r'''
 import 'package:test/222/old_name.dart';
 ''');
diff --git a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
index 524da05..7ce9136 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
@@ -740,7 +740,7 @@
 
   Future<void> test_createChange_MethodElement_potential_inPubCache() async {
     var externalPath = '$packagesRootPath/aaa/lib/lib.dart';
-    newFile(externalPath, content: r'''
+    newFile2(externalPath, r'''
 processObj(p) {
   p.test();
 }
@@ -819,7 +819,7 @@
   }
 
   Future<void> test_createChange_outsideOfProject_declarationInPackage() async {
-    newFile('$workspaceRootPath/aaa/lib/aaa.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/aaa.dart', r'''
 class A {
   void test() {}
 }
@@ -867,7 +867,7 @@
   }
 
   Future<void> test_createChange_outsideOfProject_referenceInPart() async {
-    newFile('/home/part.dart', content: r'''
+    newFile2('/home/part.dart', r'''
 part of test;
 
 void foo(A a) {
diff --git a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
index 16a846e..5d0000b 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
@@ -475,12 +475,12 @@
     var a = convertPath('$testPackageLibPath/a.dart');
     var b = convertPath('$testPackageLibPath/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {
   A({test});
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 
 void f() {
diff --git a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
index e0ebb09..34c0d21 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
@@ -236,7 +236,7 @@
   }
 
   Future<void> test_checkInitialConditions_outsideOfProject() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {}
 ''');
 
@@ -644,7 +644,7 @@
   }
 
   Future<void> test_createChange_outsideOfProject_referenceInPart() async {
-    newFile('/home/part.dart', content: r'''
+    newFile2('/home/part.dart', r'''
 part of test;
 
 Test test2;
diff --git a/pkg/analysis_server/test/services/search/search_engine_test.dart b/pkg/analysis_server/test/services/search/search_engine_test.dart
index 0097edb..6a43b83 100644
--- a/pkg/analysis_server/test/services/search/search_engine_test.dart
+++ b/pkg/analysis_server/test/services/search/search_engine_test.dart
@@ -31,7 +31,7 @@
   String get testFilePath => '$testPackageLibPath/test.dart';
 
   void addTestFile(String content) {
-    newFile(testFilePath, content: content);
+    newFile2(testFilePath, content);
   }
 
   /// Resolve the file with the [path] into [result].
@@ -62,7 +62,7 @@
   }
 
   Future<void> test_membersOfSubtypes_classByClass_hasMembers() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void a() {}
   void b() {}
@@ -70,14 +70,14 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class B extends A {
   void a() {}
 }
 ''');
 
-    newFile('$testPackageLibPath/c.dart', content: '''
+    newFile2('$testPackageLibPath/c.dart', '''
 import 'a.dart';
 class C extends A {
   void b() {}
@@ -126,7 +126,7 @@
   }
 
   Future<void> test_membersOfSubtypes_noMembers() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void a() {}
   void b() {}
@@ -134,7 +134,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class B extends A {}
 ''');
@@ -147,7 +147,7 @@
   }
 
   Future<void> test_membersOfSubtypes_noSubtypes() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void a() {}
   void b() {}
@@ -155,7 +155,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class B {
   void a() {}
@@ -170,7 +170,7 @@
   }
 
   Future<void> test_membersOfSubtypes_private() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void a() {}
   void _b() {}
@@ -181,7 +181,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class C extends A {
   void a() {}
@@ -219,12 +219,12 @@
   Future<void> test_searchAllSubtypes_acrossDrivers() async {
     var aaaRootPath = _configureForPackage_aaa();
 
-    newFile('$aaaRootPath/lib/a.dart', content: '''
+    newFile2('$aaaRootPath/lib/a.dart', '''
 class T {}
 class A extends T {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'package:aaa/a.dart';
 class B extends A {}
 class C extends B {}
@@ -279,8 +279,8 @@
 int test;
 ''';
 
-    newFile('$testPackageLibPath/a.dart', content: codeA);
-    newFile('$testPackageLibPath/b.dart', content: codeB);
+    newFile2('$testPackageLibPath/a.dart', codeA);
+    newFile2('$testPackageLibPath/b.dart', codeB);
 
     var matches = await searchEngine.searchMemberDeclarations('test');
     expect(matches, hasLength(2));
@@ -299,7 +299,7 @@
   }
 
   Future<void> test_searchMemberReferences() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   int test;
 }
@@ -308,7 +308,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 bar(p) {
   p.test = 1;
@@ -330,7 +330,7 @@
   Future<void> test_searchReferences() async {
     var aaaRootPath = _configureForPackage_aaa();
 
-    newFile('$aaaRootPath/lib/a.dart', content: '''
+    newFile2('$aaaRootPath/lib/a.dart', '''
 class T {}
 T a;
 ''');
@@ -352,11 +352,11 @@
   Future<void> test_searchReferences_discover_owned() async {
     var aaaRootPath = _configureForPackage_aaa();
 
-    var a = newFile('$aaaRootPath/lib/a.dart', content: '''
+    var a = newFile2('$aaaRootPath/lib/a.dart', '''
 int a;
 ''').path;
 
-    var t = newFile('$testPackageLibPath/lib/t.dart', content: '''
+    var t = newFile2('$testPackageLibPath/lib/t.dart', '''
 import 'package:aaa/a.dart';
 int t;
 ''').path;
@@ -497,12 +497,12 @@
   }
 
   Future<void> test_searchTopLevelDeclarations() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {}
 int a;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 class B {}
 get b => 42;
 ''');
@@ -528,13 +528,13 @@
   Future<void> test_searchTopLevelDeclarations_dependentPackage() async {
     var aaaRootPath = _configureForPackage_aaa();
 
-    newFile('$aaaRootPath/lib/a.dart', content: '''
+    newFile2('$aaaRootPath/lib/a.dart', '''
 class A {}
 ''');
 
     // The `package:test` uses the class `A` from the `package:aaa`.
     // So it sees the declaration the element `A`.
-    newFile('$testFilePath', content: '''
+    newFile2('$testFilePath', '''
 import 'package:aaa/a.dart';
 class B extends A {}
 ''');
diff --git a/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart b/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
index 5482204..15df536 100644
--- a/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
+++ b/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
@@ -22,10 +22,60 @@
     defineReflectiveTests(DartSwitchSnippetProducerTest);
     defineReflectiveTests(DartTryCatchSnippetProducerTest);
     defineReflectiveTests(DartWhileLoopSnippetProducerTest);
+    defineReflectiveTests(DartClassSnippetProducerTest);
+    defineReflectiveTests(DartTestBlockSnippetProducerTest);
+    defineReflectiveTests(DartTestGroupBlockSnippetProducerTest);
   });
 }
 
 @reflectiveTest
+class DartClassSnippetProducerTest extends DartSnippetProducerTest {
+  @override
+  final generator = DartClassSnippetProducer.newInstance;
+
+  @override
+  String get label => DartClassSnippetProducer.label;
+
+  @override
+  String get prefix => DartClassSnippetProducer.prefix;
+
+  Future<void> test_class() async {
+    var code = r'''
+class A {}
+  
+^
+
+class B {}''';
+    final snippet = await expectValidSnippet(code);
+    expect(snippet.prefix, prefix);
+    expect(snippet.label, label);
+    expect(snippet.change.edits, hasLength(1));
+    code = withoutMarkers(code);
+    snippet.change.edits
+        .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+    expect(code, '''
+class A {}
+  
+class  {
+  
+}
+
+class B {}''');
+    expect(snippet.change.selection!.file, testFile);
+    expect(snippet.change.selection!.offset, 25);
+    expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+      {
+        'positions': [
+          {'file': testFile, 'offset': 20},
+        ],
+        'length': 0,
+        'suggestions': []
+      }
+    ]);
+  }
+}
+
+@reflectiveTest
 class DartDoWhileLoopSnippetProducerTest extends DartSnippetProducerTest {
   @override
   final generator = DartDoWhileLoopSnippetProducer.newInstance;
@@ -524,6 +574,110 @@
 }
 
 @reflectiveTest
+class DartTestBlockSnippetProducerTest extends DartSnippetProducerTest {
+  @override
+  final generator = DartTestBlockSnippetProducer.newInstance;
+
+  @override
+  String get label => DartTestBlockSnippetProducer.label;
+
+  @override
+  String get prefix => DartTestBlockSnippetProducer.prefix;
+
+  Future<void> test_inTestFile() async {
+    testFile = convertPath('$testPackageLibPath/test/foo_test.dart');
+    var code = r'''
+void f() {
+  test^
+}''';
+    final snippet = await expectValidSnippet(code);
+    expect(snippet.prefix, prefix);
+    expect(snippet.label, label);
+    expect(snippet.change.edits, hasLength(1));
+    code = withoutMarkers(code);
+    snippet.change.edits
+        .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+    expect(code, '''
+void f() {
+  test('', () {
+    
+  });
+}''');
+    expect(snippet.change.selection!.file, testFile);
+    expect(snippet.change.selection!.offset, 31);
+    expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+      {
+        'positions': [
+          {'file': testFile, 'offset': 19},
+        ],
+        'length': 0,
+        'suggestions': []
+      }
+    ]);
+  }
+
+  Future<void> test_notTestFile() async {
+    var code = r'''
+void f() {
+  test^
+}''';
+    await expectNotValidSnippet(code);
+  }
+}
+
+@reflectiveTest
+class DartTestGroupBlockSnippetProducerTest extends DartSnippetProducerTest {
+  @override
+  final generator = DartTestGroupBlockSnippetProducer.newInstance;
+
+  @override
+  String get label => DartTestGroupBlockSnippetProducer.label;
+
+  @override
+  String get prefix => DartTestGroupBlockSnippetProducer.prefix;
+
+  Future<void> test_inTestFile() async {
+    testFile = convertPath('$testPackageLibPath/test/foo_test.dart');
+    var code = r'''
+void f() {
+  group^
+}''';
+    final snippet = await expectValidSnippet(code);
+    expect(snippet.prefix, prefix);
+    expect(snippet.label, label);
+    expect(snippet.change.edits, hasLength(1));
+    code = withoutMarkers(code);
+    snippet.change.edits
+        .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+    expect(code, '''
+void f() {
+  group('', () {
+    
+  });
+}''');
+    expect(snippet.change.selection!.file, testFile);
+    expect(snippet.change.selection!.offset, 32);
+    expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+      {
+        'positions': [
+          {'file': testFile, 'offset': 20},
+        ],
+        'length': 0,
+        'suggestions': []
+      }
+    ]);
+  }
+
+  Future<void> test_notTestFile() async {
+    var code = r'''
+void f() {
+  group^
+}''';
+    await expectNotValidSnippet(code);
+  }
+}
+
+@reflectiveTest
 class DartTryCatchSnippetProducerTest extends DartSnippetProducerTest {
   @override
   final generator = DartTryCatchSnippetProducer.newInstance;
diff --git a/pkg/analysis_server/test/src/cider/assists_test.dart b/pkg/analysis_server/test/src/cider/assists_test.dart
index 0dfc1321..d4182cb 100644
--- a/pkg/analysis_server/test/src/cider/assists_test.dart
+++ b/pkg/analysis_server/test/src/cider/assists_test.dart
@@ -132,7 +132,7 @@
     var location = lineInfo.getLocation(offset);
 
     content = content.substring(0, offset) + content.substring(offset + 1);
-    newFile(testPath, content: content);
+    newFile2(testPath, content);
 
     _correctionContext = _CorrectionContext(
       content,
diff --git a/pkg/analysis_server/test/src/cider/cider_service.dart b/pkg/analysis_server/test/src/cider/cider_service.dart
index 32aafc2..0e40f53 100644
--- a/pkg/analysis_server/test/src/cider/cider_service.dart
+++ b/pkg/analysis_server/test/src/cider/cider_service.dart
@@ -51,8 +51,8 @@
 
     logger = PerformanceLog(logBuffer);
 
-    newFile('/workspace/WORKSPACE');
-    newFile('/workspace/dart/test/BUILD');
+    newFile2('/workspace/WORKSPACE', '');
+    newFile2('/workspace/dart/test/BUILD', '');
     createFileResolver();
   }
 
diff --git a/pkg/analysis_server/test/src/cider/completion_test.dart b/pkg/analysis_server/test/src/cider/completion_test.dart
index 7a50af7..06ee178 100644
--- a/pkg/analysis_server/test/src/cider/completion_test.dart
+++ b/pkg/analysis_server/test/src/cider/completion_test.dart
@@ -112,7 +112,7 @@
 
   Future<void> test_compute_updateImportedLibrary() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
@@ -132,7 +132,7 @@
     _assertHasClass(text: 'A');
 
     // Update the imported library, has 'B', but not 'A'.
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class B {}
 ''');
     _createFileResolver();
@@ -144,7 +144,7 @@
 
   Future<void> test_compute_updateImports() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
@@ -166,7 +166,7 @@
   }
 
   Future<void> test_compute_uriContributor_disabled() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: '');
+    newFile2('/workspace/dart/test/lib/a.dart', '');
     await _compute(r'''
 import '^';
 ''');
@@ -474,7 +474,7 @@
   }
 
   Future<void> test_limitedResolution_hasPart() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 class A {}
 ''');
 
@@ -488,7 +488,7 @@
   }
 
   Future<void> test_limitedResolution_inPart_partOfName() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 library my_lib;
 part 'test.dart';
 class A {}
@@ -504,7 +504,7 @@
   }
 
   Future<void> test_limitedResolution_inPart_partOfUri() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 part 'test.dart';
 class A {}
 ''');
@@ -599,12 +599,12 @@
 
   Future<void> test_warmUp_cachesImportedLibraries() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 ''');
 
@@ -885,7 +885,7 @@
     var location = lineInfo.getLocation(offset);
 
     content = content.substring(0, offset) + content.substring(offset + 1);
-    newFile(testPath, content: content);
+    newFile2(testPath, content);
 
     return _CompletionContext(
       content,
diff --git a/pkg/analysis_server/test/src/cider/fixes_test.dart b/pkg/analysis_server/test/src/cider/fixes_test.dart
index 63179b7..8bb64dc 100644
--- a/pkg/analysis_server/test/src/cider/fixes_test.dart
+++ b/pkg/analysis_server/test/src/cider/fixes_test.dart
@@ -73,7 +73,7 @@
   }
 
   Future<void> test_importLibrary_withClass() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 class Test {}
 ''');
     fileResolver.resolve(path: a.path);
@@ -90,7 +90,7 @@
   }
 
   Future<void> test_importLibrary_withEnum() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 enum Test {a, b, c}
 ''');
     fileResolver.resolve(path: a.path);
@@ -107,7 +107,7 @@
   }
 
   Future<void> test_importLibrary_withExtension() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 extension E on int {
   void foo() {}
 }
@@ -130,7 +130,7 @@
   }
 
   Future<void> test_importLibrary_withFunction() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 void foo() {}
 ''');
     fileResolver.resolve(path: a.path);
@@ -151,7 +151,7 @@
   }
 
   Future<void> test_importLibrary_withMixin() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 mixin Test {}
 ''');
     fileResolver.resolve(path: a.path);
@@ -168,7 +168,7 @@
   }
 
   Future<void> test_importLibrary_withTopLevelVariable() async {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 var a = 0;
 ''');
     fileResolver.resolve(path: a.path);
@@ -230,7 +230,7 @@
     var location = lineInfo.getLocation(offset);
 
     content = content.substring(0, offset) + content.substring(offset + 1);
-    newFile(testPath, content: content);
+    newFile2(testPath, content);
 
     _correctionContext = _CorrectionContext(
       content,
diff --git a/pkg/analysis_server/test/src/cider/rename_test.dart b/pkg/analysis_server/test/src/cider/rename_test.dart
index 59f686d..98341fb 100644
--- a/pkg/analysis_server/test/src/cider/rename_test.dart
+++ b/pkg/analysis_server/test/src/cider/rename_test.dart
@@ -325,7 +325,7 @@
   }
 
   void test_rename_function_imported() {
-    var a = newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    var a = newFile2('/workspace/dart/test/lib/a.dart', r'''
 foo() {}
 ''');
     fileResolver.resolve(path: a.path);
@@ -451,7 +451,7 @@
     var location = lineInfo.getLocation(offset);
 
     content = content.substring(0, offset) + content.substring(offset + 1);
-    newFile(testPath, content: content);
+    newFile2(testPath, content);
 
     _correctionContext = _CorrectionContext(
       content,
diff --git a/pkg/analysis_server/test/src/cider/signature_help_test.dart b/pkg/analysis_server/test/src/cider/signature_help_test.dart
index 2b99d72..a5384eb 100644
--- a/pkg/analysis_server/test/src/cider/signature_help_test.dart
+++ b/pkg/analysis_server/test/src/cider/signature_help_test.dart
@@ -232,7 +232,7 @@
     var location = lineInfo.getLocation(offset);
 
     content = content.substring(0, offset) + content.substring(offset + 1);
-    newFile(testPath, content: content);
+    newFile2(testPath, content);
 
     _correctionContext = _CorrectionContext(
       content,
diff --git a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
index 037bb02..307a91f 100644
--- a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
@@ -396,7 +396,7 @@
   }
 
   Future<List<ClosingLabel>> _computeElements(String sourceContent) async {
-    newFile(sourcePath, content: sourceContent);
+    newFile2(sourcePath, sourceContent);
     var result =
         await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
     var computer = DartUnitClosingLabelsComputer(result.lineInfo, result.unit);
diff --git a/pkg/analysis_server/test/src/computer/color_computer_test.dart b/pkg/analysis_server/test/src/computer/color_computer_test.dart
index c6ec12a..2083610 100644
--- a/pkg/analysis_server/test/src/computer/color_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/color_computer_test.dart
@@ -127,9 +127,9 @@
     dartCode = _withCommonImports(dartCode);
     otherCode = otherCode != null ? _withCommonImports(otherCode) : null;
 
-    newFile(testPath, content: dartCode);
+    newFile2(testPath, dartCode);
     if (otherCode != null) {
-      newFile(otherPath, content: otherCode);
+      newFile2(otherPath, otherCode);
       final otherResult = await (await session).getResolvedUnit(otherPath)
           as ResolvedUnitResult;
       expectNoErrors(otherResult);
diff --git a/pkg/analysis_server/test/src/computer/folding_computer_test.dart b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
index b0a445f..09c90df 100644
--- a/pkg/analysis_server/test/src/computer/folding_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/folding_computer_test.dart
@@ -580,7 +580,7 @@
   }
 
   Future<List<FoldingRegion>> _computeRegions(String sourceContent) async {
-    newFile(sourcePath, content: sourceContent);
+    newFile2(sourcePath, sourceContent);
     var result =
         await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
     var computer = DartUnitFoldingComputer(result.lineInfo, result.unit);
diff --git a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
index 0314f65..a38a867 100644
--- a/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/highlights_computer_test.dart
@@ -112,7 +112,7 @@
     bool hasErrors = false,
   }) async {
     this.content = content;
-    newFile(sourcePath, content: content);
+    newFile2(sourcePath, content);
     var result =
         await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
 
diff --git a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
index 4cf9605..9e66300 100644
--- a/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/import_elements_computer_test.dart
@@ -49,7 +49,7 @@
 
   Future<void> createBuilder(String content) async {
     originalContent = content;
-    newFile(path, content: content);
+    newFile2(path, content);
     var result =
         await (await session).getResolvedUnit(path) as ResolvedUnitResult;
     computer = ImportElementsComputer(resourceProvider, result);
@@ -81,7 +81,7 @@
   }
 
   Future<void> test_createEdits_addImport_noPrefix() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -101,7 +101,7 @@
   }
 
   Future<void> test_createEdits_addImport_prefix() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -121,7 +121,7 @@
   }
 
   Future<void> test_createEdits_addShow_multipleNames() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -142,7 +142,7 @@
   }
 
   Future<void> test_createEdits_addShow_removeHide() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -161,7 +161,7 @@
   }
 
   Future<void> test_createEdits_addShow_singleName_noPrefix() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -180,7 +180,7 @@
   }
 
   Future<void> test_createEdits_addShow_singleName_prefix() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -201,7 +201,7 @@
   }
 
   Future<void> test_createEdits_alreadyImported_noCombinators() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -218,7 +218,7 @@
   }
 
   Future<void> test_createEdits_alreadyImported_withPrefix() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -235,7 +235,7 @@
   }
 
   Future<void> test_createEdits_alreadyImported_withShow() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -264,7 +264,7 @@
   }
 
   Future<void> test_createEdits_invalidUri() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -290,7 +290,7 @@
   }
 
   Future<void> test_createEdits_removeHide_firstInCombinator() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -309,7 +309,7 @@
   }
 
   Future<void> test_createEdits_removeHide_lastInCombinator() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -328,7 +328,7 @@
   }
 
   Future<void> test_createEdits_removeHide_middleInCombinator() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -347,7 +347,7 @@
   }
 
   Future<void> test_createEdits_removeHide_multipleCombinators() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -366,7 +366,7 @@
   }
 
   Future<void> test_createEdits_removeHide_multipleNames() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -385,7 +385,7 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_first() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -404,7 +404,7 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_last() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -423,7 +423,7 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_middle() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -442,7 +442,7 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_only() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -461,7 +461,7 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_only_multiple() async {
-    var fooFile = newFile('$workspaceRootPath/pkg/lib/foo.dart');
+    var fooFile = newFile2('$workspaceRootPath/pkg/lib/foo.dart', '');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
diff --git a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
index e3140d3..c9f45ba 100644
--- a/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/imported_elements_computer_test.dart
@@ -223,7 +223,7 @@
 
   Future<void> test_package_multipleInSame() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 class A {
   static String a = '';
 }
@@ -252,7 +252,7 @@
 
   Future<void> test_package_noPrefix() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 class Foo {
   static String first = '';
 }
@@ -278,7 +278,7 @@
 
   Future<void> test_package_prefix_selected_class() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 class Foo {
   static String first = '';
 }
@@ -304,7 +304,7 @@
 
   Future<void> test_package_prefix_selected_function() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 String foo() => '';
 ''');
 
@@ -328,7 +328,7 @@
 
   Future<void> test_package_prefix_selected_getter() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 String foo = '';
 ''');
 
@@ -352,7 +352,7 @@
 
   Future<void> test_package_prefix_selected_setter() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 String foo = '';
 ''');
 
@@ -376,7 +376,7 @@
 
   Future<void> test_package_prefix_unselected() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 class Foo {
   static String first = '';
 }
@@ -402,7 +402,7 @@
 
   Future<void> test_package_prefixedAndNot() async {
     var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
-    newFile(fooPath, content: '''
+    newFile2(fooPath, '''
 class Foo {
   static String first = '';
   static String second = '';
@@ -469,7 +469,7 @@
 
   Future<void> _computeElements(String content, String selection) async {
     // TODO(brianwilkerson) Automatically extract the selection from the content.
-    newFile(sourcePath, content: content);
+    newFile2(sourcePath, content);
     var result =
         await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
     var computer = ImportedElementsComputer(
diff --git a/pkg/analysis_server/test/src/computer/outline_computer_test.dart b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
index 46d85a7..25fdf23 100644
--- a/pkg/analysis_server/test/src/computer/outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
@@ -31,7 +31,7 @@
 
   Future<Outline> _computeOutline(String code) async {
     testCode = code;
-    newFile(testPath, content: code);
+    newFile2(testPath, code);
     var resolveResult =
         await (await session).getResolvedUnit(testPath) as ResolvedUnitResult;
     return DartUnitOutlineComputer(
diff --git a/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart b/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
index 0a3539b..20fdbfd 100644
--- a/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/selection_range_computer_test.dart
@@ -192,7 +192,7 @@
 
   Future<List<SelectionRange>?> _computeSelectionRanges(
       String sourceContent, int offset) async {
-    newFile(sourcePath, content: sourceContent);
+    newFile2(sourcePath, sourceContent);
     var result =
         await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
     var computer = DartSelectionRangeComputer(result.unit, offset);
diff --git a/pkg/analysis_server/test/src/domains/completion/available_suggestion_sets_test.dart b/pkg/analysis_server/test/src/domains/completion/available_suggestion_sets_test.dart
index 477d52b..4b42e1a 100644
--- a/pkg/analysis_server/test/src/domains/completion/available_suggestion_sets_test.dart
+++ b/pkg/analysis_server/test/src/domains/completion/available_suggestion_sets_test.dart
@@ -26,7 +26,7 @@
 
     // Create the file, should get the set.
     {
-      newFile(path, content: r'''
+      newFile2(path, r'''
 class A {}
 ''');
       var set = await waitForSetWithUri(uriStr);
@@ -35,7 +35,7 @@
 
     // Update the file, should get the updated set.
     {
-      newFile(path, content: r'''
+      newFile2(path, r'''
 class B {}
 ''');
       removeSet(uriStr);
@@ -52,7 +52,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {
   A.a();
 }
@@ -120,7 +120,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 abstract class A {
   A.a();
   factory A.b() => _B();
@@ -195,12 +195,12 @@
     var b_path = convertPath('/home/test/lib/b.dart');
     var a_uriStr = 'package:test/a.dart';
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 part 'b.dart';
 class A {}
 ''');
 
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 part of 'a.dart';
 class B {}
 ''');
@@ -264,7 +264,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 enum MyEnum {
   aaa,
   bbb,
@@ -355,7 +355,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 var boolV = false;
 var intV = 0;
 var doubleV = 0.1;
@@ -473,7 +473,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 typedef MyAlias = double;
 ''');
 
@@ -509,7 +509,7 @@
     var path = convertPath('/home/test/lib/a.dart');
     var uriStr = 'package:test/a.dart';
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 typedef MyAlias = void Function();
 ''');
 
diff --git a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
index d528d5f..9fee7ee 100644
--- a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
+++ b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
@@ -81,8 +81,7 @@
     newPubspecYamlFile('/home/test', '');
     newPackageConfigJsonFile(
       '/home/test',
-      content: (PackageConfigFileBuilder()
-            ..add(name: 'test', rootPath: '/home/test'))
+      (PackageConfigFileBuilder()..add(name: 'test', rootPath: '/home/test'))
           .toContent(toUriStr: toUriStr),
     );
 
diff --git a/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart b/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
index 9009034..75ae254 100644
--- a/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
+++ b/pkg/analysis_server/test/src/domains/completion/get_suggestion_details_test.dart
@@ -17,7 +17,7 @@
 @reflectiveTest
 class GetSuggestionDetailsTest extends AvailableSuggestionsBase {
   Future<void> test_enum() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 enum MyEnum {
   aaa, bbb
 }
@@ -218,7 +218,7 @@
 
 main() {} // ref
 ''';
-    var partPath = newFile('/home/test/lib/a.dart', content: partCode).path;
+    var partPath = newFile2('/home/test/lib/a.dart', partCode).path;
     addTestFile(r'''
 part 'a.dart';
 ''');
diff --git a/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart b/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
index 9c47432..8a1b392 100644
--- a/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
+++ b/pkg/analysis_server/test/src/domains/completion/get_suggestions_available_test.dart
@@ -110,7 +110,7 @@
   }
 
   Future<void> test_defaultArgumentListString() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 void fff(int aaa, int bbb) {}
 
 void ggg({int aaa, @required int bbb, @required int ccc}) {}
@@ -129,11 +129,11 @@
 
   Future<void> test_displayUri_file() async {
     var aPath = '/home/test/test/a.dart';
-    newFile(aPath, content: 'class A {}');
+    newFile2(aPath, 'class A {}');
 
     var aSet = await waitForSetWithUri(toUriStr(aPath));
 
-    var testPath = newFile('/home/test/test/sub/test.dart').path;
+    var testPath = newFile2('/home/test/test/sub/test.dart', '').path;
     var results = await _getSuggestions(testPath, 0);
 
     expect(
@@ -146,10 +146,10 @@
 
   Future<void> test_displayUri_package() async {
     var aPath = '/home/test/lib/a.dart';
-    newFile(aPath, content: 'class A {}');
+    newFile2(aPath, 'class A {}');
 
     var aSet = await waitForSetWithUri('package:test/a.dart');
-    var testPath = newFile('/home/test/lib/test.dart').path;
+    var testPath = newFile2('/home/test/lib/test.dart', '').path;
 
     var results = await _getSuggestions(testPath, 0);
     expect(
@@ -217,10 +217,10 @@
   }
 
   Future<void> test_inHtml() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
+    newFile2('/home/test/lib/a.dart', 'class A {}');
 
     var path = convertPath('/home/test/doc/a.html');
-    newFile(path, content: '<html></html>');
+    newFile2(path, '<html></html>');
 
     await waitResponse(
       CompletionGetSuggestionsParams(path, 0).toRequest('0'),
@@ -257,7 +257,7 @@
   }
 
   Future<void> test_relevanceTags_enum() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 enum MyEnum {
   aaa, bbb
 }
diff --git a/pkg/analysis_server/test/src/domains/execution/completion_test.dart b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
index 4f3af62..b7cccdc 100644
--- a/pkg/analysis_server/test/src/domains/execution/completion_test.dart
+++ b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
@@ -335,8 +335,8 @@
 
   @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_syntheticImportPrefix() async {
-    newFile('/test/lib/a.dart', content: 'class A {}');
-    newFile('/test/lib/b.dart', content: 'class B {}');
+    newFile2('/test/lib/a.dart', 'class A {}');
+    newFile2('/test/lib/b.dart', 'class B {}');
     addContextFile(r'''
 import 'a.dart';
 impoty 'b.dart';
diff --git a/pkg/analysis_server/test/src/domains/flutter/base.dart b/pkg/analysis_server/test/src/domains/flutter/base.dart
index 659378f..39d724f 100644
--- a/pkg/analysis_server/test/src/domains/flutter/base.dart
+++ b/pkg/analysis_server/test/src/domains/flutter/base.dart
@@ -50,7 +50,7 @@
     var flutterLib = MockPackages.instance.addFlutter(resourceProvider);
     newPackageConfigJsonFile(
       '/home/test',
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'test', rootPath: '/home/test')
             ..add(name: 'meta', rootPath: metaLib.parent.path)
             ..add(name: 'flutter', rootPath: flutterLib.parent.path))
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
index e8fd170..c698324 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_computer_test.dart
@@ -234,7 +234,7 @@
   }
 
   Future<void> test_children_closure_blockBody() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:flutter/widgets.dart';
 
 class WidgetA extends StatelessWidget {
@@ -270,7 +270,7 @@
   }
 
   Future<void> test_children_closure_expressionBody() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:flutter/widgets.dart';
 
 class WidgetA extends StatelessWidget {
@@ -472,7 +472,7 @@
   }
 
   Future<void> test_namedArgument_anywhere() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:flutter/widgets.dart';
 
 class WidgetA extends StatelessWidget {
@@ -512,7 +512,7 @@
   }
 
   Future<void> test_parentAssociationLabel() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:flutter/widgets.dart';
 
 class WidgetA extends StatelessWidget {
@@ -584,7 +584,7 @@
 
   Future<FlutterOutline> _computeOutline(String code) async {
     testCode = code;
-    newFile(testPath, content: code);
+    newFile2(testPath, code);
     resolveResult =
         await (await session).getResolvedUnit(testPath) as ResolvedUnitResult;
     computer = FlutterOutlineComputer(resolveResult);
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
index 58b7f0e..96c2b66 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
@@ -75,11 +75,11 @@
   Future<void> test_children() async {
     newPackageConfigJsonFile(
       projectPath,
-      content: (PackageConfigFileBuilder()
+      (PackageConfigFileBuilder()
             ..add(name: 'flutter', rootPath: flutterFolder.parent.path))
           .toContent(toUriStr: toUriStr),
     );
-    newAnalysisOptionsYamlFile(projectPath, content: '''
+    newAnalysisOptionsYamlFile2(projectPath, '''
 analyzer:
   strong-mode: true
 ''');
diff --git a/pkg/analysis_server/test/src/g3/fixes_test.dart b/pkg/analysis_server/test/src/g3/fixes_test.dart
index 34bdfbf..a90cff0 100644
--- a/pkg/analysis_server/test/src/g3/fixes_test.dart
+++ b/pkg/analysis_server/test/src/g3/fixes_test.dart
@@ -202,6 +202,6 @@
       }
     }
 
-    newFile('/home/test/analysis_options.yaml', content: buffer.toString());
+    newFile2('/home/test/analysis_options.yaml', buffer.toString());
   }
 }
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index d2644f7..4241eec 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -480,8 +480,8 @@
     // a .packages file.
     //
     var pluginDirPath = newFolder('/plugin').path;
-    var pluginFilePath = newFile('/plugin/bin/plugin.dart').path;
-    var packagesFilePath = newDotPackagesFile('/plugin').path;
+    var pluginFilePath = newFile2('/plugin/bin/plugin.dart', '').path;
+    var packagesFilePath = newDotPackagesFile('/plugin', '').path;
     //
     // Test path computation.
     //
@@ -495,14 +495,14 @@
     //
     // Build a Bazel workspace containing four packages, including the plugin.
     //
-    newFile('/workspaceRoot/WORKSPACE');
+    newFile2('/workspaceRoot/WORKSPACE', '');
     newFolder('/workspaceRoot/bazel-bin');
     newFolder('/workspaceRoot/bazel-genfiles');
 
     String newPackage(String packageName, [List<String>? dependencies]) {
       var packageRoot =
           newFolder('/workspaceRoot/third_party/dart/$packageName').path;
-      newFile('$packageRoot/lib/$packageName.dart');
+      newFile2('$packageRoot/lib/$packageName.dart', '');
       var buffer = StringBuffer();
       if (dependencies != null) {
         buffer.writeln('dependencies:');
@@ -518,7 +518,7 @@
     newPackage('b', ['d']);
     newPackage('c', ['d']);
     newPackage('d');
-    var pluginFilePath = newFile('$pluginDirPath/bin/plugin.dart').path;
+    var pluginFilePath = newFile2('$pluginDirPath/bin/plugin.dart', '').path;
     //
     // Test path computation.
     //
diff --git a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
index 62eb89f..7d12566 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart
@@ -36,9 +36,10 @@
 
   Future<void> test_addedDriver() async {
     newPubspecYamlFile('/foo', 'name: foo');
-    newFile(
+    newFile2(
       join('/foo', PluginLocator.toolsFolderName,
           PluginLocator.defaultPluginFolderName, 'bin', 'plugin.dart'),
+      '',
     );
 
     writeTestPackageConfig(
diff --git a/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart b/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
index d131792..b6ad6a1 100644
--- a/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/dart/completion_test.dart
@@ -205,7 +205,7 @@
   }
 
   Future<void> test_explicitTarget_method_imported() async {
-    newFile(convertPath('/project/bin/lib.dart'), content: '''
+    newFile2(convertPath('/project/bin/lib.dart'), '''
 extension E on String {
   void m() {}
 }
@@ -221,7 +221,7 @@
   }
 
   Future<void> test_explicitTarget_method_inLibrary() async {
-    newFile(convertPath('/project/bin/lib.dart'), content: '''
+    newFile2(convertPath('/project/bin/lib.dart'), '''
 part 'test.dart';
 extension E on String {
   void m() {}
@@ -238,7 +238,7 @@
   }
 
   Future<void> test_explicitTarget_method_inPart() async {
-    newFile(convertPath('/project/bin/part.dart'), content: '''
+    newFile2(convertPath('/project/bin/part.dart'), '''
 extension E on String {
   void m() {}
 }
@@ -257,7 +257,7 @@
   Future<void> test_explicitTarget_method_notImported() async {
     // Available suggestions data doesn't yet have information about extension
     // methods.
-    newFile(convertPath('/project/bin/lib.dart'), content: '''
+    newFile2(convertPath('/project/bin/lib.dart'), '''
 extension E on String {
   void m() {}
 }
@@ -589,7 +589,7 @@
 
   @failingTest
   Future<void> test_unnamedConstructor_inDifferentLibrary() async {
-    newFile('/project/bin/b.dart', content: '''
+    newFile2('/project/bin/b.dart', '''
 class B implements A {
   B();
 }
@@ -710,7 +710,7 @@
 @reflectiveTest
 class SuperConstructorInvocationCompletionTest extends CompletionTestCase {
   Future<void> test_namedConstructor_notVisible() async {
-    newFile('/project/bin/a.dart', content: '''
+    newFile2('/project/bin/a.dart', '''
 class A {
   A._() {}
 }
diff --git a/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart b/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
index 1104ef2..d3d1e91 100644
--- a/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/yaml/pubspec_generator_test.dart
@@ -85,7 +85,7 @@
   }
 
   void test_flutter_assets_invalidPath() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -95,7 +95,7 @@
   }
 
   void test_flutter_assets_nonExistentPath() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -105,7 +105,7 @@
   }
 
   void test_flutter_assets_noPath() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -115,7 +115,7 @@
   }
 
   void test_flutter_assets_partialPath() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -125,7 +125,7 @@
   }
 
   void test_flutter_assets_path_withFollowing() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -135,7 +135,7 @@
   }
 
   void test_flutter_assets_path_withoutFollowing() {
-    newFile('/home/test/assets/img1.jpg');
+    newFile2('/home/test/assets/img1.jpg', '');
     getCompletions('''
 flutter:
   assets:
@@ -380,7 +380,7 @@
       return MockProcess(1, 0, '', '');
     };
 
-    newFile('/home/DEPS');
+    newFile2('/home/DEPS', '');
     pubPackageService.beginCachePreloads([convertPath('/home/test/$fileName')]);
     await pumpEventQueue(times: 500);
 
diff --git a/pkg/analysis_server/test/src/services/completion/yaml/yaml_generator_test_support.dart b/pkg/analysis_server/test/src/services/completion/yaml/yaml_generator_test_support.dart
index 90a8df5..c0c63d4 100644
--- a/pkg/analysis_server/test/src/services/completion/yaml/yaml_generator_test_support.dart
+++ b/pkg/analysis_server/test/src/services/completion/yaml/yaml_generator_test_support.dart
@@ -57,7 +57,7 @@
     content = content.substring(0, completionOffset) +
         content.substring(completionOffset + 1);
     // Add the file to the file system.
-    var file = newFile('/home/test/$fileName', content: content);
+    var file = newFile2('/home/test/$fileName', content);
     // Generate completions.
     results = generator.getSuggestions(file.path, completionOffset).suggestions;
   }
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
index fa8e2fe..0eeb8a9 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
@@ -321,7 +321,7 @@
   Future<void> test_invalid_hasPart() async {
     // Change this test if the assist becomes able to look for references to the
     // class and its constructors in part files.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 part of 'test.dart';
 ''');
     await resolveTestCode('''
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_initializing_parameter_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_initializing_parameter_test.dart
deleted file mode 100644
index df4f094..0000000
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_initializing_parameter_test.dart
+++ /dev/null
@@ -1,484 +0,0 @@
-// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analysis_server/src/services/correction/assist.dart';
-import 'package:analyzer_plugin/utilities/assist/assist.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'assist_processor.dart';
-
-void main() {
-  defineReflectiveSuite(() {
-    defineReflectiveTests(ConvertToSuperInitializingParameterTest);
-  });
-}
-
-@reflectiveTest
-class ConvertToSuperInitializingParameterTest extends AssistProcessorTest {
-  @override
-  AssistKind get kind => DartAssistKind.CONVERT_TO_SUPER_INITIALIZING_PARAMETER;
-
-  Future<void> test_named_first() async {
-    await resolveTestCode('''
-class A {
-  A({int? x, int? y});
-}
-class B extends A {
-  B({int? x, int? y}) : super(x: x, y: y);
-}
-''');
-    await assertHasAssistAt('x, int? y}) :', '''
-class A {
-  A({int? x, int? y});
-}
-class B extends A {
-  B({super.x, int? y}) : super(y: y);
-}
-''');
-  }
-
-  Future<void> test_named_last() async {
-    await resolveTestCode('''
-class A {
-  A({int? x, int? y});
-}
-class B extends A {
-  B({int? x, int? y}) : super(x: x, y: y);
-}
-''');
-    await assertHasAssistAt('y}) :', '''
-class A {
-  A({int? x, int? y});
-}
-class B extends A {
-  B({int? x, super.y}) : super(x: x);
-}
-''');
-  }
-
-  Future<void> test_named_middle() async {
-    await resolveTestCode('''
-class A {
-  A({int? x, int? y, int? z});
-}
-class B extends A {
-  B({int? x, int? y, int? z}) : super(x: x, y: y, z: z);
-}
-''');
-    await assertHasAssistAt('y, int? z}) :', '''
-class A {
-  A({int? x, int? y, int? z});
-}
-class B extends A {
-  B({int? x, super.y, int? z}) : super(x: x, z: z);
-}
-''');
-  }
-
-  Future<void> test_named_noSuperInvocation() async {
-    await resolveTestCode('''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({int x = 1});
-}
-''');
-    await assertNoAssistAt('x = 1');
-  }
-
-  Future<void> test_named_notGenerative() async {
-    await resolveTestCode('''
-class A {
-  A({required int x});
-}
-class B extends A {
-  static List<B> instances = [];
-  factory B({required int x}) => instances[x];
-}
-''');
-    await assertNoAssistAt('x}) =>');
-  }
-
-  Future<void> test_named_notInConstructor() async {
-    await resolveTestCode('''
-class A {
-  void m({required int x}) {}
-}
-''');
-    await assertNoAssistAt('x})');
-  }
-
-  Future<void> test_named_notPassed_unreferenced() async {
-    await resolveTestCode('''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({int x = 0}) : super(x: 0);
-}
-''');
-    await assertNoAssistAt('x = 0}) :');
-  }
-
-  Future<void> test_named_notPassed_usedInExpression() async {
-    await resolveTestCode('''
-class A {
-  A({String x = ''});
-}
-class B extends A {
-  B({required Object x}) : super(x: x.toString());
-}
-''');
-    await assertNoAssistAt('x}) :');
-  }
-
-  Future<void> test_named_notSupported() async {
-    await resolveTestCode('''
-// @dart=2.16
-class A {
-  A({int? x});
-}
-class B extends A {
-  B({int? x}) : super(x: x);
-}
-''');
-    await assertNoAssistAt('x}) :');
-  }
-
-  Future<void> test_named_only() async {
-    await resolveTestCode('''
-class A {
-  A({int? x});
-}
-class B extends A {
-  B({int? x}) : super(x: x);
-}
-''');
-    await assertHasAssistAt('x}) :', '''
-class A {
-  A({int? x});
-}
-class B extends A {
-  B({super.x});
-}
-''');
-  }
-
-  Future<void> test_named_withDifferentDefaultValue() async {
-    await resolveTestCode('''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({int x = 2}) : super(x: x);
-}
-''');
-    await assertHasAssistAt('x = 2}) :', '''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({super.x = 2});
-}
-''');
-  }
-
-  Future<void> test_named_withEqualDefaultValue() async {
-    await resolveTestCode('''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({int x = 0}) : super(x: x);
-}
-''');
-    await assertHasAssistAt('x = 0}) :', '''
-class A {
-  A({int x = 0});
-}
-class B extends A {
-  B({super.x});
-}
-''');
-  }
-
-  Future<void> test_optionalPositional_singleSuperParameter_only() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B([int x = 0]) : super(x);
-}
-''');
-    await assertHasAssistAt('x = 0]', '''
-class A {
-  A(int x);
-}
-class B extends A {
-  B([super.x = 0]);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_mixedSuperParameters_first() async {
-    await resolveTestCode('''
-class A {
-  A(int x, {int? y});
-}
-class B extends A {
-  B(int x, int y) : super(x, y: y);
-}
-''');
-    await assertHasAssistAt('x, int y)', '''
-class A {
-  A(int x, {int? y});
-}
-class B extends A {
-  B(super.x, int y) : super(y: y);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_mixedSuperParameters_last() async {
-    await resolveTestCode('''
-class A {
-  A(int x, {int? y});
-}
-class B extends A {
-  B(int y, int x) : super(x, y: y);
-}
-''');
-    await assertHasAssistAt('x) :', '''
-class A {
-  A(int x, {int? y});
-}
-class B extends A {
-  B(int y, super.x) : super(y: y);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_mixedSuperParameters_middle() async {
-    await resolveTestCode('''
-class A {
-  A(int y, {int? z});
-}
-class B extends A {
-  B(int x, int y, int z) : super(y, z: z);
-}
-''');
-    await assertHasAssistAt('y, int z) :', '''
-class A {
-  A(int y, {int? z});
-}
-class B extends A {
-  B(int x, super.y, int z) : super(z: z);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_multipleSuperParameters_first() async {
-    await resolveTestCode('''
-class A {
-  A(int x, int y);
-}
-class B extends A {
-  B(int x, int y) : super(x, y);
-}
-''');
-    await assertNoAssistAt('x, int y) :');
-  }
-
-  Future<void> test_requiredPositional_multipleSuperParameters_last() async {
-    await resolveTestCode('''
-class A {
-  A(int x, int y);
-}
-class B extends A {
-  B(int x, int y) : super(x, y);
-}
-''');
-    await assertNoAssistAt('y) :');
-  }
-
-  Future<void> test_requiredPositional_multipleSuperParameters_middle() async {
-    await resolveTestCode('''
-class A {
-  A(int x, int y, int z);
-}
-class B extends A {
-  B(int x, int y, int z) : super(x, y, z);
-}
-''');
-    await assertNoAssistAt('y, int z) :');
-  }
-
-  Future<void> test_requiredPositional_noSuperInvocation() async {
-    await resolveTestCode('''
-class A {
-  A();
-}
-class B extends A {
-  B(int x);
-}
-''');
-    await assertNoAssistAt('x);');
-  }
-
-  Future<void> test_requiredPositional_notGenerative() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  static List<B> instances = [];
-  factory B(int x) => instances[x];
-}
-''');
-    await assertNoAssistAt('x) =>');
-  }
-
-  Future<void> test_requiredPositional_notInConstructor() async {
-    await resolveTestCode('''
-class A {
-  void m(int x) {}
-}
-''');
-    await assertNoAssistAt('x)');
-  }
-
-  Future<void> test_requiredPositional_notPassed_unreferenced() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x) : super(0);
-}
-''');
-    await assertNoAssistAt('x) :');
-  }
-
-  Future<void> test_requiredPositional_notPassed_usedInExpression() async {
-    await resolveTestCode('''
-class A {
-  A(String x);
-}
-class B extends A {
-  B(Object x) : super(x.toString());
-}
-''');
-    await assertNoAssistAt('x) :');
-  }
-
-  Future<void> test_requiredPositional_notSupported() async {
-    await resolveTestCode('''
-// @dart=2.16
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x) : super(x);
-}
-''');
-    await assertNoAssistAt('x) :');
-  }
-
-  Future<void> test_requiredPositional_singleSuperParameter_first() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x, int y) : super(x);
-}
-''');
-    await assertHasAssistAt('x, int y)', '''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(super.x, int y);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_singleSuperParameter_last() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x, int y) : super(y);
-}
-''');
-    await assertHasAssistAt('y) :', '''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x, super.y);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_singleSuperParameter_middle() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x, int y, int z) : super(y);
-}
-''');
-    await assertHasAssistAt('y, int z) :', '''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x, super.y, int z);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_singleSuperParameter_only() async {
-    await resolveTestCode('''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(int x) : super(x);
-}
-''');
-    await assertHasAssistAt('x) :', '''
-class A {
-  A(int x);
-}
-class B extends A {
-  B(super.x);
-}
-''');
-  }
-
-  Future<void> test_requiredPositional_unpassedOptionalPositional() async {
-    await resolveTestCode('''
-class A {
-  A(int x, [int y = 0]);
-}
-class B extends A {
-  B(int x) : super(x);
-}
-''');
-    await assertHasAssistAt('x) :', '''
-class A {
-  A(int x, [int y = 0]);
-}
-class B extends A {
-  B(super.x);
-}
-''');
-  }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
new file mode 100644
index 0000000..b3652ca
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
@@ -0,0 +1,658 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/correction/assist.dart';
+import 'package:analyzer_plugin/utilities/assist/assist.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'assist_processor.dart';
+
+void main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(ConvertToSuperParametersTest);
+  });
+}
+
+@reflectiveTest
+class ConvertToSuperParametersTest extends AssistProcessorTest {
+  @override
+  AssistKind get kind => DartAssistKind.CONVERT_TO_SUPER_PARAMETERS;
+
+  Future<void> test_cursorLocation_named_onClassName() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B.name({int? x}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('B.name', '''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B.name({super.x});
+}
+''');
+  }
+
+  Future<void> test_cursorLocation_named_onConstructorName() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B.name({int? x}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('ame(', '''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B.name({super.x});
+}
+''');
+  }
+
+  Future<void> test_cursorLocation_unnamed_notOnClassName() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({int? x}) : super(x: x);
+}
+''');
+    await assertNoAssistAt('super');
+  }
+
+  Future<void> test_cursorLocation_unnamed_onClassName() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({int? x}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({super.x});
+}
+''');
+  }
+
+  Future<void> test_defaultValue_different_named() async {
+    await resolveTestCode('''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({int x = 2}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({super.x = 2});
+}
+''');
+  }
+
+  Future<void> test_defaultValue_different_positional() async {
+    await resolveTestCode('''
+class A {
+  A([int x = 0]);
+}
+class B extends A {
+  B([int x = 2]) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A([int x = 0]);
+}
+class B extends A {
+  B([super.x = 2]);
+}
+''');
+  }
+
+  Future<void> test_defaultValue_equal_named() async {
+    await resolveTestCode('''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({int x = 0}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({super.x});
+}
+''');
+  }
+
+  Future<void> test_defaultValue_equal_positional() async {
+    await resolveTestCode('''
+class A {
+  A([int x = 0]);
+}
+class B extends A {
+  B([int x = 0]) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A([int x = 0]);
+}
+class B extends A {
+  B([super.x]);
+}
+''');
+  }
+
+  Future<void> test_invalid_namedToPositional() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B({int x = 0}) : super(x);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_noSuperInvocation_factory() async {
+    await resolveTestCode('''
+class A {
+  A({required int x});
+}
+class B extends A {
+  static List<B> instances = [];
+  factory B({required int x}) => instances[x];
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_noSuperInvocation_generative() async {
+    await resolveTestCode('''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({int x = 1});
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_notAConstructor() async {
+    await resolveTestCode('''
+class A {
+  void m({required int x}) {}
+}
+''');
+    await assertNoAssistAt('m(');
+  }
+
+  Future<void> test_invalid_notPassed_unreferenced_named() async {
+    await resolveTestCode('''
+class A {
+  A({int x = 0});
+}
+class B extends A {
+  B({int x = 0}) : super(x: 0);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_notPassed_unreferenced_positional() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x) : super(0);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_notPassed_usedInExpression_named() async {
+    await resolveTestCode('''
+class A {
+  A({String x = ''});
+}
+class B extends A {
+  B({required Object x}) : super(x: x.toString());
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_notPassed_usedInExpression_positional() async {
+    await resolveTestCode('''
+class A {
+  A(String x);
+}
+class B extends A {
+  B(Object x) : super(x.toString());
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_optedOut() async {
+    await resolveTestCode('''
+// @dart=2.16
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({int? x}) : super(x: x);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_invalid_positionalToNamed() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B(int x) : super(x: x);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_mixed_first() async {
+    await resolveTestCode('''
+class A {
+  A(int x, {int? y});
+}
+class B extends A {
+  B(int x, int y) : super(x, y: y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x, {int? y});
+}
+class B extends A {
+  B(super.x, int y) : super(y: y);
+}
+''');
+  }
+
+  Future<void> test_mixed_last() async {
+    await resolveTestCode('''
+class A {
+  A(int x, {int? y});
+}
+class B extends A {
+  B(int y, int x) : super(x, y: y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x, {int? y});
+}
+class B extends A {
+  B(int y, super.x) : super(y: y);
+}
+''');
+  }
+
+  Future<void> test_mixed_middle() async {
+    await resolveTestCode('''
+class A {
+  A(int y, {int? z});
+}
+class B extends A {
+  B(int x, int y, int z) : super(y, z: z);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int y, {int? z});
+}
+class B extends A {
+  B(int x, super.y, int z) : super(z: z);
+}
+''');
+  }
+
+  Future<void> test_named_all_reversedOrder() async {
+    await resolveTestCode('''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({int? y, int? x}) : super(x: x, y: y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({super.y, super.x});
+}
+''');
+  }
+
+  Future<void> test_named_all_sameOrder() async {
+    await resolveTestCode('''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({int? x, int? y}) : super(x: x, y: y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({super.x, super.y});
+}
+''');
+  }
+
+  Future<void> test_named_first() async {
+    await resolveTestCode('''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({int? x, required int y}) : super(x: x, y: y + 1);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({super.x, required int y}) : super(y: y + 1);
+}
+''');
+  }
+
+  Future<void> test_named_last() async {
+    await resolveTestCode('''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({required int x, int? y}) : super(x: x + 1, y: y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x, int? y});
+}
+class B extends A {
+  B({required int x, super.y}) : super(x: x + 1);
+}
+''');
+  }
+
+  Future<void> test_named_middle() async {
+    await resolveTestCode('''
+class A {
+  A({int? x, int? y, int? z});
+}
+class B extends A {
+  B({required int x, int? y, required int z}) : super(x: x + 1, y: y, z: z + 1);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x, int? y, int? z});
+}
+class B extends A {
+  B({required int x, super.y, required int z}) : super(x: x + 1, z: z + 1);
+}
+''');
+  }
+
+  Future<void> test_named_only() async {
+    await resolveTestCode('''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({int? x}) : super(x: x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A({int? x});
+}
+class B extends A {
+  B({super.x});
+}
+''');
+  }
+
+  Future<void> test_positional_first() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x, int y) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(super.x, int y);
+}
+''');
+  }
+
+  Future<void> test_positional_functionTypedFormalParameter() async {
+    await resolveTestCode('''
+class A {
+  A(int x(int));
+}
+class B extends A {
+  B(int x(int)) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x(int));
+}
+class B extends A {
+  B(super.x);
+}
+''');
+  }
+
+  Future<void> test_positional_last() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x, int y) : super(y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x, super.y);
+}
+''');
+  }
+
+  Future<void> test_positional_middle() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x, int y, int z) : super(y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x, super.y, int z);
+}
+''');
+  }
+
+  Future<void> test_positional_multiple_notInOrder() async {
+    await resolveTestCode('''
+class A {
+  A(int x, int y);
+}
+class B extends A {
+  B(int x, int y) : super(y, x);
+}
+''');
+    await assertNoAssistAt('B(');
+  }
+
+  Future<void> test_positional_multiple_optional() async {
+    await resolveTestCode('''
+class A {
+  A([int? x, int? y]);
+}
+class B extends A {
+  B([int? x, int? y]) : super(x, y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A([int? x, int? y]);
+}
+class B extends A {
+  B([super.x, super.y]);
+}
+''');
+  }
+
+  Future<void> test_positional_multiple_required() async {
+    await resolveTestCode('''
+class A {
+  A(int x, int y);
+}
+class B extends A {
+  B(int x, int y) : super(x, y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x, int y);
+}
+class B extends A {
+  B(super.x, super.y);
+}
+''');
+  }
+
+  Future<void> test_positional_multiple_requiredAndOptional() async {
+    await resolveTestCode('''
+class A {
+  A(int x, [int? y]);
+}
+class B extends A {
+  B(int x, [int? y]) : super(x, y);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x, [int? y]);
+}
+class B extends A {
+  B(super.x, [super.y]);
+}
+''');
+  }
+
+  Future<void> test_positional_only() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(int x) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x);
+}
+class B extends A {
+  B(super.x);
+}
+''');
+  }
+
+  Future<void> test_positional_only_optional() async {
+    await resolveTestCode('''
+class A {
+  A(int x);
+}
+class B extends A {
+  B([int x = 0]) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x);
+}
+class B extends A {
+  B([super.x = 0]);
+}
+''');
+  }
+
+  Future<void> test_positional_unpassedOptionalPositional() async {
+    await resolveTestCode('''
+class A {
+  A(int x, [int y = 0]);
+}
+class B extends A {
+  B(int x) : super(x);
+}
+''');
+    await assertHasAssistAt('B(', '''
+class A {
+  A(int x, [int y = 0]);
+}
+class B extends A {
+  B(super.x);
+}
+''');
+  }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/test_all.dart b/pkg/analysis_server/test/src/services/correction/assist/test_all.dart
index 2c05865..d32b3c0 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/test_all.dart
@@ -42,8 +42,7 @@
 import 'convert_to_single_quoted_string_test.dart'
     as convert_to_single_quoted_string;
 import 'convert_to_spread_test.dart' as convert_to_spread;
-import 'convert_to_super_initializing_parameter_test.dart'
-    as convert_to_super_initializing_parameter;
+import 'convert_to_super_parameters_test.dart' as convert_to_super_parameters;
 import 'encapsulate_field_test.dart' as encapsulate_field;
 import 'exchange_operands_test.dart' as exchange_operands;
 import 'flutter_convert_to_children_test.dart' as flutter_convert_to_children;
@@ -126,7 +125,7 @@
     convert_to_set_literal.main();
     convert_to_single_quoted_string.main();
     convert_to_spread.main();
-    convert_to_super_initializing_parameter.main();
+    convert_to_super_parameters.main();
     encapsulate_field.main();
     exchange_operands.main();
     flutter_convert_to_children.main();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
index d75d912..5a9faa9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_parameter_required_test.dart
@@ -166,7 +166,7 @@
   }
 
   Future<void> test_function_inPackage_inWorkspace() async {
-    newFile('/home/aaa/lib/a.dart', content: 'void test() {}');
+    newFile2('/home/aaa/lib/a.dart', 'void test() {}');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
@@ -193,7 +193,7 @@
   }
 
   Future<void> test_function_inPackage_outsideWorkspace() async {
-    newFile('/home/bbb/lib/b.dart', content: 'void test() {}');
+    newFile2('/home/bbb/lib/b.dart', 'void test() {}');
 
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_class_to_enum_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_class_to_enum_test.dart
new file mode 100644
index 0000000..b918348
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_class_to_enum_test.dart
@@ -0,0 +1,212 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'fix_processor.dart';
+
+void main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(ConvertClassToEnumBulkTest);
+    defineReflectiveTests(ConvertClassToEnumTest);
+  });
+}
+
+@reflectiveTest
+class ConvertClassToEnumBulkTest extends BulkFixProcessorTest {
+  @override
+  String get lintCode => LintNames.use_enums;
+
+  Future<void> test_multipleClasses() async {
+    await resolveTestCode('''
+class _E {
+  static const _E c0 = _E(0);
+  static const _E c1 = _E(1);
+
+  final int value;
+
+  const _E(this.value);
+}
+
+class E {
+  static const E c0 = E._(0);
+  static const E c1 = E._(1);
+
+  final int value;
+
+  const E._(this.value);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+    await assertHasFix('''
+enum _E {
+  c0(0),
+  c1(1);
+
+  final int value;
+
+  const _E(this.value);
+}
+
+enum E {
+  c0._(0),
+  c1._(1);
+
+  final int value;
+
+  const E._(this.value);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+  }
+}
+
+@reflectiveTest
+class ConvertClassToEnumTest extends FixProcessorLintTest {
+  @override
+  FixKind get kind => DartFixKind.CONVERT_CLASS_TO_ENUM;
+
+  @override
+  String get lintCode => LintNames.use_enums;
+
+  Future<void> test_minimal_intField_privateClass() async {
+    await resolveTestCode('''
+class _E {
+  static const _E c0 = _E(0);
+  static const _E c1 = _E(1);
+
+  final int value;
+
+  const _E(this.value);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+    await assertHasFix('''
+enum _E {
+  c0(0),
+  c1(1);
+
+  final int value;
+
+  const _E(this.value);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+  }
+
+  Future<void> test_minimal_intField_publicClass() async {
+    await resolveTestCode('''
+class E {
+  static const E c0 = E._(0);
+  static const E c1 = E._(1);
+
+  final int value;
+
+  const E._(this.value);
+}
+''');
+    await assertHasFix('''
+enum E {
+  c0._(0),
+  c1._(1);
+
+  final int value;
+
+  const E._(this.value);
+}
+''');
+  }
+
+  Future<void> test_minimal_notIntField_privateClass() async {
+    await resolveTestCode('''
+class _E {
+  static const _E c0 = _E('c0');
+  static const _E c1 = _E('c1');
+
+  final String name;
+
+  const _E(this.name);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+    await assertHasFix('''
+enum _E {
+  c0('c0'),
+  c1('c1');
+
+  final String name;
+
+  const _E(this.name);
+}
+
+var x = [_E.c0, _E.c1];
+''');
+  }
+
+  Future<void> test_minimal_notIntField_publicClass() async {
+    await resolveTestCode('''
+class E {
+  static const E c0 = E._('c0');
+  static const E c1 = E._('c1');
+
+  final String name;
+
+  const E._(this.name);
+}
+''');
+    await assertHasFix('''
+enum E {
+  c0._('c0'),
+  c1._('c1');
+
+  final String name;
+
+  const E._(this.name);
+}
+''');
+  }
+
+  Future<void> test_withReferencedFactoryConstructor() async {
+    await resolveTestCode('''
+class _E {
+  static const _E c0 = _E(0);
+  static const _E c1 = _E(1);
+
+  final int value;
+
+  const _E(this.value);
+
+  factory _E.withValue(int x) => c0;
+}
+
+_E e = _E.withValue(0);
+
+var x = [_E.c0, _E.c1];
+''');
+    await assertHasFix('''
+enum _E {
+  c0(0),
+  c1(1);
+
+  final int value;
+
+  const _E(this.value);
+
+  factory _E.withValue(int x) => c0;
+}
+
+_E e = _E.withValue(0);
+
+var x = [_E.c0, _E.c1];
+''');
+  }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
index 9e78353..7f66a9b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
@@ -60,7 +60,7 @@
   String get lintCode => LintNames.always_use_package_imports;
 
   Future<void> test_relativeImport() async {
-    newFile('$testPackageLibPath/foo.dart', content: '''
+    newFile2('$testPackageLibPath/foo.dart', '''
 class Foo {}
 ''');
     await resolveTestCode('''
@@ -118,7 +118,7 @@
     // This test fails because any attempt to specify a relative path that
     // includes 'lib' (which the lint requires) results in a malformed URI when
     // trying to resolve the import.
-    newFile('$testPackageLibPath/foo/bar.dart', content: '''
+    newFile2('$testPackageLibPath/foo/bar.dart', '''
 class C {}
 ''');
     await resolveTestCode('''
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
index 96d0f22..f989538 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_test.dart
@@ -41,7 +41,7 @@
   FixKind get kind => DartFixKind.CREATE_CONSTRUCTOR;
 
   Future<void> test_inLibrary_insteadOfSyntheticDefault() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: '''
+    var a = newFile2('$testPackageLibPath/a.dart', '''
 /// $_text200
 class A {}
 ''').path;
@@ -61,7 +61,7 @@
   }
 
   Future<void> test_inLibrary_named() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: '''
+    var a = newFile2('$testPackageLibPath/a.dart', '''
 /// $_text200
 class A {}
 ''').path;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
index c06ac62..eb9fe9a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_local_variable_test.dart
@@ -158,13 +158,13 @@
   }
 
   Future<void> test_withImport() async {
-    newFile('$workspaceRootPath/pkg/lib/a/a.dart', content: '''
+    newFile2('$workspaceRootPath/pkg/lib/a/a.dart', '''
 class A {}
 ''');
-    newFile('$workspaceRootPath/pkg/lib/b/b.dart', content: '''
+    newFile2('$workspaceRootPath/pkg/lib/b/b.dart', '''
 class B {}
 ''');
-    newFile('$workspaceRootPath/pkg/lib/c/c.dart', content: '''
+    newFile2('$workspaceRootPath/pkg/lib/c/c.dart', '''
 import 'package:pkg/a/a.dart';
 import 'package:pkg/b/b.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
index 82353b0..aeffff8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
@@ -576,7 +576,7 @@
   }
 
   Future<void> test_addParameter_withImport() async {
-    newFile('$workspaceRootPath/p/lib/d.dart', content: '''
+    newFile2('$workspaceRootPath/p/lib/d.dart', '''
 class D {}
 ''');
     setPackageContent('''
@@ -1356,14 +1356,14 @@
   /// Add the file containing the data used by the data-driven fix with the
   /// given [content].
   void addPackageDataFile(String content) {
-    newFile('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
-        content: content);
+    newFile2('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
+        content);
   }
 
   /// Set the content of the library that defines the element referenced by the
   /// data on which this test is based.
   void setPackageContent(String content) {
-    newFile('$workspaceRootPath/p/lib/lib.dart', content: content);
+    newFile2('$workspaceRootPath/p/lib/lib.dart', content);
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
         ..add(name: 'p', rootPath: '$workspaceRootPath/p'),
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test_support.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test_support.dart
index e26e0061..4da84b2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test_support.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test_support.dart
@@ -26,8 +26,8 @@
   /// Add the file containing the data used by the data-driven fix with the
   /// given [content].
   void addPackageDataFile(String content) {
-    newFile('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
-        content: content);
+    newFile2('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
+        content);
   }
 
   /// Return a code template that will produce the given [text].
@@ -44,7 +44,7 @@
   /// Set the content of the library that defines the element referenced by the
   /// data on which this test is based.
   void setPackageContent(String content) {
-    newFile('$workspaceRootPath/p/lib/lib.dart', content: content);
+    newFile2('$workspaceRootPath/p/lib/lib.dart', content);
     writeTestPackageConfig(
       config: PackageConfigFileBuilder()
         ..add(name: 'p', rootPath: '$workspaceRootPath/p'),
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/element_matcher_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/element_matcher_test.dart
index e7a0f03..327eb16 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/element_matcher_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/element_matcher_test.dart
@@ -366,7 +366,7 @@
 
   Future<void> test_imports_package() async {
     var packageRootPath = '$workspaceRootPath/other';
-    newFile('$packageRootPath/lib/other.dart', content: '');
+    newFile2('$packageRootPath/lib/other.dart', '');
     writeTestPackageConfig(
         config: PackageConfigFileBuilder()
           ..add(name: 'other', rootPath: packageRootPath));
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/sdk_fix_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/sdk_fix_test.dart
index 72a5b03..49604dc 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/sdk_fix_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/sdk_fix_test.dart
@@ -17,8 +17,9 @@
 
 class AbstractSdkFixTest extends DataDrivenFixProcessorTest {
   void addSdkDataFile(String content) {
-    newFile('${sdkRoot.path}/lib/_internal/${TransformSetManager.dataFileName}',
-        content: content);
+    newFile2(
+        '${sdkRoot.path}/lib/_internal/${TransformSetManager.dataFileName}',
+        content);
   }
 
   @override
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
index e6d1f6c..2f7755b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart
@@ -52,7 +52,7 @@
   }
 
   void _addDataFile(String packageName) {
-    newFile('$workspaceRootPath/$packageName/lib/fix_data.yaml', content: '''
+    newFile2('$workspaceRootPath/$packageName/lib/fix_data.yaml', '''
 version: 1
 transforms:
 - title: 'Rename A'
diff --git a/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart b/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
index 75e8a94..db8bd08 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/import_library_project_test.dart
@@ -237,11 +237,11 @@
   Future<void> test_extension_otherPackage_exported_fromSrc() async {
     var pkgRootPath = '$packagesRootPath/aaa';
 
-    newFile('$pkgRootPath/lib/a.dart', content: r'''
+    newFile2('$pkgRootPath/lib/a.dart', r'''
 export 'src/b.dart';
 ''');
 
-    newFile('$pkgRootPath/lib/src/b.dart', content: r'''
+    newFile2('$pkgRootPath/lib/src/b.dart', r'''
 extension IntExtension on int {
   int get foo => 0;
 }
@@ -299,7 +299,7 @@
   }
 
   Future<void> test_lib() async {
-    newFile('$packagesRootPath/my_pkg/lib/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -331,7 +331,7 @@
   }
 
   Future<void> test_lib_extension() async {
-    newFile('$packagesRootPath/my_pkg/lib/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/a.dart', '''
 extension E on int {
   static String m() => '';
 }
@@ -363,7 +363,7 @@
   }
 
   Future<void> test_lib_src() async {
-    newFile('$packagesRootPath/my_pkg/lib/src/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/src/a.dart', '''
 class Test {}
 ''');
 
@@ -718,7 +718,7 @@
 
   Future<void> test_withClass_pub_other_inLib_dependencies() async {
     var aaaRoot = getFolder('$packagesRootPath/aaa');
-    newFile('${aaaRoot.path}/lib/a.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -746,7 +746,7 @@
 
   Future<void> test_withClass_pub_other_inLib_devDependencies() async {
     var aaaRoot = getFolder('$packagesRootPath/aaa');
-    newFile('${aaaRoot.path}/lib/a.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -770,7 +770,7 @@
 
   Future<void> test_withClass_pub_other_inLib_notListed() async {
     var aaaRoot = getFolder('$packagesRootPath/aaa');
-    newFile('${aaaRoot.path}/lib/a.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -793,7 +793,7 @@
 
   Future<void> test_withClass_pub_other_inTest_dependencies() async {
     var aaaRoot = getFolder('$packagesRootPath/aaa');
-    newFile('${aaaRoot.path}/lib/a.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -808,7 +808,7 @@
         ..add(name: 'aaa', rootPath: aaaRoot.path),
     );
 
-    var b = newFile('$testPackageTestPath/b.dart', content: r'''
+    var b = newFile2('$testPackageTestPath/b.dart', r'''
 void f(Test t) {}
 ''');
 
@@ -823,7 +823,7 @@
 
   Future<void> test_withClass_pub_other_inTest_devDependencies() async {
     var aaaRoot = getFolder('$packagesRootPath/aaa');
-    newFile('${aaaRoot.path}/lib/a.dart', content: '''
+    newFile2('${aaaRoot.path}/lib/a.dart', '''
 class Test {}
 ''');
 
@@ -838,7 +838,7 @@
         ..add(name: 'aaa', rootPath: aaaRoot.path),
     );
 
-    var b = newFile('$testPackageTestPath/b.dart', content: r'''
+    var b = newFile2('$testPackageTestPath/b.dart', r'''
 void f(Test t) {}
 ''');
 
@@ -856,7 +856,7 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class Test {}
 ''');
 
@@ -876,7 +876,7 @@
 name: test
 ''');
 
-    newFile('$testPackageTestPath/a.dart', content: r'''
+    newFile2('$testPackageTestPath/a.dart', r'''
 class Test {}
 ''');
 
@@ -891,11 +891,11 @@
 name: test
 ''');
 
-    newFile('$testPackageTestPath/a.dart', content: r'''
+    newFile2('$testPackageTestPath/a.dart', r'''
 class Test {}
 ''');
 
-    var b = newFile('$testPackageTestPath/b.dart', content: r'''
+    var b = newFile2('$testPackageTestPath/b.dart', r'''
 void f(Test t) {}
 ''');
 
@@ -913,7 +913,7 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension IntExtension on int {
   int get foo => 0;
 }
@@ -1225,10 +1225,10 @@
   FixKind get kind => DartFixKind.IMPORT_LIBRARY_PROJECT2;
 
   Future<void> test_lib() async {
-    newFile('$packagesRootPath/my_pkg/lib/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/a.dart', '''
 export 'b.dart';
 ''');
-    newFile('$packagesRootPath/my_pkg/lib/b.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/b.dart', '''
 class Test {}
 ''');
 
@@ -1258,10 +1258,10 @@
   }
 
   Future<void> test_lib_src() async {
-    newFile('$packagesRootPath/my_pkg/lib/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/a.dart', '''
 export 'src/b.dart';
 ''');
-    newFile('$packagesRootPath/my_pkg/lib/src/b.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/src/b.dart', '''
 class Test {}
 ''');
 
@@ -1291,10 +1291,10 @@
   }
 
   Future<void> test_lib_src_extension() async {
-    newFile('$packagesRootPath/my_pkg/lib/a.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/a.dart', '''
 export 'src/b.dart';
 ''');
-    newFile('$packagesRootPath/my_pkg/lib/src/b.dart', content: '''
+    newFile2('$packagesRootPath/my_pkg/lib/src/b.dart', '''
 extension E on int {
   static String m() => '';
 }
@@ -1354,7 +1354,7 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/src/a.dart', content: r'''
+    newFile2('$testPackageLibPath/src/a.dart', r'''
 class Test {}
 ''');
 
@@ -1374,11 +1374,11 @@
 name: test
 ''');
 
-    newFile('$testPackageLibPath/src/a.dart', content: r'''
+    newFile2('$testPackageLibPath/src/a.dart', r'''
 class Test {}
 ''');
 
-    var b = newFile('$testPackageTestPath/b.dart', content: r'''
+    var b = newFile2('$testPackageTestPath/b.dart', r'''
 void f(Test t) {}
 ''');
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart
index 8d5d664..770e2c0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/organize_imports_test.dart
@@ -42,12 +42,12 @@
   }
 
   Future<void> test_organizePathImports() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
 ''');
-    newFile('$testPackageLibPath/a/b.dart', content: '''
+    newFile2('$testPackageLibPath/a/b.dart', '''
 class B {
   static void m() {}
 }
diff --git a/pkg/analysis_server/test/src/services/correction/fix/pubspec/test_support.dart b/pkg/analysis_server/test/src/services/correction/fix/pubspec/test_support.dart
index dcf483f..2f939e1 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/pubspec/test_support.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/pubspec/test_support.dart
@@ -43,7 +43,7 @@
 
   void validatePubspec(String content) {
     this.content = content;
-    var pubspecFile = newFile('/home/test/pubspec.yaml', content: content);
+    var pubspecFile = newFile2('/home/test/pubspec.yaml', content);
     document = loadYamlDocument(content);
     var yamlContent = document.contents;
     if (yamlContent is! YamlMap) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/qualify_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/qualify_reference_test.dart
index 6d3cf03..6c3ee19 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/qualify_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/qualify_reference_test.dart
@@ -43,7 +43,7 @@
   }
 
   Future<void> test_class_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
@@ -60,7 +60,7 @@
   }
 
   Future<void> test_class_importedWithPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
@@ -104,12 +104,12 @@
   }
 
   Future<void> test_class_notImported() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
 ''');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class B extends A {}
 ''');
@@ -148,7 +148,7 @@
   }
 
   Future<void> test_extension_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
@@ -165,7 +165,7 @@
   }
 
   Future<void> test_extension_importedWithPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
@@ -209,12 +209,12 @@
   }
 
   Future<void> test_extension_notImported() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void m() {}
 }
 ''');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 class B extends A {}
 ''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_assignment_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_assignment_test.dart
new file mode 100644
index 0000000..c613d86
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_assignment_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'fix_processor.dart';
+
+void main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(RemoveAssignmentBulkTest);
+    defineReflectiveTests(RemoveAssignmentTest);
+  });
+}
+
+@reflectiveTest
+class RemoveAssignmentBulkTest extends BulkFixProcessorTest {
+  @override
+  String get lintCode => LintNames.unnecessary_null_aware_assignments;
+
+  Future<void> test_singleFile() async {
+    await resolveTestCode('''
+void f() {
+  var x;
+  var y;
+  x ??= null;
+  y ??= null;
+}
+''');
+    await assertHasFix('''
+void f() {
+  var x;
+  var y;
+}
+''');
+  }
+}
+
+@reflectiveTest
+class RemoveAssignmentTest extends FixProcessorLintTest {
+  @override
+  FixKind get kind => DartFixKind.REMOVE_ASSIGNMENT;
+
+  @override
+  String get lintCode => LintNames.unnecessary_null_aware_assignments;
+
+  Future<void> test_assignment() async {
+    await resolveTestCode('''
+void f() {
+  var x;
+  x ??= null;
+}
+''');
+    await assertHasFix('''
+void f() {
+  var x;
+}
+''');
+  }
+
+  Future<void> test_assignment_compound() async {
+    await resolveTestCode('''
+void f(x, y) {
+  y = x ??= null;
+}
+''');
+    await assertHasFix('''
+void f(x, y) {
+  y = x;
+}
+''');
+  }
+
+  Future<void> test_assignment_parenthesized() async {
+    await resolveTestCode('''
+void f(int? x) {
+  (x ??= null);
+}
+''');
+    await assertHasFix('''
+void f(int? x) {
+}
+''');
+  }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
index 4dec631..319a8e9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
@@ -126,7 +126,7 @@
   @FailingTest(issue: 'https://github.com/dart-lang/linter/issues/1997')
   Future<void> test_method_nullSafety_optIn_fromOptOut() async {
     createAnalysisOptionsFile(lints: [lintCode]);
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo() => 0;
 }
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_extension_name_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_extension_name_test.dart
index eaf03e1..809b33f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_extension_name_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_extension_name_test.dart
@@ -62,7 +62,7 @@
   }
 
   Future<void> test_qualified() async {
-    newFile('$testPackageLibPath/ext.dart', content: '''
+    newFile2('$testPackageLibPath/ext.dart', '''
 extension E on String {
   static int m() => 0;
 }
diff --git a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
index 5997525..9478bc2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
@@ -48,6 +48,7 @@
 import 'change_to_static_access_test.dart' as change_to_static_access;
 import 'change_to_test.dart' as change_to;
 import 'change_type_annotation_test.dart' as change_type_annotation;
+import 'convert_class_to_enum_test.dart' as convert_class_to_enum;
 import 'convert_documentation_into_line_test.dart'
     as convert_documentation_into_line;
 import 'convert_flutter_child_test.dart' as convert_flutter_child;
@@ -128,6 +129,7 @@
 import 'remove_abstract_test.dart' as remove_abstract;
 import 'remove_annotation_test.dart' as remove_annotation;
 import 'remove_argument_test.dart' as remove_argument;
+import 'remove_assignment_test.dart' as remove_assignment;
 import 'remove_await_test.dart' as remove_await;
 import 'remove_comparison_test.dart' as remove_comparison;
 import 'remove_const_test.dart' as remove_const;
@@ -262,6 +264,7 @@
     change_to_nearest_precise_value.main();
     change_to_static_access.main();
     change_type_annotation.main();
+    convert_class_to_enum.main();
     convert_documentation_into_line.main();
     convert_flutter_child.main();
     convert_flutter_children.main();
@@ -335,6 +338,7 @@
     remove_abstract.main();
     remove_annotation.main();
     remove_argument.main();
+    remove_assignment.main();
     remove_await.main();
     remove_comparison.main();
     remove_const.main();
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index ccc51f6..a1312a7 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -10,6 +10,8 @@
 * Deprecated `astFactory`, clients should not create AST nodes manually.
 * Changed `CompilationUnit.lineInfo` to be non-nullable.
 * Changed `CompilationUnitElement.lineInfo` to be non-nullable.
+* Deprecated `ResourceProviderMixin.newFile`, use `newFile2` instead.
+* Deprecated `ResourceProviderMixin.newAnalysisOptionsYamlFile`.
 
 ## 3.3.1
 * Report HintCode.OVERRIDE_ON_NON_OVERRIDING_xyz on enum.
diff --git a/pkg/analyzer/lib/dart/analysis/analysis_context.dart b/pkg/analyzer/lib/dart/analysis/analysis_context.dart
index b30e1fc..68fb611 100644
--- a/pkg/analyzer/lib/dart/analysis/analysis_context.dart
+++ b/pkg/analyzer/lib/dart/analysis/analysis_context.dart
@@ -38,5 +38,12 @@
 
   /// Return a [Future] that completes after pending file changes are applied,
   /// so that [currentSession] can be used to compute results.
-  Future<void> applyPendingFileChanges();
+  ///
+  /// The value is the set of all files that are potentially affected by
+  /// the pending changes. This set can be both wider than the set of analyzed
+  /// files (because it may include files imported from other packages, and
+  /// which are on the import path from a changed file to an analyze file),
+  /// and narrower than the set of analyzed files (because only files that
+  /// were previously accessed are considered to be known and affected).
+  Future<List<String>> applyPendingFileChanges();
 }
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index c1d72a8..562528c 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -82,7 +82,7 @@
 /// TODO(scheglov) Clean up the list of implicitly analyzed files.
 class AnalysisDriver implements AnalysisDriverGeneric {
   /// The version of data format, should be incremented on every format change.
-  static const int DATA_VERSION = 209;
+  static const int DATA_VERSION = 210;
 
   static const bool _applyFileChangesSynchronously = true;
 
@@ -145,8 +145,12 @@
   /// The file changes that should be applied before processing requests.
   final List<_FileChange> _pendingFileChanges = [];
 
+  /// When [_applyFileChangesSynchronously] is `true`, affected files are
+  /// accumulated here.
+  Set<String> _accumulatedAffected = {};
+
   /// The completers to complete after [_pendingFileChanges] are applied.
-  final _pendingFileChangesCompleters = <Completer<void>>[];
+  final _pendingFileChangesCompleters = <Completer<List<String>>>[];
 
   /// The mapping from the files for which analysis was requested using
   /// [getResult] to the [Completer]s to report the result.
@@ -453,7 +457,7 @@
     if (file_paths.isDart(resourceProvider.pathContext, path)) {
       _priorityResults.clear();
       if (_applyFileChangesSynchronously) {
-        _removePotentiallyAffectedLibraries(path);
+        _removePotentiallyAffectedLibraries(_accumulatedAffected, path);
         _fileTracker.addFile(path);
       } else {
         _pendingFileChanges.add(
@@ -466,13 +470,22 @@
 
   /// Return a [Future] that completes after pending file changes are applied,
   /// so that [currentSession] can be used to compute results.
-  Future<void> applyPendingFileChanges() {
+  ///
+  /// The value is the set of all files that are potentially affected by
+  /// the pending changes. This set can be both wider than the set of analyzed
+  /// files (because it may include files imported from other packages, and
+  /// which are on the import path from a changed file to an analyze file),
+  /// and narrower than the set of analyzed files (because only files that
+  /// were previously accessed are considered to be known and affected).
+  Future<List<String>> applyPendingFileChanges() {
     if (_pendingFileChanges.isNotEmpty) {
-      var completer = Completer<void>();
+      var completer = Completer<List<String>>();
       _pendingFileChangesCompleters.add(completer);
       return completer.future;
     } else {
-      return Future.value();
+      var accumulatedAffected = _accumulatedAffected.toList();
+      _accumulatedAffected = {};
+      return Future.value(accumulatedAffected);
     }
   }
 
@@ -500,7 +513,7 @@
     if (file_paths.isDart(resourceProvider.pathContext, path)) {
       _priorityResults.clear();
       if (_applyFileChangesSynchronously) {
-        _removePotentiallyAffectedLibraries(path);
+        _removePotentiallyAffectedLibraries(_accumulatedAffected, path);
         _fileTracker.changeFile(path);
       } else {
         _pendingFileChanges.add(
@@ -1386,7 +1399,7 @@
       _lastProducedSignatures.remove(path);
       _priorityResults.clear();
       if (_applyFileChangesSynchronously) {
-        _removePotentiallyAffectedLibraries(path);
+        _removePotentiallyAffectedLibraries(_accumulatedAffected, path);
         _fileTracker.removeFile(path);
       } else {
         _pendingFileChanges.add(
@@ -1464,9 +1477,10 @@
   }
 
   void _applyPendingFileChanges() {
+    var accumulatedAffected = <String>{};
     for (var fileChange in _pendingFileChanges) {
       var path = fileChange.path;
-      _removePotentiallyAffectedLibraries(path);
+      _removePotentiallyAffectedLibraries(accumulatedAffected, path);
       switch (fileChange.kind) {
         case _FileChangeKind.add:
           _fileTracker.addFile(path);
@@ -1485,7 +1499,9 @@
       var completers = _pendingFileChangesCompleters.toList();
       _pendingFileChangesCompleters.clear();
       for (var completer in completers) {
-        completer.complete();
+        completer.complete(
+          accumulatedAffected.toList(),
+        );
       }
     }
   }
@@ -1896,12 +1912,16 @@
         'missing', errorsResult, AnalysisDriverUnitIndexBuilder());
   }
 
-  void _removePotentiallyAffectedLibraries(String path) {
+  void _removePotentiallyAffectedLibraries(
+    Set<String> accumulatedAffected,
+    String path,
+  ) {
     var affected = <FileState>{};
     _fsState.collectAffected(path, affected);
 
     for (var file in affected) {
       file.invalidateLibraryCycle();
+      accumulatedAffected.add(file.path);
     }
 
     _libraryContext?.elementFactory.removeLibraries(
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart b/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
index b00038a..79b54c0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver_based_analysis_context.dart
@@ -55,7 +55,7 @@
   }
 
   @override
-  Future<void> applyPendingFileChanges() {
+  Future<List<String>> applyPendingFileChanges() {
     return driver.applyPendingFileChanges();
   }
 }
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 0f0720a..11e0af2 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -712,6 +712,14 @@
     return true;
   }
 
+  bool get isMacro {
+    return hasModifier(Modifier.MACRO);
+  }
+
+  set isMacro(bool isMacro) {
+    setModifier(Modifier.MACRO, isMacro);
+  }
+
   @override
   bool get isMixinApplication {
     return hasModifier(Modifier.MIXIN_APPLICATION);
@@ -4338,23 +4346,26 @@
   /// Indicates that modifier 'lazy' was applied to the element.
   static const Modifier LATE = Modifier('LATE', 17);
 
+  /// Indicates that a class is a macro builder.
+  static const Modifier MACRO = Modifier('MACRO', 18);
+
   /// Indicates that a class is a mixin application.
-  static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 18);
+  static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 19);
 
   /// Indicates that the pseudo-modifier 'set' was applied to the element.
-  static const Modifier SETTER = Modifier('SETTER', 19);
+  static const Modifier SETTER = Modifier('SETTER', 20);
 
   /// See [TypeParameterizedElement.isSimplyBounded].
-  static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 20);
+  static const Modifier SIMPLY_BOUNDED = Modifier('SIMPLY_BOUNDED', 21);
 
   /// Indicates that the modifier 'static' was applied to the element.
-  static const Modifier STATIC = Modifier('STATIC', 21);
+  static const Modifier STATIC = Modifier('STATIC', 22);
 
   /// Indicates that the element does not appear in the source code but was
   /// implicitly created. For example, if a class does not define any
   /// constructors, an implicit zero-argument constructor will be created and it
   /// will be marked as being synthetic.
-  static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 22);
+  static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 23);
 
   static const List<Modifier> values = [
     ABSTRACT,
@@ -4374,6 +4385,7 @@
     HAS_PART_OF_DIRECTIVE,
     IMPLICIT_TYPE,
     LATE,
+    MACRO,
     MIXIN_APPLICATION,
     SETTER,
     STATIC,
diff --git a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
index f4077d4..eb43608 100644
--- a/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/element/generic_inferrer.dart
@@ -56,12 +56,34 @@
   final Set<TypeParameterElement> _typeParameters = Set.identity();
   final Map<TypeParameterElement, List<_TypeConstraint>> _constraints = {};
 
-  GenericInferrer(
-    this._typeSystem,
-    Iterable<TypeParameterElement> typeFormals,
-  ) {
-    _typeParameters.addAll(typeFormals);
-    for (var formal in typeFormals) {
+  /// The list of type parameters being inferred.
+  final List<TypeParameterElement> _typeFormals;
+
+  /// Indicates whether type parameter bounds should be included in constraints.
+  final bool considerExtendsClause;
+
+  /// The [ErrorReporter] to which inference errors should be reported, or
+  /// `null` if errors shouldn't be reported.
+  final ErrorReporter? errorReporter;
+
+  /// The [AstNode] to which errors should be attached.  May be `null` if errors
+  /// are not being reported (that is, if [errorReporter] is also `null`).
+  final AstNode? errorNode;
+
+  /// Indicates whether the "generic metadata" feature is enabled.  When it is,
+  /// type arguments are allowed to be instantiated with generic function types.
+  final bool genericMetadataIsEnabled;
+
+  GenericInferrer(this._typeSystem, this._typeFormals,
+      {this.considerExtendsClause = true,
+      this.errorReporter,
+      this.errorNode,
+      required this.genericMetadataIsEnabled}) {
+    if (errorReporter != null) {
+      assert(errorNode != null);
+    }
+    _typeParameters.addAll(_typeFormals);
+    for (var formal in _typeFormals) {
       _constraints[formal] = [];
     }
   }
@@ -85,6 +107,24 @@
     tryMatchSubtypeOf(argumentType, parameterType, origin, covariant: false);
   }
 
+  /// Applies all the argument constraints implied by [parameters] and
+  /// [argumentTypes].
+  void constrainArguments(
+      {ClassElement? genericClass,
+      required List<ParameterElement> parameters,
+      required List<DartType> argumentTypes}) {
+    for (int i = 0; i < argumentTypes.length; i++) {
+      // Try to pass each argument to each parameter, recording any type
+      // parameter bounds that were implied by this assignment.
+      constrainArgument(
+        argumentTypes[i],
+        parameters[i].type,
+        parameters[i].name,
+        genericClass: genericClass,
+      );
+    }
+  }
+
   /// Constrain a universal function type [fnType] used in a context
   /// [contextType].
   void constrainGenericFunctionInContext(
@@ -117,67 +157,46 @@
     tryMatchSubtypeOf(declaredType, contextType, origin, covariant: true);
   }
 
-  /// Given the constraints that were given by calling [constrainArgument] and
-  /// [constrainReturnType], find the type arguments for the [typeFormals] that
-  /// satisfies these constraints.
+  /// Performs downwards inference, producing a set of inferred types that may
+  /// contain references to the "unknown type".
+  List<DartType> downwardsInfer() => _chooseTypes(downwardsInferPhase: true);
+
+  /// Tries to make [i1] a subtype of [i2] and accumulate constraints as needed.
   ///
-  /// If [downwardsInferPhase] is set, we are in the first pass of inference,
-  /// pushing context types down. At that point we are allowed to push down
-  /// `_` to precisely represent an unknown type. If [downwardsInferPhase] is
-  /// false, we are on our final inference pass, have all available information
-  /// including argument types, and must not conclude `_` for any type formal.
-  List<DartType>? infer(
-    List<TypeParameterElement> typeFormals, {
-    bool considerExtendsClause = true,
-    ErrorReporter? errorReporter,
-    AstNode? errorNode,
-    bool failAtError = false,
-    bool downwardsInferPhase = false,
-    required bool genericMetadataIsEnabled,
-  }) {
-    // Initialize the inferred type array.
-    //
-    // In the downwards phase, they all start as `_` to offer reasonable
-    // degradation for f-bounded type parameters.
-    var inferredTypes =
-        List<DartType>.filled(typeFormals.length, UnknownInferredType.instance);
-
-    for (int i = 0; i < typeFormals.length; i++) {
-      // TODO (kallentu) : Clean up TypeParameterElementImpl casting once
-      // variance is added to the interface.
-      var typeParam = typeFormals[i] as TypeParameterElementImpl;
-      _TypeConstraint? extendsClause;
-      var bound = typeParam.bound;
-      if (considerExtendsClause && bound != null) {
-        extendsClause = _TypeConstraint.fromExtends(
-          typeParam,
-          bound,
-          Substitution.fromPairs(typeFormals, inferredTypes)
-              .substituteType(bound),
-          isNonNullableByDefault: isNonNullableByDefault,
-        );
+  /// The return value indicates whether the match was successful.  If it was
+  /// unsuccessful, any constraints that were accumulated during the match
+  /// attempt have been rewound (see [_rewindConstraints]).
+  bool tryMatchSubtypeOf(DartType t1, DartType t2, _TypeConstraintOrigin origin,
+      {required bool covariant}) {
+    var gatherer = TypeConstraintGatherer(
+        typeSystem: _typeSystem, typeParameters: _typeParameters);
+    var success = gatherer.trySubtypeMatch(t1, t2, !covariant);
+    if (success) {
+      var constraints = gatherer.computeConstraints();
+      for (var entry in constraints.entries) {
+        if (!entry.value.isEmpty) {
+          var constraint = _constraints[entry.key]!;
+          constraint.add(
+            _TypeConstraint(origin, entry.key,
+                lower: entry.value.lower, upper: entry.value.upper),
+          );
+        }
       }
-
-      var constraints = _constraints[typeParam]!;
-      inferredTypes[i] = downwardsInferPhase
-          ? _inferTypeParameterFromContext(constraints, extendsClause,
-              isContravariant: typeParam.variance.isContravariant)
-          : _inferTypeParameterFromAll(constraints, extendsClause,
-              isContravariant: typeParam.variance.isContravariant,
-              preferUpwardsInference: !typeParam.isLegacyCovariant);
     }
 
-    // If the downwards infer phase has failed, we'll catch this in the upwards
-    // phase later on.
-    if (downwardsInferPhase) {
-      return inferredTypes;
-    }
+    return success;
+  }
 
+  /// Same as [upwardsInfer], but if [failAtError] is `true` (the default) and
+  /// inference fails, returns `null` rather than trying to perform error
+  /// recovery.
+  List<DartType>? tryUpwardsInfer({bool failAtError = true}) {
+    var inferredTypes = _chooseTypes(downwardsInferPhase: false);
     // Check the inferred types against all of the constraints.
     var knownTypes = <TypeParameterElement, DartType>{};
     var hasErrorReported = false;
-    for (int i = 0; i < typeFormals.length; i++) {
-      TypeParameterElement parameter = typeFormals[i];
+    for (int i = 0; i < _typeFormals.length; i++) {
+      TypeParameterElement parameter = _typeFormals[i];
       var constraints = _constraints[parameter]!;
 
       var inferred = inferredTypes[i];
@@ -189,7 +208,7 @@
         var parameterBoundRaw = parameter.bound;
         if (parameterBoundRaw != null) {
           var parameterBound =
-              Substitution.fromPairs(typeFormals, inferredTypes)
+              Substitution.fromPairs(_typeFormals, inferredTypes)
                   .substituteType(parameterBoundRaw);
           parameterBound = _toLegacyElementIfOptOut(parameterBound);
           var extendsConstraint = _TypeConstraint.fromExtends(
@@ -225,7 +244,7 @@
         hasErrorReported = true;
         var typeFormals = inferred.typeFormals;
         var typeFormalsStr = typeFormals.map(_elementStr).join(', ');
-        errorReporter.reportErrorForNode(
+        errorReporter!.reportErrorForNode(
             CompileTimeErrorCode.COULD_NOT_INFER, errorNode!, [
           parameter.name,
           ' Inferred candidate type ${_typeStr(inferred)} has type parameters'
@@ -250,8 +269,8 @@
     }
 
     // Use instantiate to bounds to finish things off.
-    var hasError = List<bool>.filled(typeFormals.length, false);
-    var result = _typeSystem.instantiateTypeFormalsToBounds(typeFormals,
+    var hasError = List<bool>.filled(_typeFormals.length, false);
+    var result = _typeSystem.instantiateTypeFormalsToBounds(_typeFormals,
         hasError: hasError, knownTypes: knownTypes);
 
     // Report any errors from instantiateToBounds.
@@ -259,8 +278,8 @@
       if (hasError[i]) {
         if (failAtError) return null;
         hasErrorReported = true;
-        TypeParameterElement typeParam = typeFormals[i];
-        var typeParamBound = Substitution.fromPairs(typeFormals, inferredTypes)
+        TypeParameterElement typeParam = _typeFormals[i];
+        var typeParamBound = Substitution.fromPairs(_typeFormals, inferredTypes)
             .substituteType(typeParam.bound ?? typeProvider.objectType);
         // TODO(jmesserly): improve this error message.
         errorReporter?.reportErrorForNode(
@@ -277,7 +296,6 @@
       _checkArgumentsNotMatchingBounds(
         errorNode: errorNode,
         errorReporter: errorReporter,
-        typeParameters: typeFormals,
         typeArguments: result,
       );
     }
@@ -286,47 +304,18 @@
     return result;
   }
 
-  /// Tries to make [i1] a subtype of [i2] and accumulate constraints as needed.
-  ///
-  /// The return value indicates whether the match was successful.  If it was
-  /// unsuccessful, any constraints that were accumulated during the match
-  /// attempt have been rewound (see [_rewindConstraints]).
-  bool tryMatchSubtypeOf(DartType t1, DartType t2, _TypeConstraintOrigin origin,
-      {required bool covariant}) {
-    var gatherer = TypeConstraintGatherer(
-      typeSystem: _typeSystem,
-      typeParameters: _typeParameters,
-    );
-    var success = gatherer.trySubtypeMatch(t1, t2, !covariant);
-    if (success) {
-      var constraints = gatherer.computeConstraints();
-      for (var entry in constraints.entries) {
-        if (!entry.value.isEmpty) {
-          var constraint = _constraints[entry.key]!;
-          constraint.add(
-            _TypeConstraint(
-              origin,
-              entry.key,
-              lower: entry.value.lower,
-              upper: entry.value.upper,
-            ),
-          );
-        }
-      }
-    }
-
-    return success;
-  }
+  /// Performs upwards inference, producing a final set of inferred types that
+  /// does not  contain references to the "unknown type".
+  List<DartType> upwardsInfer() => tryUpwardsInfer(failAtError: false)!;
 
   /// Check that inferred [typeArguments] satisfy the [typeParameters] bounds.
   void _checkArgumentsNotMatchingBounds({
     required AstNode? errorNode,
     required ErrorReporter? errorReporter,
-    required List<TypeParameterElement> typeParameters,
     required List<DartType> typeArguments,
   }) {
-    for (int i = 0; i < typeParameters.length; i++) {
-      var parameter = typeParameters[i];
+    for (int i = 0; i < _typeFormals.length; i++) {
+      var parameter = _typeFormals[i];
       var argument = typeArguments[i];
 
       var rawBound = parameter.bound;
@@ -335,7 +324,7 @@
       }
       rawBound = _typeSystem.toLegacyTypeIfOptOut(rawBound);
 
-      var substitution = Substitution.fromPairs(typeParameters, typeArguments);
+      var substitution = Substitution.fromPairs(_typeFormals, typeArguments);
       var bound = substitution.substituteType(rawBound);
       if (!_typeSystem.isSubtypeOf(argument, bound)) {
         errorReporter?.reportErrorForNode(
@@ -438,6 +427,38 @@
     }
   }
 
+  /// Computes (or recomputes) a set of [inferredTypes] based on the constraints
+  /// that have been recorded so far.
+  List<DartType> _chooseTypes({required bool downwardsInferPhase}) {
+    var inferredTypes = List<DartType>.filled(
+        _typeFormals.length, UnknownInferredType.instance);
+    for (int i = 0; i < _typeFormals.length; i++) {
+      // TODO (kallentu) : Clean up TypeParameterElementImpl casting once
+      // variance is added to the interface.
+      var typeParam = _typeFormals[i] as TypeParameterElementImpl;
+      _TypeConstraint? extendsClause;
+      var bound = typeParam.bound;
+      if (considerExtendsClause && bound != null) {
+        extendsClause = _TypeConstraint.fromExtends(
+            typeParam,
+            bound,
+            Substitution.fromPairs(_typeFormals, inferredTypes)
+                .substituteType(bound),
+            isNonNullableByDefault: isNonNullableByDefault);
+      }
+
+      var constraints = _constraints[typeParam]!;
+      inferredTypes[i] = downwardsInferPhase
+          ? _inferTypeParameterFromContext(constraints, extendsClause,
+              isContravariant: typeParam.variance.isContravariant)
+          : _inferTypeParameterFromAll(constraints, extendsClause,
+              isContravariant: typeParam.variance.isContravariant,
+              preferUpwardsInference: !typeParam.isLegacyCovariant);
+    }
+
+    return inferredTypes;
+  }
+
   String _elementStr(Element element) {
     return element.getDisplayString(withNullability: isNonNullableByDefault);
   }
diff --git a/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart b/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
index ccbba42..eed4d97 100644
--- a/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_constraint_gatherer.dart
@@ -47,6 +47,8 @@
     _typeParameters.addAll(typeParameters);
   }
 
+  bool get isConstraintSetEmpty => _constraints.isEmpty;
+
   DartType get _defaultTypeParameterBound {
     if (_typeSystem.isNonNullableByDefault) {
       return _typeSystem.objectQuestion;
diff --git a/pkg/analyzer/lib/src/dart/element/type_system.dart b/pkg/analyzer/lib/src/dart/element/type_system.dart
index 9097f205..10f80f7 100644
--- a/pkg/analyzer/lib/src/dart/element/type_system.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_system.dart
@@ -425,13 +425,9 @@
   /// Given a generic function type `F<T0, T1, ... Tn>` and a context type C,
   /// infer an instantiation of F, such that `F<S0, S1, ..., Sn>` <: C.
   ///
-  /// This is similar to [inferGenericFunctionOrType], but the return type is
+  /// This is similar to [setupGenericTypeInference], but the return type is
   /// also considered as part of the solution.
-  ///
-  /// If this function is called with a [contextType] that is also
-  /// uninstantiated, or a [fnType] that is already instantiated, it will have
-  /// no effect and return `null`.
-  List<DartType>? inferFunctionTypeInstantiation(
+  List<DartType> inferFunctionTypeInstantiation(
     FunctionType contextType,
     FunctionType fnType, {
     ErrorReporter? errorReporter,
@@ -446,87 +442,14 @@
     // inferred. It will optimistically assume these type parameters can be
     // subtypes (or supertypes) as necessary, and track the constraints that
     // are implied by this.
-    var inferrer = GenericInferrer(this, fnType.typeFormals);
+    var inferrer = GenericInferrer(this, fnType.typeFormals,
+        errorReporter: errorReporter,
+        errorNode: errorNode,
+        genericMetadataIsEnabled: genericMetadataIsEnabled);
     inferrer.constrainGenericFunctionInContext(fnType, contextType);
 
     // Infer and instantiate the resulting type.
-    return inferrer.infer(
-      fnType.typeFormals,
-      errorReporter: errorReporter,
-      errorNode: errorNode,
-      genericMetadataIsEnabled: genericMetadataIsEnabled,
-    );
-  }
-
-  /// Infers type arguments for a generic type, function, method, or
-  /// list/map literal, using the downward context type as well as the
-  /// argument types if available.
-  ///
-  /// For example, given a function type with generic type parameters, this
-  /// infers the type parameters from the actual argument types, and returns the
-  /// instantiated function type.
-  ///
-  /// Concretely, given a function type with parameter types P0, P1, ... Pn,
-  /// result type R, and generic type parameters T0, T1, ... Tm, use the
-  /// argument types A0, A1, ... An to solve for the type parameters.
-  ///
-  /// For each parameter Pi, we want to ensure that Ai <: Pi. We can do this by
-  /// running the subtype algorithm, and when we reach a type parameter Tj,
-  /// recording the lower or upper bound it must satisfy. At the end, all
-  /// constraints can be combined to determine the type.
-  ///
-  /// All constraints on each type parameter Tj are tracked, as well as where
-  /// they originated, so we can issue an error message tracing back to the
-  /// argument values, type parameter "extends" clause, or the return type
-  /// context.
-  List<DartType>? inferGenericFunctionOrType({
-    ClassElement? genericClass,
-    required List<TypeParameterElement> typeParameters,
-    required List<ParameterElement> parameters,
-    required DartType declaredReturnType,
-    required List<DartType> argumentTypes,
-    required DartType? contextReturnType,
-    ErrorReporter? errorReporter,
-    AstNode? errorNode,
-    bool downwards = false,
-    bool isConst = false,
-    required bool genericMetadataIsEnabled,
-  }) {
-    if (typeParameters.isEmpty) {
-      return null;
-    }
-
-    // Create a TypeSystem that will allow certain type parameters to be
-    // inferred. It will optimistically assume these type parameters can be
-    // subtypes (or supertypes) as necessary, and track the constraints that
-    // are implied by this.
-    var inferrer = GenericInferrer(this, typeParameters);
-
-    if (contextReturnType != null) {
-      if (isConst) {
-        contextReturnType = eliminateTypeVariables(contextReturnType);
-      }
-      inferrer.constrainReturnType(declaredReturnType, contextReturnType);
-    }
-
-    for (int i = 0; i < argumentTypes.length; i++) {
-      // Try to pass each argument to each parameter, recording any type
-      // parameter bounds that were implied by this assignment.
-      inferrer.constrainArgument(
-        argumentTypes[i],
-        parameters[i].type,
-        parameters[i].name,
-        genericClass: genericClass,
-      );
-    }
-
-    return inferrer.infer(
-      typeParameters,
-      errorReporter: errorReporter,
-      errorNode: errorNode,
-      downwardsInferPhase: downwards,
-      genericMetadataIsEnabled: genericMetadataIsEnabled,
-    );
+    return inferrer.upwardsInfer();
   }
 
   /// Given a [DartType] [type], if [type] is an uninstantiated
@@ -1295,19 +1218,18 @@
     required bool genericMetadataIsEnabled,
   }) {
     var typeParameters = mixinElement.typeParameters;
-    var inferrer = GenericInferrer(this, typeParameters);
+    var inferrer = GenericInferrer(this, typeParameters,
+        considerExtendsClause: false,
+        genericMetadataIsEnabled: genericMetadataIsEnabled);
     for (int i = 0; i < srcTypes.length; i++) {
       inferrer.constrainReturnType(srcTypes[i], destTypes[i]);
       inferrer.constrainReturnType(destTypes[i], srcTypes[i]);
     }
 
-    var inferredTypes = inferrer.infer(
-      typeParameters,
-      considerExtendsClause: false,
-      genericMetadataIsEnabled: genericMetadataIsEnabled,
-    )!;
-    inferredTypes =
-        inferredTypes.map(_removeBoundsOfGenericFunctionTypes).toList();
+    var inferredTypes = inferrer
+        .upwardsInfer()
+        .map(_removeBoundsOfGenericFunctionTypes)
+        .toList();
     var substitution = Substitution.fromPairs(typeParameters, inferredTypes);
 
     for (int i = 0; i < srcTypes.length; i++) {
@@ -1568,6 +1490,36 @@
     return RuntimeTypeEqualityHelper(this).equal(T1, T2);
   }
 
+  /// Prepares to infer type arguments for a generic type, function, method, or
+  /// list/map literal, initializing a [GenericInferrer] using the downward
+  /// context type.
+  GenericInferrer setupGenericTypeInference(
+      {required List<TypeParameterElement> typeParameters,
+      required DartType declaredReturnType,
+      required DartType? contextReturnType,
+      ErrorReporter? errorReporter,
+      AstNode? errorNode,
+      required bool genericMetadataIsEnabled,
+      bool isConst = false}) {
+    // Create a GenericInferrer that will allow certain type parameters to be
+    // inferred. It will optimistically assume these type parameters can be
+    // subtypes (or supertypes) as necessary, and track the constraints that
+    // are implied by this.
+    var inferrer = GenericInferrer(this, typeParameters,
+        errorReporter: errorReporter,
+        errorNode: errorNode,
+        genericMetadataIsEnabled: genericMetadataIsEnabled);
+
+    if (contextReturnType != null) {
+      if (isConst) {
+        contextReturnType = eliminateTypeVariables(contextReturnType);
+      }
+      inferrer.constrainReturnType(declaredReturnType, contextReturnType);
+    }
+
+    return inferrer;
+  }
+
   /// If a legacy library, return the legacy version of the [type].
   /// Otherwise, return the original type.
   DartType toLegacyTypeIfOptOut(DartType type) {
diff --git a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
index 5d26817..0d09988 100644
--- a/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/applicable_extensions.dart
@@ -196,24 +196,21 @@
       var freshTypeParameters = freshTypes.freshTypeParameters;
       var rawExtendedType = freshTypes.substitute(extension.extendedType);
 
-      var inferrer = GenericInferrer(typeSystem, freshTypeParameters);
+      var inferrer = GenericInferrer(typeSystem, freshTypeParameters,
+          genericMetadataIsEnabled: genericMetadataIsEnabled);
       inferrer.constrainArgument(
         targetType,
         rawExtendedType,
         'extendedType',
       );
-      var typeArguments = inferrer.infer(
-        freshTypeParameters,
-        failAtError: true,
-        genericMetadataIsEnabled: genericMetadataIsEnabled,
-      );
-      if (typeArguments == null) {
+      var inferredTypes = inferrer.tryUpwardsInfer();
+      if (inferredTypes == null) {
         continue;
       }
 
       var substitution = Substitution.fromPairs(
         extension.typeParameters,
-        typeArguments,
+        inferredTypes,
       );
       var extendedType = substitution.substituteType(
         extension.extendedType,
diff --git a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
index 15862ca..0e5d140 100644
--- a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart
@@ -343,18 +343,16 @@
         return _listOfDynamic(typeParameters);
       }
     } else {
-      var inferrer = GenericInferrer(_typeSystem, typeParameters);
+      var inferrer = GenericInferrer(_typeSystem, typeParameters,
+          errorReporter: _errorReporter,
+          errorNode: node.extensionName,
+          genericMetadataIsEnabled: _genericMetadataIsEnabled);
       inferrer.constrainArgument(
         receiverType,
         element.extendedType,
         'extendedType',
       );
-      return inferrer.infer(
-        typeParameters,
-        errorReporter: _errorReporter,
-        errorNode: node.extensionName,
-        genericMetadataIsEnabled: _genericMetadataIsEnabled,
-      );
+      return inferrer.upwardsInfer();
     }
   }
 
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
index 945c794..80295e6 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
@@ -133,7 +133,7 @@
         errorReporter: _errorReporter,
         errorNode: expression,
         genericMetadataIsEnabled: _genericMetadataIsEnabled,
-      )!;
+      );
       identifier.tearOffTypeArgumentTypes = typeArguments;
       if (typeArguments.isNotEmpty) {
         return tearOffType.instantiate(typeArguments);
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
index 3d3278b..01e63e9 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
@@ -8,6 +8,7 @@
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
 import 'package:analyzer/src/dart/ast/extensions.dart';
+import 'package:analyzer/src/dart/element/generic_inferrer.dart';
 import 'package:analyzer/src/dart/element/member.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_algebra.dart';
@@ -97,6 +98,7 @@
 
     List<DartType>? typeArgumentTypes;
     FunctionType? invokeType;
+    GenericInferrer? inferrer;
     if (_isGenericInferenceDisabled(resolver)) {
       if (rawType != null && rawType.typeFormals.isNotEmpty) {
         typeArgumentTypes = List.filled(
@@ -156,21 +158,17 @@
       rawType = getFreshTypeParameters(rawType.typeFormals)
           .applyToFunctionType(rawType);
 
-      var downwardsTypeArguments =
-          resolver.typeSystem.inferGenericFunctionOrType(
+      inferrer = resolver.typeSystem.setupGenericTypeInference(
         typeParameters: rawType.typeFormals,
-        parameters: const <ParameterElement>[],
         declaredReturnType: rawType.returnType,
-        argumentTypes: const <DartType>[],
         contextReturnType: contextType,
-        downwards: true,
         isConst: _getIsConst(node),
         errorReporter: resolver.errorReporter,
         errorNode: _getErrorNode(node),
         genericMetadataIsEnabled: resolver.genericMetadataIsEnabled,
-      )!;
+      );
 
-      invokeType = rawType.instantiate(downwardsTypeArguments);
+      invokeType = rawType.instantiate(inferrer.downwardsInfer());
     }
 
     super.resolveInvocation(
@@ -182,7 +180,7 @@
 
     var argumentList = _getArgumentList(node);
 
-    if (typeArgumentTypes == null) {
+    if (inferrer != null) {
       if (rawType != null) {
         // Get the parameters that correspond to the uninstantiated generic.
         List<ParameterElement?> rawParameters =
@@ -200,17 +198,9 @@
             argTypes.add(argumentList.arguments[i].typeOrThrow);
           }
         }
-        typeArgumentTypes = resolver.typeSystem.inferGenericFunctionOrType(
-          typeParameters: rawType.typeFormals,
-          parameters: params,
-          declaredReturnType: rawType.returnType,
-          argumentTypes: argTypes,
-          contextReturnType: contextType,
-          isConst: _getIsConst(node),
-          errorReporter: resolver.errorReporter,
-          errorNode: _getErrorNode(node),
-          genericMetadataIsEnabled: resolver.genericMetadataIsEnabled,
-        )!;
+        inferrer.constrainArguments(
+            parameters: params, argumentTypes: argTypes);
+        typeArgumentTypes = inferrer.upwardsInfer();
         invokeType = rawType.instantiate(typeArgumentTypes);
       } else {
         typeArgumentTypes = const [];
diff --git a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
index 5063c86..1d564ff 100644
--- a/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/named_type_resolver.dart
@@ -172,14 +172,13 @@
       if (typeParameters.isEmpty) {
         return element.thisType;
       } else {
-        var typeArguments = typeSystem.inferGenericFunctionOrType(
+        var inferrer = typeSystem.setupGenericTypeInference(
           typeParameters: typeParameters,
-          parameters: const [],
           declaredReturnType: element.thisType,
-          argumentTypes: const [],
           contextReturnType: enclosingClass!.thisType,
           genericMetadataIsEnabled: _genericMetadataIsEnabled,
-        )!;
+        );
+        var typeArguments = inferrer.upwardsInfer();
         return element.instantiate(
           typeArguments: typeArguments,
           nullabilitySuffix: _noneOrStarSuffix,
diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
index 660a6eb..747b7f0 100644
--- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
@@ -11,6 +11,7 @@
 import 'package:analyzer/src/dart/ast/ast.dart';
 import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/src/dart/element/generic_inferrer.dart';
 import 'package:analyzer/src/dart/element/type.dart';
 import 'package:analyzer/src/dart/element/type_provider.dart';
 import 'package:analyzer/src/dart/element/type_system.dart';
@@ -98,6 +99,7 @@
   void resolveListLiteral(ListLiteralImpl node,
       {required DartType? contextType}) {
     InterfaceType? listType;
+    GenericInferrer? inferrer;
 
     var typeArguments = node.typeArguments?.arguments;
     if (typeArguments != null) {
@@ -108,8 +110,12 @@
         }
       }
     } else {
-      listType =
-          _inferListType(node, downwards: true, contextType: contextType);
+      inferrer = _inferListTypeDownwards(node, contextType: contextType);
+      if (contextType != null) {
+        var typeArguments = inferrer.downwardsInfer();
+        listType = _typeProvider.listElement.instantiate(
+            typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix);
+      }
     }
     CollectionLiteralContext? context;
     if (listType != null) {
@@ -121,7 +127,7 @@
 
     node.typeArguments?.accept(_resolver);
     _resolveElements(node.elements, context);
-    _resolveListLiteral2(node, contextType: contextType);
+    _resolveListLiteral2(inferrer, node, contextType: contextType);
   }
 
   void resolveSetOrMapLiteral(SetOrMapLiteral node,
@@ -130,6 +136,7 @@
     var typeArguments = node.typeArguments?.arguments;
 
     InterfaceType? literalType;
+    GenericInferrer? inferrer;
     var literalResolution =
         _computeSetOrMapResolution(node, contextType: contextType);
     if (literalResolution.kind == _LiteralResolutionKind.set) {
@@ -137,8 +144,13 @@
         var elementType = typeArguments[0].typeOrThrow;
         literalType = _typeProvider.setType(elementType);
       } else {
-        literalType =
-            _inferSetTypeDownwards(node, literalResolution.contextType);
+        inferrer = _inferSetTypeDownwards(node, literalResolution.contextType);
+        if (literalResolution.contextType != null) {
+          var typeArguments = inferrer.downwardsInfer();
+          literalType = _typeProvider.setElement.instantiate(
+              typeArguments: typeArguments,
+              nullabilitySuffix: _noneOrStarSuffix);
+        }
       }
     } else if (literalResolution.kind == _LiteralResolutionKind.map) {
       if (typeArguments != null && typeArguments.length == 2) {
@@ -146,8 +158,13 @@
         var valueType = typeArguments[1].typeOrThrow;
         literalType = _typeProvider.mapType(keyType, valueType);
       } else {
-        literalType =
-            _inferMapTypeDownwards(node, literalResolution.contextType);
+        inferrer = _inferMapTypeDownwards(node, literalResolution.contextType);
+        if (literalResolution.contextType != null) {
+          var typeArguments = inferrer.downwardsInfer();
+          literalType = _typeProvider.mapElement.instantiate(
+              typeArguments: typeArguments,
+              nullabilitySuffix: _noneOrStarSuffix);
+        }
       }
     } else {
       assert(literalResolution.kind == _LiteralResolutionKind.ambiguous);
@@ -182,7 +199,8 @@
 
     node.typeArguments?.accept(_resolver);
     _resolveElements(node.elements, context);
-    _resolveSetOrMapLiteral2(node, contextType: contextType);
+    _resolveSetOrMapLiteral2(inferrer, literalResolution, node,
+        contextType: contextType);
   }
 
   DartType _computeElementType(CollectionElement element) {
@@ -450,30 +468,37 @@
     }
   }
 
-  InterfaceType? _inferListType(ListLiteral node,
-      {bool downwards = false, required DartType? contextType}) {
+  GenericInferrer _inferListTypeDownwards(ListLiteral node,
+      {required DartType? contextType}) {
+    var element = _typeProvider.listElement;
+    var typeParameters = element.typeParameters;
+
+    return _typeSystem.setupGenericTypeInference(
+        typeParameters: typeParameters,
+        declaredReturnType: element.thisType,
+        contextReturnType: contextType,
+        isConst: node.isConst,
+        errorReporter: _errorReporter,
+        errorNode: node,
+        genericMetadataIsEnabled: _genericMetadataIsEnabled);
+  }
+
+  InterfaceType? _inferListTypeUpwards(
+      GenericInferrer inferrer, ListLiteral node,
+      {required DartType? contextType}) {
     var element = _typeProvider.listElement;
     var typeParameters = element.typeParameters;
     var genericElementType = typeParameters[0].instantiate(
       nullabilitySuffix: _noneOrStarSuffix,
     );
 
-    List<DartType> elementTypes;
-    List<ParameterElement> parameters;
-
-    if (downwards) {
-      if (contextType == null) {
-        return null;
-      }
-      elementTypes = [];
-      parameters = [];
-    } else {
-      // Also use upwards information to infer the type.
-      elementTypes = _getListElements(node).map(_computeElementType).toList();
-      var syntheticParameter = ParameterElementImpl.synthetic(
-          'element', genericElementType, ParameterKind.POSITIONAL);
-      parameters = List.filled(elementTypes.length, syntheticParameter);
-    }
+    // Also use upwards information to infer the type.
+    List<DartType> elementTypes =
+        _getListElements(node).map(_computeElementType).toList();
+    var syntheticParameter = ParameterElementImpl.synthetic(
+        'element', genericElementType, ParameterKind.POSITIONAL);
+    List<ParameterElement> parameters =
+        List.filled(elementTypes.length, syntheticParameter);
     if (_strictInference && parameters.isEmpty && contextType == null) {
       // We cannot infer the type of a collection literal with no elements, and
       // no context type. If there are any elements, inference has not failed,
@@ -482,50 +507,29 @@
           HintCode.INFERENCE_FAILURE_ON_COLLECTION_LITERAL, node, ['List']);
     }
 
-    var typeArguments = _typeSystem.inferGenericFunctionOrType(
-      typeParameters: typeParameters,
-      parameters: parameters,
-      declaredReturnType: element.thisType,
-      argumentTypes: elementTypes,
-      contextReturnType: contextType,
-      downwards: downwards,
-      isConst: node.isConst,
-      errorReporter: _errorReporter,
-      errorNode: node,
-      genericMetadataIsEnabled: _genericMetadataIsEnabled,
-    )!;
+    inferrer.constrainArguments(
+        parameters: parameters, argumentTypes: elementTypes);
+    var typeArguments = inferrer.upwardsInfer();
     return element.instantiate(
       typeArguments: typeArguments,
       nullabilitySuffix: _noneOrStarSuffix,
     );
   }
 
-  InterfaceType? _inferMapTypeDownwards(
+  GenericInferrer _inferMapTypeDownwards(
       SetOrMapLiteral node, DartType? contextType) {
-    if (contextType == null) {
-      return null;
-    }
-
     var element = _typeProvider.mapElement;
-    var typeArguments = _typeSystem.inferGenericFunctionOrType(
+    return _typeSystem.setupGenericTypeInference(
       typeParameters: element.typeParameters,
-      parameters: const [],
       declaredReturnType: element.thisType,
-      argumentTypes: const [],
       contextReturnType: contextType,
-      downwards: true,
       isConst: node.isConst,
-      errorReporter: _errorReporter,
-      errorNode: node,
       genericMetadataIsEnabled: _genericMetadataIsEnabled,
-    )!;
-    return element.instantiate(
-      typeArguments: typeArguments,
-      nullabilitySuffix: _noneOrStarSuffix,
     );
   }
 
-  DartType _inferSetOrMapLiteralType(SetOrMapLiteral literal) {
+  DartType _inferSetOrMapLiteralType(GenericInferrer? inferrer,
+      _LiteralResolution literalResolution, SetOrMapLiteral literal) {
     var literalImpl = literal as SetOrMapLiteralImpl;
     var contextType = literalImpl.contextType;
     literalImpl.contextType = null; // Not needed anymore.
@@ -545,9 +549,9 @@
       mustBeASet = mustBeASet || inferredType.mustBeSet;
     }
     if (canBeASet && mustBeASet) {
-      return _toSetType(literal, contextType, inferredTypes);
+      return _toSetType(inferrer, literalResolution, literal, inferredTypes);
     } else if (canBeAMap && mustBeAMap) {
-      return _toMapType(literal, contextType, inferredTypes);
+      return _toMapType(inferrer, literalResolution, literal, inferredTypes);
     }
 
     // Note: according to the spec, the following computations should be based
@@ -568,12 +572,12 @@
 
       // When `S` implements `Iterable` but not `Map`, `e` is a set literal.
       if (contextIsIterable && !contextIsMap) {
-        return _toSetType(literal, contextType, inferredTypes);
+        return _toSetType(inferrer, literalResolution, literal, inferredTypes);
       }
 
       // When `S` implements `Map` but not `Iterable`, `e` is a map literal.
       if (contextIsMap && !contextIsIterable) {
-        return _toMapType(literal, contextType, inferredTypes);
+        return _toMapType(inferrer, literalResolution, literal, inferredTypes);
       }
     }
 
@@ -599,28 +603,15 @@
     return _typeProvider.dynamicType;
   }
 
-  InterfaceType? _inferSetTypeDownwards(
+  GenericInferrer _inferSetTypeDownwards(
       SetOrMapLiteral node, DartType? contextType) {
-    if (contextType == null) {
-      return null;
-    }
-
     var element = _typeProvider.setElement;
-    var typeArguments = _typeSystem.inferGenericFunctionOrType(
+    return _typeSystem.setupGenericTypeInference(
       typeParameters: element.typeParameters,
-      parameters: const [],
       declaredReturnType: element.thisType,
-      argumentTypes: const [],
       contextReturnType: contextType,
-      downwards: true,
       isConst: node.isConst,
-      errorReporter: _errorReporter,
-      errorNode: node,
       genericMetadataIsEnabled: _genericMetadataIsEnabled,
-    )!;
-    return element.instantiate(
-      typeArguments: typeArguments,
-      nullabilitySuffix: _noneOrStarSuffix,
     );
   }
 
@@ -631,7 +622,7 @@
     }
   }
 
-  void _resolveListLiteral2(ListLiteralImpl node,
+  void _resolveListLiteral2(GenericInferrer? inferrer, ListLiteralImpl node,
       {required DartType? contextType}) {
     var typeArguments = node.typeArguments?.arguments;
 
@@ -651,7 +642,8 @@
     DartType listDynamicType = _typeProvider.listType(_dynamicType);
 
     // If there are no type arguments, try to infer some arguments.
-    var inferred = _inferListType(node, contextType: contextType);
+    var inferred =
+        _inferListTypeUpwards(inferrer!, node, contextType: contextType);
 
     if (inferred != listDynamicType) {
       // TODO(brianwilkerson) Determine whether we need to make the inferred
@@ -664,7 +656,8 @@
     node.staticType = listDynamicType;
   }
 
-  void _resolveSetOrMapLiteral2(SetOrMapLiteralImpl node,
+  void _resolveSetOrMapLiteral2(GenericInferrer? inferrer,
+      _LiteralResolution literalResolution, SetOrMapLiteralImpl node,
       {required DartType? contextType}) {
     var typeArguments = node.typeArguments?.arguments;
 
@@ -693,7 +686,8 @@
       // If we get here, then a nonsense number of type arguments were provided,
       // so treat it as though no type arguments were provided.
     }
-    DartType literalType = _inferSetOrMapLiteralType(node);
+    DartType literalType =
+        _inferSetOrMapLiteralType(inferrer, literalResolution, node);
     if (literalType.isDynamic) {
       // The literal is ambiguous, and further analysis won't resolve the
       // ambiguity.  Leave it as neither a set nor a map.
@@ -720,7 +714,10 @@
     node.staticType = literalType;
   }
 
-  DartType _toMapType(SetOrMapLiteral node, DartType? contextType,
+  DartType _toMapType(
+      GenericInferrer? inferrer,
+      _LiteralResolution literalResolution,
+      SetOrMapLiteral node,
       List<_InferredCollectionElementTypeInformation> inferredTypes) {
     DartType dynamicType = _typeProvider.dynamicType;
 
@@ -744,21 +741,25 @@
       argumentTypes.add(inferredTypes[i].valueType ?? dynamicType);
     }
 
-    var typeArguments = _typeSystem.inferGenericFunctionOrType(
-      typeParameters: typeParameters,
+    if (inferrer == null ||
+        literalResolution.kind == _LiteralResolutionKind.set) {
+      inferrer = _inferMapTypeDownwards(node, null);
+    }
+    inferrer.constrainArguments(
       parameters: parameters,
-      declaredReturnType: element.thisType,
       argumentTypes: argumentTypes,
-      contextReturnType: contextType,
-      genericMetadataIsEnabled: _genericMetadataIsEnabled,
-    )!;
+    );
+    var typeArguments = inferrer.upwardsInfer();
     return element.instantiate(
       typeArguments: typeArguments,
       nullabilitySuffix: _noneOrStarSuffix,
     );
   }
 
-  DartType _toSetType(SetOrMapLiteral node, DartType? contextType,
+  DartType _toSetType(
+      GenericInferrer? inferrer,
+      _LiteralResolution literalResolution,
+      SetOrMapLiteral node,
       List<_InferredCollectionElementTypeInformation> inferredTypes) {
     DartType dynamicType = _typeProvider.dynamicType;
 
@@ -776,18 +777,15 @@
       argumentTypes.add(inferredTypes[i].elementType ?? dynamicType);
     }
 
-    var typeArguments = _typeSystem.inferGenericFunctionOrType(
-      typeParameters: typeParameters,
-      parameters: parameters,
-      declaredReturnType: element.thisType,
-      argumentTypes: argumentTypes,
-      contextReturnType: contextType,
-      genericMetadataIsEnabled: _genericMetadataIsEnabled,
-    )!;
+    if (inferrer == null ||
+        literalResolution.kind == _LiteralResolutionKind.map) {
+      inferrer = _inferSetTypeDownwards(node, null);
+    }
+    inferrer.constrainArguments(
+        parameters: parameters, argumentTypes: argumentTypes);
+    var typeArguments = inferrer.upwardsInfer();
     return element.instantiate(
-      typeArguments: typeArguments,
-      nullabilitySuffix: _noneOrStarSuffix,
-    );
+        typeArguments: typeArguments, nullabilitySuffix: _noneOrStarSuffix);
   }
 }
 
diff --git a/pkg/analyzer/lib/src/error/literal_element_verifier.dart b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
index 05ee001..4cb6aef 100644
--- a/pkg/analyzer/lib/src/error/literal_element_verifier.dart
+++ b/pkg/analyzer/lib/src/error/literal_element_verifier.dart
@@ -211,7 +211,7 @@
             errorReporter: errorReporter,
             errorNode: expression,
             genericMetadataIsEnabled: true,
-          )!;
+          );
           if (typeArguments.isNotEmpty) {
             tearoffType = tearoffType.instantiate(typeArguments);
           }
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 01ff198..a407d52 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -2451,7 +2451,7 @@
             errorReporter: errorReporter,
             errorNode: node.iterable,
             genericMetadataIsEnabled: true,
-          )!;
+          );
           if (typeArguments.isNotEmpty) {
             tearoffType = tearoffType.instantiate(typeArguments);
           }
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 92f03a7..d5dbff1 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -664,7 +664,7 @@
       // If the constructor-tearoffs feature is enabled, then so is
       // generic-metadata.
       genericMetadataIsEnabled: true,
-    )!;
+    );
     if (typeArgumentTypes.isNotEmpty) {
       staticType = staticType.instantiate(typeArgumentTypes);
     }
@@ -2577,7 +2577,7 @@
         // If the constructor-tearoffs feature is enabled, then so is
         // generic-metadata.
         genericMetadataIsEnabled: true,
-      )!;
+      );
       if (typeArgumentTypes.isNotEmpty) {
         callMethodType = callMethodType.instantiate(typeArgumentTypes);
       }
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index a8fdcde..18a8a06 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -98,6 +98,7 @@
 
     var element = ClassElementImpl(name, nameNode.offset);
     element.isAbstract = node.isAbstract;
+    element.isMacro = node.macroKeyword != null;
     element.metadata = _buildAnnotations(node.metadata);
     _setCodeRange(element, node);
     _setDocumentation(element, node);
@@ -130,6 +131,7 @@
 
     var element = ClassElementImpl(name, nameNode.offset);
     element.isAbstract = node.isAbstract;
+    element.isMacro = node.macroKeyword != null;
     element.isMixinApplication = true;
     element.metadata = _buildAnnotations(node.metadata);
     _setCodeRange(element, node);
diff --git a/pkg/analyzer/lib/src/summary2/element_flags.dart b/pkg/analyzer/lib/src/summary2/element_flags.dart
index 201c671..945b4ab 100644
--- a/pkg/analyzer/lib/src/summary2/element_flags.dart
+++ b/pkg/analyzer/lib/src/summary2/element_flags.dart
@@ -8,12 +8,14 @@
 
 class ClassElementFlags {
   static const int _isAbstract = 1 << 0;
-  static const int _isMixinApplication = 1 << 1;
-  static const int _isSimplyBounded = 1 << 2;
+  static const int _isMacro = 1 << 1;
+  static const int _isMixinApplication = 1 << 2;
+  static const int _isSimplyBounded = 1 << 3;
 
   static void read(SummaryDataReader reader, ClassElementImpl element) {
     var byte = reader.readByte();
     element.isAbstract = (byte & _isAbstract) != 0;
+    element.isMacro = (byte & _isMacro) != 0;
     element.isMixinApplication = (byte & _isMixinApplication) != 0;
     element.isSimplyBounded = (byte & _isSimplyBounded) != 0;
   }
@@ -21,6 +23,7 @@
   static void write(BufferedSink sink, ClassElementImpl element) {
     var result = 0;
     result |= element.isAbstract ? _isAbstract : 0;
+    result |= element.isMacro ? _isMacro : 0;
     result |= element.isMixinApplication ? _isMixinApplication : 0;
     result |= element.isSimplyBounded ? _isSimplyBounded : 0;
     sink.writeByte(result);
diff --git a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
index 867272e..d74721d 100644
--- a/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
+++ b/pkg/analyzer/lib/src/test_utilities/resource_provider_mixin.dart
@@ -64,22 +64,32 @@
     resourceProvider.modifyFile(convertedPath, content);
   }
 
+  @Deprecated('Use newAnalysisOptionsYamlFile2() instead')
   File newAnalysisOptionsYamlFile(String directoryPath, {String content = ''}) {
+    return newAnalysisOptionsYamlFile2(directoryPath, content);
+  }
+
+  File newAnalysisOptionsYamlFile2(String directoryPath, String content) {
     String path = join(directoryPath, file_paths.analysisOptionsYaml);
-    return newFile(path, content: content);
+    return newFile2(path, content);
   }
 
   File newBazelBuildFile(String directoryPath, String content) {
     String path = join(directoryPath, file_paths.bazelBuild);
-    return newFile(path, content: content);
+    return newFile2(path, content);
   }
 
-  File newDotPackagesFile(String directoryPath, {String content = ''}) {
+  File newDotPackagesFile(String directoryPath, String content) {
     String path = join(directoryPath, file_paths.dotPackages);
-    return newFile(path, content: content);
+    return newFile2(path, content);
   }
 
+  @Deprecated('Use newFile2() instead')
   File newFile(String path, {String content = ''}) {
+    return newFile2(path, content);
+  }
+
+  File newFile2(String path, String content) {
     String convertedPath = convertPath(path);
     return resourceProvider.newFile(convertedPath, content);
   }
@@ -89,18 +99,18 @@
     return resourceProvider.newFolder(convertedPath);
   }
 
-  File newPackageConfigJsonFile(String directoryPath, {String content = ''}) {
+  File newPackageConfigJsonFile(String directoryPath, String content) {
     String path = join(
       directoryPath,
       file_paths.dotDartTool,
       file_paths.packageConfigJson,
     );
-    return newFile(path, content: content);
+    return newFile2(path, content);
   }
 
   File newPubspecYamlFile(String directoryPath, String content) {
     String path = join(directoryPath, file_paths.pubspecYaml);
-    return newFile(path, content: content);
+    return newFile2(path, content);
   }
 
   Uri toUri(String path) {
diff --git a/pkg/analyzer/test/error/error_reporter_test.dart b/pkg/analyzer/test/error/error_reporter_test.dart
index 55923b8..41d54bd 100644
--- a/pkg/analyzer/test/error/error_reporter_test.dart
+++ b/pkg/analyzer/test/error/error_reporter_test.dart
@@ -73,8 +73,8 @@
   }
 
   test_reportErrorForNode_types_differentNames() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/b.dart', content: 'class B {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/b.dart', 'class B {}');
     await resolveTestCode(r'''
 import 'package:test/a.dart';
 import 'package:test/b.dart';
@@ -112,8 +112,8 @@
   }
 
   test_reportErrorForNode_types_sameName() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/b.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/b.dart', 'class A {}');
     await resolveTestCode(r'''
 import 'package:test/a.dart';
 import 'package:test/b.dart';
@@ -150,8 +150,8 @@
   }
 
   test_reportErrorForNode_types_sameName_functionType() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A{}');
-    newFile('$testPackageLibPath/b.dart', content: 'class A{}');
+    newFile2('$testPackageLibPath/a.dart', 'class A{}');
+    newFile2('$testPackageLibPath/b.dart', 'class A{}');
     await resolveTestCode(r'''
 import 'a.dart' as a;
 import 'b.dart' as b;
@@ -184,8 +184,8 @@
   }
 
   test_reportErrorForNode_types_sameName_nested() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A{}');
-    newFile('$testPackageLibPath/b.dart', content: 'class A{}');
+    newFile2('$testPackageLibPath/a.dart', 'class A{}');
+    newFile2('$testPackageLibPath/b.dart', 'class A{}');
     await resolveTestCode(r'''
 import 'a.dart' as a;
 import 'b.dart' as b;
diff --git a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
index 61f06df..a34d548 100644
--- a/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
+++ b/pkg/analyzer/test/file_system/resource_uri_resolver_test.dart
@@ -20,7 +20,7 @@
 
   void setUp() {
     resolver = ResourceUriResolver(resourceProvider);
-    newFile('/test.dart');
+    newFile2('/test.dart', '');
     newFolder('/folder');
   }
 
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 532fa53..2b959b8 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -213,19 +213,18 @@
   late final DartSdk sdk;
 
   void setUp() {
-    newFile('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart',
-        content: '''
+    newFile2('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart', '''
 const Map<String, LibraryInfo> libraries = const {
   "core": const LibraryInfo("core/core.dart")
 };
 ''');
 
-    newFile('/sdk/lib/core/core.dart', content: '''
+    newFile2('/sdk/lib/core/core.dart', '''
 library dart.core;
 part 'int.dart';
 ''');
 
-    newFile('/sdk/lib/core/int.dart', content: '''
+    newFile2('/sdk/lib/core/int.dart', '''
 part of dart.core;
 ''');
 
diff --git a/pkg/analyzer/test/generated/element_resolver_test.dart b/pkg/analyzer/test/generated/element_resolver_test.dart
index f6b0fed..9cd13b7 100644
--- a/pkg/analyzer/test/generated/element_resolver_test.dart
+++ b/pkg/analyzer/test/generated/element_resolver_test.dart
@@ -21,7 +21,7 @@
 @reflectiveTest
 class AnnotationElementResolverTest extends PubPackageResolutionTest {
   test_class_namedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
@@ -46,7 +46,7 @@
   }
 
   test_class_prefixed_namedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
@@ -72,7 +72,7 @@
   }
 
   test_class_prefixed_staticConstField() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const V = 0;
 }
@@ -97,7 +97,7 @@
   }
 
   test_class_prefixed_unnamedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A();
 }
@@ -121,7 +121,7 @@
   }
 
   test_class_staticConstField() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const V = 0;
 }
@@ -145,7 +145,7 @@
   }
 
   test_class_unnamedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A();
 }
@@ -168,7 +168,7 @@
   }
 
   test_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const V = 0;
 ''');
     await _validateAnnotation('', '@V',
@@ -189,7 +189,7 @@
   }
 
   test_topLevelVariable_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const V = 0;
 ''');
     await _validateAnnotation('as p', '@p.V',
@@ -437,7 +437,7 @@
   }
 
   test_visitImportDirective_withCombinators() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 int v1 = 0;
 final int v2 = 0;
 ''');
diff --git a/pkg/analyzer/test/generated/invalid_code_test.dart b/pkg/analyzer/test/generated/invalid_code_test.dart
index 51d910d..a3f6f3d 100644
--- a/pkg/analyzer/test/generated/invalid_code_test.dart
+++ b/pkg/analyzer/test/generated/invalid_code_test.dart
@@ -61,7 +61,7 @@
   }
 
   test_methodInvocation_ofGenericClass_generic_static_fromLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   static void foo<T2>() {}
 }
@@ -162,7 +162,7 @@
   }
 
   test_extensionOverrideInAnnotationContext_importedWithPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on Object {
   int f() => 0;
 }
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index bc4e648..461dba2 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -138,7 +138,7 @@
   }
 
   test_typedef_not_function() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 typedef F = int;
 ''');
     await assertNoErrorsInCode('''
@@ -150,11 +150,11 @@
 
 mixin NonErrorResolverTestCases on PubPackageResolutionTest {
   test_ambiguousExport() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 class M {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library lib2;
 class N {}
 ''');
@@ -166,12 +166,12 @@
   }
 
   test_ambiguousExport_combinators_hide() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library L1;
 class A {}
 class B {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library L2;
 class B {}
 class C {}
@@ -184,12 +184,12 @@
   }
 
   test_ambiguousExport_combinators_show() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library L1;
 class A {}
 class B {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library L2;
 class B {}
 class C {}
@@ -202,7 +202,7 @@
   }
 
   test_ambiguousExport_sameDeclaration() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 class N {}
 ''');
@@ -214,7 +214,7 @@
   }
 
   test_ambiguousImport_dart_implicitHide() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 class Future {
   static const zero = 0;
 }
@@ -228,17 +228,17 @@
   }
 
   test_ambiguousImport_hideCombinator() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 class N {}
 class N1 {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library lib2;
 class N {}
 class N2 {}
 ''');
-    newFile("$testPackageLibPath/lib3.dart", content: r'''
+    newFile2("$testPackageLibPath/lib3.dart", r'''
 library lib3;
 class N {}
 class N3 {}
@@ -256,12 +256,12 @@
   }
 
   test_ambiguousImport_showCombinator() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 class N {}
 class N1 {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library lib2;
 class N {}
 class N2 {}
@@ -279,7 +279,7 @@
   }
 
   test_annotated_partOfDeclaration() async {
-    newFile('$testPackageLibPath/part.dart', content: '''
+    newFile2('$testPackageLibPath/part.dart', '''
 @deprecated part of L;
 ''');
     await assertNoErrorsInCode('''
@@ -505,7 +505,7 @@
   }
 
   test_assignmentToFinals_importWithPrefix() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 bool x = false;''');
     await assertNoErrorsInCode(r'''
@@ -773,7 +773,7 @@
   }
 
   test_closure_in_type_inferred_variable_in_other_lib() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 var y = (Object x) => x is int && x.isEven;
 ''');
     await assertNoErrorsInCode('''
@@ -817,13 +817,13 @@
   }
 
   test_const_imported_defaultParameterValue_withImportPrefix() async {
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'c.dart' as ccc;
 class B {
   const B([p = ccc.value]);
 }
 ''');
-    newFile('$testPackageLibPath/c.dart', content: r'''
+    newFile2('$testPackageLibPath/c.dart', r'''
 const int value = 12345;
 ''');
     await assertNoErrorsInCode(r'''
@@ -900,7 +900,7 @@
   }
 
   test_constDeferredClass_new() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 class A {
   const A.b();
 }
@@ -921,7 +921,7 @@
   }
 
   test_constEval_propertyExtraction_fieldStatic_targetType() async {
-    newFile("$testPackageLibPath/math.dart", content: r'''
+    newFile2("$testPackageLibPath/math.dart", r'''
 library math;
 const PI = 3.14;
 ''');
@@ -942,7 +942,7 @@
   }
 
   test_constEval_symbol() async {
-    newFile("$testPackageLibPath/math.dart", content: r'''
+    newFile2("$testPackageLibPath/math.dart", r'''
 library math;
 const PI = 3.14;
 ''');
@@ -1117,7 +1117,7 @@
   }
 
   test_deprecatedMemberUse_hide() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 class A {}
 @deprecated
@@ -1626,7 +1626,7 @@
   }
 
   test_importDuplicatedLibraryName() async {
-    newFile("$testPackageLibPath/lib.dart", content: "library lib;");
+    newFile2("$testPackageLibPath/lib.dart", "library lib;");
     await assertErrorsInCode(r'''
 library test;
 import 'lib.dart';
@@ -1639,8 +1639,8 @@
   }
 
   test_importDuplicatedLibraryUnnamed() async {
-    newFile("$testPackageLibPath/lib1.dart");
-    newFile("$testPackageLibPath/lib2.dart");
+    newFile2("$testPackageLibPath/lib1.dart", '');
+    newFile2("$testPackageLibPath/lib2.dart", '');
     // No warning on duplicate import (https://github.com/dart-lang/sdk/issues/24156)
     await assertErrorsInCode(r'''
 library test;
@@ -1653,7 +1653,7 @@
   }
 
   test_importOfNonLibrary_libraryDeclared() async {
-    newFile("$testPackageLibPath/part.dart", content: r'''
+    newFile2("$testPackageLibPath/part.dart", r'''
 library lib1;
 class A {}
 ''');
@@ -1665,7 +1665,7 @@
   }
 
   test_importOfNonLibrary_libraryNotDeclared() async {
-    newFile("$testPackageLibPath/part.dart", content: '''
+    newFile2("$testPackageLibPath/part.dart", '''
 class A {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -1676,11 +1676,11 @@
   }
 
   test_importPrefixes_withFirstLetterDifference() async {
-    newFile("$testPackageLibPath/lib1.dart", content: r'''
+    newFile2("$testPackageLibPath/lib1.dart", r'''
 library lib1;
 test1() {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: r'''
+    newFile2("$testPackageLibPath/lib2.dart", r'''
 library lib2;
 test2() {}
 ''');
@@ -1846,7 +1846,7 @@
   }
 
   test_instanceMethodNameCollidesWithSuperclassStatic_field() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library L;
 class A {
   static var _m;
@@ -1863,7 +1863,7 @@
   }
 
   test_instanceMethodNameCollidesWithSuperclassStatic_method() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library L;
 class A {
   static _m() {}
@@ -1937,7 +1937,7 @@
   }
 
   test_invalidAnnotation_constantVariable_field_importWithPrefix() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 class A {
   static const C = 0;
@@ -1961,7 +1961,7 @@
   }
 
   test_invalidAnnotation_constantVariable_topLevel_importWithPrefix() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 const C = 0;
 ''');
@@ -1974,7 +1974,7 @@
   }
 
   test_invalidAnnotation_constConstructor_importWithPrefix() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 class A {
   const A(int p);
@@ -1989,7 +1989,7 @@
   }
 
   test_invalidAnnotation_constConstructor_named_importWithPrefix() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 class A {
   const A.named(int p);
@@ -2166,12 +2166,12 @@
   }
 
   Future test_issue32114() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class O {}
 
 typedef T Func<T extends O>(T e);
 ''');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 export 'a.dart' show Func;
 
@@ -2219,7 +2219,7 @@
   }
 
   test_issue_35320_lists() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 const x = const <String>['a'];
 ''');
     await assertNoErrorsInCode('''
@@ -2239,7 +2239,7 @@
   }
 
   test_issue_35320_maps() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 const x = const <String, String>{'a': 'b'};
 ''');
     await assertNoErrorsInCode('''
@@ -2259,7 +2259,7 @@
   }
 
   test_loadLibraryDefined() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 foo() => 22;''');
     await assertNoErrorsInCode(r'''
@@ -2813,13 +2813,13 @@
   }
 
   test_optionalNew_rewrite() async {
-    newFile("$testPackageLibPath/a.dart", content: r'''
+    newFile2("$testPackageLibPath/a.dart", r'''
 class A {
   const A();
   const A.named();
 }
 ''');
-    newFile("$testPackageLibPath/b.dart", content: r'''
+    newFile2("$testPackageLibPath/b.dart", r'''
 import 'a.dart';
 import 'a.dart' as p;
 
@@ -2849,7 +2849,7 @@
   }
 
   test_optionalNew_rewrite_instantiatesToBounds() async {
-    newFile("$testPackageLibPath/a.dart", content: r'''
+    newFile2("$testPackageLibPath/a.dart", r'''
 class Unbounded<T> {
   const Unbounded();
   const Unbounded.named();
@@ -2859,7 +2859,7 @@
   const Bounded.named();
 }
 ''');
-    newFile("$testPackageLibPath/b.dart", content: r'''
+    newFile2("$testPackageLibPath/b.dart", r'''
 import 'a.dart';
 import 'a.dart' as p;
 
@@ -3050,13 +3050,13 @@
   }
 
   test_sharedDeferredPrefix() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 f1() {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 f2() {}
 ''');
-    newFile('$testPackageLibPath/lib3.dart', content: r'''
+    newFile2('$testPackageLibPath/lib3.dart', r'''
 f3() {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -3237,7 +3237,7 @@
   }
 
   test_typeType_class_prefixed() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 class C {}''');
     await assertNoErrorsInCode(r'''
@@ -3260,7 +3260,7 @@
   }
 
   test_typeType_functionTypeAlias_prefixed() async {
-    newFile("$testPackageLibPath/lib.dart", content: r'''
+    newFile2("$testPackageLibPath/lib.dart", r'''
 library lib;
 typedef F();''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/generated/non_hint_code_test.dart b/pkg/analyzer/test/generated/non_hint_code_test.dart
index e283dd5..17cf69b 100644
--- a/pkg/analyzer/test/generated/non_hint_code_test.dart
+++ b/pkg/analyzer/test/generated/non_hint_code_test.dart
@@ -235,8 +235,8 @@
   }
 
   test_import_referenceIntoLibDirectory() async {
-    newFile("/myproj/pubspec.yaml", content: "");
-    newFile("/myproj/lib/other.dart", content: "");
+    newFile2("/myproj/pubspec.yaml", '');
+    newFile2("/myproj/lib/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/web/test.dart", "import '../lib/other.dart';", [
       error(HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE, 0, 0),
@@ -244,14 +244,14 @@
   }
 
   test_import_referenceIntoLibDirectory_no_pubspec() async {
-    newFile("/myproj/lib/other.dart", content: "");
+    newFile2("/myproj/lib/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/web/test.dart", "import '../lib/other.dart';", []);
   }
 
   test_import_referenceOutOfLibDirectory() async {
-    newFile("/myproj/pubspec.yaml", content: "");
-    newFile("/myproj/web/other.dart", content: "");
+    newFile2("/myproj/pubspec.yaml", '');
+    newFile2("/myproj/web/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/lib/test.dart", "import '../web/other.dart';", [
       error(HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE, 0, 0),
@@ -259,28 +259,28 @@
   }
 
   test_import_referenceOutOfLibDirectory_no_pubspec() async {
-    newFile("/myproj/web/other.dart", content: "");
+    newFile2("/myproj/web/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/lib/test.dart", "import '../web/other.dart';", []);
   }
 
   test_import_valid_inside_lib1() async {
-    newFile("/myproj/pubspec.yaml", content: "");
-    newFile("/myproj/lib/other.dart", content: "");
+    newFile2("/myproj/pubspec.yaml", '');
+    newFile2("/myproj/lib/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/lib/test.dart", "import 'other.dart';", []);
   }
 
   test_import_valid_inside_lib2() async {
-    newFile("/myproj/pubspec.yaml", content: "");
-    newFile("/myproj/lib/bar/other.dart", content: "");
+    newFile2("/myproj/pubspec.yaml", '');
+    newFile2("/myproj/lib/bar/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/lib/foo/test.dart", "import '../bar/other.dart';", []);
   }
 
   test_import_valid_outside_lib() async {
-    newFile("/myproj/pubspec.yaml", content: "");
-    newFile("/myproj/web/other.dart", content: "");
+    newFile2("/myproj/pubspec.yaml", '');
+    newFile2("/myproj/web/other.dart", '');
     await _assertErrorsInCodeInFile(
         "/myproj/lib2/test.dart", "import '../web/other.dart';", []);
   }
@@ -288,7 +288,7 @@
   Future<void> _assertErrorsInCodeInFile(
       String path, String content, List<ExpectedError> expectedErrors) async {
     path = convertPath(path);
-    newFile(path, content: content);
+    newFile2(path, content);
     result = await resolveFile(path);
 
     var errorListener = GatheringErrorListener();
diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
index e53b5e8..e5232e6 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -528,7 +528,7 @@
   }
 
   test_invocation_target_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int max(int x, int y) => 0;
 ''');
     await resolveTestCode('''
@@ -591,7 +591,7 @@
   }
 
   test_objectAccessInference_disabled_for_library_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 dynamic get hashCode => 42;
 ''');
     await assertNoErrorsInCode('''
@@ -612,7 +612,7 @@
   }
 
   test_objectMethodInference_disabled_for_library_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 dynamic toString = (int x) => x + 42;
 ''');
     await assertNoErrorsInCode('''
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index 254dea0..d4cedc5 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -422,7 +422,7 @@
   }
 
   test_entryPoint_exported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 main() {}
 ''');
 
@@ -457,7 +457,7 @@
   }
 
   test_enum_externalLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum EEE {A, B, C}
 ''');
     await assertNoErrorsInCode(r'''
@@ -590,11 +590,11 @@
   }
 
   test_import_hide() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 set foo(value) {}
 class A {}''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 set foo(value) {}''');
 
     await assertNoErrorsInCode(r'''
@@ -609,7 +609,7 @@
   }
 
   test_import_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 f(int x) {
   return x * x;
 }''');
@@ -678,7 +678,7 @@
   }
 
   test_import_spaceInUri() async {
-    newFile('$testPackageLibPath/sub folder/a.dart', content: r'''
+    newFile2('$testPackageLibPath/sub folder/a.dart', r'''
 foo() {}''');
 
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/source/analysis_options_provider_test.dart b/pkg/analyzer/test/source/analysis_options_provider_test.dart
index 8cb98e3..cb2db31 100644
--- a/pkg/analyzer/test/source/analysis_options_provider_test.dart
+++ b/pkg/analyzer/test/source/analysis_options_provider_test.dart
@@ -101,12 +101,12 @@
 
   void test_getOptions_crawlUp_hasInFolder() {
     newFolder('/foo/bar');
-    newFile('/foo/$analysisOptionsYaml', content: r'''
+    newFile2('/foo/$analysisOptionsYaml', r'''
 analyzer:
   ignore:
     - foo
 ''');
-    newFile('/foo/bar/$analysisOptionsYaml', content: r'''
+    newFile2('/foo/bar/$analysisOptionsYaml', r'''
 analyzer:
   ignore:
     - bar
@@ -122,12 +122,12 @@
 
   void test_getOptions_crawlUp_hasInParent() {
     newFolder('/foo/bar/baz');
-    newFile('/foo/$analysisOptionsYaml', content: r'''
+    newFile2('/foo/$analysisOptionsYaml', r'''
 analyzer:
   ignore:
     - foo
 ''');
-    newFile('/foo/bar/$analysisOptionsYaml', content: r'''
+    newFile2('/foo/bar/$analysisOptionsYaml', r'''
 analyzer:
   ignore:
     - bar
@@ -148,20 +148,20 @@
   }
 
   void test_getOptions_empty() {
-    newFile('/$analysisOptionsYaml', content: r'''#empty''');
+    newFile2('/$analysisOptionsYaml', r'''#empty''');
     YamlMap options = _getOptions('/');
     expect(options, isNotNull);
     expect(options, isEmpty);
   }
 
   void test_getOptions_include() {
-    newFile('/foo.include', content: r'''
+    newFile2('/foo.include', r'''
 analyzer:
   ignore:
     - ignoreme.dart
     - 'sdk_ext/**'
 ''');
-    newFile('/$analysisOptionsYaml', content: r'''
+    newFile2('/$analysisOptionsYaml', r'''
 include: foo.include
 ''');
     YamlMap options = _getOptions('/');
@@ -179,12 +179,12 @@
   }
 
   void test_getOptions_include_emptyLints() {
-    newFile('/foo.include', content: r'''
+    newFile2('/foo.include', r'''
 linter:
   rules:
     - prefer_single_quotes
 ''');
-    newFile('/$analysisOptionsYaml', content: r'''
+    newFile2('/$analysisOptionsYaml', r'''
 include: foo.include
 linter:
   rules:
@@ -204,7 +204,7 @@
   }
 
   void test_getOptions_include_missing() {
-    newFile('/$analysisOptionsYaml', content: r'''
+    newFile2('/$analysisOptionsYaml', r'''
 include: /foo.include
 ''');
     YamlMap options = _getOptions('/');
@@ -212,13 +212,13 @@
   }
 
   void test_getOptions_invalid() {
-    newFile('/$analysisOptionsYaml', content: r''':''');
+    newFile2('/$analysisOptionsYaml', r''':''');
     YamlMap options = _getOptions('/');
     expect(options, hasLength(1));
   }
 
   void test_getOptions_simple() {
-    newFile('/$analysisOptionsYaml', content: r'''
+    newFile2('/$analysisOptionsYaml', r'''
 analyzer:
   ignore:
     - ignoreme.dart
diff --git a/pkg/analyzer/test/src/context/package_config_json_test.dart b/pkg/analyzer/test/src/context/package_config_json_test.dart
index 382d4ce..b1090fd 100644
--- a/pkg/analyzer/test/src/context/package_config_json_test.dart
+++ b/pkg/analyzer/test/src/context/package_config_json_test.dart
@@ -24,7 +24,7 @@
   }
 
   void setUp() {
-    newFile('/test/lib/test.dart', content: '');
+    newFile2('/test/lib/test.dart', '');
   }
 
   test_configVersion_2() {
@@ -301,7 +301,7 @@
 
   PackageConfigJson _parse(String content) {
     var path = '/test/.dart_tool/package_config.json';
-    newFile(path, content: content);
+    newFile2(path, content);
 
     var uri = toUri(path);
     return parsePackageConfigJson(uri, content);
diff --git a/pkg/analyzer/test/src/context/packages_test.dart b/pkg/analyzer/test/src/context/packages_test.dart
index aead226..a4e359a6 100644
--- a/pkg/analyzer/test/src/context/packages_test.dart
+++ b/pkg/analyzer/test/src/context/packages_test.dart
@@ -17,7 +17,7 @@
 @reflectiveTest
 class PackagesTest with ResourceProviderMixin {
   void setUp() {
-    newFile('/test/lib/test.dart', content: '');
+    newFile2('/test/lib/test.dart', '');
   }
 
   void test_findPackagesFrom_missing() {
@@ -66,7 +66,7 @@
   }
 
   test_parsePackageConfigJsonFile() {
-    var file = newFile('/test/.dart_tool/package_config.json', content: '''
+    var file = newFile2('/test/.dart_tool/package_config.json', '''
 {
   "configVersion": 2,
   "packages": [
@@ -116,7 +116,7 @@
 
   test_parsePackagesFile_packageConfig() {
     var path = convertPath('/test/.dart_tool/package_config.json');
-    newFile(path, content: '''
+    newFile2(path, '''
 {
   "configVersion": 2,
   "packages": [
diff --git a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
index e8c8c62..2ff4f6d 100644
--- a/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/analysis_context_collection_test.dart
@@ -57,7 +57,7 @@
   test_new_analysisOptions_includes() {
     var rootFolder = newFolder('/home/test');
     var fooFolder = newFolder('/home/packages/foo');
-    newFile('${fooFolder.path}/lib/included.yaml', content: r'''
+    newFile2('${fooFolder.path}/lib/included.yaml', r'''
 linter:
   rules:
     - empty_statements
@@ -67,10 +67,10 @@
       ..add(name: 'foo', rootPath: fooFolder.path);
     newPackageConfigJsonFile(
       rootFolder.path,
-      content: packageConfigFileBuilder.toContent(toUriStr: toUriStr),
+      packageConfigFileBuilder.toContent(toUriStr: toUriStr),
     );
 
-    newAnalysisOptionsYamlFile(rootFolder.path, content: r'''
+    newAnalysisOptionsYamlFile2(rootFolder.path, r'''
 include: package:foo/included.yaml
 
 linter:
@@ -90,7 +90,7 @@
 
   test_new_analysisOptions_lintRules() {
     var rootFolder = newFolder('/home/test');
-    newAnalysisOptionsYamlFile(rootFolder.path, content: r'''
+    newAnalysisOptionsYamlFile2(rootFolder.path, r'''
 linter:
   rules:
     - non_existent_lint_rule
@@ -124,11 +124,11 @@
 
   test_new_outer_inner() {
     var outerFolder = newFolder('/test/outer');
-    newFile('/test/outer/lib/outer.dart');
+    newFile2('/test/outer/lib/outer.dart', '');
 
     var innerFolder = newFolder('/test/outer/inner');
-    newAnalysisOptionsYamlFile('/test/outer/inner');
-    newFile('/test/outer/inner/inner.dart');
+    newAnalysisOptionsYamlFile2('/test/outer/inner', '');
+    newFile2('/test/outer/inner/inner.dart', '');
 
     var collection = _newCollection(includedPaths: [outerFolder.path]);
 
diff --git a/pkg/analyzer/test/src/dart/analysis/base.dart b/pkg/analyzer/test/src/dart/analysis/base.dart
index 4ed178b..f6e1433 100644
--- a/pkg/analyzer/test/src/dart/analysis/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/base.dart
@@ -42,7 +42,7 @@
 
   void addTestFile(String content, {bool priority = false}) {
     testCode = content;
-    newFile(testFile, content: content);
+    newFile2(testFile, content);
     driver.addFile(testFile);
     if (priority) {
       driver.priorityFiles = [testFile];
diff --git a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
index 17144c0..dc50e76 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_builder_test.dart
@@ -60,7 +60,7 @@
 
   void test_analysisOptions_invalid() {
     var projectPath = convertPath('/home/test');
-    newAnalysisOptionsYamlFile(projectPath, content: ';');
+    newAnalysisOptionsYamlFile2(projectPath, ';');
 
     var analysisContext = _createSingleAnalysisContext(projectPath);
     var analysisOptions = analysisContext.analysisOptionsImpl;
@@ -69,9 +69,9 @@
 
   void test_analysisOptions_languageOptions() {
     var projectPath = convertPath('/home/test');
-    newAnalysisOptionsYamlFile(
+    newAnalysisOptionsYamlFile2(
       projectPath,
-      content: AnalysisOptionsFileConfig(
+      AnalysisOptionsFileConfig(
         strictRawTypes: true,
       ).toContent(),
     );
@@ -98,7 +98,7 @@
 
   void test_analysisOptions_sdkVersionConstraint_noPubspec() {
     var projectPath = convertPath('/home/test');
-    newFile('$projectPath/lib/a.dart');
+    newFile2('$projectPath/lib/a.dart', '');
 
     var analysisContext = _createSingleAnalysisContext(projectPath);
     var analysisOptions = analysisContext.driver.analysisOptions;
@@ -167,7 +167,7 @@
 
   void test_sourceFactory_bazelWorkspace() {
     var projectPath = convertPath('/workspace/my/module');
-    newFile('/workspace/WORKSPACE');
+    newFile2('/workspace/WORKSPACE', '');
     newFolder('/workspace/bazel-bin');
     newFolder('/workspace/bazel-genfiles');
 
@@ -186,7 +186,7 @@
 
   void test_sourceFactory_pubWorkspace() {
     var projectPath = convertPath('/home/my');
-    newFile('/home/my/pubspec.yaml');
+    newFile2('/home/my/pubspec.yaml', '');
 
     var analysisContext = _createSingleAnalysisContext(projectPath);
     expect(analysisContext.contextRoot.workspace, isA<PubWorkspace>());
diff --git a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
index cddb12c..36f385f 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_locator_test.dart
@@ -48,8 +48,8 @@
 
   void test_locateRoots_link_file_toOutOfRoot() {
     Folder rootFolder = newFolder('/home/test');
-    newFile('/home/test/lib/a.dart');
-    newFile('/home/b.dart');
+    newFile2('/home/test/lib/a.dart', '');
+    newFile2('/home/b.dart', '');
     resourceProvider.newLink(
       convertPath('/home/test/lib/c.dart'),
       convertPath('/home/b.dart'),
@@ -73,7 +73,7 @@
 
   void test_locateRoots_link_file_toSiblingInRoot() {
     Folder rootFolder = newFolder('/test');
-    newFile('/test/lib/a.dart');
+    newFile2('/test/lib/a.dart', '');
     resourceProvider.newLink(
       convertPath('/test/lib/b.dart'),
       convertPath('/test/lib/a.dart'),
@@ -97,7 +97,7 @@
 
   void test_locateRoots_link_folder_notExistingTarget() {
     var rootFolder = newFolder('/test');
-    newFile('/test/lib/a.dart');
+    newFile2('/test/lib/a.dart', '');
     newFolder('/test/lib/foo');
     resourceProvider.newLink(
       convertPath('/test/lib/foo'),
@@ -127,7 +127,7 @@
 
   void test_locateRoots_link_folder_toParentInRoot() {
     Folder rootFolder = newFolder('/test');
-    newFile('/test/lib/a.dart');
+    newFile2('/test/lib/a.dart', '');
     resourceProvider.newLink(
       convertPath('/test/lib/foo'),
       convertPath('/test/lib'),
@@ -153,9 +153,9 @@
 
   void test_locateRoots_link_folder_toParentOfRoot() {
     Folder rootFolder = newFolder('/home/test');
-    newFile('/home/test/lib/a.dart');
-    newFile('/home/b.dart');
-    newFile('/home/other/c.dart');
+    newFile2('/home/test/lib/a.dart', '');
+    newFile2('/home/b.dart', '');
+    newFile2('/home/other/c.dart', '');
     resourceProvider.newLink(
       convertPath('/home/test/lib/foo'),
       convertPath('/home'),
@@ -182,8 +182,8 @@
 
   void test_locateRoots_link_folder_toSiblingInRoot() {
     Folder rootFolder = newFolder('/test');
-    newFile('/test/lib/a.dart');
-    newFile('/test/lib/foo/b.dart');
+    newFile2('/test/lib/a.dart', '');
+    newFile2('/test/lib/foo/b.dart', '');
     resourceProvider.newLink(
       convertPath('/test/lib/bar'),
       convertPath('/test/lib/foo'),
@@ -209,12 +209,12 @@
   void test_locateRoots_multiple_dirAndNestedDir_excludedByOptions() {
     var rootPath = convertPath('/home/test');
     var rootFolder = newFolder(rootPath);
-    var optionsFile = newAnalysisOptionsYamlFile(rootPath, content: r'''
+    var optionsFile = newAnalysisOptionsYamlFile2(rootPath, r'''
 analyzer:
   exclude:
     - examples/**
 ''');
-    var packagesFile = newPackageConfigJsonFile(rootPath);
+    var packagesFile = newPackageConfigJsonFile(rootPath, '');
     var includedFolder = newFolder('$rootPath/examples/included');
     newFolder('$rootPath/examples/not_included'); // not used
 
@@ -234,8 +234,10 @@
 
   void test_locateRoots_multiple_dirAndNestedDir_innerConfigurationFiles() {
     var outerRootFolder = newFolder('/outer');
-    var innerOptionsFile = newAnalysisOptionsYamlFile('/outer/examples/inner');
-    var innerPackagesFile = newPackageConfigJsonFile('/outer/examples/inner');
+    var innerOptionsFile =
+        newAnalysisOptionsYamlFile2('/outer/examples/inner', '');
+    var innerPackagesFile =
+        newPackageConfigJsonFile('/outer/examples/inner', '');
     var innerRootFolder = newFolder('/outer/examples/inner');
 
     var roots = contextLocator.locateRoots(
@@ -273,8 +275,8 @@
 
   void test_locateRoots_multiple_dirAndNestedDir_outerConfigurationFiles() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
@@ -291,15 +293,15 @@
   void test_locateRoots_multiple_dirAndNestedFile_excludedByOptions() {
     var rootPath = convertPath('/home/test');
     var rootFolder = newFolder(rootPath);
-    var optionsFile = newAnalysisOptionsYamlFile(rootPath, content: r'''
+    var optionsFile = newAnalysisOptionsYamlFile2(rootPath, r'''
 analyzer:
   exclude:
     - lib/f*.dart
 ''');
-    var packagesFile = newPackageConfigJsonFile(rootPath);
-    var fooFile = newFile('$rootPath/lib/foo.dart');
-    newFile('$rootPath/lib/far.dart'); // not used
-    var barFile = newFile('$rootPath/lib/bar.dart');
+    var packagesFile = newPackageConfigJsonFile(rootPath, '');
+    var fooFile = newFile2('$rootPath/lib/foo.dart', '');
+    newFile2('$rootPath/lib/far.dart', ''); // not used
+    var barFile = newFile2('$rootPath/lib/bar.dart', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [rootFolder.path, fooFile.path],
@@ -320,7 +322,7 @@
 
   void test_locateRoots_multiple_dirAndNestedFile_noConfigurationFiles() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File testFile = newFile('/test/outer/examples/inner/test.dart');
+    File testFile = newFile2('/test/outer/examples/inner/test.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [outerRootFolder.path, testFile.path]);
@@ -335,9 +337,9 @@
 
   void test_locateRoots_multiple_dirAndNestedFile_outerConfigurationFiles() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
-    File testFile = newFile('/test/outer/examples/inner/test.dart');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
+    File testFile = newFile2('/test/outer/examples/inner/test.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [outerRootFolder.path, testFile.path]);
@@ -352,12 +354,12 @@
 
   void test_locateRoots_multiple_dirAndSiblingDir_bothConfigurationFiles() {
     Folder outer1RootFolder = newFolder('/test/outer1');
-    File outer1OptionsFile = newAnalysisOptionsYamlFile('/test/outer1');
-    File outer1PackagesFile = newPackageConfigJsonFile('/test/outer1');
+    File outer1OptionsFile = newAnalysisOptionsYamlFile2('/test/outer1', '');
+    File outer1PackagesFile = newPackageConfigJsonFile('/test/outer1', '');
 
     Folder outer2RootFolder = newFolder('/test/outer2');
-    File outer2OptionsFile = newAnalysisOptionsYamlFile('/test/outer2');
-    File outer2PackagesFile = newPackageConfigJsonFile('/test/outer2');
+    File outer2OptionsFile = newAnalysisOptionsYamlFile2('/test/outer2', '');
+    File outer2PackagesFile = newPackageConfigJsonFile('/test/outer2', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outer1RootFolder.path, outer2RootFolder.path]);
@@ -399,12 +401,12 @@
 
   void test_locateRoots_multiple_dirAndSiblingFile() {
     Folder outer1RootFolder = newFolder('/test/outer1');
-    File outer1OptionsFile = newAnalysisOptionsYamlFile('/test/outer1');
-    File outer1PackagesFile = newPackageConfigJsonFile('/test/outer1');
+    File outer1OptionsFile = newAnalysisOptionsYamlFile2('/test/outer1', '');
+    File outer1PackagesFile = newPackageConfigJsonFile('/test/outer1', '');
 
-    File outer2OptionsFile = newAnalysisOptionsYamlFile('/test/outer2');
-    File outer2PackagesFile = newPackageConfigJsonFile('/test/outer2');
-    File testFile = newFile('/test/outer2/test.dart');
+    File outer2OptionsFile = newAnalysisOptionsYamlFile2('/test/outer2', '');
+    File outer2PackagesFile = newPackageConfigJsonFile('/test/outer2', '');
+    File testFile = newFile2('/test/outer2/test.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [outer1RootFolder.path, testFile.path]);
@@ -425,7 +427,7 @@
 
   void test_locateRoots_multiple_dirAndSiblingFile_noConfigurationFiles() {
     Folder outer1RootFolder = newFolder('/test/outer1');
-    File testFile = newFile('/test/outer2/test.dart');
+    File testFile = newFile2('/test/outer2/test.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [outer1RootFolder.path, testFile.path]);
@@ -450,15 +452,15 @@
     var pkgPath1 = '$workspacePath1/pkg1';
     var pkgPath2 = '$workspacePath2/pkg2';
 
-    newFile('$workspacePath1/WORKSPACE');
-    newFile('$workspacePath2/WORKSPACE');
+    newFile2('$workspacePath1/WORKSPACE', '');
+    newFile2('$workspacePath2/WORKSPACE', '');
     newBazelBuildFile(pkgPath1, '');
     newBazelBuildFile(pkgPath2, '');
 
     var folder1 = newFolder('$pkgPath1/lib/folder1');
     var folder2 = newFolder('$pkgPath2/lib/folder2');
-    var file1 = newFile('$pkgPath1/lib/folder1/file1.dart');
-    var file2 = newFile('$pkgPath2/lib/folder2/file2.dart');
+    var file1 = newFile2('$pkgPath1/lib/folder1/file1.dart', '');
+    var file2 = newFile2('$pkgPath2/lib/folder2/file2.dart', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [folder1.path, folder2.path],
@@ -485,14 +487,14 @@
   /// Even if a file is excluded by the options, when it is explicitly included
   /// into analysis, it should be analyzed.
   void test_locateRoots_multiple_fileAndSiblingFile_excludedByOptions() {
-    File optionsFile = newAnalysisOptionsYamlFile('/home/test', content: r'''
+    File optionsFile = newAnalysisOptionsYamlFile2('/home/test', r'''
 analyzer:
   exclude:
     - lib/test2.dart
 ''');
-    File packagesFile = newPackageConfigJsonFile('/home/test');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    File packagesFile = newPackageConfigJsonFile('/home/test', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [testFile1.path, testFile2.path]);
@@ -509,9 +511,9 @@
   }
 
   void test_locateRoots_multiple_fileAndSiblingFile_hasOptions() {
-    File optionsFile = newAnalysisOptionsYamlFile('/home/test');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    File optionsFile = newAnalysisOptionsYamlFile2('/home/test', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [testFile1.path, testFile2.path]);
@@ -529,10 +531,10 @@
 
   void
       test_locateRoots_multiple_fileAndSiblingFile_hasOptions_overrideOptions() {
-    newAnalysisOptionsYamlFile('/home/test'); // not used
-    File overrideOptionsFile = newAnalysisOptionsYamlFile('/home');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    newAnalysisOptionsYamlFile2('/home/test', ''); // not used
+    File overrideOptionsFile = newAnalysisOptionsYamlFile2('/home', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
       includedPaths: [testFile1.path, testFile2.path],
@@ -551,10 +553,10 @@
   }
 
   void test_locateRoots_multiple_fileAndSiblingFile_hasOptionsPackages() {
-    File optionsFile = newAnalysisOptionsYamlFile('/home/test');
-    File packagesFile = newPackageConfigJsonFile('/home/test');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    File optionsFile = newAnalysisOptionsYamlFile2('/home/test', '');
+    File packagesFile = newPackageConfigJsonFile('/home/test', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [testFile1.path, testFile2.path]);
@@ -571,9 +573,9 @@
   }
 
   void test_locateRoots_multiple_fileAndSiblingFile_hasPackages() {
-    File packagesFile = newPackageConfigJsonFile('/home/test');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    File packagesFile = newPackageConfigJsonFile('/home/test', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [testFile1.path, testFile2.path]);
@@ -595,10 +597,10 @@
   /// just the file system root.
   void
       test_locateRoots_multiple_fileAndSiblingFile_hasPackages_overridePackages() {
-    newPackageConfigJsonFile('/home/test'); // not used
-    File overridePackagesFile = newPackageConfigJsonFile('/home');
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    newPackageConfigJsonFile('/home/test', ''); // not used
+    File overridePackagesFile = newPackageConfigJsonFile('/home', '');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
       includedPaths: [testFile1.path, testFile2.path],
@@ -619,8 +621,8 @@
   /// When there are no configuration files, we can use the root of the file
   /// system, because it contains all the files.
   void test_locateRoots_multiple_fileAndSiblingFile_noConfigurationFiles() {
-    File testFile1 = newFile('/home/test/lib/test1.dart');
-    File testFile2 = newFile('/home/test/lib/test2.dart');
+    File testFile1 = newFile2('/home/test/lib/test1.dart', '');
+    File testFile2 = newFile2('/home/test/lib/test2.dart', '');
 
     List<ContextRoot> roots = contextLocator
         .locateRoots(includedPaths: [testFile1.path, testFile2.path]);
@@ -643,13 +645,13 @@
     var pkgPath1 = '$workspacePath1/pkg1';
     var pkgPath2 = '$workspacePath2/pkg2';
 
-    newFile('$workspacePath1/WORKSPACE');
-    newFile('$workspacePath2/WORKSPACE');
+    newFile2('$workspacePath1/WORKSPACE', '');
+    newFile2('$workspacePath2/WORKSPACE', '');
     newBazelBuildFile(pkgPath1, '');
     newBazelBuildFile(pkgPath2, '');
 
-    var file1 = newFile('$pkgPath1/lib/file1.dart');
-    var file2 = newFile('$pkgPath2/lib/file2.dart');
+    var file1 = newFile2('$pkgPath1/lib/file1.dart', '');
+    var file2 = newFile2('$pkgPath2/lib/file2.dart', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [file1.path, file2.path],
@@ -678,12 +680,12 @@
     var fooPath = '$workspacePath/foo';
     var barPath = '$workspacePath/bar';
 
-    newFile('$workspacePath/WORKSPACE');
+    newFile2('$workspacePath/WORKSPACE', '');
     newBazelBuildFile(fooPath, '');
     newBazelBuildFile(barPath, '');
 
-    var fooFile = newFile('$fooPath/lib/foo.dart');
-    var barFile = newFile('$barPath/lib/bar.dart');
+    var fooFile = newFile2('$fooPath/lib/foo.dart', '');
+    var barFile = newFile2('$barPath/lib/bar.dart', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [fooFile.path, barFile.path],
@@ -707,8 +709,8 @@
     newPubspecYamlFile(fooPath, '');
     newPubspecYamlFile(barPath, '');
 
-    var fooFile = newFile('$fooPath/lib/foo.dart');
-    var barFile = newFile('$barPath/lib/bar.dart');
+    var fooFile = newFile2('$fooPath/lib/foo.dart', '');
+    var barFile = newFile2('$barPath/lib/bar.dart', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [fooFile.path, barFile.path],
@@ -733,11 +735,11 @@
   }
 
   void test_locateRoots_multiple_files_sameOptions_differentPackages() {
-    var fooPackagesFile = newPackageConfigJsonFile('/home/foo');
-    var barPackagesFile = newPackageConfigJsonFile('/home/bar');
-    var optionsFile = newAnalysisOptionsYamlFile('/home');
-    var fooFile = newFile('/home/foo/lib/foo.dart');
-    var barFile = newFile('/home/bar/lib/bar.dart');
+    var fooPackagesFile = newPackageConfigJsonFile('/home/foo', '');
+    var barPackagesFile = newPackageConfigJsonFile('/home/bar', '');
+    var optionsFile = newAnalysisOptionsYamlFile2('/home', '');
+    var fooFile = newFile2('/home/foo/lib/foo.dart', '');
+    var barFile = newFile2('/home/bar/lib/bar.dart', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
       includedPaths: [fooFile.path, barFile.path],
@@ -760,11 +762,11 @@
   }
 
   void test_locateRoots_multiple_files_samePackages_differentOptions() {
-    var packagesFile = newPackageConfigJsonFile('/home');
-    var fooOptionsFile = newAnalysisOptionsYamlFile('/home/foo');
-    var barOptionsFile = newAnalysisOptionsYamlFile('/home/bar');
-    var fooFile = newFile('/home/foo/lib/foo.dart');
-    var barFile = newFile('/home/bar/lib/bar.dart');
+    var packagesFile = newPackageConfigJsonFile('/home', '');
+    var fooOptionsFile = newAnalysisOptionsYamlFile2('/home/foo', '');
+    var barOptionsFile = newAnalysisOptionsYamlFile2('/home/bar', '');
+    var fooFile = newFile2('/home/foo/lib/foo.dart', '');
+    var barFile = newFile2('/home/bar/lib/bar.dart', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
       includedPaths: [fooFile.path, barFile.path],
@@ -788,11 +790,11 @@
 
   void test_locateRoots_nested_excluded_dot() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
 
     newFolder('/test/outer/.examples');
-    newAnalysisOptionsYamlFile('/test/outer/.examples/inner');
+    newAnalysisOptionsYamlFile2('/test/outer/.examples/inner', '');
 
     // Only one analysis root, we skipped `.examples` for context roots.
     List<ContextRoot> roots =
@@ -808,10 +810,10 @@
 
   void test_locateRoots_nested_excluded_explicit() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder excludedFolder = newFolder('/test/outer/examples');
-    newAnalysisOptionsYamlFile('/test/outer/examples/inner');
+    newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -827,14 +829,14 @@
 
   void test_locateRoots_nested_multiple() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder inner1RootFolder = newFolder('/test/outer/examples/inner1');
     File inner1OptionsFile =
-        newAnalysisOptionsYamlFile('/test/outer/examples/inner1');
+        newAnalysisOptionsYamlFile2('/test/outer/examples/inner1', '');
     Folder inner2RootFolder = newFolder('/test/outer/examples/inner2');
     File inner2PackagesFile =
-        newPackageConfigJsonFile('/test/outer/examples/inner2');
+        newPackageConfigJsonFile('/test/outer/examples/inner2', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [outerRootFolder.path]);
@@ -862,11 +864,11 @@
 
   void test_locateRoots_nested_options() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
     File innerOptionsFile =
-        newAnalysisOptionsYamlFile('/test/outer/examples/inner');
+        newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [outerRootFolder.path]);
@@ -887,11 +889,12 @@
 
   void test_locateRoots_nested_options_overriddenOptions() {
     Folder outerRootFolder = newFolder('/test/outer');
-    newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     newFolder('/test/outer/examples/inner');
-    newAnalysisOptionsYamlFile('/test/outer/examples/inner');
-    File overrideOptionsFile = newAnalysisOptionsYamlFile('/test/override');
+    newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
+    File overrideOptionsFile =
+        newAnalysisOptionsYamlFile2('/test/override', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -907,12 +910,12 @@
 
   void test_locateRoots_nested_options_overriddenPackages() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
     File innerOptionsFile =
-        newAnalysisOptionsYamlFile('/test/outer/examples/inner');
-    File overridePackagesFile = newPackageConfigJsonFile('/test/override');
+        newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
+    File overridePackagesFile = newPackageConfigJsonFile('/test/override', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -934,13 +937,13 @@
 
   void test_locateRoots_nested_optionsAndPackages() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
     File innerOptionsFile =
-        newAnalysisOptionsYamlFile('/test/outer/examples/inner');
+        newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
     File innerPackagesFile =
-        newPackageConfigJsonFile('/test/outer/examples/inner');
+        newPackageConfigJsonFile('/test/outer/examples/inner', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [outerRootFolder.path]);
@@ -961,13 +964,14 @@
 
   void test_locateRoots_nested_optionsAndPackages_overriddenBoth() {
     Folder outerRootFolder = newFolder('/test/outer');
-    newAnalysisOptionsYamlFile('/test/outer');
-    newPackageConfigJsonFile('/test/outer');
+    newAnalysisOptionsYamlFile2('/test/outer', '');
+    newPackageConfigJsonFile('/test/outer', '');
     newFolder('/test/outer/examples/inner');
-    newAnalysisOptionsYamlFile('/test/outer/examples/inner');
-    newPackageConfigJsonFile('/test/outer/examples/inner');
-    File overrideOptionsFile = newAnalysisOptionsYamlFile('/test/override');
-    File overridePackagesFile = newPackageConfigJsonFile('/test/override');
+    newAnalysisOptionsYamlFile2('/test/outer/examples/inner', '');
+    newPackageConfigJsonFile('/test/outer/examples/inner', '');
+    File overrideOptionsFile =
+        newAnalysisOptionsYamlFile2('/test/override', '');
+    File overridePackagesFile = newPackageConfigJsonFile('/test/override', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -984,11 +988,11 @@
 
   void test_locateRoots_nested_packageConfigJson() {
     var outerRootFolder = newFolder('/test/outer');
-    var outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    var outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    var outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    var outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     var innerRootFolder = newFolder('/test/outer/examples/inner');
     var innerPackagesFile =
-        newPackageConfigJsonFile('/test/outer/examples/inner');
+        newPackageConfigJsonFile('/test/outer/examples/inner', '');
 
     var roots = contextLocator.locateRoots(
       includedPaths: [outerRootFolder.path],
@@ -1010,11 +1014,11 @@
 
   void test_locateRoots_nested_packages() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
     File innerPackagesFile =
-        newPackageConfigJsonFile('/test/outer/examples/inner');
+        newPackageConfigJsonFile('/test/outer/examples/inner', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [outerRootFolder.path]);
@@ -1035,12 +1039,13 @@
 
   void test_locateRoots_nested_packages_overriddenOptions() {
     Folder outerRootFolder = newFolder('/test/outer');
-    newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     Folder innerRootFolder = newFolder('/test/outer/examples/inner');
     File innerPackagesFile =
-        newPackageConfigJsonFile('/test/outer/examples/inner');
-    File overrideOptionsFile = newAnalysisOptionsYamlFile('/test/override');
+        newPackageConfigJsonFile('/test/outer/examples/inner', '');
+    File overrideOptionsFile =
+        newAnalysisOptionsYamlFile2('/test/override', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -1062,11 +1067,11 @@
 
   void test_locateRoots_nested_packages_overriddenPackages() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    newPackageConfigJsonFile('/test/outer', '');
     newFolder('/test/outer/examples/inner');
-    newPackageConfigJsonFile('/test/outer/examples/inner');
-    File overridePackagesFile = newPackageConfigJsonFile('/test/override');
+    newPackageConfigJsonFile('/test/outer/examples/inner', '');
+    File overridePackagesFile = newPackageConfigJsonFile('/test/override', '');
 
     List<ContextRoot> roots = contextLocator.locateRoots(
         includedPaths: [outerRootFolder.path],
@@ -1082,10 +1087,10 @@
 
   void test_locateRoots_nested_packagesDirectory_included() {
     Folder outerRootFolder = newFolder('/test/outer');
-    File outerOptionsFile = newAnalysisOptionsYamlFile('/test/outer');
-    File outerPackagesFile = newPackageConfigJsonFile('/test/outer');
+    File outerOptionsFile = newAnalysisOptionsYamlFile2('/test/outer', '');
+    File outerPackagesFile = newPackageConfigJsonFile('/test/outer', '');
     File innerOptionsFile =
-        newAnalysisOptionsYamlFile('/test/outer/packages/inner');
+        newAnalysisOptionsYamlFile2('/test/outer/packages/inner', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [outerRootFolder.path]);
@@ -1102,9 +1107,10 @@
   void test_locateRoots_options_default_bazel() {
     var workspacePath = '/home/workspace';
     var workspaceFolder = getFolder(workspacePath);
-    newFile('$workspacePath/WORKSPACE');
-    var bazelOptionsFile = newFile(
+    newFile2('$workspacePath/WORKSPACE', '');
+    var bazelOptionsFile = newFile2(
       '$workspacePath/dart/analysis_options/lib/default.yaml',
+      '',
     );
 
     var rootFolder = getFolder('$workspacePath/test');
@@ -1125,15 +1131,16 @@
     var rootFolder = newFolder('/home/test');
 
     var flutterPath = '/home/packages/flutter';
-    var flutterAnalysisOptionsFile = newFile(
+    var flutterAnalysisOptionsFile = newFile2(
       '$flutterPath/lib/analysis_options_user.yaml',
+      '',
     );
 
     var packageConfigFileBuilder = PackageConfigFileBuilder()
       ..add(name: 'flutter', rootPath: flutterPath);
     var packagesFile = newPackageConfigJsonFile(
       rootFolder.path,
-      content: packageConfigFileBuilder.toContent(toUriStr: toUriStr),
+      packageConfigFileBuilder.toContent(toUriStr: toUriStr),
     );
 
     var roots = contextLocator.locateRoots(
@@ -1150,13 +1157,13 @@
 
   void test_locateRoots_options_hasError() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 analyzer:
   exclude:
     - **.g.dart
 analyzer:
 ''');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1177,12 +1184,12 @@
 
   void test_locateRoots_options_withExclude_someFiles() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 analyzer:
   exclude:
     - data/**.g.dart
 ''');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1210,12 +1217,12 @@
 
   void test_locateRoots_options_withExclude_someFolders() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 analyzer:
   exclude:
     - data/**/foo/**
 ''');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1242,12 +1249,12 @@
 
   void test_locateRoots_options_withExclude_wholeFolder() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 analyzer:
   exclude:
     - data/**
 ''');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
     newFolder('/test/root/data');
 
     List<ContextRoot> roots =
@@ -1272,16 +1279,16 @@
 
   void test_locateRoots_options_withExclude_wholeFolder_includedOptions() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 include: has_excludes.yaml
 ''');
-    newFile('/test/root/has_excludes.yaml', content: '''
+    newFile2('/test/root/has_excludes.yaml', '''
 analyzer:
   exclude:
     - data/**
 ''');
 
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
     newFolder('/test/root/data');
 
     List<ContextRoot> roots =
@@ -1306,19 +1313,19 @@
 
   void test_locateRoots_options_withExclude_wholeFolder_includedOptionsMerge() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 include: has_excludes.yaml
 analyzer:
   exclude:
     - bar/**
 ''');
-    newFile('/test/root/has_excludes.yaml', content: '''
+    newFile2('/test/root/has_excludes.yaml', '''
 analyzer:
   exclude:
     - foo/**
 ''');
 
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
     newFolder('/test/root/foo');
     newFolder('/test/root/bar');
 
@@ -1347,14 +1354,14 @@
 
   void test_locateRoots_options_withExclude_wholeFolder_withItsOptions() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root', content: '''
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '''
 analyzer:
   exclude:
     - data/**
 ''');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
     newFolder('/test/root/data');
-    newAnalysisOptionsYamlFile('/test/root/data', content: '');
+    newAnalysisOptionsYamlFile2('/test/root/data', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1378,8 +1385,8 @@
 
   void test_locateRoots_single_dir_directOptions_directPackages() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1394,8 +1401,8 @@
 
   void test_locateRoots_single_dir_directOptions_inheritedPackages() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test/root');
-    File packagesFile = newPackageConfigJsonFile('/test');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test/root', '');
+    File packagesFile = newPackageConfigJsonFile('/test', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1410,8 +1417,8 @@
 
   void test_locateRoots_single_dir_inheritedOptions_directPackages() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test', '');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1426,8 +1433,8 @@
 
   void test_locateRoots_single_dir_inheritedOptions_inheritedPackages() {
     Folder rootFolder = newFolder('/test/root');
-    File optionsFile = newAnalysisOptionsYamlFile('/test');
-    File packagesFile = newPackageConfigJsonFile('/test');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test', '');
+    File packagesFile = newPackageConfigJsonFile('/test', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [rootFolder.path]);
@@ -1442,9 +1449,9 @@
 
   void test_locateRoots_single_dir_prefer_packageConfigJson() {
     var rootFolder = newFolder('/test');
-    var optionsFile = newAnalysisOptionsYamlFile('/test');
-    newPackageConfigJsonFile('/test'); // the file is not used
-    var packageConfigJsonFile = newPackageConfigJsonFile('/test');
+    var optionsFile = newAnalysisOptionsYamlFile2('/test', '');
+    newPackageConfigJsonFile('/test', ''); // the file is not used
+    var packageConfigJsonFile = newPackageConfigJsonFile('/test', '');
 
     var roots = contextLocator.locateRoots(includedPaths: [rootFolder.path]);
     expect(roots, hasLength(1));
@@ -1457,9 +1464,9 @@
   }
 
   void test_locateRoots_single_file_inheritedOptions_directPackages() {
-    File optionsFile = newAnalysisOptionsYamlFile('/test');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
-    File testFile = newFile('/test/root/test.dart');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test', '');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
+    File testFile = newFile2('/test/root/test.dart', '');
 
     List<ContextRoot> roots =
         contextLocator.locateRoots(includedPaths: [testFile.path]);
@@ -1473,8 +1480,8 @@
   }
 
   void test_locateRoots_single_file_notExisting() {
-    File optionsFile = newAnalysisOptionsYamlFile('/test');
-    File packagesFile = newPackageConfigJsonFile('/test/root');
+    File optionsFile = newAnalysisOptionsYamlFile2('/test', '');
+    File packagesFile = newPackageConfigJsonFile('/test/root', '');
     File testFile = getFile('/test/root/test.dart');
 
     List<ContextRoot> roots =
diff --git a/pkg/analyzer/test/src/dart/analysis/context_root_test.dart b/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
index 90eb23e..7f8f853 100644
--- a/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/context_root_test.dart
@@ -42,11 +42,11 @@
     String excludePath = convertPath('/test/root/exclude');
     String cPath = convertPath('/test/root/exclude/c.dart');
 
-    newFile(optionsPath);
-    newFile(readmePath);
-    newFile(aPath);
-    newFile(bPath);
-    newFile(cPath);
+    newFile2(optionsPath, '');
+    newFile2(readmePath, '');
+    newFile2(aPath, '');
+    newFile2(bPath, '');
+    newFile2(cPath, '');
     contextRoot.excluded.add(newFolder(excludePath));
 
     expect(contextRoot.analyzedFiles(),
@@ -55,9 +55,9 @@
 
   test_isAnalyzed_excludedByGlob_includedFile() {
     var rootPath = '/home/test';
-    var includedFile = newFile('$rootPath/lib/a1.dart');
-    var excludedFile = newFile('$rootPath/lib/a2.dart');
-    var implicitFile = newFile('$rootPath/lib/b.dart');
+    var includedFile = newFile2('$rootPath/lib/a1.dart', '');
+    var excludedFile = newFile2('$rootPath/lib/a2.dart', '');
+    var implicitFile = newFile2('$rootPath/lib/b.dart', '');
 
     var root = _createContextRoot(rootPath);
     root.included.add(includedFile);
@@ -80,14 +80,14 @@
 
     var includedFolderPath = convertPath('$rootPath/lib/src/included');
     var includedFolder = getFolder(includedFolderPath);
-    var includedFile1 = newFile('$includedFolderPath/a1.dart');
-    var includedFile2 = newFile('$includedFolderPath/inner/a2.dart');
-    var excludedFile1 = newFile('$includedFolderPath/a1.g.dart');
+    var includedFile1 = newFile2('$includedFolderPath/a1.dart', '');
+    var includedFile2 = newFile2('$includedFolderPath/inner/a2.dart', '');
+    var excludedFile1 = newFile2('$includedFolderPath/a1.g.dart', '');
 
     var excludedFolderPath = convertPath('$rootPath/lib/src/not_included');
-    var excludedFile2 = newFile('$excludedFolderPath/b.dart');
+    var excludedFile2 = newFile2('$excludedFolderPath/b.dart', '');
 
-    var implicitFile = newFile('$rootPath/lib/c.dart');
+    var implicitFile = newFile2('$rootPath/lib/c.dart', '');
 
     var root = _createContextRoot(rootPath);
     root.included.add(includedFolder);
diff --git a/pkg/analyzer/test/src/dart/analysis/dependency/base.dart b/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
index fa356af..c263789 100644
--- a/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
+++ b/pkg/analyzer/test/src/dart/analysis/dependency/base.dart
@@ -60,7 +60,7 @@
 //      await _addLibraryByUri('dart:_internal');
 //    }
 
-    newFile(path, content: content);
+    newFile2(path, content);
 
     var analysisDriver = driverFor(path);
     analysisDriver.changeFile(path);
diff --git a/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart b/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
index 5e1206c..38d8b2d 100644
--- a/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/dependency/reference_collector_test.dart
@@ -1085,7 +1085,7 @@
   }
 
   test_prefixedIdentifier_importPrefix() async {
-    newFile(b, content: 'var b = 0;');
+    newFile2(b, 'var b = 0;');
     var library = await buildTestLibrary(a, r'''
 import 'b.dart' as pb;
 
@@ -1099,7 +1099,7 @@
   }
 
   test_prefixedIdentifier_importPrefix_unresolvedIdentifier() async {
-    newFile(b, content: '');
+    newFile2(b, '');
     var library = await buildTestLibrary(a, r'''
 import 'b.dart' as pb;
 
@@ -1420,7 +1420,7 @@
   }
 
   test_class_constructor_factoryRedirect_named_prefixed() async {
-    newFile(b, content: 'class A {}');
+    newFile2(b, 'class A {}');
 
     var library = await buildTestLibrary(a, r'''
 import 'b.dart' as p;
@@ -1464,7 +1464,7 @@
   }
 
   test_class_constructor_factoryRedirect_unnamed_prefixed() async {
-    newFile(b, content: 'class A {}');
+    newFile2(b, 'class A {}');
 
     var library = await buildTestLibrary(a, r'''
 import 'b.dart' as p;
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
index 421716f..e64b61a 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_caching_test.dart
@@ -35,7 +35,7 @@
       ),
     );
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 dynamic a = 0;
 int b = a;
 ''');
@@ -117,7 +117,7 @@
   test_change_field_staticFinal_hasConstConstructor_changeInitializer() async {
     useEmptyByteStore();
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 class A {
   static const a = 0;
   static const b = 1;
@@ -137,7 +137,7 @@
     // We will reuse the byte store, so can reuse summaries.
     disposeAnalysisContextCollection();
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 class A {
   static const a = 0;
   static const b = 1;
@@ -158,7 +158,7 @@
   test_change_functionBody() async {
     useEmptyByteStore();
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 void f() {
   print(0);
 }
@@ -175,7 +175,7 @@
     // We will reuse the byte store, so can reuse summaries.
     disposeAnalysisContextCollection();
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 void f() {
   print(1);
 }
@@ -192,7 +192,7 @@
     useEmptyByteStore();
 
     var aaaPackageRootPath = '$packagesRootPath/aaa';
-    newFile('$aaaPackageRootPath/lib/a.dart', content: '');
+    newFile2('$aaaPackageRootPath/lib/a.dart', '');
 
     writeTestPackageConfig(
       PackageConfigFileBuilder()
@@ -213,7 +213,7 @@
       ),
     );
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 // ignore:unused_import
 import 'package:aaa/a.dart';
 ''');
@@ -256,7 +256,7 @@
       AnalysisOptionsFileConfig(lints: []),
     );
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 void f() {
   ![0].isEmpty;
 }
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
index ebf8025..83e4941 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_resolution_test.dart
@@ -247,7 +247,7 @@
   }
 
   test_annotation_onDirective_part() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 part of 'test.dart';
 ''');
     addTestFile(r'''
@@ -270,7 +270,7 @@
   }
 
   test_annotation_onDirective_partOf() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 part 'test.dart';
 ''');
     addTestFile(r'''
@@ -393,7 +393,7 @@
   }
 
   test_annotation_prefixed_classField() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const a = 1;
 }
@@ -432,7 +432,7 @@
   }
 
   test_annotation_prefixed_constructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A(int a, {int b});
 }
@@ -473,7 +473,7 @@
   }
 
   test_annotation_prefixed_constructor_named() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named(int a, {int b});
 }
@@ -516,7 +516,7 @@
   }
 
   test_annotation_prefixed_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const topAnnotation = 1;
 ''');
     addTestFile(r'''
@@ -1422,7 +1422,7 @@
   }
 
   test_deferredImport_loadLibrary_invocation() async {
-    newFile('$testPackageLibPath/a.dart');
+    newFile2('$testPackageLibPath/a.dart', '');
     addTestFile(r'''
 import 'a.dart' deferred as a;
 main() {
@@ -1446,7 +1446,7 @@
   }
 
   test_deferredImport_loadLibrary_invocation_argument() async {
-    newFile('$testPackageLibPath/a.dart');
+    newFile2('$testPackageLibPath/a.dart', '');
     addTestFile(r'''
 import 'a.dart' deferred as a;
 var b = 1;
@@ -1480,7 +1480,7 @@
   }
 
   test_deferredImport_loadLibrary_tearOff() async {
-    newFile('$testPackageLibPath/a.dart');
+    newFile2('$testPackageLibPath/a.dart', '');
     addTestFile(r'''
 import 'a.dart' deferred as a;
 main() {
@@ -1503,7 +1503,7 @@
   }
 
   test_deferredImport_variable() async {
-    newFile('$testPackageLibPath/a.dart', content: 'var v = 0;');
+    newFile2('$testPackageLibPath/a.dart', 'var v = 0;');
     addTestFile(r'''
 import 'a.dart' deferred as a;
 main() async {
@@ -1542,7 +1542,7 @@
   }
 
   test_directive_export() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class MyClass {}
 int myVar;
 int get myGetter => 0;
@@ -1590,7 +1590,7 @@
   }
 
   test_directive_import_hide() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class MyClass {}
 int myVar;
 int get myGetter => 0;
@@ -1638,7 +1638,7 @@
   }
 
   test_directive_import_show() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class MyClass {}
 int myVar;
 int get myGetter => 0;
@@ -2187,7 +2187,7 @@
   }
 
   test_instanceCreation_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C<T> {
   C(T p);
   C.named(T p);
@@ -3595,7 +3595,7 @@
 
   @failingTest
   test_invalid_nonTypeAsType_topLevelFunction_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int T() => 0;
 ''');
     addTestFile(r'''
@@ -3663,7 +3663,7 @@
 
   @failingTest
   test_invalid_nonTypeAsType_topLevelVariable_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int T;
 ''');
     addTestFile(r'''
@@ -5618,7 +5618,7 @@
   }
 
   test_optionalConst_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   const C();
   const C.named();
@@ -6132,7 +6132,7 @@
   }
 
   test_prefixedIdentifier_importPrefix_className() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class MyClass {}
 typedef void MyFunctionTypeAlias();
 int myTopVariable;
@@ -7733,9 +7733,9 @@
   }
 
   test_typeAnnotation_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/b.dart', content: "export 'a.dart';");
-    newFile('$testPackageLibPath/c.dart', content: "export 'a.dart';");
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/b.dart', "export 'a.dart';");
+    newFile2('$testPackageLibPath/c.dart', "export 'a.dart';");
     addTestFile(r'''
 import 'b.dart' as b;
 import 'c.dart' as c;
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 1aba4d2..1bfe413 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -58,7 +58,7 @@
 
     var innerPath = convertPath('$outerLibPath/inner/lib/b.dart');
     var innerUri = Uri.parse('package:my.outer.lib.inner/b.dart');
-    newFile(innerPath, content: 'class B {}');
+    newFile2(innerPath, 'class B {}');
 
     var analysisSession = contextFor(innerPath).currentSession;
 
@@ -71,7 +71,7 @@
 
     // Reference "inner" using a non-canonical URI.
     {
-      var a = newFile(convertPath('$outerLibPath/a.dart'), content: r'''
+      var a = newFile2(convertPath('$outerLibPath/a.dart'), r'''
 import 'inner/lib/b.dart';
 ''');
       var result = await analysisSession.getResolvedUnit(a.path);
@@ -81,7 +81,7 @@
 
     // Reference "inner" using the canonical URI, via relative.
     {
-      var c = newFile('$outerLibPath/inner/lib/c.dart', content: r'''
+      var c = newFile2('$outerLibPath/inner/lib/c.dart', r'''
 import 'b.dart';
 ''');
       var result = await analysisSession.getResolvedUnit(c.path);
@@ -91,7 +91,7 @@
 
     // Reference "inner" using the canonical URI, via absolute.
     {
-      var d = newFile('$outerLibPath/inner/lib/d.dart', content: '''
+      var d = newFile2('$outerLibPath/inner/lib/d.dart', '''
 import '$innerUri';
 ''');
       var result = await analysisSession.getResolvedUnit(d.path);
@@ -153,10 +153,10 @@
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
     String d = convertPath('/d.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: "import 'a.dart';");
-    newFile(c, content: 'class C {}');
-    newFile(d, content: "import 'c.dart';");
+    newFile2(a, 'class A {}');
+    newFile2(b, "import 'a.dart';");
+    newFile2(c, 'class C {}');
+    newFile2(d, "import 'c.dart';");
     driver1.addFile(a);
     driver1.addFile(b);
     driver2.addFile(c);
@@ -185,9 +185,9 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
-    newFile(a, content: "import 'c.dart';");
-    newFile(b, content: 'class B {}');
-    newFile(c, content: "import 'b.dart';");
+    newFile2(a, "import 'c.dart';");
+    newFile2(b, 'class B {}');
+    newFile2(c, "import 'b.dart';");
     driver1.addFile(a);
     driver1.addFile(b);
     driver2.addFile(c);
@@ -213,10 +213,10 @@
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
     String d = convertPath('/d.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: "export 'a.dart';");
-    newFile(c, content: "import 'b.dart';");
-    newFile(d, content: "import 'b.dart'; class D extends X {}");
+    newFile2(a, 'class A {}');
+    newFile2(b, "export 'a.dart';");
+    newFile2(c, "import 'b.dart';");
+    newFile2(d, "import 'b.dart'; class D extends X {}");
     driver1.addFile(a);
     driver1.addFile(b);
     driver2.addFile(c);
@@ -242,9 +242,9 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
     driver1.addFile(a);
     driver2.addFile(b);
     driver2.addFile(c);
@@ -268,8 +268,8 @@
 
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
     driver1.addFile(a);
     driver2.addFile(b);
     driver1.priorityFiles = [a];
@@ -288,8 +288,8 @@
 
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
     driver1.addFile(a);
     driver2.addFile(b);
     driver1.priorityFiles = [b];
@@ -309,9 +309,9 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
     driver1.addFile(a);
     driver1.addFile(b);
     driver2.addFile(c);
@@ -333,9 +333,9 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
     String c = convertPath('/c.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
     driver1.addFile(a);
     driver2.addFile(b);
     driver2.addFile(c);
@@ -366,8 +366,8 @@
 
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
     driver1.addFile(a);
     driver2.addFile(b);
 
@@ -427,8 +427,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: 'class A {}');
-    newFile(b, content: r'''
+    newFile2(a, 'class A {}');
+    newFile2(b, r'''
 import 'a.dart';
 ''');
 
@@ -446,7 +446,7 @@
     assertNumberOfErrorsInB(1);
 
     // Update 'b' to use 'a', no more hints.
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 main() {
   print(A);
@@ -459,7 +459,7 @@
     // Change 'b' content so that it has a hint.
     // Remove 'b' and add it again.
     // The file 'b' must be refreshed, and the hint must be reported.
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 ''');
     driver.removeFile(b);
@@ -471,8 +471,8 @@
   test_addFile_thenRemove() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
     driver.addFile(a);
     driver.addFile(b);
 
@@ -490,15 +490,15 @@
     var lib = convertPath('/test/lib.dart');
     var part1 = convertPath('/test/part1.dart');
     var part2 = convertPath('/test/part2.dart');
-    newFile(lib, content: '''
+    newFile2(lib, '''
 library lib;
 part 'part1.dart';
 part 'part2.dart';
 ''');
-    newFile(part1, content: '''
+    newFile2(part1, '''
 part of lib;
 ''');
-    newFile(part2, content: '''
+    newFile2(part2, '''
 part of 'lib.dart';
 ''');
 
@@ -540,10 +540,10 @@
   test_analyze_resolveDirectives_error_missingLibraryDirective() async {
     var lib = convertPath('/test/lib.dart');
     var part = convertPath('/test/part.dart');
-    newFile(lib, content: '''
+    newFile2(lib, '''
 part 'part.dart';
 ''');
-    newFile(part, content: '''
+    newFile2(part, '''
 part of lib;
 ''');
 
@@ -558,11 +558,11 @@
   test_analyze_resolveDirectives_error_partOfDifferentLibrary_byName() async {
     var lib = convertPath('/test/lib.dart');
     var part = convertPath('/test/part.dart');
-    newFile(lib, content: '''
+    newFile2(lib, '''
 library lib;
 part 'part.dart';
 ''');
-    newFile(part, content: '''
+    newFile2(part, '''
 part of someOtherLib;
 ''');
 
@@ -577,11 +577,11 @@
   test_analyze_resolveDirectives_error_partOfDifferentLibrary_byUri() async {
     var lib = convertPath('/test/lib.dart');
     var part = convertPath('/test/part.dart');
-    newFile(lib, content: '''
+    newFile2(lib, '''
 library lib;
 part 'part.dart';
 ''');
-    newFile(part, content: '''
+    newFile2(part, '''
 part of 'other_lib.dart';
 ''');
 
@@ -596,11 +596,11 @@
   test_analyze_resolveDirectives_error_partOfNonPart() async {
     var lib = convertPath('/test/lib.dart');
     var part = convertPath('/test/part.dart');
-    newFile(lib, content: '''
+    newFile2(lib, '''
 library lib;
 part 'part.dart';
 ''');
-    newFile(part, content: '''
+    newFile2(part, '''
 // no part of directive
 ''');
 
@@ -614,7 +614,7 @@
 
   test_cachedPriorityResults() async {
     var a = convertPath('/test/bin/a.dart');
-    newFile(a, content: 'var a = 1;');
+    newFile2(a, 'var a = 1;');
 
     driver.priorityFiles = [a];
 
@@ -644,8 +644,8 @@
   test_cachedPriorityResults_flush_onAnyFileChange() async {
     var a = convertPath('/test/bin/a.dart');
     var b = convertPath('/test/bin/b.dart');
-    newFile(a, content: 'var a = 1;');
-    newFile(a, content: 'var b = 2;');
+    newFile2(a, 'var a = 1;');
+    newFile2(a, 'var b = 2;');
 
     driver.priorityFiles = [a];
 
@@ -675,8 +675,8 @@
   test_cachedPriorityResults_flush_onPrioritySetChange() async {
     var a = convertPath('/test/bin/a.dart');
     var b = convertPath('/test/bin/b.dart');
-    newFile(a, content: 'var a = 1;');
-    newFile(b, content: 'var b = 2;');
+    newFile2(a, 'var a = 1;');
+    newFile2(b, 'var b = 2;');
 
     driver.priorityFiles = [a];
 
@@ -705,7 +705,7 @@
 
   test_cachedPriorityResults_notPriority() async {
     var a = convertPath('/test/bin/a.dart');
-    newFile(a, content: 'var a = 1;');
+    newFile2(a, 'var a = 1;');
 
     ResolvedUnitResult result1 = await driver.getResultValid(a);
     expect(driver.test.priorityResults, isEmpty);
@@ -718,11 +718,11 @@
   test_changeFile_implicitlyAnalyzed() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'b.dart';
 var A = B;
 ''');
-    newFile(b, content: 'var B = 1;');
+    newFile2(b, 'var B = 1;');
 
     driver.priorityFiles = [a];
     driver.addFile(a);
@@ -766,8 +766,8 @@
   test_changeFile_notUsed() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/other/b.dart');
-    newFile(a);
-    newFile(b, content: 'class B1 {}');
+    newFile2(a, '');
+    newFile2(b, 'class B1 {}');
 
     driver.addFile(a);
 
@@ -786,17 +786,17 @@
   }
 
   test_changeFile_potentiallyAffected_imported() async {
-    newFile('/test/lib/a.dart', content: '');
-    var b = newFile('/test/lib/b.dart', content: '''
+    newFile2('/test/lib/a.dart', '');
+    var b = newFile2('/test/lib/b.dart', '''
 import 'a.dart';
 ''');
-    newFile('/test/lib/c.dart', content: '''
+    var c = newFile2('/test/lib/c.dart', '''
 import 'b.dart';
 ''');
-    newFile('/test/lib/d.dart', content: '''
+    var d = newFile2('/test/lib/d.dart', '''
 import 'c.dart';
 ''');
-    newFile('/test/lib/e.dart', content: '');
+    newFile2('/test/lib/e.dart', '');
 
     Future<LibraryElementImpl> getLibrary(String shortName) async {
       var uriStr = 'package:test/$shortName';
@@ -832,7 +832,8 @@
     // Change `b.dart`, also removes `c.dart` and `d.dart` that import it.
     // But `a.dart` and `d.dart` is not affected.
     driver.changeFile(b.path);
-    await driver.applyPendingFileChanges();
+    var affectedPathList = await driver.applyPendingFileChanges();
+    expect(affectedPathList, unorderedEquals([b.path, c.path, d.path]));
 
     // We have a new session.
     var session2 = driver.currentSession;
@@ -860,16 +861,16 @@
   }
 
   test_changeFile_potentiallyAffected_part() async {
-    var a = newFile('/test/lib/a.dart', content: '''
+    var a = newFile2('/test/lib/a.dart', '''
 part of 'b.dart';
 ''');
-    newFile('/test/lib/b.dart', content: '''
+    var b = newFile2('/test/lib/b.dart', '''
 part 'a.dart';
 ''');
-    newFile('/test/lib/c.dart', content: '''
+    var c = newFile2('/test/lib/c.dart', '''
 import 'b.dart';
 ''');
-    newFile('/test/lib/d.dart', content: '');
+    newFile2('/test/lib/d.dart', '');
 
     Future<LibraryElementImpl> getLibrary(String shortName) async {
       var uriStr = 'package:test/$shortName';
@@ -900,7 +901,13 @@
     // Removes `c.dart` that imports `b.dart`.
     // But `d.dart` is not affected.
     driver.changeFile(a.path);
-    await driver.applyPendingFileChanges();
+    var affectedPathList = await driver.applyPendingFileChanges();
+    expect(affectedPathList, unorderedEquals([a.path, b.path, c.path]));
+
+    // We have a new session.
+    var session2 = driver.currentSession;
+    expect(session2, isNot(session1));
+
     driver.assertLoadedLibraryUriSet(
       excluded: [
         'package:test/b.dart',
@@ -911,10 +918,6 @@
       ],
     );
 
-    // We have a new session.
-    var session2 = driver.currentSession;
-    expect(session2, isNot(session1));
-
     // `d.dart` moved to the new session.
     // Invalidated libraries stuck with the old session.
     expect(b_element.session, session1);
@@ -925,12 +928,12 @@
   test_changeFile_selfConsistent() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'b.dart';
 var A1 = 1;
 var A2 = B1;
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 var B1 = A1;
 ''');
@@ -1107,13 +1110,13 @@
   test_const_implicitCreation() async {
     var a = convertPath('/test/bin/a.dart');
     var b = convertPath('/test/bin/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class C {
   const C();
   static const C WARNING = C();
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 
 class D {
@@ -1131,7 +1134,7 @@
   test_const_implicitCreation_rewrite() async {
     var a = convertPath('/test/bin/a.dart');
     var b = convertPath('/test/bin/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {
   const A();
 }
@@ -1146,7 +1149,7 @@
   const C();
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 
 main() {
@@ -1182,7 +1185,7 @@
   test_currentSession() async {
     var a = convertPath('/test/lib/a.dart');
 
-    newFile(a, content: 'var V = 1;');
+    newFile2(a, 'var V = 1;');
     await driver.getResultValid(a);
 
     var session1 = driver.currentSession;
@@ -1207,12 +1210,12 @@
     var b = convertPath('/bbb/lib/b.dart');
     var c = convertPath('/ccc/lib/c.dart');
 
-    newFile(t, content: 'class T {}');
-    newFile(a1, content: 'class A1 {}');
-    newFile(a2, content: 'class A2 {}');
-    newFile(a3, content: 'text');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(t, 'class T {}');
+    newFile2(a1, 'class A1 {}');
+    newFile2(a2, 'class A2 {}');
+    newFile2(a3, 'text');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
 
     driver.addFile(t);
     // Don't add a1.dart, a2.dart, or b.dart - they should be discovered.
@@ -1299,12 +1302,12 @@
     String templatePath = convertPath('/aaa/lib/foo.dart');
     String generatedPath = convertPath('/generated/aaa/lib/foo.dart');
 
-    newFile(templatePath, content: r'''
+    newFile2(templatePath, r'''
 a() {}
 b() {}
 ''');
 
-    newFile(generatedPath, content: r'''
+    newFile2(generatedPath, r'''
 aaa() {}
 bbb() {}
 ''');
@@ -1358,7 +1361,7 @@
 
   test_getCachedResult() async {
     var a = convertPath('/test/bin/a.dart');
-    newFile(a, content: 'var a = 1;');
+    newFile2(a, 'var a = 1;');
 
     expect(driver.getCachedResult(a), isNull);
 
@@ -1387,8 +1390,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 
 void f(A a) {}
@@ -1400,7 +1403,7 @@
 
     // Update the file, changing its API signature.
     // Note that we don't call `changeFile`.
-    newFile(a, content: 'class A {}\n');
+    newFile2(a, 'class A {}\n');
 
     // Get the file.
     // We have not called `changeFile(a)`, so we should not read the file.
@@ -1423,7 +1426,7 @@
 
   test_getFile_library() async {
     var path = convertPath('/test/lib/a.dart');
-    newFile(path);
+    newFile2(path, '');
     var file = await driver.getFileValid(path);
     expect(file.path, path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -1437,7 +1440,7 @@
 
   test_getFile_part() async {
     var path = convertPath('/test/lib/a.dart');
-    newFile(path, content: 'part of lib;');
+    newFile2(path, 'part of lib;');
     var file = await driver.getFileValid(path);
     expect(file.path, path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -1450,10 +1453,10 @@
     var c = convertPath('/test/bin/c.dart');
     var d = convertPath('/test/bin/d.dart');
 
-    newFile(a, content: 'class A { m1() {} }');
-    newFile(b, content: 'class B { m2() {} }');
-    newFile(c, content: 'class C { m2() {} }');
-    newFile(d, content: 'class D { m3() {} }');
+    newFile2(a, 'class A { m1() {} }');
+    newFile2(b, 'class B { m2() {} }');
+    newFile2(c, 'class C { m2() {} }');
+    newFile2(d, 'class D { m3() {} }');
 
     driver.addFile(a);
     driver.addFile(b);
@@ -1476,10 +1479,10 @@
     var c = convertPath('/test/bin/c.dart');
     var d = convertPath('/test/bin/d.dart');
 
-    newFile(a, content: 'mixin A { m1() {} }');
-    newFile(b, content: 'mixin B { m2() {} }');
-    newFile(c, content: 'mixin C { m2() {} }');
-    newFile(d, content: 'mixin D { m3() {} }');
+    newFile2(a, 'mixin A { m1() {} }');
+    newFile2(b, 'mixin B { m2() {} }');
+    newFile2(c, 'mixin C { m2() {} }');
+    newFile2(d, 'mixin D { m3() {} }');
 
     driver.addFile(a);
     driver.addFile(b);
@@ -1503,11 +1506,11 @@
     var d = convertPath('/test/bin/d.dart');
     var e = convertPath('/test/bin/e.dart');
 
-    newFile(a, content: 'class A {}');
-    newFile(b, content: "import 'a.dart'; A a;");
-    newFile(c, content: "import 'a.dart'; var a = new A();");
-    newFile(d, content: "class A{} A a;");
-    newFile(e, content: "import 'a.dart'; main() {}");
+    newFile2(a, 'class A {}');
+    newFile2(b, "import 'a.dart'; A a;");
+    newFile2(c, "import 'a.dart'; var a = new A();");
+    newFile2(d, "class A{} A a;");
+    newFile2(e, "import 'a.dart'; main() {}");
 
     driver.addFile(a);
     driver.addFile(b);
@@ -1533,10 +1536,10 @@
     var b = convertPath('/bbb/lib/b.dart');
     var c = convertPath('/ccc/lib/c.dart');
 
-    newFile(t, content: 'int t;');
-    newFile(a, content: 'int a;');
-    newFile(b, content: 'int b;');
-    newFile(c, content: 'int c;');
+    newFile2(t, 'int t;');
+    newFile2(a, 'int a;');
+    newFile2(b, 'int b;');
+    newFile2(c, 'int c;');
 
     driver.addFile(t);
 
@@ -1552,8 +1555,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 
 void f(A a) {}
@@ -1565,7 +1568,7 @@
 
     // Update the file, changing its API signature.
     // Note that we don't call `changeFile`.
-    newFile(a, content: 'class A {}\n');
+    newFile2(a, 'class A {}\n');
 
     // Get the file.
     // We have not called `changeFile(a)`, so we should not read the file.
@@ -1588,7 +1591,7 @@
   @deprecated
   test_getFileSync_library() async {
     var path = convertPath('/test/lib/a.dart');
-    newFile(path);
+    newFile2(path, '');
     var file = driver.getFileSyncValid(path);
     expect(file.path, path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -1604,7 +1607,7 @@
   @deprecated
   test_getFileSync_part() async {
     var path = convertPath('/test/lib/a.dart');
-    newFile(path, content: 'part of lib;');
+    newFile2(path, 'part of lib;');
     var file = driver.getFileSyncValid(path);
     expect(file.path, path);
     expect(file.uri.toString(), 'package:test/a.dart');
@@ -1641,13 +1644,13 @@
     String aUriStr = 'package:test/a.dart';
     String bUriStr = 'package:test/b.dart';
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 
 class A {}
 ''');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 
 class B {}
@@ -1850,8 +1853,8 @@
   test_getResult_constants_defaultParameterValue_localFunction() async {
     var a = convertPath('/test/bin/a.dart');
     var b = convertPath('/test/bin/b.dart');
-    newFile(a, content: 'const C = 42;');
-    newFile(b, content: r'''
+    newFile2(a, 'const C = 42;');
+    newFile2(b, r'''
 import 'a.dart';
 main() {
   foo({int p: C}) {}
@@ -1929,8 +1932,8 @@
   test_getResult_importLibrary_thenRemoveIt() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: r'''
+    newFile2(a, 'class A {}');
+    newFile2(b, r'''
 import 'a.dart';
 class B extends A {}
 ''');
@@ -1959,7 +1962,7 @@
     }
 
     // Restore a.dart and reanalyze.
-    newFile(a, content: 'class A {}');
+    newFile2(a, 'class A {}');
     driver.addFile(a);
 
     // No errors in b.dart again.
@@ -2092,7 +2095,7 @@
 
   test_getResult_languageVersion() async {
     var path = convertPath('/test/lib/test.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 // @dart = 2.7
 class A{}
 ''');
@@ -2108,19 +2111,19 @@
     var b = convertPath('/test/bin/b.dart');
     var c = convertPath('/test/lib/c.dart');
     var d = convertPath('/test/test/d.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'package:test/c.dart';
 int x = y;
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import '../lib/c.dart';
 int x = y;
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 import '../test/d.dart';
 var y = z;
 ''');
-    newFile(d, content: r'''
+    newFile2(d, r'''
 String z = "string";
 ''');
 
@@ -2174,7 +2177,7 @@
 
   test_getResult_notDartFile() async {
     var path = convertPath('/test/lib/test.txt');
-    newFile(path, content: 'class A {}');
+    newFile2(path, 'class A {}');
 
     ResolvedUnitResult result = await driver.getResultValid(path);
     expect(result, isNotNull);
@@ -2195,12 +2198,12 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/test/c.dart');
-    newFile(a, content: 'class A<T> {}');
-    newFile(b, content: r'''
+    newFile2(a, 'class A<T> {}');
+    newFile2(b, r'''
 import 'a.dart';
 var VB = new A<int>();
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 import '../lib/a.dart';
 var VC = new A<double>();
 ''');
@@ -2231,12 +2234,12 @@
   test_getResult_selfConsistent() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'b.dart';
 var A1 = 1;
 var A2 = B1;
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 import 'a.dart';
 var B1 = A1;
 ''');
@@ -2319,7 +2322,7 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'package:test/b.dart';
 ''');
 
@@ -2334,7 +2337,7 @@
 
   test_getUnitElement_notDart() async {
     var path = convertPath('/test.txt');
-    newFile(path, content: 'class A {}');
+    newFile2(path, 'class A {}');
     var unitResult = await driver.getUnitElement(path);
     unitResult as UnitElementResult;
     expect(unitResult.element.classes.map((e) => e.name), ['A']);
@@ -2375,14 +2378,14 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 part 'b.dart';
 class C {
   int foo;
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of a;
 var c = new C();
 ''');
@@ -2394,7 +2397,7 @@
 
     // Modify the library, but don't notify the driver.
     // The driver should use the previous library content and elements.
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 part 'b.dart';
 class C {
@@ -2415,17 +2418,17 @@
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
 
-    newFile(a, content: '''
+    newFile2(a, '''
 library my.lib;
 
 part 'b.dart';
 ''');
-    newFile(b, content: '''
+    newFile2(b, '''
 part of my.lib;
 
 class A {}
 ''');
-    newFile(c, content: '''
+    newFile2(c, '''
 import 'b.dart';
 ''');
 
@@ -2438,7 +2441,7 @@
 
   test_instantiateToBounds_invalid() async {
     var a = convertPath('/test/lib/a.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A<T extends B> {}
 class B<T extends A<B>> {}
 ''');
@@ -2459,7 +2462,7 @@
 
   test_issue34619() async {
     var a = convertPath('/test/lib/a.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class C {
   final Set<String> f = new Set<String>();
 
@@ -2489,11 +2492,11 @@
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'b.dart';
 ''');
-    newFile(b);
-    newFile(c);
+    newFile2(b, '');
+    newFile2(c, '');
 
     driver.addFile(a);
     driver.addFile(c);
@@ -2516,7 +2519,7 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a);
+    newFile2(a, '');
 
     // 'a.dart' is added, but not processed yet.
     // So, the set of known files is empty yet.
@@ -2559,8 +2562,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 
 void f(A a) {}
@@ -2572,7 +2575,7 @@
 
     // Update the file, changing its API signature.
     // Note that we don't call `changeFile`.
-    newFile(a, content: 'class A {}');
+    newFile2(a, 'class A {}');
 
     // Parse the file.
     // We have not called `changeFile(a)`, so we should not read the file.
@@ -2609,8 +2612,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 ''');
 
@@ -2629,10 +2632,10 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part of my;
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 library my;
 part 'a.dart';
 ''');
@@ -2651,7 +2654,7 @@
   test_parseFile_languageVersion() async {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 // @dart = 2.7
 class A {}
 ''');
@@ -2665,7 +2668,7 @@
   test_parseFile_languageVersion_null() async {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {}
 ''');
 
@@ -2680,7 +2683,7 @@
 
   test_parseFile_notDart() async {
     var p = convertPath('/test/bin/a.txt');
-    newFile(p, content: 'class A {}');
+    newFile2(p, 'class A {}');
 
     var parseResult = await driver.parseFile(p) as ParsedUnitResult;
     expect(parseResult, isNotNull);
@@ -2692,8 +2695,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 
 void f(A a) {}
@@ -2705,7 +2708,7 @@
 
     // Update the file, changing its API signature.
     // Note that we don't call `changeFile`.
-    newFile(a, content: 'class A {}');
+    newFile2(a, 'class A {}');
 
     // Parse the file.
     // We have not called `changeFile(a)`, so we should not read the file.
@@ -2742,8 +2745,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: r'''
+    newFile2(a, '');
+    newFile2(b, r'''
 import 'a.dart';
 ''');
 
@@ -2763,10 +2766,10 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part of my;
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 library my;
 part 'a.dart';
 ''');
@@ -2786,7 +2789,7 @@
   test_parseFileSync_languageVersion() async {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 // @dart = 2.7
 class A {}
 ''');
@@ -2801,7 +2804,7 @@
   test_parseFileSync_languageVersion_null() async {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {}
 ''');
 
@@ -2818,7 +2821,7 @@
   @deprecated
   test_parseFileSync_notDart() async {
     var p = convertPath('/test/bin/a.txt');
-    newFile(p, content: 'class A {}');
+    newFile2(p, 'class A {}');
 
     var parseResult = driver.parseFileSync(p) as ParsedUnitResult;
     expect(parseResult, isNotNull);
@@ -2829,15 +2832,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -2865,15 +2868,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -2895,15 +2898,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -2934,15 +2937,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -2964,7 +2967,7 @@
   test_part_getResult_changePart_invalidatesLibraryCycle() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'dart:async';
 part 'b.dart';
 ''');
@@ -2976,7 +2979,7 @@
     // Create the part file.
     // This should invalidate library file state (specifically the library
     // cycle), so that we can re-link the library, and get new dependencies.
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 Future<int> f;
 ''');
@@ -2989,7 +2992,7 @@
 
   test_part_getResult_noLibrary() async {
     var c = convertPath('/test/lib/c.dart');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3009,15 +3012,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3049,15 +3052,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3084,7 +3087,7 @@
 
   test_part_getUnitElement_noLibrary() async {
     var c = convertPath('/test/lib/c.dart');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 part of a;
 var a = new A();
 var b = new B();
@@ -3111,15 +3114,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3159,15 +3162,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3192,7 +3195,7 @@
 
   test_part_results_noLibrary() async {
     var c = convertPath('/test/lib/c.dart');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3214,15 +3217,15 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library a;
 import 'b.dart';
 part 'c.dart';
 class A {}
 var c = new C();
 ''');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: r'''
+    newFile2(b, 'class B {}');
+    newFile2(c, r'''
 part of a;
 class C {}
 var a = new A();
@@ -3250,7 +3253,7 @@
 
   test_removeFile_addFile_results() async {
     var a = convertPath('/test/lib/a.dart');
-    newFile(a, content: 'class A {}');
+    newFile2(a, 'class A {}');
 
     driver.addFile(a);
 
@@ -3269,11 +3272,11 @@
   test_removeFile_changeFile_implicitlyAnalyzed() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'b.dart';
 var A = B;
 ''');
-    newFile(b, content: 'var B = 1;');
+    newFile2(b, 'var B = 1;');
 
     driver.priorityFiles = [a, b];
     driver.addFile(a);
@@ -3337,8 +3340,8 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: 'class A {}');
-    newFile(b, content: "import 'a.dart';  var a = new A();");
+    newFile2(a, 'class A {}');
+    newFile2(b, "import 'a.dart';  var a = new A();");
 
     driver.addFile(a);
     driver.addFile(b);
@@ -3369,20 +3372,20 @@
     var d = convertPath('/test/lib/d.dart');
     var e = convertPath('/test/lib/e.dart');
     var f = convertPath('/test/lib/f.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 import 'd.dart';
 ''');
-    newFile(b);
-    newFile(c, content: r'''
+    newFile2(b, '');
+    newFile2(c, r'''
 import 'd.dart';
 ''');
-    newFile(d, content: r'''
+    newFile2(d, r'''
 import 'b.dart';
 ''');
-    newFile(e, content: r'''
+    newFile2(e, r'''
 export 'b.dart';
 ''');
-    newFile(f, content: r'''
+    newFile2(f, r'''
 import 'e.dart';
 class F extends X {}
 ''');
@@ -3424,11 +3427,11 @@
     var c = convertPath('/test/lib/c.dart');
     var d = convertPath('/test/lib/d.dart');
     var e = convertPath('/test/lib/e.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c);
-    newFile(d, content: "import 'a.dart';");
-    newFile(e, content: "import 'b.dart';");
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, '');
+    newFile2(d, "import 'a.dart';");
+    newFile2(e, "import 'b.dart';");
 
     driver.addFile(a);
     driver.addFile(b);
@@ -3482,9 +3485,9 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
     var c = convertPath('/test/lib/c.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
 
     driver.addFile(a);
     driver.addFile(b);
@@ -3515,7 +3518,7 @@
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 var v = 0;
 ''');
     driver.addFile(a);
@@ -3524,7 +3527,7 @@
     expect(allResults.singleWhere((r) => r.path == a).errors, hasLength(0));
     allResults.clear();
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 var v = 0
 ''');
     driver.removeFile(b);
@@ -3536,8 +3539,8 @@
   test_results_skipNotAffected() async {
     var a = convertPath('/test/lib/a.dart');
     var b = convertPath('/test/lib/b.dart');
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
 
     driver.addFile(a);
     driver.addFile(b);
diff --git a/pkg/analyzer/test/src/dart/analysis/feature_set_provider_test.dart b/pkg/analyzer/test/src/dart/analysis/feature_set_provider_test.dart
index 0f485b1..d4c241f 100644
--- a/pkg/analyzer/test/src/dart/analysis/feature_set_provider_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/feature_set_provider_test.dart
@@ -32,7 +32,7 @@
   Folder get sdkRoot => newFolder('/sdk');
 
   void setUp() {
-    newFile('/test/lib/test.dart', content: '');
+    newFile2('/test/lib/test.dart', '');
 
     createMockSdk(
       resourceProvider: resourceProvider,
@@ -457,7 +457,6 @@
   }
 
   void _newSdkExperimentsFile(String content) {
-    newFile('$sdkRoot/lib/_internal/allowed_experiments.json',
-        content: content);
+    newFile2('$sdkRoot/lib/_internal/allowed_experiments.json', content);
   }
 }
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 3cc2617..5326c4c 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -47,7 +47,7 @@
     var generatedPath = convertPath('$workspaceRootPath/bazel-bin/$relPath');
 
     // This generated file should be used instead of the writable.
-    newFile(generatedPath);
+    newFile2(generatedPath, '');
 
     var analysisDriver = driverFor(convertPath(testFilePath));
 
@@ -73,7 +73,7 @@
     var generatedPath = convertPath('$workspaceRootPath/bazel-bin/$relPath');
 
     // This generated file should be used instead of the writable.
-    newFile(generatedPath);
+    newFile2(generatedPath, '');
 
     var analysisDriver = driverFor(convertPath(testFilePath));
 
@@ -182,7 +182,7 @@
 
   test_definedClassMemberNames() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {
   int a, b;
   A();
@@ -202,7 +202,7 @@
 
   test_definedClassMemberNames_enum() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 enum E1 {
   v1;
   int field1, field2;
@@ -236,7 +236,7 @@
 
   test_definedTopLevelNames() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {}
 class B = Object with A;
 typedef C();
@@ -270,7 +270,7 @@
 
   test_getFileForPath_emptyUri() {
     String path = convertPath('/test.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 import '';
 export '';
 part '';
@@ -284,7 +284,7 @@
 
   test_getFileForPath_hasLibraryDirective_hasPartOfDirective() {
     String a = convertPath('/test/lib/a.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library L;
 part of L;
 ''');
@@ -307,7 +307,7 @@
 part 'a3.dart';
 part ':[invalid uri]';
 ''';
-    newFile(a, content: content_a1);
+    newFile2(a, content_a1);
 
     FileState file = fileSystemState.getFileForPath(a);
 
@@ -346,7 +346,7 @@
 
 class A1 {}
 ''';
-    newFile(a1, content: content_a1);
+    newFile2(a1, content_a1);
 
     FileState file = fileSystemState.getFileForPath(a1);
     expect(file.path, a1);
@@ -388,7 +388,7 @@
     String b = convertPath('/test/lib/b.dart');
     String c = convertPath('/test/lib/c.dart');
     String d = convertPath('/test/lib/d.dart');
-    newFile(a, content: r'''
+    newFile2(a, r'''
 library lib;
 import 'dart:math';
 import 'b.dart';
@@ -409,11 +409,11 @@
   test_getFileForPath_part() {
     String a1 = convertPath('/aaa/lib/a1.dart');
     String a2 = convertPath('/aaa/lib/a2.dart');
-    newFile(a1, content: r'''
+    newFile2(a1, r'''
 library a1;
 part 'a2.dart';
 ''');
-    newFile(a2, content: r'''
+    newFile2(a2, r'''
 part of a1;
 class A2 {}
 ''');
@@ -446,7 +446,7 @@
     // Now update the library, and refresh its file.
     // The 'a2.dart' is not referenced anymore.
     // So the part file does not have the library anymore.
-    newFile(a1, content: r'''
+    newFile2(a1, r'''
 library a1;
 part 'not-a2.dart';
 ''');
@@ -477,11 +477,11 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 class B extends A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class A {}
 class D implements A {}
 ''');
@@ -495,7 +495,7 @@
     );
 
     // Change b.dart so that it does not subtype A.
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class C {}
 class D implements C {}
 ''');
@@ -514,13 +514,13 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 enum E1 implements A {
   v
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class A {}
 enum E2 implements A {
   v
@@ -536,7 +536,7 @@
     );
 
     // Change b.dart so that it does not subtype A.
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class C {}
 enum E2 implements C {
   v
@@ -557,13 +557,13 @@
     String a = convertPath('/a.dart');
     String b = convertPath('/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 mixin M {}
 enum E1 with M {
   v
 }
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 mixin M {}
 enum E2 with M {
   v
@@ -611,17 +611,17 @@
     _assertFilesWithoutLibraryCycle([]);
 
     // No imports, so just a single file.
-    newFile(pa);
+    newFile2(pa, '');
     _assertLibraryCycle(fa, [fa], []);
 
     // Import b.dart into a.dart, two files now.
-    newFile(pa, content: "import 'b.dart';");
+    newFile2(pa, "import 'b.dart';");
     fa.refresh();
     _assertFilesWithoutLibraryCycle([fa]);
     _assertLibraryCycle(fa, [fa], [fb.libraryCycle]);
 
     // Update b.dart so that it imports c.dart now.
-    newFile(pb, content: "import 'c.dart';");
+    newFile2(pb, "import 'c.dart';");
     fb.refresh();
     _assertFilesWithoutLibraryCycle([fa, fb]);
     _assertLibraryCycle(fa, [fa], [fb.libraryCycle]);
@@ -629,7 +629,7 @@
     _assertFilesWithoutLibraryCycle([]);
 
     // Update b.dart so that it exports d.dart instead.
-    newFile(pb, content: "export 'd.dart';");
+    newFile2(pb, "export 'd.dart';");
     fb.refresh();
     _assertFilesWithoutLibraryCycle([fa, fb]);
     _assertLibraryCycle(fa, [fa], [fb.libraryCycle]);
@@ -637,7 +637,7 @@
     _assertFilesWithoutLibraryCycle([]);
 
     // Update a.dart so that it does not import b.dart anymore.
-    newFile(pa);
+    newFile2(pa, '');
     fa.refresh();
     _assertFilesWithoutLibraryCycle([fa]);
     _assertLibraryCycle(fa, [fa], []);
@@ -647,8 +647,8 @@
     String pa = convertPath('/aaa/lib/a.dart');
     String pb = convertPath('/aaa/lib/b.dart');
 
-    newFile(pa, content: "import 'b.dart';");
-    newFile(pb, content: "import 'a.dart';");
+    newFile2(pa, "import 'b.dart';");
+    newFile2(pb, "import 'a.dart';");
 
     FileState fa = fileSystemState.getFileForPath(pa);
     FileState fb = fileSystemState.getFileForPath(pb);
@@ -664,7 +664,7 @@
     expect(fa.libraryCycle, same(fb.libraryCycle));
 
     // Update a.dart so that it does not import b.dart anymore.
-    newFile(pa);
+    newFile2(pa, '');
     fa.refresh();
     _assertFilesWithoutLibraryCycle([fa, fb]);
     _assertLibraryCycle(fa, [fa], []);
@@ -674,7 +674,7 @@
   test_libraryCycle_invalidPart_withPart() {
     var pa = convertPath('/aaa/lib/a.dart');
 
-    newFile(pa, content: r'''
+    newFile2(pa, r'''
 part of lib;
 part 'a.dart';
 ''');
@@ -688,10 +688,10 @@
     var a_path = convertPath('/aaa/lib/a.dart');
     var b_path = convertPath('/aaa/lib/b.dart');
 
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 part 'b.dart';
 ''');
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 part of 'a.dart';
 ''');
 
@@ -716,7 +716,7 @@
 
   test_referencedNames() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 A foo(B p) {
   foo(null);
   C c = new C(p);
@@ -729,7 +729,7 @@
 
   test_refresh_differentApiSignature() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class A {}
 ''');
     FileState file = fileSystemState.getFileForPath(path);
@@ -737,7 +737,7 @@
     List<int> signature = file.apiSignature;
 
     // Update the resource and refresh the file state.
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class B {}
 ''');
     bool apiSignatureChanged = file.refresh();
@@ -749,7 +749,7 @@
 
   test_refresh_sameApiSignature() {
     String path = convertPath('/aaa/lib/a.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class C {
   foo() {
     print(111);
@@ -760,7 +760,7 @@
     List<int> signature = file.apiSignature;
 
     // Update the resource and refresh the file state.
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class C {
   foo() {
     print(222);
@@ -775,7 +775,7 @@
 
   test_store_zeroLengthUnlinked() {
     String path = convertPath('/test.dart');
-    newFile(path, content: 'class A {}');
+    newFile2(path, 'class A {}');
 
     // Get the file, prepare unlinked.
     FileState file = fileSystemState.getFileForPath(path);
@@ -791,7 +791,7 @@
 
   test_subtypedNames() {
     String path = convertPath('/test.dart');
-    newFile(path, content: r'''
+    newFile2(path, r'''
 class X extends A {}
 class Y extends A with B {}
 class Z implements C, D {}
@@ -806,10 +806,10 @@
     String pc = convertPath('/aaa/lib/c.dart');
     String pd = convertPath('/aaa/lib/d.dart');
 
-    newFile(pa, content: "class A {}");
-    newFile(pb, content: "import 'a.dart';");
-    newFile(pc, content: "import 'b.dart';");
-    newFile(pd, content: "class D {}");
+    newFile2(pa, "class A {}");
+    newFile2(pb, "import 'a.dart';");
+    newFile2(pc, "import 'b.dart';");
+    newFile2(pd, "class D {}");
 
     FileState fa = fileSystemState.getFileForPath(pa);
     FileState fb = fileSystemState.getFileForPath(pb);
@@ -826,13 +826,13 @@
 
     // Make an update to a.dart that does not change its API signature.
     // All library cycles are still valid.
-    newFile(pa, content: "class A {} // the same API signature");
+    newFile2(pa, "class A {} // the same API signature");
     fa.refresh();
     _assertFilesWithoutLibraryCycle([]);
 
     // Change a.dart API signature.
     // This flushes signatures of b.dart and c.dart, but d.dart is still OK.
-    newFile(pa, content: "class A2 {}");
+    newFile2(pa, "class A2 {}");
     fa.refresh();
     _assertFilesWithoutLibraryCycle([fa, fb, fc]);
   }
@@ -841,10 +841,10 @@
     var aPath = convertPath('/test/lib/a.dart');
     var bPath = convertPath('/test/lib/b.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 part 'b.dart';
 ''');
-    newFile(bPath, content: '''
+    newFile2(bPath, '''
 part of 'a.dart';
 ''');
 
diff --git a/pkg/analyzer/test/src/dart/analysis/index_test.dart b/pkg/analyzer/test/src/dart/analysis/index_test.dart
index 4c31935..c07ab6e 100644
--- a/pkg/analyzer/test/src/dart/analysis/index_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/index_test.dart
@@ -107,7 +107,7 @@
   }
 
   test_isExtendedBy_ClassDeclaration_isQualified() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 ''');
     await _indexTestUnit('''
@@ -152,7 +152,7 @@
   }
 
   test_isExtendedBy_ClassTypeAlias_isQualified() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 ''');
     await _indexTestUnit('''
@@ -178,7 +178,7 @@
   }
 
   test_isImplementedBy_ClassDeclaration_isQualified() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 ''');
     await _indexTestUnit('''
@@ -251,7 +251,7 @@
   }
 
   test_isInvokedBy_FunctionElement() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 foo() {}
 ''');
@@ -510,7 +510,7 @@
   }
 
   test_isMixedInBy_ClassDeclaration_isQualified() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 ''');
     await _indexTestUnit('''
@@ -674,7 +674,7 @@
   }
 
   test_isReferencedBy_ClassElement_invocation_isQualified() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 ''');
     await _indexTestUnit('''
@@ -713,7 +713,7 @@
   }
 
   test_isReferencedBy_CompilationUnitElement_export() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await _indexTestUnit('''
@@ -724,7 +724,7 @@
   }
 
   test_isReferencedBy_CompilationUnitElement_import() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await _indexTestUnit('''
@@ -735,7 +735,7 @@
   }
 
   test_isReferencedBy_CompilationUnitElement_part() async {
-    newFile('$testPackageLibPath/my_unit.dart', content: 'part of my_lib;');
+    newFile2('$testPackageLibPath/my_unit.dart', 'part of my_lib;');
     await _indexTestUnit('''
 library my_lib;
 part 'my_unit.dart';
@@ -745,8 +745,8 @@
   }
 
   test_isReferencedBy_CompilationUnitElement_part_inPart() async {
-    newFile('$testPackageLibPath/a.dart', content: 'part of lib;');
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', 'part of lib;');
+    newFile2('$testPackageLibPath/b.dart', '''
 library lib;
 part 'a.dart';
 ''');
@@ -1227,7 +1227,7 @@
   }
 
   test_isReferencedBy_FunctionElement_with_LibraryElement() async {
-    newFile('$testPackageLibPath/foo.dart', content: r'''
+    newFile2('$testPackageLibPath/foo.dart', r'''
 bar() {}
 ''');
     await _indexTestUnit('''
@@ -1306,8 +1306,8 @@
   }
 
   test_isReferencedBy_MultiplyDefinedElement() async {
-    newFile('$testPackageLibPath/a1.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a2.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a1.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a2.dart', 'class A {}');
     await _indexTestUnit('''
 import 'a1.dart';
 import 'a2.dart';
@@ -1357,10 +1357,10 @@
   }
 
   test_isReferencedBy_ParameterElement_multiplyDefined_generic() async {
-    newFile('/test/lib/a.dart', content: r'''
+    newFile2('/test/lib/a.dart', r'''
 void foo<T>({T? a}) {}
 ''');
-    newFile('/test/lib/b.dart', content: r'''
+    newFile2('/test/lib/b.dart', r'''
 void foo<T>({T? a}) {}
 ''');
     await _indexTestUnit(r"""
@@ -1563,7 +1563,7 @@
   }
 
   test_isReferencedBy_TopLevelVariableElement() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 var V;
 ''');
@@ -1587,7 +1587,7 @@
   }
 
   test_isReferencedBy_TopLevelVariableElement_synthetic_hasGetterSetter() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 int get V => 0;
 void set V(_) {}
 ''');
@@ -1599,7 +1599,7 @@
   }
 
   test_isReferencedBy_TopLevelVariableElement_synthetic_hasSetter() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 void set V(_) {}
 ''');
     await _indexTestUnit('''
@@ -1661,7 +1661,7 @@
 
   test_subtypes_classDeclaration() async {
     String libP = 'package:test/lib.dart;package:test/lib.dart';
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 class B {}
 class C {}
@@ -1711,7 +1711,7 @@
 
   test_subtypes_classTypeAlias() async {
     String libP = 'package:test/lib.dart;package:test/lib.dart';
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 class B {}
 class C {}
@@ -1779,7 +1779,7 @@
 
   test_subtypes_mixinDeclaration() async {
     String libP = 'package:test/lib.dart;package:test/lib.dart';
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 class B {}
 class C {}
diff --git a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
index bcf846f..56ea4ff 100644
--- a/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/resolve_for_completion_test.dart
@@ -458,7 +458,7 @@
   }
 
   test_processPendingChanges() async {
-    newFile(testFilePath, content: 'class A {}');
+    newFile2(testFilePath, 'class A {}');
 
     // Read the file.
     await testDriver.getFile(testFilePathPlatform);
@@ -559,7 +559,7 @@
 
     var before = content.substring(0, offset);
     var after = content.substring(offset + 1);
-    newFile(path, content: before + after);
+    newFile2(path, before + after);
 
     return offset;
   }
diff --git a/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart b/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
index f60b34d..d374b9c 100644
--- a/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/results/get_element_declaration_test.dart
@@ -59,7 +59,7 @@
   }
 
   test_class_inPart() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 part of 'test.dart';
 class A {}
 ''');
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index 69278e4..55c4c67 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -179,9 +179,9 @@
         ..add(name: 'bbb', rootPath: bbbPackageRootPath),
     );
 
-    newFile(aaaFilePath, content: 'class A {}');
-    newFile(bbbFilePath, content: 'class B {}');
-    newFile(cccFilePath, content: 'class C {}');
+    newFile2(aaaFilePath, 'class A {}');
+    newFile2(bbbFilePath, 'class B {}');
+    newFile2(cccFilePath, 'class C {}');
 
     await resolveTestCode('class T {}');
 
@@ -252,8 +252,8 @@
   }
 
   test_declarations_onlyForFile() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    var b = newFile('$testPackageLibPath/b.dart', content: 'class B {}').path;
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    var b = newFile2('$testPackageLibPath/b.dart', 'class B {}').path;
 
     var results = WorkspaceSymbols();
     await driver.search.declarations(results, null, null, onlyForFile: b);
@@ -525,7 +525,7 @@
   }
 
   test_searchReferences_ClassElement_definedOutside() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 class A {};
 ''');
     await resolveTestCode('''
@@ -600,7 +600,7 @@
   }
 
   test_searchReferences_CompilationUnitElement() async {
-    newFile('$testPackageLibPath/foo.dart');
+    newFile2('$testPackageLibPath/foo.dart', '');
     await resolveTestCode('''
 import 'foo.dart'; // import
 export 'foo.dart'; // export
@@ -734,7 +734,7 @@
   A(); // in other
 }
 ''';
-    newFile(other, content: otherCode);
+    newFile2(other, otherCode);
 
     await resolveTestCode('''
 class A {
@@ -1100,7 +1100,7 @@
   }
 
   test_searchReferences_ImportElement_noPrefix_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class N1 {}
 void N2() {}
 int get N3 => 0;
@@ -1184,7 +1184,7 @@
   }
 
   test_searchReferences_ImportElement_withPrefix_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class N1 {}
 void N2() {}
 int get N3 => 0;
@@ -1239,8 +1239,8 @@
   test_searchReferences_LibraryElement() async {
     var codeA = 'part of lib; // A';
     var codeB = 'part of lib; // B';
-    newFile('$testPackageLibPath/unitA.dart', content: codeA);
-    newFile('$testPackageLibPath/unitB.dart', content: codeB);
+    newFile2('$testPackageLibPath/unitA.dart', codeA);
+    newFile2('$testPackageLibPath/unitB.dart', codeB);
     await resolveTestCode('''
 library lib;
 part 'unitA.dart';
@@ -1272,8 +1272,8 @@
 
     var codeA = 'part of lib; // A';
     var codeB = 'part of lib; // B';
-    newFile(partPathA, content: codeA);
-    newFile(partPathB, content: codeB);
+    newFile2(partPathA, codeA);
+    newFile2(partPathB, codeB);
 
     pathForContextSelection = testFilePath;
 
@@ -1786,7 +1786,7 @@
 part of my_lib;
 ppp.Future c;
 ''';
-    newFile('$testPackageLibPath/my_part.dart', content: partCode);
+    newFile2('$testPackageLibPath/my_part.dart', partCode);
     await resolveTestCode('''
 library my_lib;
 import 'dart:async' as ppp;
@@ -1825,7 +1825,7 @@
 part of my_lib;
 ppp.Future c;
 ''';
-    newFile(partPath, content: partCode);
+    newFile2(partPath, partCode);
     await resolveFileCode(libPath, '''
 library my_lib;
 import 'dart:async' as ppp;
@@ -1853,9 +1853,9 @@
     String p3 = convertPath('$testPackageLibPath/part3.dart');
     String code1 = 'part of lib; _C v1;';
     String code2 = 'part of lib; _C v2;';
-    newFile(p1, content: code1);
-    newFile(p2, content: code2);
-    newFile(p3, content: 'part of lib; int v3;');
+    newFile2(p1, code1);
+    newFile2(p2, code2);
+    newFile2(p3, 'part of lib; int v3;');
 
     await resolveTestCode('''
 library lib;
@@ -1897,9 +1897,9 @@
 ''';
     String code2 = 'part of lib; _C v2;';
 
-    newFile(p, content: code);
-    newFile(p1, content: code1);
-    newFile(p2, content: code2);
+    newFile2(p, code);
+    newFile2(p1, code1);
+    newFile2(p2, code2);
 
     await resolveTestCode(code);
 
@@ -1940,8 +1940,8 @@
     String code1 = 'part of lib; _C v1;';
     String code2 = 'part of lib; _C v2;';
 
-    newFile(p1, content: code1);
-    newFile(p2, content: code2);
+    newFile2(p1, code1);
+    newFile2(p2, code2);
 
     await resolveFileCode(testFile, testCode);
 
@@ -2059,7 +2059,7 @@
   }
 
   test_searchReferences_TopLevelVariableElement() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 var V;
 ''');
@@ -2125,7 +2125,7 @@
   }
 
   test_searchReferences_TypeAliasElement_fromLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef A<T> = Map<int, T>;
 ''');
     await resolveTestCode('''
@@ -2358,7 +2358,7 @@
     var aUri = 'package:aaa/a.dart';
     var bUri = 'package:bbb/b.dart';
 
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 import 'package:aaa/a.dart';
 
 class T1 extends A {
@@ -2370,7 +2370,7 @@
 }
 ''');
 
-    newFile(bbbFilePath, content: r'''
+    newFile2(bbbFilePath, r'''
 import 'package:aaa/a.dart';
 
 class B extends A {
@@ -2378,7 +2378,7 @@
 }
 ''');
 
-    newFile(aaaFilePath, content: r'''
+    newFile2(aaaFilePath, r'''
 class A {
   void method1() {}
   void method2() {}
@@ -2426,10 +2426,10 @@
         ..add(name: 'bbb', rootPath: bbbPackageRootPath),
     );
 
-    newFile(testFilePath, content: 'class T implements List {}');
-    newFile(aaaFilePath, content: 'class A implements List {}');
-    newFile(bbbFilePath, content: 'class B implements List {}');
-    newFile(cccFilePath, content: 'class C implements List {}');
+    newFile2(testFilePath, 'class T implements List {}');
+    newFile2(aaaFilePath, 'class A implements List {}');
+    newFile2(bbbFilePath, 'class B implements List {}');
+    newFile2(cccFilePath, 'class C implements List {}');
 
     var coreLibResult =
         await driver.getLibraryByUri('dart:core') as LibraryElementResult;
@@ -2455,11 +2455,11 @@
   test_subtypes_class_files() async {
     String pathB = convertPath('$testPackageLibPath/b.dart');
     String pathC = convertPath('$testPackageLibPath/c.dart');
-    newFile(pathB, content: r'''
+    newFile2(pathB, r'''
 import 'test.dart';
 class B extends A {}
 ''');
-    newFile(pathC, content: r'''
+    newFile2(pathC, r'''
 import 'test.dart';
 class C extends A {}
 class D {}
diff --git a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
index 6beca53..46131f0 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
@@ -28,7 +28,7 @@
   }
 
   test_getClass_defined() async {
-    var file = newFile('$testPackageLibPath/c.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/c.dart', r'''
 class C {}
 int v = 0;
 ''');
@@ -39,7 +39,7 @@
   }
 
   test_getClass_defined_notClass() async {
-    var file = newFile('$testPackageLibPath/c.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/c.dart', r'''
 int v = 0;
 ''');
     String uri = file.toUri().toString();
@@ -49,10 +49,10 @@
   }
 
   test_getClass_exported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
-    var bFile = newFile('$testPackageLibPath/b.dart', content: r'''
+    var bFile = newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
     String bUri = bFile.toUri().toString();
@@ -62,10 +62,10 @@
   }
 
   test_getClass_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
-    var bFile = newFile('$testPackageLibPath/b.dart', content: r'''
+    var bFile = newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart';
 ''');
     String bUri = bFile.toUri().toString();
@@ -95,7 +95,7 @@
   }
 
   test_getTopLevelPropertyAccessor_defined_getter() async {
-    var file = newFile('$testPackageLibPath/test.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/test.dart', r'''
 int get a => 0;
 ''');
     String uri = file.toUri().toString();
@@ -106,7 +106,7 @@
   }
 
   test_getTopLevelPropertyAccessor_defined_setter() async {
-    var file = newFile('$testPackageLibPath/test.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/test.dart', r'''
 set a(_) {}
 ''');
     String uri = file.toUri().toString();
@@ -117,7 +117,7 @@
   }
 
   test_getTopLevelPropertyAccessor_defined_variable() async {
-    var file = newFile('$testPackageLibPath/test.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/test.dart', r'''
 int a;
 ''');
     String uri = file.toUri().toString();
@@ -128,10 +128,10 @@
   }
 
   test_getTopLevelPropertyAccessor_exported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int a;
 ''');
-    var bFile = newFile('$testPackageLibPath/b.dart', content: r'''
+    var bFile = newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
     String bUri = bFile.toUri().toString();
@@ -142,10 +142,10 @@
   }
 
   test_getTopLevelPropertyAccessor_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int a;
 ''');
-    var bFile = newFile('$testPackageLibPath/b.dart', content: r'''
+    var bFile = newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart';
 ''');
     String bUri = bFile.toUri().toString();
@@ -155,7 +155,7 @@
   }
 
   test_getTopLevelPropertyAccessor_notDefined() async {
-    var file = newFile('$testPackageLibPath/test.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/test.dart', r'''
 int a;
 ''');
     String uri = file.toUri().toString();
@@ -165,7 +165,7 @@
   }
 
   test_getTopLevelPropertyAccessor_notPropertyAccessor() async {
-    var file = newFile('$testPackageLibPath/test.dart', content: r'''
+    var file = newFile2('$testPackageLibPath/test.dart', r'''
 int a() {}
 ''');
     String uri = file.toUri().toString();
diff --git a/pkg/analyzer/test/src/dart/analysis/session_test.dart b/pkg/analyzer/test/src/dart/analysis/session_test.dart
index db20934..b95640d 100644
--- a/pkg/analyzer/test/src/dart/analysis/session_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/session_test.dart
@@ -23,7 +23,7 @@
     extends BazelWorkspaceResolutionTest {
   void test_getErrors_notFileOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -32,9 +32,9 @@
   }
 
   void test_getErrors_valid() async {
-    var file = newFile(
+    var file = newFile2(
       '$workspaceRootPath/dart/my/lib/a.dart',
-      content: 'var x = 0',
+      'var x = 0',
     );
 
     var session = contextFor(file.path).currentSession;
@@ -46,7 +46,7 @@
 
   void test_getParsedLibrary2_notFileOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -57,7 +57,7 @@
   @deprecated
   void test_getParsedLibrary_notFileOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -67,7 +67,7 @@
 
   void test_getResolvedLibrary_notFileOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -77,7 +77,7 @@
 
   void test_getResolvedUnit_notFileOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -86,9 +86,9 @@
   }
 
   void test_getResolvedUnit_valid() async {
-    var file = newFile(
+    var file = newFile2(
       '$workspaceRootPath/dart/my/lib/a.dart',
-      content: 'class A {}',
+      'class A {}',
     );
 
     var session = contextFor(file.path).currentSession;
@@ -99,9 +99,9 @@
   }
 
   void test_getUnitElement_invalidPath_notAbsolute() async {
-    var file = newFile(
+    var file = newFile2(
       '$workspaceRootPath/dart/my/lib/a.dart',
-      content: 'class A {}',
+      'class A {}',
     );
 
     var session = contextFor(file.path).currentSession;
@@ -111,7 +111,7 @@
 
   void test_getUnitElement_notPathOfUri() async {
     var relPath = 'dart/my/lib/a.dart';
-    newFile('$workspaceRootPath/bazel-bin/$relPath');
+    newFile2('$workspaceRootPath/bazel-bin/$relPath', '');
 
     var path = convertPath('$workspaceRootPath/$relPath');
     var session = contextFor(path).currentSession;
@@ -120,9 +120,9 @@
   }
 
   void test_getUnitElement_valid() async {
-    var file = newFile(
+    var file = newFile2(
       '$workspaceRootPath/dart/my/lib/a.dart',
-      content: 'class A {}',
+      'class A {}',
     );
 
     var session = contextFor(file.path).currentSession;
@@ -136,7 +136,7 @@
 @reflectiveTest
 class AnalysisSessionImplTest extends PubPackageResolutionTest {
   test_getErrors() async {
-    var test = newFile(testFilePath, content: 'class C {');
+    var test = newFile2(testFilePath, 'class C {');
 
     var session = contextFor(testFilePath).currentSession;
     var errorsResult = await session.getErrorsValid(test.path);
@@ -146,7 +146,7 @@
   }
 
   test_getErrors_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -162,7 +162,7 @@
   }
 
   test_getFile2_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -178,7 +178,7 @@
   }
 
   test_getFile2_library() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: '');
+    var a = newFile2('$testPackageLibPath/a.dart', '');
 
     var session = contextFor(testFilePath).currentSession;
     var file = await session.getFile2Valid(a.path);
@@ -188,7 +188,7 @@
   }
 
   test_getFile2_part() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: 'part of lib;');
+    var a = newFile2('$testPackageLibPath/a.dart', 'part of lib;');
 
     var session = contextFor(testFilePath).currentSession;
     var file = await session.getFile2Valid(a.path);
@@ -199,7 +199,7 @@
 
   @deprecated
   test_getFile_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -217,7 +217,7 @@
 
   @deprecated
   test_getFile_library() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: '');
+    var a = newFile2('$testPackageLibPath/a.dart', '');
 
     var session = contextFor(testFilePath).currentSession;
     var file = session.getFileValid(a.path);
@@ -228,7 +228,7 @@
 
   @deprecated
   test_getFile_part() async {
-    var a = newFile('$testPackageLibPath/a.dart', content: 'part of lib;');
+    var a = newFile2('$testPackageLibPath/a.dart', 'part of lib;');
 
     var session = contextFor(testFilePath).currentSession;
     var file = session.getFileValid(a.path);
@@ -238,7 +238,7 @@
   }
 
   test_getLibraryByUri() async {
-    newFile(testFilePath, content: r'''
+    newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -252,7 +252,7 @@
   }
 
   test_getLibraryByUri_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -269,7 +269,7 @@
 
   @deprecated
   test_getParsedLibrary() async {
-    var test = newFile('$testPackageLibPath/a.dart', content: r'''
+    var test = newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 ''');
@@ -289,7 +289,7 @@
   }
 
   test_getParsedLibrary2() async {
-    var test = newFile('$testPackageLibPath/a.dart', content: r'''
+    var test = newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 ''');
@@ -309,7 +309,7 @@
   }
 
   test_getParsedLibrary2_getElementDeclaration_class() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -329,7 +329,7 @@
   }
 
   test_getParsedLibrary2_getElementDeclaration_notThisLibrary() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var resolvedUnit =
@@ -345,7 +345,7 @@
   }
 
   test_getParsedLibrary2_getElementDeclaration_synthetic() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 int foo = 0;
 ''');
 
@@ -370,7 +370,7 @@
   }
 
   test_getParsedLibrary2_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -380,7 +380,7 @@
   }
 
   test_getParsedLibrary2_invalidPartUri() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 part 'a.dart';
 part ':[invalid uri].dart';
 part 'c.dart';
@@ -411,7 +411,7 @@
   }
 
   test_getParsedLibrary2_notLibrary() async {
-    var test = newFile(testFilePath, content: 'part of "a.dart";');
+    var test = newFile2(testFilePath, 'part of "a.dart";');
     var session = contextFor(testFilePath).currentSession;
     var result = await session.getParsedLibrary2(test.path);
     expect(result, isA<NotLibraryButPartResult>());
@@ -440,9 +440,9 @@
 class C3 {}
 ''';
 
-    var a = newFile('$testPackageLibPath/a.dart', content: aContent);
-    var b = newFile('$testPackageLibPath/b.dart', content: bContent);
-    var c = newFile('$testPackageLibPath/c.dart', content: cContent);
+    var a = newFile2('$testPackageLibPath/a.dart', aContent);
+    var b = newFile2('$testPackageLibPath/b.dart', bContent);
+    var c = newFile2('$testPackageLibPath/c.dart', cContent);
 
     var session = contextFor(testFilePath).currentSession;
     var parsedLibrary = await session.getParsedLibrary2Valid(a.path);
@@ -472,7 +472,7 @@
 
   @deprecated
   test_getParsedLibrary_getElementDeclaration_class() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -493,7 +493,7 @@
 
   @deprecated
   test_getParsedLibrary_getElementDeclaration_notThisLibrary() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var resolvedUnit =
@@ -510,7 +510,7 @@
 
   @deprecated
   test_getParsedLibrary_getElementDeclaration_synthetic() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 int foo = 0;
 ''');
 
@@ -536,7 +536,7 @@
 
   @deprecated
   test_getParsedLibrary_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -547,7 +547,7 @@
 
   @deprecated
   test_getParsedLibrary_invalidPartUri() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 part 'a.dart';
 part ':[invalid uri].dart';
 part 'c.dart';
@@ -580,7 +580,7 @@
 
   @deprecated
   test_getParsedLibrary_notLibrary() async {
-    var test = newFile(testFilePath, content: 'part of "a.dart";');
+    var test = newFile2(testFilePath, 'part of "a.dart";');
     var session = contextFor(testFilePath).currentSession;
     expect(session.getParsedLibrary(test.path), isA<NotLibraryButPartResult>());
   }
@@ -609,9 +609,9 @@
 class C3 {}
 ''';
 
-    var a = newFile('$testPackageLibPath/a.dart', content: aContent);
-    var b = newFile('$testPackageLibPath/b.dart', content: bContent);
-    var c = newFile('$testPackageLibPath/c.dart', content: cContent);
+    var a = newFile2('$testPackageLibPath/a.dart', aContent);
+    var b = newFile2('$testPackageLibPath/b.dart', bContent);
+    var c = newFile2('$testPackageLibPath/c.dart', cContent);
 
     var session = contextFor(testFilePath).currentSession;
     var parsedLibrary = session.getParsedLibraryValid(a.path);
@@ -641,7 +641,7 @@
 
   @deprecated
   test_getParsedLibraryByElement() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -662,7 +662,7 @@
   }
 
   test_getParsedLibraryByElement2() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -683,7 +683,7 @@
   }
 
   test_getParsedLibraryByElement2_differentSession() async {
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -699,7 +699,7 @@
 
   @deprecated
   test_getParsedLibraryByElement_differentSession() async {
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -715,7 +715,7 @@
 
   @deprecated
   test_getParsedUnit() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -729,7 +729,7 @@
   }
 
   test_getParsedUnit2() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -743,7 +743,7 @@
   }
 
   test_getParsedUnit2_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -760,7 +760,7 @@
 
   @deprecated
   test_getParsedUnit_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -782,7 +782,7 @@
 
 class A /*a*/ {}
 ''';
-    var a = newFile('$testPackageLibPath/a.dart', content: aContent);
+    var a = newFile2('$testPackageLibPath/a.dart', aContent);
 
     var bContent = r'''
 part of 'a.dart';
@@ -790,7 +790,7 @@
 class B /*b*/ {}
 class B2 extends X {}
 ''';
-    var b = newFile('$testPackageLibPath/b.dart', content: bContent);
+    var b = newFile2('$testPackageLibPath/b.dart', bContent);
 
     var session = contextFor(testFilePath).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(a.path);
@@ -839,7 +839,7 @@
   }
 
   test_getResolvedLibrary_getElementDeclaration_notThisLibrary() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var resolvedLibrary = await session.getResolvedLibraryValid(test.path);
@@ -851,7 +851,7 @@
   }
 
   test_getResolvedLibrary_getElementDeclaration_synthetic() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 int foo = 0;
 ''');
 
@@ -876,7 +876,7 @@
   }
 
   test_getResolvedLibrary_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -886,7 +886,7 @@
   }
 
   test_getResolvedLibrary_invalidPartUri() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 part 'a.dart';
 part ':[invalid uri].dart';
 part 'c.dart';
@@ -917,7 +917,7 @@
   }
 
   test_getResolvedLibrary_notLibrary() async {
-    var test = newFile(testFilePath, content: 'part of "a.dart";');
+    var test = newFile2(testFilePath, 'part of "a.dart";');
 
     var session = contextFor(testFilePath).currentSession;
     var result = await session.getResolvedLibrary(test.path);
@@ -925,7 +925,7 @@
   }
 
   test_getResolvedLibraryByElement() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -942,7 +942,7 @@
   }
 
   test_getResolvedLibraryByElement_differentSession() async {
-    newFile(testFilePath, content: '');
+    newFile2(testFilePath, '');
 
     var session = contextFor(testFilePath).currentSession;
     var libraryResult = await session.getLibraryByUriValid(
@@ -957,7 +957,7 @@
   }
 
   test_getResolvedUnit() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -974,7 +974,7 @@
   }
 
   test_getResolvedUnit_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
@@ -984,7 +984,7 @@
   }
 
   test_getUnitElement() async {
-    var test = newFile(testFilePath, content: r'''
+    var test = newFile2(testFilePath, r'''
 class A {}
 class B {}
 ''');
@@ -998,7 +998,7 @@
   }
 
   test_getUnitElement_inconsistent() async {
-    var test = newFile(testFilePath, content: '');
+    var test = newFile2(testFilePath, '');
     var session = contextFor(test.path).currentSession;
     driverFor(test.path).changeFile(test.path);
     expect(
diff --git a/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart b/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart
index 7bd38c2..954761a 100644
--- a/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart
@@ -27,11 +27,11 @@
   void assertSignature(String oldCode, String newCode, {required bool same}) {
     var path = convertPath('/test.dart');
 
-    newFile(path, content: oldCode);
+    newFile2(path, oldCode);
     var oldUnit = parseUnit(path).unit;
     var oldSignature = computeUnlinkedApiSignature(oldUnit);
 
-    newFile(path, content: newCode);
+    newFile2(path, newCode);
     var newUnit = parseUnit(path).unit;
     var newSignature = computeUnlinkedApiSignature(newUnit);
 
diff --git a/pkg/analyzer/test/src/dart/ast/ast_test.dart b/pkg/analyzer/test/src/dart/ast/ast_test.dart
index c388c0b..efd2a34 100644
--- a/pkg/analyzer/test/src/dart/ast/ast_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/ast_test.dart
@@ -615,7 +615,7 @@
   }
 
   test_isConst_notInContext_constructor_const_generic_named_prefixed() async {
-    newFile('$testPackageLibPath/c.dart', content: '''
+    newFile2('$testPackageLibPath/c.dart', '''
 class C<E> {
   const C.n();
 }
@@ -638,7 +638,7 @@
   }
 
   test_isConst_notInContext_constructor_const_generic_unnamed_prefixed() async {
-    newFile('$testPackageLibPath/c.dart', content: '''
+    newFile2('$testPackageLibPath/c.dart', '''
 class C<E> {
   const C();
 }
@@ -689,7 +689,7 @@
   }
 
   test_isConst_notInContext_constructor_const_nonGeneric_named_prefixed() async {
-    newFile('$testPackageLibPath/c.dart', content: '''
+    newFile2('$testPackageLibPath/c.dart', '''
 class C {
   const C.n();
 }
@@ -712,7 +712,7 @@
   }
 
   test_isConst_notInContext_constructor_const_nonGeneric_unnamed_prefixed() async {
-    newFile('$testPackageLibPath/c.dart', content: '''
+    newFile2('$testPackageLibPath/c.dart', '''
 class C {
   const C();
 }
diff --git a/pkg/analyzer/test/src/dart/ast/constant_evaluator_test.dart b/pkg/analyzer/test/src/dart/ast/constant_evaluator_test.dart
index d491c73..5dd2c78 100644
--- a/pkg/analyzer/test/src/dart/ast/constant_evaluator_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/constant_evaluator_test.dart
@@ -339,7 +339,7 @@
   Object? _getConstantValue(String expressionCode) {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: '''
+    newFile2(path, '''
 void f() {
   ($expressionCode); // ref
 }
diff --git a/pkg/analyzer/test/src/dart/ast/element_locator_test.dart b/pkg/analyzer/test/src/dart/ast/element_locator_test.dart
index 4bd8ed4..2c0abd8 100644
--- a/pkg/analyzer/test/src/dart/ast/element_locator_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/element_locator_test.dart
@@ -204,7 +204,7 @@
   }
 
   test_locate_InstanceCreationExpression_type_prefixedIdentifier() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await resolveTestCode(r'''
@@ -220,7 +220,7 @@
   }
 
   test_locate_InstanceCreationExpression_type_simpleIdentifier() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 ''');
     await resolveTestCode(r'''
 class A {}
@@ -284,12 +284,12 @@
     var libPath = convertPath('$testPackageLibPath/lib.dart');
     var partPath = convertPath('$testPackageLibPath/test.dart');
 
-    newFile(libPath, content: r'''
+    newFile2(libPath, r'''
 library my.lib;
 part 'test.dart';
 ''');
 
-    newFile(partPath, content: r'''
+    newFile2(partPath, r'''
 part of my.lib;
 ''');
 
@@ -326,7 +326,7 @@
   }
 
   test_locate_StringLiteral_exportUri() async {
-    newFile("$testPackageLibPath/foo.dart", content: '');
+    newFile2("$testPackageLibPath/foo.dart", '');
     await resolveTestCode("export 'foo.dart';");
     var node = findNode.stringLiteral('foo.dart');
     var element = ElementLocator.locate(node);
@@ -341,7 +341,7 @@
   }
 
   test_locate_StringLiteral_importUri() async {
-    newFile("$testPackageLibPath/foo.dart", content: '');
+    newFile2("$testPackageLibPath/foo.dart", '');
     await resolveTestCode("import 'foo.dart';");
     var node = findNode.stringLiteral('foo.dart');
     var element = ElementLocator.locate(node);
@@ -349,7 +349,7 @@
   }
 
   test_locate_StringLiteral_partUri() async {
-    newFile("$testPackageLibPath/foo.dart", content: 'part of lib;');
+    newFile2("$testPackageLibPath/foo.dart", 'part of lib;');
     await resolveTestCode('''
 library lib;
 
diff --git a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
index e356a67..b86f22b 100644
--- a/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
+++ b/pkg/analyzer/test/src/dart/constant/potentially_constant_test.dart
@@ -25,7 +25,7 @@
   }
 
   test_class_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await _assertConst(r'''
@@ -35,7 +35,7 @@
   }
 
   test_class_prefix_deferred() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await _assertNeverConst(r'''
@@ -805,7 +805,7 @@
   }
 
   test_prefixedIdentifier_importPrefix_deferred() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 0;
 ''');
     await _assertNotConst(r'''
@@ -815,7 +815,7 @@
   }
 
   test_prefixedIdentifier_importPrefix_function() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void f() {}
 ''');
     await _assertConst(r'''
@@ -825,7 +825,7 @@
   }
 
   test_prefixedIdentifier_importPrefix_topVar() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 0;
 ''');
     await _assertConst(r'''
@@ -920,7 +920,7 @@
   }
 
   test_prefixedIdentifier_typedef_interfaceType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef A = List<int>;
 ''');
     await _assertConst(r'''
@@ -978,7 +978,7 @@
   }
 
   test_propertyAccess_staticField_withPrefix_const() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const a = 0;
 }
@@ -990,7 +990,7 @@
   }
 
   test_propertyAccess_staticField_withPrefix_deferred() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const a = 0;
 }
@@ -1002,7 +1002,7 @@
   }
 
   test_propertyAccess_staticField_withPrefix_final() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static final a = 0;
 }
@@ -1024,7 +1024,7 @@
   }
 
   test_propertyAccess_target_variable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final a = 0;
   const A();
diff --git a/pkg/analyzer/test/src/dart/element/class_element_test.dart b/pkg/analyzer/test/src/dart/element/class_element_test.dart
index 9505982..6562a8c 100644
--- a/pkg/analyzer/test/src/dart/element/class_element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/class_element_test.dart
@@ -174,7 +174,7 @@
   }
 
   test_lookUpInheritedConcreteGetter_declared_hasExtends_private_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -478,7 +478,7 @@
   }
 
   test_lookUpInheritedConcreteMethod_declared_hasExtends_private_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -782,7 +782,7 @@
   }
 
   test_lookUpInheritedConcreteSetter_declared_hasExtends_private_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   set _foo(int _) {}
 }
@@ -1086,7 +1086,7 @@
   }
 
   test_lookUpInheritedMethod_declared_hasExtends_private_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index e39414a..94515af 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -487,7 +487,7 @@
 @reflectiveTest
 class ElementAnnotationImplTest extends PubPackageResolutionTest {
   test_computeConstantValue() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final String f;
   const A(this.f);
@@ -1361,7 +1361,7 @@
 @reflectiveTest
 class TopLevelVariableElementImplTest extends PubPackageResolutionTest {
   test_computeConstantValue() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const int C = 42;
 ''');
     await resolveTestCode(r'''
diff --git a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
index 82433a76..221b9e0 100644
--- a/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
+++ b/pkg/analyzer/test/src/dart/element/generic_inferrer_test.dart
@@ -646,16 +646,17 @@
       isNonNullableByDefault: false,
     );
 
-    var typeArguments = typeSystem.inferGenericFunctionOrType(
+    var inferrer = typeSystem.setupGenericTypeInference(
       typeParameters: ft.typeFormals,
-      parameters: ft.parameters,
       declaredReturnType: ft.returnType,
-      argumentTypes: arguments,
       contextReturnType: returnType,
       errorReporter: reporter,
       errorNode: astFactory.nullLiteral(KeywordToken(Keyword.NULL, 0)),
       genericMetadataIsEnabled: true,
     );
+    inferrer.constrainArguments(
+        parameters: ft.parameters, argumentTypes: arguments);
+    var typeArguments = inferrer.upwardsInfer();
 
     if (expectError) {
       expect(listener.errors.map((e) => e.errorCode).toList(),
@@ -664,7 +665,7 @@
     } else {
       expect(listener.errors, isEmpty, reason: 'did not expect any errors.');
     }
-    return typeArguments!;
+    return typeArguments;
   }
 
   FunctionType _inferCall2(FunctionType ft, List<DartType> arguments,
diff --git a/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart b/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
index 704c6ed..8524280 100644
--- a/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
+++ b/pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart
@@ -19,7 +19,7 @@
 @reflectiveTest
 class InheritanceManager3Test extends _InheritanceManager3Base {
   test_getInheritedMap_topMerge_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.6
 class A {
   void foo({int a}) {}
@@ -69,7 +69,7 @@
   }
 
   test_getMember_optIn_inheritsOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -93,7 +93,7 @@
   }
 
   test_getMember_optIn_inheritsOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.6
 class A {
   int foo(int a, int b) => 0;
@@ -218,7 +218,7 @@
   }
 
   test_getMember_optOut_inheritsOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -244,7 +244,7 @@
   }
 
   test_getMember_optOut_mixesOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -269,12 +269,12 @@
   }
 
   test_getMember_optOut_passOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
 ''');
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.6
 import 'a.dart';
 class B extends A {
diff --git a/pkg/analyzer/test/src/dart/element/type_constraint_gatherer_test.dart b/pkg/analyzer/test/src/dart/element/type_constraint_gatherer_test.dart
index 8695591..e78f19a 100644
--- a/pkg/analyzer/test/src/dart/element/type_constraint_gatherer_test.dart
+++ b/pkg/analyzer/test/src/dart/element/type_constraint_gatherer_test.dart
@@ -1137,5 +1137,6 @@
 
     var isMatch = gatherer.trySubtypeMatch(P, Q, leftSchema);
     expect(isMatch, isFalse);
+    expect(gatherer.isConstraintSetEmpty, isTrue);
   }
 }
diff --git a/pkg/analyzer/test/src/dart/micro/file_resolution.dart b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
index 52969ec..716f124 100644
--- a/pkg/analyzer/test/src/dart/micro/file_resolution.dart
+++ b/pkg/analyzer/test/src/dart/micro/file_resolution.dart
@@ -37,7 +37,7 @@
 
   @override
   void addTestFile(String content) {
-    newFile(_testFile, content: content);
+    newFile2(_testFile, content);
   }
 
   /// Create a new [FileResolver] into [fileResolver].
@@ -100,8 +100,8 @@
       root: sdkRoot,
     );
 
-    newFile('/workspace/WORKSPACE', content: '');
-    newFile('/workspace/dart/test/BUILD', content: '');
+    newFile2('/workspace/WORKSPACE', '');
+    newFile2('/workspace/dart/test/BUILD', '');
     createFileResolver();
   }
 
diff --git a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
index de30fd9..4ac48f7 100644
--- a/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
+++ b/pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart
@@ -38,15 +38,15 @@
   }
 
   test_changeFile_refreshedFiles() async {
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 class B {}
 ''');
 
-    newFile(cPath, content: r'''
+    newFile2(cPath, r'''
 import 'a.dart';
 import 'b.dart';
 ''');
@@ -70,11 +70,11 @@
   }
 
   test_changeFile_resolution() async {
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 A a;
 B b;
@@ -85,7 +85,7 @@
       error(CompileTimeErrorCode.UNDEFINED_CLASS, 22, 1),
     ]);
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 class B {}
 ''');
@@ -96,13 +96,13 @@
   }
 
   test_changeFile_resolution_flushInheritanceManager() async {
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   final int foo = 0;
 }
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 void f(A a) {
@@ -115,7 +115,7 @@
       error(CompileTimeErrorCode.ASSIGNMENT_TO_FINAL, 36, 3),
     ]);
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   int foo = 0;
 }
@@ -127,7 +127,7 @@
   }
 
   test_changeFile_resolution_missingChangeFileForPart() async {
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 part 'b.dart';
 
 var b = B(0);
@@ -141,7 +141,7 @@
 
     // Update a.dart, and notify the resolver. We need this to have at least
     // one change, so that we decided to rebuild the library summary.
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 part 'b.dart';
 
 var b = B(1);
@@ -150,7 +150,7 @@
 
     // Update b.dart, but do not notify the resolver.
     // If we try to read it now, it will throw.
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 part of 'a.dart';
 
 class B {
@@ -169,19 +169,19 @@
   }
 
   test_changePartFile_refreshedFiles() async {
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 part 'b.dart';
 
 class A {}
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 part of 'a.dart';
 
 class B extends A {}
 ''');
 
-    newFile(cPath, content: r'''
+    newFile2(cPath, r'''
 import 'a.dart';
 ''');
 
@@ -225,7 +225,7 @@
   bool isNullSafetyEnabled = false;
 
   test_analysisOptions_default_fromPackageUri() async {
-    newFile('/workspace/dart/analysis_options/lib/default.yaml', content: r'''
+    newFile2('/workspace/dart/analysis_options/lib/default.yaml', r'''
 analyzer:
   strong-mode:
     implicit-casts: false
@@ -240,7 +240,7 @@
   }
 
   test_analysisOptions_file_inPackage() async {
-    newAnalysisOptionsYamlFile('/workspace/dart/test', content: r'''
+    newAnalysisOptionsYamlFile2('/workspace/dart/test', r'''
 analyzer:
   strong-mode:
     implicit-casts: false
@@ -255,14 +255,13 @@
   }
 
   test_analysisOptions_file_inThirdParty() async {
-    newFile('/workspace/dart/analysis_options/lib/third_party.yaml',
-        content: r'''
+    newFile2('/workspace/dart/analysis_options/lib/third_party.yaml', r'''
 analyzer:
   strong-mode:
     implicit-casts: false
 ''');
 
-    newAnalysisOptionsYamlFile('/workspace/third_party/dart/aaa', content: r'''
+    newAnalysisOptionsYamlFile2('/workspace/third_party/dart/aaa', r'''
 analyzer:
   strong-mode:
     implicit-casts: true
@@ -278,15 +277,13 @@
   }
 
   test_analysisOptions_file_inThirdPartyDartLang() async {
-    newFile('/workspace/dart/analysis_options/lib/third_party.yaml',
-        content: r'''
+    newFile2('/workspace/dart/analysis_options/lib/third_party.yaml', r'''
 analyzer:
   strong-mode:
     implicit-casts: false
 ''');
 
-    newAnalysisOptionsYamlFile('/workspace/third_party/dart_lang/aaa',
-        content: r'''
+    newAnalysisOptionsYamlFile2('/workspace/third_party/dart_lang/aaa', r'''
 analyzer:
   strong-mode:
     implicit-casts: true
@@ -302,7 +299,7 @@
   }
 
   test_analysisOptions_lints() async {
-    newFile('/workspace/dart/analysis_options/lib/default.yaml', content: r'''
+    newFile2('/workspace/dart/analysis_options/lib/default.yaml', r'''
 linter:
   rules:
     - omit_local_variable_types
@@ -341,7 +338,7 @@
   test_collectSharedDataIdentifiers() async {
     var aPath = convertPath('/workspace/third_party/dart/aaa/lib/a.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
@@ -353,7 +350,7 @@
 
   test_elements_export_dartCoreDynamic() async {
     var a_path = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 export 'dart:core' show dynamic;
 ''');
 
@@ -376,14 +373,14 @@
 
   test_findReferences_class() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   int foo;
 }
 ''');
 
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 void func() {
@@ -403,7 +400,7 @@
 
   test_findReferences_field() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   int foo = 0;
 
@@ -424,7 +421,7 @@
 
   test_findReferences_function() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 main() {
   foo('Hello');
 }
@@ -443,13 +440,13 @@
 
   test_findReferences_getter() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   int get foo => 6;
 }
 ''');
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 main() {
@@ -469,7 +466,7 @@
 
   test_findReferences_local_variable() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   void func(int n) {
     var foo = bar+1;
@@ -488,7 +485,7 @@
 
   test_findReferences_method() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   void func() {
    print('hello');
@@ -501,7 +498,7 @@
 ''');
 
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 main() {
@@ -522,13 +519,13 @@
 
   test_findReferences_setter() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   void set value(int m){ };
 }
 ''');
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 main() {
@@ -549,14 +546,14 @@
   test_findReferences_top_level_getter() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 int _foo;
 
 int get foo => _foo;
 ''');
 
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 main() {
@@ -576,14 +573,14 @@
   test_findReferences_top_level_setter() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 int _foo;
 
 void set foo(int bar) { _foo = bar; }
 ''');
 
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 main() {
@@ -603,7 +600,7 @@
   test_findReferences_top_level_variable() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 const int C = 42;
 
 void func() {
@@ -622,7 +619,7 @@
 
   test_findReferences_type_parameter() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class Foo<T> {
   List<T> l;
 
@@ -646,12 +643,12 @@
 
   test_findReferences_typedef() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 typedef func = int Function(int);
 
 ''');
     var bPath = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 
 void f(func o) {}
@@ -718,7 +715,7 @@
   }
 
   test_getErrors_reuse_changeDependency() {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 var a = 0;
 ''');
 
@@ -743,7 +740,7 @@
     // Change the dependency, new resolver.
     // The signature of the result is different.
     // The previously cached result cannot be used.
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 var a = 4.2;
 ''');
     createFileResolver();
@@ -783,7 +780,7 @@
   }
 
   test_getLibraryByUri() {
-    newFile('/workspace/dart/my/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/my/lib/a.dart', r'''
 class A {}
 ''');
 
@@ -801,7 +798,7 @@
   }
 
   test_getLibraryByUri_partOf() {
-    newFile('/workspace/dart/my/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/my/lib/a.dart', r'''
 part of 'b.dart';
 ''');
 
@@ -828,7 +825,7 @@
 
   test_hint_in_third_party() async {
     var aPath = convertPath('/workspace/third_party/dart/aaa/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 import 'dart:math';
 ''');
     await resolveFile(aPath);
@@ -854,7 +851,7 @@
   }
 
   test_nameOffset_class_method_fromBytes() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 class A {
   void foo() {}
 }
@@ -885,7 +882,7 @@
   }
 
   test_nameOffset_unit_variable_fromBytes() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 var a = 0;
 ''');
 
@@ -913,7 +910,7 @@
   test_nullSafety_enabled() async {
     isNullSafetyEnabled = true;
 
-    newFile('/workspace/dart/test/BUILD', content: r'''
+    newFile2('/workspace/dart/test/BUILD', r'''
 dart_package(
   null_safety = True,
 )
@@ -960,15 +957,15 @@
     var bPath = convertPath('/workspace/dart/aaa/lib/b.dart');
     var cPath = convertPath('/workspace/dart/aaa/lib/c.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 import 'a.dart';
 ''');
 
-    newFile(cPath, content: r'''
+    newFile2(cPath, r'''
 import 'a.dart';
 ''');
 
@@ -984,28 +981,28 @@
     var ePath = convertPath('/workspace/dart/aaa/lib/e.dart');
     var fPath = convertPath('/workspace/dart/aaa/lib/f.dart');
 
-    newFile('/workspace/dart/aaa/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/aaa/lib/a.dart', r'''
 class A {}
 ''');
 
-    newFile(bPath, content: r'''
+    newFile2(bPath, r'''
 class B {}
 ''');
 
-    newFile('/workspace/dart/aaa/lib/c.dart', content: r'''
+    newFile2('/workspace/dart/aaa/lib/c.dart', r'''
 class C {}
 ''');
 
-    newFile(dPath, content: r'''
+    newFile2(dPath, r'''
 import 'a.dart';
 ''');
 
-    newFile(ePath, content: r'''
+    newFile2(ePath, r'''
 import 'a.dart';
 import 'b.dart';
 ''');
 
-    newFile(fPath, content: r'''
+    newFile2(fPath, r'''
 import 'c.dart';
  ''');
 
@@ -1020,7 +1017,7 @@
     var aPath = convertPath('/workspace/dart/aaa/lib/a.dart');
     var bPath = convertPath('/workspace/dart/aaa/lib/b.dart');
 
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {}
 ''');
 
@@ -1032,7 +1029,7 @@
 
   test_resolve_libraryWithPart_noLibraryDiscovery() async {
     var partPath = '/workspace/dart/test/lib/a.dart';
-    newFile(partPath, content: r'''
+    newFile2(partPath, r'''
 part of 'test.dart';
 
 class A {}
@@ -1050,7 +1047,7 @@
   }
 
   test_resolve_part_of_name() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 library my.lib;
 
 part 'test.dart';
@@ -1073,7 +1070,7 @@
   }
 
   test_resolve_part_of_uri() async {
-    newFile('/workspace/dart/test/lib/a.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/a.dart', r'''
 part 'test.dart';
 
 class A {
@@ -1095,7 +1092,7 @@
 
   test_resolveFile_cache() async {
     var path = convertPath('/workspace/dart/test/lib/test.dart');
-    newFile(path, content: 'var a = 0;');
+    newFile2(path, 'var a = 0;');
 
     // No resolved files yet.
     var testView = fileResolver.testView!;
@@ -1131,12 +1128,12 @@
 
   test_resolveFile_dontCache_whenForCompletion() async {
     var a_path = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(a_path, content: r'''
+    newFile2(a_path, r'''
 part 'b.dart';
 ''');
 
     var b_path = convertPath('/workspace/dart/test/lib/b.dart');
-    newFile(b_path, content: r'''
+    newFile2(b_path, r'''
 part of 'a.dart';
 ''');
 
@@ -1160,7 +1157,7 @@
 
   test_resolveLibrary() async {
     var aPath = convertPath('/workspace/dart/test/lib/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 part 'test.dart';
 
 class A {
@@ -1168,7 +1165,7 @@
 }
 ''');
 
-    newFile('/workspace/dart/test/lib/test.dart', content: r'''
+    newFile2('/workspace/dart/test/lib/test.dart', r'''
 part of 'a.dart';
 
 void func() {
@@ -1184,8 +1181,8 @@
   }
 
   test_reuse_compatibleOptions() async {
-    newFile('/workspace/dart/aaa/BUILD', content: '');
-    newFile('/workspace/dart/bbb/BUILD', content: '');
+    newFile2('/workspace/dart/aaa/BUILD', '');
+    newFile2('/workspace/dart/bbb/BUILD', '');
 
     var aPath = '/workspace/dart/aaa/lib/a.dart';
     var aResult = await assertErrorsInFile(aPath, r'''
@@ -1208,15 +1205,15 @@
   }
 
   test_reuse_incompatibleOptions_implicitCasts() async {
-    newFile('/workspace/dart/aaa/BUILD', content: '');
-    newAnalysisOptionsYamlFile('/workspace/dart/aaa', content: r'''
+    newFile2('/workspace/dart/aaa/BUILD', '');
+    newAnalysisOptionsYamlFile2('/workspace/dart/aaa', r'''
 analyzer:
   strong-mode:
     implicit-casts: false
 ''');
 
-    newFile('/workspace/dart/bbb/BUILD', content: '');
-    newAnalysisOptionsYamlFile('/workspace/dart/bbb', content: r'''
+    newFile2('/workspace/dart/bbb/BUILD', '');
+    newAnalysisOptionsYamlFile2('/workspace/dart/bbb', r'''
 analyzer:
   strong-mode:
     implicit-casts: true
diff --git a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
index 3ee6a27..b230bf5 100644
--- a/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/assignment_test.dart
@@ -636,8 +636,8 @@
   }
 
   test_notLValue_typeLiteral_class_ambiguous_simple() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class C {}');
-    newFile('$testPackageLibPath/b.dart', content: 'class C {}');
+    newFile2('$testPackageLibPath/a.dart', 'class C {}');
+    newFile2('$testPackageLibPath/b.dart', 'class C {}');
     await assertErrorsInCode('''
 import 'a.dart';
 import 'b.dart';
@@ -902,7 +902,7 @@
   }
 
   test_prefixedIdentifier_topLevel_compound() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int get x => 0;
 set x(num _) {}
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart b/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
index 26937b0..2050ac9 100644
--- a/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
@@ -543,7 +543,7 @@
   }
 
   test_targetPrefixedIdentifier_prefix_class_constructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A.named(T a);
 }
@@ -597,7 +597,7 @@
   }
 
   test_targetPrefixedIdentifier_prefix_class_constructor_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A.named(int a);
 }
@@ -665,7 +665,7 @@
   }
 
   test_targetPrefixedIdentifier_prefix_class_constructor_typeArguments_new() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A.new(int a);
 }
@@ -733,7 +733,7 @@
   }
 
   test_targetPrefixedIdentifier_prefix_getter_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 A get foo => A();
 
 class A {
@@ -782,7 +782,7 @@
   }
 
   test_targetPrefixedIdentifier_typeAlias_interfaceType_constructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A.named(T a);
 }
@@ -1021,7 +1021,7 @@
   }
 
   test_targetSimpleIdentifier_prefix_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T, U> {
   A(int a);
 }
@@ -1084,7 +1084,7 @@
   }
 
   test_targetSimpleIdentifier_prefix_extension() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 
 extension E<T> on A {
@@ -1113,7 +1113,7 @@
   }
 
   test_targetSimpleIdentifier_prefix_function() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void A<T, U>(int a) {}
 ''');
 
diff --git a/pkg/analyzer/test/src/dart/resolution/constant_test.dart b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
index 286ec22..24c790e 100644
--- a/pkg/analyzer/test/src/dart/resolution/constant_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
@@ -23,7 +23,7 @@
 @reflectiveTest
 class ConstantResolutionTest extends PubPackageResolutionTest {
   test_constructor_nullSafe_fromLegacy_super() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A(List<Object> a);
 }
@@ -46,7 +46,7 @@
   }
 
   test_constructor_nullSafe_fromLegacy_this() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A(List<Object> a) : this(a);
   const A.second(List<Object> a);
@@ -87,7 +87,7 @@
   }
 
   test_field_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const foo = 42;
 }
@@ -105,7 +105,7 @@
   }
 
   test_fromEnvironment_optOut_fromOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 
 const cBool = const bool.fromEnvironment('foo', defaultValue: false);
@@ -133,7 +133,7 @@
   }
 
   test_topLevelVariable_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const foo = 42;
 ''');
 
@@ -150,11 +150,11 @@
   }
 
   test_topLevelVariable_optOut2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 42;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart';
 
 const b = a;
@@ -173,7 +173,7 @@
   }
 
   test_topLevelVariable_optOut3() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 const a = int.fromEnvironment('a', defaultValue: 42);
 ''');
@@ -199,7 +199,7 @@
 class ConstantResolutionWithoutNullSafetyTest extends PubPackageResolutionTest
     with WithoutNullSafetyMixin {
   test_constantValue_defaultParameter_noDefaultValue() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A({int p});
 }
@@ -281,7 +281,7 @@
   }
 
   test_functionType_element_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F<T> = T Function(int);
 const a = C<F<double>>();
 
@@ -312,7 +312,7 @@
   }
 
   test_imported_prefixedIdentifier_staticField_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = C.f;
 
 class C {
@@ -329,7 +329,7 @@
   }
 
   test_imported_prefixedIdentifier_staticField_extension() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = E.f;
 
 extension E on int {
@@ -346,7 +346,7 @@
   }
 
   test_imported_prefixedIdentifier_staticField_mixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = M.f;
 
 class C {}
@@ -365,7 +365,7 @@
   }
 
   test_imported_super_defaultFieldFormalParameter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'test.dart';
 
 class A {
@@ -409,7 +409,7 @@
 
   /// See https://github.com/dart-lang/sdk/issues/43462
   test_useLanguageVersionOfEnclosingLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class Wrapper {
   final int value;
   const Wrapper(Object value) : value = value as int;
diff --git a/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart b/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
index a48aaa1..aa3e3d3 100644
--- a/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constructor_reference_test.dart
@@ -830,7 +830,7 @@
   }
 
   test_prefixedAlias_generic_unnamed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A<T> {
   A();
 }
@@ -886,7 +886,7 @@
   }
 
   test_prefixedClass_generic_named() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A<T> {
   A.foo();
 }
@@ -941,7 +941,7 @@
   }
 
   test_prefixedClass_generic_targetOfFunctionCall() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A<T> {
   A();
 }
@@ -999,7 +999,7 @@
   }
 
   test_prefixedClass_generic_unnamed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A<T> {
   A();
 }
@@ -1388,7 +1388,7 @@
   }
 
   test_prefixedAlias_nonGeneric_named() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   A.foo();
 }
@@ -1430,7 +1430,7 @@
   }
 
   test_prefixedAlias_nonGeneric_unnamed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   A();
 }
@@ -1472,7 +1472,7 @@
   }
 
   test_prefixedClass_nonGeneric_named() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   A.foo();
 }
@@ -1513,7 +1513,7 @@
   }
 
   test_prefixedClass_nonGeneric_unnamed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   A();
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
index bd15dd4..45f9fd3 100644
--- a/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/context_collection_resolution.dart
@@ -102,8 +102,8 @@
   @override
   void setUp() {
     super.setUp();
-    newFile('$workspaceRootPath/WORKSPACE', content: '');
-    newFile('$myPackageRootPath/BUILD', content: '');
+    newFile2('$workspaceRootPath/WORKSPACE', '');
+    newFile2('$myPackageRootPath/BUILD', '');
   }
 
   @override
@@ -183,12 +183,12 @@
   }
 
   @override
-  File newFile(String path, {String content = ''}) {
+  File newFile2(String path, String content) {
     if (_analysisContextCollection != null && !path.endsWith('.dart')) {
       throw StateError('Only dart files can be changed after analysis.');
     }
 
-    return super.newFile(path, content: content);
+    return super.newFile2(path, content);
   }
 
   @override
@@ -300,18 +300,18 @@
   }
 
   void writePackageConfig(String path, PackageConfigFileBuilder config) {
-    newFile(
+    newFile2(
       path,
-      content: config.toContent(
+      config.toContent(
         toUriStr: toUriStr,
       ),
     );
   }
 
   void writeTestPackageAnalysisOptionsFile(AnalysisOptionsFileConfig config) {
-    newAnalysisOptionsYamlFile(
+    newAnalysisOptionsYamlFile2(
       testPackageRootPath,
-      content: config.toContent(),
+      config.toContent(),
     );
   }
 
diff --git a/pkg/analyzer/test/src/dart/resolution/export_test.dart b/pkg/analyzer/test/src/dart/resolution/export_test.dart
index fe41eaf..84d485d 100644
--- a/pkg/analyzer/test/src/dart/resolution/export_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/export_test.dart
@@ -16,9 +16,9 @@
 @reflectiveTest
 class ExportResolutionTest extends PubPackageResolutionTest {
   test_configurations_default() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'false',
@@ -44,9 +44,9 @@
   }
 
   test_configurations_first() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'true',
@@ -72,9 +72,9 @@
   }
 
   test_configurations_second() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'false',
@@ -101,7 +101,7 @@
 
   /// Test that both getter and setter are in the export namespace.
   test_namespace_getter_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 get f => null;
 set f(_) {}
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
index bbd5bbb..bafe4c6 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
@@ -178,7 +178,7 @@
   }
 
   test_visibility_hidden() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int a = 1;
@@ -196,7 +196,7 @@
   }
 
   test_visibility_notShown() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int a = 1;
@@ -214,7 +214,7 @@
   }
 
   test_visibility_shadowed_byClass() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int get a => 1;
@@ -235,12 +235,12 @@
   }
 
   test_visibility_shadowed_byImport() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 extension E on Object {
   int get a => 1;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 class E {}
 class A {}
 ''');
@@ -259,7 +259,7 @@
   }
 
   test_visibility_shadowed_byLocal_imported() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int get a => 1;
@@ -300,7 +300,7 @@
   }
 
   test_visibility_shadowed_byTopLevelVariable() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int get a => 1;
@@ -321,7 +321,7 @@
   }
 
   test_visibility_shadowed_platformByNonPlatform() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 extension E on Object {
   int get a => 1;
 }
@@ -338,7 +338,7 @@
   }
 
   test_visibility_withPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 extension E on C {
   int get a => 1;
@@ -1551,7 +1551,7 @@
   }
 
   test_static_field_importedWithPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 
 extension E on C {
@@ -1589,7 +1589,7 @@
   }
 
   test_static_getter_importedWithPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 
 extension E on C {
@@ -1627,7 +1627,7 @@
   }
 
   test_static_method_importedWithPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 
 extension E on C {
@@ -1665,7 +1665,7 @@
   }
 
   test_static_setter_importedWithPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 
 extension E on C {
diff --git a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
index 0c703558..c8dc8ea 100644
--- a/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/extension_override_test.dart
@@ -323,7 +323,7 @@
   }
 
   test_call_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   int call(String s) => 0;
@@ -414,7 +414,7 @@
 
   test_call_prefix_typeArguments() async {
     // The test is failing because we're not yet doing type inference.
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   int call(T s) => 0;
@@ -779,7 +779,7 @@
   }
 
   test_getter_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   int get g => 0;
@@ -863,7 +863,7 @@
   }
 
   test_getter_prefix_typeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   int get g => 0;
@@ -1149,7 +1149,7 @@
   }
 
   test_method_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   void m() {}
@@ -1241,7 +1241,7 @@
   }
 
   test_method_prefix_typeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   void m() {}
@@ -1601,7 +1601,7 @@
   }
 
   test_operator_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   void operator +(int offset) {}
@@ -1687,7 +1687,7 @@
   }
 
   test_operator_prefix_typeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   void operator +(int offset) {}
@@ -1999,7 +1999,7 @@
   }
 
   test_setter_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   set s(int x) {}
@@ -2105,7 +2105,7 @@
   }
 
   test_setter_prefix_typeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   set s(int x) {}
@@ -2451,7 +2451,7 @@
   }
 
   test_setterAndGetter_prefix_noTypeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E on A {
   int get s => 0;
@@ -2560,7 +2560,7 @@
   }
 
   test_setterAndGetter_prefix_typeArguments() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class A {}
 extension E<T> on A {
   int get s => 0;
diff --git a/pkg/analyzer/test/src/dart/resolution/field_test.dart b/pkg/analyzer/test/src/dart/resolution/field_test.dart
index 1ff7e4e..f4805b3 100644
--- a/pkg/analyzer/test/src/dart/resolution/field_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/field_test.dart
@@ -63,7 +63,7 @@
   }
 
   test_type_inferred_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 var a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/for_element_test.dart b/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
index 06f0e44..82803f7 100644
--- a/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/for_element_test.dart
@@ -17,7 +17,7 @@
 class ForEachElementTest extends PubPackageResolutionTest
     with WithoutNullSafetyMixin {
   test_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A implements Iterable<int> {
   Iterator<int> iterator => throw 0;
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
index 747cb36..98e0425 100644
--- a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
@@ -1016,7 +1016,7 @@
   }
 
   test_extension_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 extension E<T> on String {}
 ''');
     await assertErrorsInCode('''
@@ -1802,7 +1802,7 @@
   }
 
   test_implicitCallTearoff_prefix_class_staticGetter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   static const v = C();
   const C();
@@ -1858,7 +1858,7 @@
   }
 
   test_implicitCallTearoff_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class C {
   T call<T>(T t) => t;
 }
@@ -2597,7 +2597,7 @@
   }
 
   test_instanceMethod_explicitReceiver_topLevelVariable_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   void foo<T>(T a) {}
 }
@@ -2652,7 +2652,7 @@
   }
 
   test_instanceMethod_explicitReceiver_topLevelVariable_prefix_unknown() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {}
 var a = A();
 ''');
@@ -3380,7 +3380,7 @@
   }
 
   test_staticMethod_explicitReceiver_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void foo<T>(T a) {}
 }
@@ -3435,7 +3435,7 @@
   }
 
   test_staticMethod_explicitReceiver_prefix_typeAlias() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void foo<T>(T a) {}
 }
@@ -3534,7 +3534,7 @@
   }
 
   test_staticMethod_explicitReciver_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   static void foo<T>(T a) {}
 }
@@ -3701,7 +3701,7 @@
   }
 
   test_topLevelFunction_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void foo<T>(T arg) {}
 ''');
     await assertNoErrorsInCode('''
@@ -3745,7 +3745,7 @@
   }
 
   test_topLevelFunction_importPrefix_asTargetOfFunctionCall() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void foo<T>(T arg) {}
 ''');
     await assertNoErrorsInCode('''
@@ -3896,7 +3896,7 @@
   }
 
   test_topLevelVariable_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void Function<T>(T) foo = <T>(T arg) {}
 ''');
     await assertNoErrorsInCode('''
@@ -3940,7 +3940,7 @@
   }
 
   test_topLevelVariable_prefix_unknownIdentifier() async {
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
     await assertErrorsInCode('''
 import 'a.dart' as prefix;
 
@@ -4135,7 +4135,7 @@
   }
 
   test_unknownIdentifier_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
     await assertErrorsInCode('''
 import 'a.dart' as a;
 
diff --git a/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
index 60b6def..8d1af31 100644
--- a/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/generic_type_alias_test.dart
@@ -82,7 +82,7 @@
   }
 
   test_genericFunctionTypeCannotBeTypeArgument_optOutOfGenericMetadata() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 typedef G = Function<S>();
 ''');
     await assertErrorsInCode('''
@@ -131,7 +131,7 @@
   }
 
   test_missingGenericFunction_imported_withPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F<T> = ;
 ''');
     await assertErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/import_test.dart b/pkg/analyzer/test/src/dart/resolution/import_test.dart
index 145bae8..0249c90 100644
--- a/pkg/analyzer/test/src/dart/resolution/import_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/import_test.dart
@@ -15,9 +15,9 @@
 @reflectiveTest
 class ImportDirectiveResolutionTest extends PubPackageResolutionTest {
   test_configurations_default() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'false',
@@ -43,9 +43,9 @@
   }
 
   test_configurations_first() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'true',
@@ -71,9 +71,9 @@
   }
 
   test_configurations_second() async {
-    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_html.dart', content: 'class A {}');
-    newFile('$testPackageLibPath/a_io.dart', content: 'class A {}');
+    newFile2('$testPackageLibPath/a.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_html.dart', 'class A {}');
+    newFile2('$testPackageLibPath/a_io.dart', 'class A {}');
 
     declaredVariables = {
       'dart.library.html': 'false',
diff --git a/pkg/analyzer/test/src/dart/resolution/instance_creation_test.dart b/pkg/analyzer/test/src/dart/resolution/instance_creation_test.dart
index 1508e0f..89bebe0 100644
--- a/pkg/analyzer/test/src/dart/resolution/instance_creation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/instance_creation_test.dart
@@ -407,7 +407,7 @@
   }
 
   test_error_wrongNumberOfTypeArgumentsConstructor_explicitNew_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class Foo<X> {
   Foo.bar();
 }
@@ -522,7 +522,7 @@
   }
 
   test_error_wrongNumberOfTypeArgumentsConstructor_implicitNew_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class Foo<X> {
   Foo.bar();
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/instance_member_inference_class_test.dart b/pkg/analyzer/test/src/dart/resolution/instance_member_inference_class_test.dart
index aaf0e18..601714b 100644
--- a/pkg/analyzer/test/src/dart/resolution/instance_member_inference_class_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/instance_member_inference_class_test.dart
@@ -159,7 +159,7 @@
   }
 
   test_field_multiple_gettersSetters_final_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int get foo;
@@ -258,7 +258,7 @@
   }
 
   test_field_multiple_gettersSetters_notFinal_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int get foo;
@@ -312,7 +312,7 @@
   }
 
   test_field_single_getter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int get foo;
@@ -330,7 +330,7 @@
   }
 
   test_field_single_setter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   set foo(int _);
@@ -466,7 +466,7 @@
   }
 
   test_getter_single_getter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int get foo;
@@ -484,7 +484,7 @@
   }
 
   test_getter_single_setter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   set foo(int _);
@@ -715,7 +715,7 @@
   }
 
   test_method_parameter_required_single_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A {
   void foo(int p) {}
@@ -895,7 +895,7 @@
   }
 
   test_method_return_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int foo();
@@ -1057,7 +1057,7 @@
   }
 
   test_setter_single_getter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   int get foo;
@@ -1075,7 +1075,7 @@
   }
 
   test_setter_single_setter_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 abstract class A {
   set foo(int _);
diff --git a/pkg/analyzer/test/src/dart/resolution/language_version_test.dart b/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
index fa4ab1c..7438e78 100644
--- a/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/language_version_test.dart
@@ -37,7 +37,7 @@
 }
 ''');
 
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 int a = 0;
 ''');
 
@@ -74,7 +74,7 @@
 }
 ''');
 
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 int a = 0;
 ''');
 
@@ -148,9 +148,9 @@
 
 class _FeaturesTest extends PubPackageResolutionTest {
   void _configureTestWithJsonConfig(String content) {
-    newFile(
+    newFile2(
       '$testPackageRootPath/.dart_tool/package_config.json',
-      content: content,
+      content,
     );
   }
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/local_variable_test.dart b/pkg/analyzer/test/src/dart/resolution/local_variable_test.dart
index ddad876..f28cd14 100644
--- a/pkg/analyzer/test/src/dart/resolution/local_variable_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/local_variable_test.dart
@@ -112,7 +112,7 @@
   }
 
   test_nonNullifyType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 var a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
index 458a44b..cb2351c 100644
--- a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
@@ -43,7 +43,7 @@
   }
 
   test_location_partDirective() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 part of 'test.dart';
 ''');
 
@@ -66,11 +66,11 @@
   }
 
   test_location_partOfDirective() async {
-    var libPath = newFile('$testPackageLibPath/lib.dart', content: r'''
+    var libPath = newFile2('$testPackageLibPath/lib.dart', r'''
 part 'part.dart';
 ''').path;
 
-    var partPath = newFile('$testPackageLibPath/part.dart', content: r'''
+    var partPath = newFile2('$testPackageLibPath/part.dart', r'''
 @foo
 part of 'lib.dart';
 const foo = 42;
@@ -212,7 +212,7 @@
   }
 
   test_optIn_fromOptOut_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A(int a);
 }
@@ -239,7 +239,7 @@
   }
 
   test_optIn_fromOptOut_class_constructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final int a;
   const A.named(this.a);
@@ -273,7 +273,7 @@
   }
 
   test_optIn_fromOptOut_class_constructor_withDefault() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final int a;
   const A.named({this.a = 42});
@@ -307,7 +307,7 @@
   }
 
   test_optIn_fromOptOut_class_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const foo = 42;
 }
@@ -339,7 +339,7 @@
   }
 
   test_optIn_fromOptOut_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const foo = 42;
 ''');
 
@@ -364,7 +364,7 @@
   }
 
   test_optIn_fromOptOut_prefix_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A(int a);
 }
@@ -391,7 +391,7 @@
   }
 
   test_optIn_fromOptOut_prefix_class_constructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named(int a);
 }
@@ -418,7 +418,7 @@
   }
 
   test_optIn_fromOptOut_prefix_class_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const foo = 0;
 }
@@ -445,7 +445,7 @@
   }
 
   test_optIn_fromOptOut_prefix_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const foo = 0;
 ''');
 
@@ -1338,7 +1338,7 @@
   }
 
   test_value_otherLibrary_implicitConst() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final int f;
   const A(this.f);
@@ -1369,14 +1369,14 @@
   }
 
   test_value_otherLibrary_namedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final int f;
   const A.named(this.f);
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart';
 
 @A.named(42)
@@ -1398,14 +1398,14 @@
   }
 
   test_value_otherLibrary_unnamedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   final int f;
   const A(this.f);
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart';
 
 @A(42)
@@ -1427,7 +1427,7 @@
   }
 
   test_value_prefix_typeAlias_class_staticConstField() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static const int foo = 42;
 }
@@ -1470,7 +1470,7 @@
   }
 
   test_value_prefix_typeAlias_generic_class_generic_all_inference_namedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   final T f;
   const A.named(this.f);
@@ -1532,7 +1532,7 @@
   }
 
   test_value_prefix_typeAlias_generic_class_generic_all_inference_unnamedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   final T f;
   const A(this.f);
@@ -1587,7 +1587,7 @@
   }
 
   test_value_prefix_typeAlias_generic_class_generic_all_typeArguments_namedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   final T f;
   const A.named(this.f);
@@ -1659,7 +1659,7 @@
   }
 
   test_value_prefix_typeAlias_generic_class_generic_all_typeArguments_unnamedConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   final T f;
   const A(this.f);
diff --git a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
index 28c1a7f..3801936 100644
--- a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
@@ -20,7 +20,7 @@
 class MethodInvocationResolutionTest extends PubPackageResolutionTest
     with MethodInvocationResolutionTestCases {
   test_hasReceiver_deferredImportPrefix_loadLibrary_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
@@ -3238,10 +3238,10 @@
   }
 
   test_error_ambiguousImport_topFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo(int _) {}
 ''');
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 void foo(int _) {}
 ''');
 
@@ -3295,10 +3295,10 @@
   }
 
   test_error_ambiguousImport_topFunction_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo(int _) {}
 ''');
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 void foo(int _) {}
 ''');
 
@@ -3967,7 +3967,7 @@
   }
 
   test_error_prefixIdentifierNotFollowedByDot() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo() {}
 ''');
 
@@ -4810,7 +4810,7 @@
   }
 
   test_error_undefinedMethod_private() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo(int _) {}
 }
@@ -6024,7 +6024,7 @@
   }
 
   test_hasReceiver_importPrefix_topFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 T foo<T extends num>(T a, T b) => a;
 ''');
 
@@ -6095,7 +6095,7 @@
   }
 
   test_hasReceiver_importPrefix_topGetter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 T Function<T>(T a, T b) get foo => null;
 ''');
 
@@ -6726,7 +6726,7 @@
   }
 
   test_hasReceiver_prefixed_class_staticGetter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   static double Function(int) get foo => null;
 }
@@ -6811,7 +6811,7 @@
   }
 
   test_hasReceiver_prefixed_class_staticMethod() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   static void foo(int _) => null;
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/namespace_test.dart b/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
index fcb7a12..9a82a1d 100644
--- a/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/namespace_test.dart
@@ -15,7 +15,7 @@
 @reflectiveTest
 class ImportResolutionTest extends PubPackageResolutionTest {
   test_overrideCoreType_Never() async {
-    newFile('$testPackageLibPath/declares_never.dart', content: '''
+    newFile2('$testPackageLibPath/declares_never.dart', '''
 class Never {}
 ''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart b/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart
index 7c4aad2..a91b101 100644
--- a/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/non_nullable_bazel_workspace_test.dart
@@ -21,7 +21,7 @@
   bool get isNullSafetyEnabled => true;
 
   test_buildFile_legacy_commentedOut() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
 #  null_safety = True,
 ''');
@@ -35,7 +35,7 @@
   }
 
   test_buildFile_nonNullable() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
   null_safety = True,
 )
@@ -67,7 +67,7 @@
   }
 
   test_buildFile_nonNullable_languageVersion_current() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
   null_safety = True,
 )
@@ -84,7 +84,7 @@
   }
 
   test_buildFile_nonNullable_languageVersion_fromWorkspace() async {
-    newFile('$workspaceRootPath/dart/build_defs/bzl/language.bzl', content: r'''
+    newFile2('$workspaceRootPath/dart/build_defs/bzl/language.bzl', r'''
 _version = "2.9"
 _version_null_safety = "2.14"
 _version_for_analyzer = _version_null_safety
@@ -96,7 +96,7 @@
 )
 ''');
 
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
   null_safety = True,
 )
@@ -113,7 +113,7 @@
   }
 
   test_buildFile_nonNullable_oneLine_noComma() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(null_safety = True)
 ''');
 
@@ -126,7 +126,7 @@
   }
 
   test_buildFile_nonNullable_soundNullSafety() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
   sound_null_safety = True
 )
@@ -141,7 +141,7 @@
   }
 
   test_buildFile_nonNullable_withComments() async {
-    newFile('$myPackageRootPath/BUILD', content: r'''
+    newFile2('$myPackageRootPath/BUILD', r'''
 dart_package(
   # Preceding comment.
   null_safety = True,  # Trailing comment.
diff --git a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
index 89408dc..3f34708 100644
--- a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart
@@ -59,7 +59,7 @@
   }
 
   test_library_typeProvider_typeSystem() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await resolveTestCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart b/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
index a425545..8f6dc88 100644
--- a/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/optional_const_test.dart
@@ -234,7 +234,7 @@
   }
 
   test_prefixed_unnamed_generic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C<T> {
   const C();
 }
@@ -286,7 +286,7 @@
 
   Future<InstanceCreationExpression> _resolveImplicitConst(String expr,
       {String? prefix}) async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   const A();
   const A.named();
@@ -298,12 +298,12 @@
 ''');
 
     if (prefix != null) {
-      newFile('$testPackageLibPath/b.dart', content: '''
+      newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart' as $prefix;
 const a = $expr;
 ''');
     } else {
-      newFile('$testPackageLibPath/b.dart', content: '''
+      newFile2('$testPackageLibPath/b.dart', '''
 import 'a.dart';
 const a = $expr;
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/postfix_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/postfix_expression_test.dart
index c83a1c0..1847d44 100644
--- a/pkg/analyzer/test/src/dart/resolution/postfix_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/postfix_expression_test.dart
@@ -780,7 +780,7 @@
   }
 
   test_inc_prefixedIdentifier_topLevel() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int x = 0;
 ''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/prefix_element_test.dart b/pkg/analyzer/test/src/dart/resolution/prefix_element_test.dart
index 06faef1..845f018 100644
--- a/pkg/analyzer/test/src/dart/resolution/prefix_element_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/prefix_element_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PrefixElementTest extends PubPackageResolutionTest {
   test_scope_lookup() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var foo = 0;
 ''');
 
@@ -40,11 +40,11 @@
   }
 
   test_scope_lookup_ambiguous_notSdk_both() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var foo = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 var foo = 1.2;
 ''');
 
@@ -79,7 +79,7 @@
   }
 
   test_scope_lookup_ambiguous_notSdk_first() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var pi = 4;
 ''');
 
@@ -101,7 +101,7 @@
   }
 
   test_scope_lookup_ambiguous_notSdk_second() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var pi = 4;
 ''');
 
@@ -123,11 +123,11 @@
   }
 
   test_scope_lookup_ambiguous_same() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var foo = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart';
 ''');
 
@@ -154,11 +154,11 @@
   }
 
   test_scope_lookup_differentPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var foo = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 var bar = 0;
 ''');
 
diff --git a/pkg/analyzer/test/src/dart/resolution/prefix_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/prefix_expression_test.dart
index e0e6a2c..888d74f 100644
--- a/pkg/analyzer/test/src/dart/resolution/prefix_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/prefix_expression_test.dart
@@ -700,7 +700,7 @@
   }
 
   test_plusPlus_prefixedIdentifier_topLevel() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int x = 0;
 ''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/prefixed_identifier_test.dart b/pkg/analyzer/test/src/dart/resolution/prefixed_identifier_test.dart
index 998efbf..1a011b1 100644
--- a/pkg/analyzer/test/src/dart/resolution/prefixed_identifier_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/prefixed_identifier_test.dart
@@ -19,7 +19,7 @@
 class PrefixedIdentifierResolutionTest extends PubPackageResolutionTest
     with PrefixedIdentifierResolutionTestCases {
   test_deferredImportPrefix_loadLibrary_optIn_fromOptOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
@@ -145,7 +145,7 @@
   }
 
   test_implicitCall_tearOff_nullable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int call() => 0;
 }
@@ -171,7 +171,7 @@
   }
 
   test_read_typedef_interfaceType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef A = List<int>;
 ''');
 
@@ -298,7 +298,7 @@
   }
 
   test_class_read_typedef_functionType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef A = void Function();
 ''');
 
@@ -431,7 +431,7 @@
   }
 
   test_implicitCall_tearOff() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int call() => 0;
 }
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 002686b..ae050fb 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -87,7 +87,7 @@
   VoidType get voidType => VoidTypeImpl.instance;
 
   void addTestFile(String content) {
-    newFile(testFilePath, content: content);
+    newFile2(testFilePath, content);
   }
 
   void assertAssignment(
@@ -281,7 +281,7 @@
     List<ExpectedError> expectedErrors,
   ) async {
     path = convertPath(path);
-    newFile(path, content: content);
+    newFile2(path, content);
 
     var result = await resolveFile(path);
     assertErrorsInResolvedUnit(result, expectedErrors);
@@ -826,7 +826,7 @@
 
   /// Create a new file with the [path] and [content], resolve it into [result].
   Future<void> resolveFileCode(String path, String content) {
-    newFile(path, content: content);
+    newFile2(path, content);
     return resolveFile2(path);
   }
 
diff --git a/pkg/analyzer/test/src/dart/resolution/top_level_variable_test.dart b/pkg/analyzer/test/src/dart/resolution/top_level_variable_test.dart
index 444c894..f478f61 100644
--- a/pkg/analyzer/test/src/dart/resolution/top_level_variable_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/top_level_variable_test.dart
@@ -19,7 +19,7 @@
 class TopLevelVariableTest extends PubPackageResolutionTest
     with TopLevelVariableTestCases {
   test_type_inferred_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 var a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
index 11676d2..c761dab 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/function_expression_test.dart
@@ -18,7 +18,7 @@
 class FunctionExpressionTest extends PubPackageResolutionTest
     with FunctionExpressionTestCases {
   test_contextFunctionType_nonNullify() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 
 int Function(int a) v;
@@ -42,7 +42,7 @@
   }
 
   test_contextFunctionType_nonNullify_returnType_takeActual() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 
 void foo(int Function() x) {}
@@ -60,7 +60,7 @@
   }
 
   test_contextFunctionType_nonNullify_returnType_takeContext() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 
 void foo(int Function() x) {}
@@ -117,7 +117,7 @@
   }
 
   test_optOut_downward_returnType_expressionBody_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo(Map<String, String> Function() f) {}
 ''');
     await resolveTestCode('''
@@ -460,7 +460,7 @@
   }
 
   test_noContext_returnType_sync_blockBody_notNullable_switch_onEnum_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 enum E { a, b }
 ''');
 
diff --git a/pkg/analyzer/test/src/dart/resolution/type_literal_test.dart b/pkg/analyzer/test/src/dart/resolution/type_literal_test.dart
index 866b8c3..a0a53a1 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_literal_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_literal_test.dart
@@ -28,7 +28,7 @@
   }
 
   test_class_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class C<T> {}
 ''');
     await assertNoErrorsInCode('''
@@ -119,7 +119,7 @@
   }
 
   test_classAlias_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class C<T> {}
 typedef CA<T> = C<T>;
 ''');
@@ -163,7 +163,7 @@
   }
 
   test_functionAlias_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 typedef Fn<T> = void Function(T);
 ''');
     await assertNoErrorsInCode('''
@@ -204,7 +204,7 @@
   }
 
   test_functionAlias_targetOfMethodCall_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 typedef Fn<T> = void Function(T);
 ''');
     await assertErrorsInCode('''
@@ -433,7 +433,7 @@
   }
 
   test_class_importPrefix() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class C<T> {}
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart b/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
index 2e4fc17..1e9d9ca 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_name_test.dart
@@ -24,7 +24,7 @@
   }
 
   test_optIn_fromOptOut_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
@@ -43,7 +43,7 @@
   }
 
   test_optIn_fromOptOut_class_generic_toBounds() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T extends num> {}
 ''');
 
@@ -62,7 +62,7 @@
   }
 
   test_optIn_fromOptOut_class_generic_toBounds_dynamic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 ''');
 
@@ -81,7 +81,7 @@
   }
 
   test_optIn_fromOptOut_class_generic_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 ''');
 
@@ -100,7 +100,7 @@
   }
 
   test_optIn_fromOptOut_functionTypeAlias() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F = int Function(bool);
 ''');
 
@@ -124,7 +124,7 @@
   }
 
   test_optIn_fromOptOut_functionTypeAlias_generic_dynamic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F<T> = T Function(bool);
 ''');
 
@@ -148,7 +148,7 @@
   }
 
   test_optIn_fromOptOut_functionTypeAlias_generic_toBounds() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F<T extends num> = T Function(bool);
 ''');
 
@@ -172,7 +172,7 @@
   }
 
   test_optIn_fromOptOut_functionTypeAlias_generic_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef F<T> = T Function(bool);
 ''');
 
@@ -196,7 +196,7 @@
   }
 
   test_optOut_fromOptIn_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A {}
 ''');
@@ -217,7 +217,7 @@
   }
 
   test_optOut_fromOptIn_class_generic_toBounds() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A<T extends num> {}
 ''');
@@ -238,7 +238,7 @@
   }
 
   test_optOut_fromOptIn_class_generic_toBounds_dynamic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A<T> {}
 ''');
@@ -259,7 +259,7 @@
   }
 
   test_optOut_fromOptIn_class_generic_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A<T> {}
 ''');
@@ -280,7 +280,7 @@
   }
 
   test_optOut_fromOptIn_functionTypeAlias() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 typedef F = int Function();
 ''');
@@ -301,7 +301,7 @@
   }
 
   test_optOut_fromOptIn_functionTypeAlias_generic_toBounds() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 typedef F<T extends num> = T Function();
 ''');
@@ -322,7 +322,7 @@
   }
 
   test_optOut_fromOptIn_functionTypeAlias_generic_toBounds_dynamic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 typedef F<T> = T Function();
 ''');
@@ -343,7 +343,7 @@
   }
 
   test_optOut_fromOptIn_functionTypeAlias_generic_typeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 typedef F<T> = T Function();
 ''');
@@ -437,7 +437,7 @@
   }
 
   test_typeAlias_asParameterType_interfaceType_none_inLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef X<T> = Map<int, T>;
 ''');
     await assertNoErrorsInCode(r'''
@@ -473,7 +473,7 @@
   }
 
   test_typeAlias_asParameterType_interfaceType_question_inLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef X<T> = List<T?>;
 ''');
     await assertNoErrorsInCode(r'''
@@ -509,7 +509,7 @@
   }
 
   test_typeAlias_asParameterType_Never_none_inLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 typedef X = Never;
 ''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/dart/resolution/yield_statement_test.dart b/pkg/analyzer/test/src/dart/resolution/yield_statement_test.dart
index 23db79e..972c387 100644
--- a/pkg/analyzer/test/src/dart/resolution/yield_statement_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/yield_statement_test.dart
@@ -18,7 +18,7 @@
   setUp() {
     super.setUp();
 
-    newFile('$testPackageLibPath/my_stream.dart', content: r'''
+    newFile2('$testPackageLibPath/my_stream.dart', r'''
 import 'dart:async';
 
 export 'dart:async';
diff --git a/pkg/analyzer/test/src/dart/resolver/exit_detector_test.dart b/pkg/analyzer/test/src/dart/resolver/exit_detector_test.dart
index c2fe3b1..f80c2d8 100644
--- a/pkg/analyzer/test/src/dart/resolver/exit_detector_test.dart
+++ b/pkg/analyzer/test/src/dart/resolver/exit_detector_test.dart
@@ -114,7 +114,7 @@
   void _assertHasReturn(String expressionCode, bool expected) {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: '''
+    newFile2(path, '''
 void f() { // ref
   $expressionCode;
 }
@@ -903,7 +903,7 @@
   void _assertHasReturn(String statementCode, bool expected) {
     var path = convertPath('/test/lib/test.dart');
 
-    newFile(path, content: '''
+    newFile2(path, '''
 void f() { // ref
   $statementCode
 }
diff --git a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
index 6e9b9ef..ebc6338 100644
--- a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart
@@ -244,7 +244,7 @@
       parent = parent.getChildAssumingFolder(segments[i]);
     }
     File file = parent.getChildAssumingFile(segments[last]);
-    newFile(file.path, content: content);
+    newFile2(file.path, content);
   }
 
   String _librariesFileContent() => '''
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
index b22efa2..ee5cdfb 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_export_test.dart
@@ -16,10 +16,10 @@
 @reflectiveTest
 class AmbiguousExportTest extends PubPackageResolutionTest {
   test_class() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class N {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class N {}
 ''');
     await assertErrorsInCode(r'''
@@ -31,10 +31,10 @@
   }
 
   test_extensions_bothExported() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 extension E on String {}
 ''');
     await assertErrorsInCode(r'''
@@ -46,7 +46,7 @@
   }
 
   test_extensions_localAndExported() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {}
 ''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
index 81c91fd..ec177b1 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_import_test.dart
@@ -20,11 +20,11 @@
 @reflectiveTest
 class AmbiguousImportTest extends PubPackageResolutionTest {
   test_annotation_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const foo = 0;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 const foo = 0;
 ''');
 
@@ -41,10 +41,10 @@
   }
 
   test_as() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -56,10 +56,10 @@
   }
 
   test_extends() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -72,10 +72,10 @@
   }
 
   test_implements() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -88,19 +88,19 @@
   }
 
   test_inPart() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}
 ''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}
 ''');
-    newFile('$testPackageLibPath/part.dart', content: '''
+    newFile2('$testPackageLibPath/part.dart', '''
 part of lib;
 class A extends N {}
 ''');
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 import 'lib1.dart';
 import 'lib2.dart';
@@ -120,10 +120,10 @@
   }
 
   test_instanceCreation() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -136,10 +136,10 @@
   }
 
   test_is() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -151,10 +151,10 @@
   }
 
   test_qualifier() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -168,7 +168,7 @@
   test_systemLibrary_nonSystemLibrary() async {
     // From the spec, "a declaration from a non-system library shadows
     // declarations from system libraries."
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class StreamController {}
 ''');
     await assertNoErrorsInCode('''
@@ -190,10 +190,10 @@
   }
 
   test_typeAnnotation() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -220,10 +220,10 @@
   }
 
   test_typeArgument_annotation() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -236,10 +236,10 @@
   }
 
   test_typeArgument_instanceCreation() async {
-    newFile("$testPackageLibPath/lib1.dart", content: '''
+    newFile2("$testPackageLibPath/lib1.dart", '''
 library lib1;
 class N {}''');
-    newFile("$testPackageLibPath/lib2.dart", content: '''
+    newFile2("$testPackageLibPath/lib2.dart", '''
 library lib2;
 class N {}''');
     await assertErrorsInCode('''
@@ -252,11 +252,11 @@
   }
 
   test_variable_read() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var x;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var x;
 ''');
 
@@ -273,11 +273,11 @@
   }
 
   test_variable_read_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var x;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var x;
 ''');
 
@@ -294,11 +294,11 @@
   }
 
   test_variable_write() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var x;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var x;
 ''');
 
@@ -321,11 +321,11 @@
   }
 
   test_variable_write_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var x;
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 var x;
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
index 59d97c5..4a5a07d 100644
--- a/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/argument_type_not_assignable_test.dart
@@ -210,7 +210,7 @@
 mixin ArgumentTypeNotAssignableTestCases on PubPackageResolutionTest {
   test_ambiguousClassName() async {
     // See dartbug.com/19624
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 class _A {}
 g(h(_A a)) {}''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart b/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
index a0c388c..d644c46 100644
--- a/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/assignment_of_do_not_store_test.dart
@@ -296,7 +296,7 @@
   }
 
   test_topLevelVariable_libraryAnnotation() async {
-    newFile('$testPackageLibPath/library.dart', content: '''
+    newFile2('$testPackageLibPath/library.dart', '''
 @doNotStore
 library lib;
 
diff --git a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
index cfa5128..34462f3 100644
--- a/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/conflicting_generic_interfaces_test.dart
@@ -47,7 +47,7 @@
   }
 
   test_class_extends_implements_optOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class I<T> {}
 class A implements I<int> {}
 class B implements I<int?> {}
@@ -61,7 +61,7 @@
   }
 
   test_class_extends_optIn_implements_optOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 
 class B extends A<int> {}
@@ -86,7 +86,7 @@
   }
 
   test_class_mixed_viaLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 
 class Bi implements A<int> {}
@@ -95,7 +95,7 @@
 ''');
 
     // Both `Bi` and `Biq` implement `A<int*>` in legacy, so identical.
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.7
 import 'a.dart';
 
@@ -124,11 +124,11 @@
   }
 
   test_class_topMerge_optIn_optOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.5
 import 'a.dart';
 
diff --git a/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart b/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
index 6f8fad0..8988cf5 100644
--- a/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_constructor_field_type_mismatch_test.dart
@@ -75,7 +75,7 @@
   }
 
   test_notGeneric_null_forNonNullable_fromLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   final int f;
   const C(a) : f = a;
diff --git a/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart b/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
index 5cb3c4e..af72941 100644
--- a/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_constructor_param_type_mismatch_test.dart
@@ -131,7 +131,7 @@
   }
 
   test_int_to_double_reference_from_other_library_other_file_after() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 import 'test.dart';
 class D {
   final C c;
@@ -159,7 +159,7 @@
 }
 const C constant = const C(0);
 ''');
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 import 'test.dart';
 class D {
   final C c;
@@ -183,7 +183,7 @@
   }
 
   test_int_to_double_via_default_value_other_file_after() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class C {
   final double x;
   const C([this.x = 0]);
@@ -199,7 +199,7 @@
   }
 
   test_int_to_double_via_default_value_other_file_before() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class C {
   final double x;
   const C([this.x = 0]);
diff --git a/pkg/analyzer/test/src/diagnostics/const_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/const_deferred_class_test.dart
index 31e9d07..f39c1e2 100644
--- a/pkg/analyzer/test/src/diagnostics/const_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_deferred_class_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ConstDeferredClassTest extends PubPackageResolutionTest {
   test_namedConstructor() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {
   const A.b();
@@ -32,7 +32,7 @@
   }
 
   test_nonFunctionTypedef() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {
   const A();
@@ -51,7 +51,7 @@
   }
 
   test_unnamed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {
   const A();
diff --git a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
index f5911ee..e51f7d3 100644
--- a/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_eval_throws_exception_test.dart
@@ -82,7 +82,7 @@
 
   test_CastError_intToDouble_constructor_importAnalyzedAfter() async {
     // See dartbug.com/35993
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class Foo {
   final double value;
 
@@ -112,7 +112,7 @@
 
   test_CastError_intToDouble_constructor_importAnalyzedBefore() async {
     // See dartbug.com/35993
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class Foo {
   final double value;
 
@@ -141,7 +141,7 @@
   }
 
   test_default_constructor_arg_empty_map_import() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class C {
   final Map<String, int> m;
   const C({this.m = const <String, int>{}})
@@ -290,7 +290,7 @@
   }
 
   test_invalid_constructorFieldInitializer_fromSeparateLibrary() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 class A<T> {
   final int f;
   const A() : f = T.foo;
diff --git a/pkg/analyzer/test/src/diagnostics/const_initialized_with_non_constant_value_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/const_initialized_with_non_constant_value_from_deferred_library_test.dart
index 2a14814..ba5f389 100644
--- a/pkg/analyzer/test/src/diagnostics/const_initialized_with_non_constant_value_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_initialized_with_non_constant_value_from_deferred_library_test.dart
@@ -18,7 +18,7 @@
 class ConstInitializedWithNonConstantValueFromDeferredLibraryTest
     extends PubPackageResolutionTest {
   test_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const V = 1;
 ''');
@@ -36,7 +36,7 @@
   }
 
   test_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const V = 1;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart b/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
index 3f39cf5..0c5ecbe 100644
--- a/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_with_non_type_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ConstWithNonTypeTest extends PubPackageResolutionTest {
   test_fromLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode('''
 import 'lib1.dart' as lib;
 void f() {
diff --git a/pkg/analyzer/test/src/diagnostics/const_with_undefined_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/const_with_undefined_constructor_test.dart
index 90bd671..29c62ef 100644
--- a/pkg/analyzer/test/src/diagnostics/const_with_undefined_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/const_with_undefined_constructor_test.dart
@@ -75,7 +75,7 @@
   }
 
   test_unnamed_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {
   const A.name();
 }
diff --git a/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart b/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
index 70ce1ae..768c741 100644
--- a/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/could_not_infer_test.dart
@@ -19,7 +19,7 @@
 @reflectiveTest
 class CouldNotInferTest extends PubPackageResolutionTest {
   test_constructor_nullSafe_fromLegacy() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class C<T extends Object> {
   C(T t);
 }
@@ -46,7 +46,7 @@
   }
 
   test_functionType_optOutOfGenericMetadata() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void f<X>() {}
 ''');
     await assertErrorsInCode('''
@@ -224,7 +224,7 @@
   }
 
   test_functionType_parameterIsObject_returnIsBound_prefixedFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 external T f<T extends num>(T a, T b);
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
index 1ef5d39..3483ddf 100644
--- a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart
@@ -315,7 +315,7 @@
   }
 
   test_deadBlock_if_debugConst_prefixedIdentifier2() async {
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class A {
   static const bool DEBUG = false;
 }''');
@@ -327,7 +327,7 @@
   }
 
   test_deadBlock_if_debugConst_propertyAccessor() async {
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class A {
   static const bool DEBUG = false;
 }''');
diff --git a/pkg/analyzer/test/src/diagnostics/dead_null_aware_expression_test.dart b/pkg/analyzer/test/src/diagnostics/dead_null_aware_expression_test.dart
index 05b0e8b..7cfa142 100644
--- a/pkg/analyzer/test/src/diagnostics/dead_null_aware_expression_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/dead_null_aware_expression_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class DeadNullAwareExpressionTest extends PubPackageResolutionTest {
   test_assignCompound_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = 0;
 ''');
@@ -64,7 +64,7 @@
   }
 
   test_binary_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = 0;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/deferred_import_of_extension_test.dart b/pkg/analyzer/test/src/diagnostics/deferred_import_of_extension_test.dart
index 2475e1e..702d49f 100644
--- a/pkg/analyzer/test/src/diagnostics/deferred_import_of_extension_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/deferred_import_of_extension_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class DeferredImportOfExtensionTest extends PubPackageResolutionTest {
   test_deferredImport_withExtensions() {
-    newFile('$testPackageLibPath/foo.dart', content: '''
+    newFile2('$testPackageLibPath/foo.dart', '''
 extension E on C {}
 class C {}
 ''');
@@ -32,7 +32,7 @@
   }
 
   test_deferredImport_withHiddenExtensions() {
-    newFile('$testPackageLibPath/foo.dart', content: '''
+    newFile2('$testPackageLibPath/foo.dart', '''
 extension E on C {}
 class C {}
 ''');
@@ -46,7 +46,7 @@
   }
 
   test_deferredImport_withoutExtensions() {
-    newFile('$testPackageLibPath/foo.dart', content: '''
+    newFile2('$testPackageLibPath/foo.dart', '''
 class C {}
 ''');
     assertNoErrorsInCode('''
@@ -59,7 +59,7 @@
   }
 
   test_deferredImport_withShownNonExtensions() {
-    newFile('$testPackageLibPath/foo.dart', content: '''
+    newFile2('$testPackageLibPath/foo.dart', '''
 extension E on C {}
 class C {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
index 0b7b7e8..d1364a8 100644
--- a/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/deprecated_member_use_test.dart
@@ -38,7 +38,7 @@
 class DeprecatedMemberUse_BasicWorkspaceTest extends PubPackageResolutionTest
     with DeprecatedMemberUse_BasicWorkspaceTestCases {
   test_instanceCreation_namedParameter_fromLegacy() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   A({@deprecated int a}) {}
 }
@@ -57,7 +57,7 @@
   }
 
   test_methodInvocation_namedParameter_ofFunction_fromLegacy() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 void foo({@deprecated int a}) {}
 ''');
 
@@ -74,7 +74,7 @@
   }
 
   test_methodInvocation_namedParameter_ofMethod_fromLegacy() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   void foo({@deprecated int a}) {}
 }
@@ -93,7 +93,7 @@
   }
 
   test_superConstructorInvocation_namedParameter_fromLegacy() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   A({@deprecated int a}) {}
 }
@@ -124,7 +124,7 @@
   }
 
   test_export() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 @deprecated
 library a;
 ''');
@@ -137,7 +137,7 @@
   }
 
   test_field_inDeprecatedConstructor() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   int x = 0;
@@ -158,7 +158,7 @@
   }
 
   test_fieldGet_implicitGetter() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   int foo = 0;
@@ -177,7 +177,7 @@
   }
 
   test_fieldSet_implicitSetter() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   int foo = 0;
@@ -196,7 +196,7 @@
   }
 
   test_import() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 @deprecated
 library a;
 ''');
@@ -211,7 +211,7 @@
   }
 
   test_method_inDeprecatedConstructor() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   void foo() {}
@@ -231,7 +231,7 @@
   }
 
   test_methodInvocation() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   void foo() {}
@@ -250,7 +250,7 @@
   }
 
   test_methodInvocation_withMessage() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @Deprecated('0.9')
   void foo() {}
@@ -269,7 +269,7 @@
   }
 
   test_parameter_named_ofFunction() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 void foo({@deprecated int a}) {}
 ''');
 
@@ -285,7 +285,7 @@
   }
 
   test_parameter_named_ofMethod() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   void foo({@deprecated int a}) {}
 }
@@ -303,7 +303,7 @@
   }
 
   test_setterInvocation() async {
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 class A {
   @deprecated
   set foo(int _) {}
@@ -332,7 +332,7 @@
 class DeprecatedMemberUse_BazelWorkspaceTest
     extends BazelWorkspaceResolutionTest {
   test_dart() async {
-    newFile('$workspaceRootPath/foo/bar/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/bar/lib/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -347,7 +347,7 @@
   }
 
   test_thirdPartyDart() async {
-    newFile('$workspaceThirdPartyDartPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceThirdPartyDartPath/aaa/lib/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -386,17 +386,17 @@
 
   test_differentPackage() async {
     newPubspecYamlFile('$workspaceRootPath/my', '');
-    newFile('$workspaceRootPath/my/BUILD.gn');
+    newFile2('$workspaceRootPath/my/BUILD.gn', '');
 
     newPubspecYamlFile('$workspaceRootPath/aaa', '');
-    newFile('$workspaceRootPath/aaa/BUILD.gn');
+    newFile2('$workspaceRootPath/aaa/BUILD.gn', '');
 
     _writeWorkspacePackagesFile({
       'aaa': '$workspaceRootPath/aaa/lib',
       'my': myPackageLibPath,
     });
 
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -412,13 +412,13 @@
 
   test_samePackage() async {
     newPubspecYamlFile('$workspaceRootPath/my', '');
-    newFile('$workspaceRootPath/my/BUILD.gn');
+    newFile2('$workspaceRootPath/my/BUILD.gn', '');
 
     _writeWorkspacePackagesFile({
       'my': myPackageLibPath,
     });
 
-    newFile('$myPackageLibPath/a.dart', content: r'''
+    newFile2('$myPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -448,7 +448,7 @@
 
     var buildDir = 'out/debug-x87_128';
     var genPath = '$workspaceRootPath/$buildDir/dartlang/gen';
-    newFile('$genPath/foo_package_config.json', content: '''{
+    newFile2('$genPath/foo_package_config.json', '''{
   "configVersion": 2,
   "packages": [ ${packages.join(', ')} ]
 }''');
@@ -489,7 +489,7 @@
         ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
     );
 
-    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
+    newFile2('$workspaceRootPath/aaa/lib/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -597,7 +597,7 @@
   }
 
   test_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -627,7 +627,7 @@
   }
 
   test_export() async {
-    newFile('$testPackageLibPath/deprecated_library.dart', content: r'''
+    newFile2('$testPackageLibPath/deprecated_library.dart', r'''
 @deprecated
 library deprecated_library;
 class A {}
@@ -713,7 +713,7 @@
   }
 
   test_hideCombinator() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -725,7 +725,7 @@
   }
 
   test_import() async {
-    newFile('$testPackageLibPath/deprecated_library.dart', content: r'''
+    newFile2('$testPackageLibPath/deprecated_library.dart', r'''
 @deprecated
 library deprecated_library;
 class A {}
@@ -1235,7 +1235,7 @@
   }
 
   test_showCombinator() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -1559,7 +1559,7 @@
 class DeprecatedMemberUseFromSamePackage_BazelWorkspaceTest
     extends BazelWorkspaceResolutionTest {
   test_it() async {
-    newFile('$myPackageLibPath/a.dart', content: r'''
+    newFile2('$myPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -1602,7 +1602,7 @@
     newPubspecYamlFile(testPackageRootPath, 'name: test');
     _createTestPackageBuildMarker();
 
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 @deprecated
 class A {}
 ''');
@@ -1637,9 +1637,9 @@
     required String pathInLib,
     required String content,
   }) {
-    newFile(
+    newFile2(
       '$testPackageGeneratedPath/$packageName/lib/$pathInLib',
-      content: content,
+      content,
     );
   }
 }
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
index 7fec331..34cbd6e 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart
@@ -1556,12 +1556,12 @@
   test_unitMembers_part_library() async {
     var libPath = convertPath('$testPackageLibPath/lib.dart');
     var aPath = convertPath('$testPackageLibPath/a.dart');
-    newFile(libPath, content: '''
+    newFile2(libPath, '''
 part 'a.dart';
 
 class A {}
 ''');
-    newFile(aPath, content: '''
+    newFile2(aPath, '''
 part of 'lib.dart';
 
 class A {}
@@ -1581,16 +1581,16 @@
     var libPath = convertPath('$testPackageLibPath/lib.dart');
     var aPath = convertPath('$testPackageLibPath/a.dart');
     var bPath = convertPath('$testPackageLibPath/b.dart');
-    newFile(libPath, content: '''
+    newFile2(libPath, '''
 part 'a.dart';
 part 'b.dart';
 ''');
-    newFile(aPath, content: '''
+    newFile2(aPath, '''
 part of 'lib.dart';
 
 class A {}
 ''');
-    newFile(bPath, content: '''
+    newFile2(bPath, '''
 part of 'lib.dart';
 
 class A {}
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_hidden_name_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_hidden_name_test.dart
index ab9c46d..f607d26 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_hidden_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_hidden_name_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class DuplicateHiddenNameTest extends PubPackageResolutionTest {
   test_hidden() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_import_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_import_test.dart
index 85eb884..343555d 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_import_test.dart
@@ -17,11 +17,11 @@
 @reflectiveTest
 class DuplicateImportTest extends PubPackageResolutionTest {
   test_duplicateImport() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart';
 import 'lib1.dart';
@@ -34,13 +34,13 @@
   }
 
   test_importsHaveIdenticalShowHide() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart' as M show A hide B;
 import 'lib1.dart' as M show A hide B;
@@ -54,12 +54,12 @@
   }
 
   test_oneImportHasHide() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}
 class B {}''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart';
 import 'lib1.dart' hide A;
@@ -71,13 +71,13 @@
   }
 
   test_oneImportHasShow() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart';
 import 'lib1.dart' show A; // ignore: unnecessary_import
@@ -90,11 +90,11 @@
   }
 
   test_oneImportUsesAs() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart';
 import 'lib1.dart' as one;
@@ -107,11 +107,11 @@
   }
 
   test_twoDuplicateImports() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 library lib1;
 class A {}''');
 
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 library L;
 import 'lib1.dart';
 import 'lib1.dart';
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_part_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_part_test.dart
index 64ed945..19acede 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_part_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_part_test.dart
@@ -16,10 +16,10 @@
 @reflectiveTest
 class DuplicatePartTest extends PubPackageResolutionTest {
   test_no_duplicates() async {
-    newFile('$testPackageLibPath/part1.dart', content: '''
+    newFile2('$testPackageLibPath/part1.dart', '''
 part of lib;
 ''');
-    newFile('$testPackageLibPath/part2.dart', content: '''
+    newFile2('$testPackageLibPath/part2.dart', '''
 part of lib;
 ''');
     await assertNoErrorsInCode(r'''
@@ -30,7 +30,7 @@
   }
 
   test_sameSource() async {
-    newFile('$testPackageLibPath/part.dart', content: 'part of lib;');
+    newFile2('$testPackageLibPath/part.dart', 'part of lib;');
     await assertErrorsInCode(r'''
 library lib;
 part 'part.dart';
@@ -41,7 +41,7 @@
   }
 
   test_sameUri() async {
-    newFile('$testPackageLibPath/part.dart', content: 'part of lib;');
+    newFile2('$testPackageLibPath/part.dart', 'part of lib;');
     await assertErrorsInCode(r'''
 library lib;
 part 'part.dart';
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_shown_name_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_shown_name_test.dart
index e1e0cde..5a6f20b 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_shown_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_shown_name_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class DuplicateShownNameTest extends PubPackageResolutionTest {
   test_hidden() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/export_legacy_symbol_test.dart b/pkg/analyzer/test/src/diagnostics/export_legacy_symbol_test.dart
index 2f22ba9..c7549ef 100644
--- a/pkg/analyzer/test/src/diagnostics/export_legacy_symbol_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/export_legacy_symbol_test.dart
@@ -28,7 +28,7 @@
   }
 
   test_exportOptedIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -37,11 +37,11 @@
   }
 
   test_exportOptedOut_exportOptedIn_hasLegacySymbol() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.5
 export 'a.dart';
 class B {}
@@ -55,11 +55,11 @@
   }
 
   test_exportOptedOut_exportOptedIn_hideLegacySymbol() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.5
 export 'a.dart';
 class B {}
@@ -71,7 +71,7 @@
   }
 
   test_exportOptedOut_hasLegacySymbol() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 class A {}
 class B {}
diff --git a/pkg/analyzer/test/src/diagnostics/export_of_non_library_test.dart b/pkg/analyzer/test/src/diagnostics/export_of_non_library_test.dart
index d595b74..dbc6573 100644
--- a/pkg/analyzer/test/src/diagnostics/export_of_non_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/export_of_non_library_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ExportOfNonLibraryTest extends PubPackageResolutionTest {
   test_export_of_non_library() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 part of lib;
 ''');
     await assertErrorsInCode(r'''
@@ -29,7 +29,7 @@
   }
 
   test_libraryDeclared() async {
-    newFile('$testPackageLibPath/lib1.dart', content: "library lib1;");
+    newFile2('$testPackageLibPath/lib1.dart', "library lib1;");
     await assertNoErrorsInCode(r'''
 library L;
 export 'lib1.dart';
@@ -37,7 +37,7 @@
   }
 
   test_libraryNotDeclared() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertNoErrorsInCode(r'''
 library L;
 export 'lib1.dart';
diff --git a/pkg/analyzer/test/src/diagnostics/extends_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/extends_deferred_class_test.dart
index effaba0..798558b 100644
--- a/pkg/analyzer/test/src/diagnostics/extends_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extends_deferred_class_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ExtendsDeferredClassTest extends PubPackageResolutionTest {
   test_classTypeAlias() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
@@ -31,7 +31,7 @@
   }
 
   test_extends_deferred_class() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
@@ -45,7 +45,7 @@
   }
 
   test_extends_deferred_interfaceTypeTypedef() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 class B {}
diff --git a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
index e38a3bb..62547b2 100644
--- a/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extends_non_class_test.dart
@@ -128,7 +128,7 @@
   }
 
   test_undefined_ignore_part_exists_uriGenerated_nameIgnorable() async {
-    newFile('$testPackageLibPath/a.g.dart', content: r'''
+    newFile2('$testPackageLibPath/a.g.dart', r'''
 part of 'test.dart';
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart b/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
index 61d3e2c..4c9374b 100644
--- a/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/extension_as_expression_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ExtensionAsExpressionTest extends PubPackageResolutionTest {
   test_prefixedIdentifier() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {}
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/generic_function_type_cannot_be_bound_test.dart b/pkg/analyzer/test/src/diagnostics/generic_function_type_cannot_be_bound_test.dart
index 02c4641..d32935b 100644
--- a/pkg/analyzer/test/src/diagnostics/generic_function_type_cannot_be_bound_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/generic_function_type_cannot_be_bound_test.dart
@@ -32,7 +32,7 @@
   }
 
   test_genericFunction_optOutOfGenericMetadata() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 typedef F = S Function<S>(S);
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart b/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart
index 517130b..876c26e 100644
--- a/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart
@@ -54,7 +54,7 @@
   }
 
   test_class_instance_private_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -71,12 +71,12 @@
   }
 
   test_class_instance_private_interfaces() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
 ''');
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 class B {
   set _foo(String _) {}
 }
@@ -90,7 +90,7 @@
   }
 
   test_class_instance_private_interfaces2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -107,7 +107,7 @@
   }
 
   test_class_instance_private_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   set _foo(String _) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart b/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart
index 249ce8d..7f6a0b0 100644
--- a/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart
@@ -74,7 +74,7 @@
   }
 
   test_class_instance_private_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -91,12 +91,12 @@
   }
 
   test_class_instance_private_interfaces() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
 ''');
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 class B {
   set _foo(String _) {}
 }
@@ -110,7 +110,7 @@
   }
 
   test_class_instance_private_interfaces2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -127,7 +127,7 @@
   }
 
   test_class_instance_private_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   set _foo(String _) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/if_element_condition_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/if_element_condition_from_deferred_library_test.dart
index c85d229..db0c21d 100644
--- a/pkg/analyzer/test/src/diagnostics/if_element_condition_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/if_element_condition_from_deferred_library_test.dart
@@ -20,7 +20,7 @@
 mixin IfElementConditionFromDeferredLibraryTestCases
     on PubPackageResolutionTest {
   test_inList_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -33,7 +33,7 @@
   }
 
   test_inList_nonConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -43,7 +43,7 @@
   }
 
   test_inList_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
@@ -53,7 +53,7 @@
   }
 
   test_inMap_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -66,7 +66,7 @@
   }
 
   test_inMap_notConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -76,7 +76,7 @@
   }
 
   test_inMap_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
@@ -86,7 +86,7 @@
   }
 
   test_inSet_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -99,7 +99,7 @@
   }
 
   test_inSet_notConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -109,7 +109,7 @@
   }
 
   test_inSet_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const bool c = true;''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
diff --git a/pkg/analyzer/test/src/diagnostics/implements_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/implements_deferred_class_test.dart
index bfa2a8d..da1430f 100644
--- a/pkg/analyzer/test/src/diagnostics/implements_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/implements_deferred_class_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ImplementsDeferredClassTest extends PubPackageResolutionTest {
   test_class_implements() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
@@ -30,7 +30,7 @@
   }
 
   test_class_implements_interfaceTypeTypedef() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 typedef B = A;
@@ -45,7 +45,7 @@
   }
 
   test_classTypeAlias() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart b/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
index 5befb60..388dd30 100644
--- a/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/import_deferred_library_with_load_function_test.dart
@@ -17,7 +17,7 @@
 class ImportDeferredLibraryWithLoadFunctionTest
     extends PubPackageResolutionTest {
   test_deferredImport_withLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void loadLibrary() {}
 void f() {}
 ''');
@@ -33,7 +33,7 @@
   }
 
   test_deferredImport_withLoadLibraryFunction_hide() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void loadLibrary() {}
 void f() {}
 ''');
@@ -47,7 +47,7 @@
   }
 
   test_deferredImport_withLoadLibraryFunction_hide2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void loadLibrary() {}
 void f() {}
 void f2() {}
@@ -64,7 +64,7 @@
   }
 
   test_deferredImport_withLoadLibraryFunction_show() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void loadLibrary() {}
 void f() {}
 ''');
@@ -78,7 +78,7 @@
   }
 
   test_deferredImport_withoutLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void f() {}
 ''');
 
@@ -91,7 +91,7 @@
   }
 
   test_nonDeferredImport_withLoadLibraryFunction() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void loadLibrary() {}
 void f() {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/import_of_legacy_library_into_null_safe_test.dart b/pkg/analyzer/test/src/diagnostics/import_of_legacy_library_into_null_safe_test.dart
index 7a6c3ab..e56a81d 100644
--- a/pkg/analyzer/test/src/diagnostics/import_of_legacy_library_into_null_safe_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/import_of_legacy_library_into_null_safe_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ImportOfLegacyLibraryInoNullSafeTest extends PubPackageResolutionTest {
   test_legacy_into_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.9
 class A {}
 ''');
@@ -29,7 +29,7 @@
   }
 
   test_legacy_into_nullSafe() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.9
 class A {}
 ''');
@@ -43,7 +43,7 @@
   }
 
   test_nullSafe_into_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -55,7 +55,7 @@
   }
 
   test_nullSafe_into_nullSafe() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -66,9 +66,9 @@
   }
 
   test_nullSafe_into_nullSafe_part() async {
-    newFile('$testPackageLibPath/a.dart', content: '');
+    newFile2('$testPackageLibPath/a.dart', '');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 part of 'test.dart';
 import 'a.dart';
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/import_of_non_library_test.dart b/pkg/analyzer/test/src/diagnostics/import_of_non_library_test.dart
index 04c4fc3..77f8322 100644
--- a/pkg/analyzer/test/src/diagnostics/import_of_non_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/import_of_non_library_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class ImportOfNonLibraryTest extends PubPackageResolutionTest {
   test_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 part of lib;
 class A {}
 ''');
@@ -31,7 +31,7 @@
   }
 
   test_part() async {
-    newFile('$testPackageLibPath/part.dart', content: r'''
+    newFile2('$testPackageLibPath/part.dart', r'''
 part of lib;
 class A{}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/inconsistent_case_expression_types_test.dart b/pkg/analyzer/test/src/diagnostics/inconsistent_case_expression_types_test.dart
index 8045084..805135e 100644
--- a/pkg/analyzer/test/src/diagnostics/inconsistent_case_expression_types_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/inconsistent_case_expression_types_test.dart
@@ -17,7 +17,7 @@
 @reflectiveTest
 class InconsistentCaseExpressionTypesTest extends PubPackageResolutionTest {
   test_int_none_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 0;
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/inconsistent_language_version_override_test.dart b/pkg/analyzer/test/src/diagnostics/inconsistent_language_version_override_test.dart
index 617a0d2..e71a823 100644
--- a/pkg/analyzer/test/src/diagnostics/inconsistent_language_version_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/inconsistent_language_version_override_test.dart
@@ -103,9 +103,9 @@
     var libraryPath = convertPath('$testPackageLibPath/a.dart');
     var partPath = convertPath('$testPackageLibPath/b.dart');
 
-    newFile(libraryPath, content: libraryContent);
+    newFile2(libraryPath, libraryContent);
 
-    newFile(partPath, content: partContent);
+    newFile2(partPath, partContent);
 
     await assertErrorsInFile2(libraryPath, libraryErrors);
   }
diff --git a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
index 67cc9aa..83ddae8 100644
--- a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_invocation_test.dart
@@ -224,7 +224,7 @@
   }
 
   test_topLevelFunction_withImportPrefix_noInference() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 void f<T>() {}
 ''');
     await assertErrorsInCode('''
@@ -238,7 +238,7 @@
   }
 
   test_topLevelFunction_withImportPrefix_optionalTypeArgs() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'package:meta/meta.dart';
 @optionalTypeArgs
 void f<T>() {}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
index 518858a..31828e1 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_annotation_from_deferred_library_test.dart
@@ -17,7 +17,7 @@
 class InvalidAnnotationFromDeferredLibraryTest
     extends PubPackageResolutionTest {
   test_constructor() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class C { const C(); }
 ''');
@@ -32,7 +32,7 @@
   }
 
   test_constructor_argument() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 const x = 0;
 ''');
     await assertErrorsInCode('''
@@ -50,7 +50,7 @@
   }
 
   test_from_deferred_library() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class V { const V(); }
 const v = const V();
@@ -66,7 +66,7 @@
   }
 
   test_namedConstructor() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class C { const C.name(); }
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_annotation_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_annotation_test.dart
index 00abc76..6212082 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_annotation_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_annotation_test.dart
@@ -66,7 +66,7 @@
   }
 
   test_getter_importWithPrefix() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 get V => 0;
 ''');
@@ -81,7 +81,7 @@
   }
 
   test_importWithPrefix_notConstantVariable() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 final V = 0;
 ''');
@@ -96,7 +96,7 @@
   }
 
   test_importWithPrefix_notVariableOrConstructorInvocation() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 typedef V();
 ''');
@@ -145,7 +145,7 @@
   }
 
   test_notClass_importWithPrefix() async {
-    newFile('$testPackageLibPath/annotations.dart', content: r'''
+    newFile2('$testPackageLibPath/annotations.dart', r'''
 class Property {
   final int value;
   const Property(this.value);
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
index 78185db..3958315 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_constant_test.dart
@@ -61,7 +61,7 @@
   }
 
   test_in_initializer_from_deferred_library_field() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const int c = 1;''');
     await assertErrorsInCode('''
@@ -77,7 +77,7 @@
   }
 
   test_in_initializer_from_deferred_library_field_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const int c = 1;
 ''');
@@ -94,7 +94,7 @@
   }
 
   test_in_initializer_from_deferred_library_redirecting() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const int c = 1;
 ''');
@@ -111,7 +111,7 @@
   }
 
   test_in_initializer_from_deferred_library_super() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const int c = 1;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
index c52be8b..2f9fb0c 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
@@ -36,12 +36,12 @@
     MockPackages.addMetaPackageFiles(
       getFolder(metaPath),
     );
-    newFile('$testPackageBazelBinPath/my.packages');
+    newFile2('$testPackageBazelBinPath/my.packages', '');
     newFolder('$workspaceRootPath/bazel-out');
   }
 
   void test_exporterIsInBazelBinLib() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -56,7 +56,7 @@
   }
 
   void test_exporterIsInBazelBinLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -69,7 +69,7 @@
   }
 
   void test_exporterIsInGenfilesLib() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -84,7 +84,7 @@
   }
 
   void test_exporterIsInGenfilesLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -97,7 +97,7 @@
   }
 
   void test_exporterIsInLib() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -112,7 +112,7 @@
   }
 
   void test_exporterIsInLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -125,7 +125,7 @@
   }
 
   void test_exporterIsInTest() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -138,7 +138,7 @@
   }
 
   void test_internalIsInBazelBin() async {
-    newFile('$testPackageBazelBinPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageBazelBinPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -151,7 +151,7 @@
   }
 
   void test_internalIsInGenfiles() async {
-    newFile('$testPackageGenfilesPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageGenfilesPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -164,7 +164,7 @@
   }
 
   void test_internalIsInLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -188,7 +188,7 @@
 analysis. So, there is no context to analyze it.
 ''')
   void test_exporterInGeneratedLib() async {
-    newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageRootPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -207,7 +207,7 @@
 analysis. So, there is no context to analyze it.
 ''')
   void test_exporterInGeneratedLibSrc() async {
-    newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageRootPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -220,7 +220,7 @@
   }
 
   void test_exporterInLib() async {
-    newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageRootPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -235,7 +235,7 @@
   }
 
   void test_exporterInLibSrc() async {
-    newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageRootPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -248,7 +248,7 @@
   }
 
   void test_internalIsInGeneratedLibSrc() async {
-    newFile('$testPackageDartToolPath/lib/src/foo.dart', content: r'''
+    newFile2('$testPackageDartToolPath/lib/src/foo.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -262,7 +262,7 @@
 
   @override
   void test_internalIsLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -289,7 +289,7 @@
   }
 
   void test_exporterIsInLib() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -304,7 +304,7 @@
   }
 
   void test_exporterIsInLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -317,7 +317,7 @@
   }
 
   void test_exporterIsInTest() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -330,7 +330,7 @@
   }
 
   void test_internalIsLibSrc() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -350,7 +350,7 @@
   String get testPackageLibPath;
 
   void test_hideCombinator_internalHidden() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 class Two {}
@@ -362,7 +362,7 @@
   }
 
   void test_hideCombinator_internalNotHidden() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 class Two {}
@@ -376,7 +376,7 @@
   }
 
   void test_indirectlyViaFunction_parameter() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef int IntFunc(int x);
 int func(IntFunc f, int x) => f(x);
@@ -390,7 +390,7 @@
   }
 
   void test_indirectlyViaFunction_parameter_generic() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef IntFunc = int Function(int);
 int func(IntFunc f, int x) => f(x);
@@ -404,7 +404,7 @@
   }
 
   void test_indirectlyViaFunction_parameter_generic_typeArg() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef IntFunc<T> = int Function(T);
 int func(IntFunc<num> f, int x) => f(x);
@@ -418,7 +418,7 @@
   }
 
   void test_indirectlyViaFunction_returnType() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef int IntFunc(int x);
 IntFunc func() => (int x) => x;
@@ -432,7 +432,7 @@
   }
 
   void test_indirectlyViaFunction_typeArgument_bounded() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef int IntFunc(int x);
 void func<T extends IntFunc>() {}
@@ -446,7 +446,7 @@
   }
 
   void test_indirectlyViaFunction_typeArgument_unbounded() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal typedef int IntFunc(int x);
 void func<T>() {}
@@ -458,7 +458,7 @@
   }
 
   void test_noCombinators() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -471,11 +471,11 @@
   }
 
   void test_noCombinators_indirectExport() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 export 'bar.dart';
 ''');
 
-    newFile('$testPackageLibPath/src/bar.dart', content: r'''
+    newFile2('$testPackageLibPath/src/bar.dart', r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 ''');
@@ -488,7 +488,7 @@
   }
 
   void test_noCombinators_library() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 @internal
 library foo;
 
@@ -503,7 +503,7 @@
   }
 
   void test_noCombinators_library_notInternal() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 library foo;
 ''');
 
@@ -513,7 +513,7 @@
   }
 
   void test_noCombinators_noInternal() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 class One {}
 ''');
 
@@ -523,7 +523,7 @@
   }
 
   void test_showCombinator_internalNotShown() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 class Two {}
@@ -535,7 +535,7 @@
   }
 
   void test_showCombinator_internalShown() async {
-    newFile(testPackageImplementationFilePath, content: r'''
+    newFile2(testPackageImplementationFilePath, r'''
 import 'package:meta/meta.dart';
 @internal class One {}
 class Two {}
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
index a411785..7343ea7 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_null_aware_operator_test.dart
@@ -195,7 +195,7 @@
   }
 
   test_getter_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = 0;
 ''');
@@ -249,7 +249,7 @@
   /// report [StaticWarningCode.INVALID_NULL_AWARE_OPERATOR]. But we also
   /// report another error.
   test_getter_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int x = 0;
 ''');
     await assertErrorsInCode('''
@@ -264,7 +264,7 @@
   }
 
   test_index_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = [0];
 ''');
@@ -327,7 +327,7 @@
   }
 
   test_method_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = 0;
 ''');
@@ -386,7 +386,7 @@
   }
 
   test_nullableSpread_legacyType() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = <int>[];
 ''');
@@ -460,7 +460,7 @@
   /// report [StaticWarningCode.INVALID_NULL_AWARE_OPERATOR]. But we also
   /// report another error.
   test_setter_prefix() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int x = 0;
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_named_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_named_test.dart
index c44810c..57bb470 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_named_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_named_test.dart
@@ -20,7 +20,7 @@
 class InvalidOverrideDifferentDefaultValuesNamedTest
     extends InvalidOverrideDifferentDefaultValuesNamedWithoutNullSafetyTest {
   test_concrete_equal_optIn_extends_optOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A {
   void foo({int a = 0}) {}
@@ -39,7 +39,7 @@
   }
 
   test_concrete_equal_optOut_extends_optIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo({int a = 0}) {}
 }
@@ -217,7 +217,7 @@
   }
 
   test_concrete_equal_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo([a = 0]) {}
 }
@@ -232,7 +232,7 @@
   }
 
   test_concrete_equal_otherLibrary_listLiteral() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class C {
   void foo({x: const ['x']}) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_positional_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_positional_test.dart
index 9c9fe63..11b7180 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_positional_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_override_different_default_values_positional_test.dart
@@ -22,7 +22,7 @@
 class InvalidOverrideDifferentDefaultValuesPositionalTest
     extends InvalidOverrideDifferentDefaultValuesPositionalWithoutNullSafetyTest {
   test_concrete_equal_optIn_extends_optOut() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 class A {
   void foo([int a = 0]) {}
@@ -41,7 +41,7 @@
   }
 
   test_concrete_equal_optOut_extends_optIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo([int a = 0]) {}
 }
@@ -231,7 +231,7 @@
   }
 
   test_concrete_equal_otherLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo([x = 0]) {}
 }
@@ -246,7 +246,7 @@
   }
 
   test_concrete_equal_otherLibrary_listLiteral() async {
-    newFile('$testPackageLibPath/other.dart', content: '''
+    newFile2('$testPackageLibPath/other.dart', '''
 class C {
   void foo([x = const ['x']]) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
index cc85b0c..9725362 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_override_test.dart
@@ -215,7 +215,7 @@
   }
 
   test_method_parameter_functionTyped_optOut_extends_optIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 abstract class A {
   A catchError(void Function(Object) a);
 }
@@ -232,7 +232,7 @@
   }
 
   test_method_parameter_interfaceOptOut_concreteOptIn() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo(Object a) {}
 }
@@ -249,7 +249,7 @@
   }
 
   test_mixedInheritance_1() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class B {
   List<int Function(int)> get a => [];
   set a(List<int Function(int)> _) {}
@@ -263,7 +263,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.7
 import 'a.dart';
 
@@ -281,7 +281,7 @@
   }
 
   test_mixedInheritance_2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class B {
   List<int Function(int)> get a => [];
   set a(List<int Function(int)> _) {}
@@ -295,7 +295,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart = 2.7
 import 'a.dart';
 
@@ -416,7 +416,7 @@
   }
 
   test_viaLegacy_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A1 {
   int m() => 0;
   int get g => 0;
@@ -430,7 +430,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart=2.6
 import 'a.dart';
 
@@ -455,7 +455,7 @@
   }
 
   test_viaLegacy_mixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A1 {
   int m() => 0;
   int get g => 0;
@@ -469,7 +469,7 @@
 }
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 // @dart=2.6
 import 'a.dart';
 
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_internal_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_internal_member_test.dart
index 2fbaf44..98da1f6 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_internal_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_internal_member_test.dart
@@ -37,12 +37,12 @@
   }
 
   test_insidePackage() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 class A {}
 ''');
-    newFile('$fooPackageRootPath/lib/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/a.dart', '''
 import 'src/a.dart';
 
 A a = A();
@@ -53,7 +53,7 @@
   }
 
   test_outsidePackage_class() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 class A {}
@@ -69,7 +69,7 @@
   }
 
   test_outsidePackage_constructor_named() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -87,7 +87,7 @@
   }
 
   test_outsidePackage_constructor_unnamed() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -105,7 +105,7 @@
   }
 
   test_outsidePackage_enum() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 enum E {one}
@@ -121,7 +121,7 @@
   }
 
   test_outsidePackage_enumValue() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 enum E {@internal one}
 ''');
@@ -136,7 +136,7 @@
   }
 
   test_outsidePackage_extensionMethod() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 extension E on String {
   @internal
@@ -154,7 +154,7 @@
   }
 
   test_outsidePackage_function() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a() => 1;
@@ -170,7 +170,7 @@
   }
 
   test_outsidePackage_function_generic() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a<T>() => 1;
@@ -186,7 +186,7 @@
   }
 
   test_outsidePackage_function_generic_tearoff() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a<T>() => 1;
@@ -202,7 +202,7 @@
   }
 
   test_outsidePackage_function_tearoff() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a() => 1;
@@ -218,7 +218,7 @@
   }
 
   test_outsidePackage_functionLiteralForInternalTypedef() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 @internal
 typedef IntFunc = int Function(int);
 int foo(IntFunc f, int x) => f(x);
@@ -232,7 +232,7 @@
   }
 
   test_outsidePackage_inCommentReference() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int get a => 1;
@@ -247,7 +247,7 @@
   }
 
   test_outsidePackage_library() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 @internal
 library a;
 import 'package:meta/meta.dart';
@@ -262,7 +262,7 @@
   }
 
   test_outsidePackage_method() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -280,7 +280,7 @@
   }
 
   test_outsidePackage_method_generic() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -298,7 +298,7 @@
   }
 
   test_outsidePackage_method_subclassed() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal int f() => 1;
@@ -317,7 +317,7 @@
   }
 
   test_outsidePackage_method_subclassed_overridden() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal int f() => 1;
@@ -336,7 +336,7 @@
   }
 
   test_outsidePackage_method_tearoff() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -354,7 +354,7 @@
   }
 
   test_outsidePackage_methodParameter_named() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   int m({@internal int a = 0}) => 1;
@@ -372,7 +372,7 @@
 
   @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/28066')
   test_outsidePackage_methodParameter_positional() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   int m([@internal int a = 0]) => 1;
@@ -389,7 +389,7 @@
   }
 
   test_outsidePackage_mixin() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 mixin A {}
@@ -405,7 +405,7 @@
   }
 
   test_outsidePackage_pairedWithProtected() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -426,7 +426,7 @@
   }
 
   test_outsidePackage_redirectingFactoryConstructor() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 import 'package:test/test.dart';
 class D implements C {
@@ -446,7 +446,7 @@
   }
 
   test_outsidePackage_setter() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal
@@ -466,7 +466,7 @@
   }
 
   test_outsidePackage_setter_compound() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   int get s() => 1;
@@ -488,7 +488,7 @@
   }
 
   test_outsidePackage_setter_questionQuestion() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   int get s() => 1;
@@ -510,7 +510,7 @@
   }
 
   test_outsidePackage_superConstructor() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal C();
@@ -529,7 +529,7 @@
   }
 
   test_outsidePackage_superConstructor_named() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 class C {
   @internal C.named();
@@ -548,7 +548,7 @@
   }
 
   test_outsidePackage_topLevelGetter() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int get a => 1;
@@ -564,7 +564,7 @@
   }
 
   test_outsidePackage_typedef() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 typedef t = void Function();
@@ -581,7 +581,7 @@
 
   @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/28066')
   test_outsidePackage_typedefParameter() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 typedef T = void Function({@internal int a = 1});
 ''');
@@ -596,7 +596,7 @@
   }
 
   test_outsidePackage_variable() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a = 1;
@@ -612,7 +612,7 @@
   }
 
   test_outsidePackage_variable_prefixed() async {
-    newFile('$fooPackageRootPath/lib/src/a.dart', content: '''
+    newFile2('$fooPackageRootPath/lib/src/a.dart', '''
 import 'package:meta/meta.dart';
 @internal
 int a = 1;
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
index 97f44e6..8b4a8e4 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_protected_member_test.dart
@@ -23,7 +23,7 @@
   }
 
   test_closure() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 
 class A {
@@ -31,7 +31,7 @@
   int a() => 42;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
@@ -59,14 +59,14 @@
   }
 
   test_extension_outsideClassAndFile() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   void a(int i) {}
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 extension E on A {
   e() {
@@ -95,14 +95,14 @@
   }
 
   test_field_outsideClassAndLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   int a = 0;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 abstract class B {
   int b() => new A().a;
@@ -128,14 +128,14 @@
   }
 
   test_fromSuperclassConstraint() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 abstract class A {
   @protected
   void foo() {}
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 mixin M on A {
   @override
@@ -150,14 +150,14 @@
   }
 
   test_function_outsideClassAndLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   void a(){ }
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 main() {
@@ -210,14 +210,14 @@
   }
 
   test_getter_outsideClassAndLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   int get a => 42;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 class B {
   A a = A();
@@ -244,7 +244,7 @@
   }
 
   test_inDocs() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 
 class A {
@@ -258,7 +258,7 @@
   int a() => 0;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 /// OK: [A.a], [A.b], [A.c].
 f() {}
@@ -269,14 +269,14 @@
   }
 
   test_method_outsideClassAndLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   void a() {}
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 class B {
@@ -355,14 +355,14 @@
     // TODO(srawlins): This test verifies that the analyzer **allows**
     // protected members to be called on objects other than `this`, which
     // violates the protected spec.
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
   void set a(int i) { }
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 class B {
   A a = A();
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_overriding_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_overriding_member_test.dart
index 0387086..a5d17bd 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_overriding_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_overriding_member_test.dart
@@ -23,7 +23,7 @@
   }
 
   test_differentLibrary_invalid() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'package:meta/meta.dart';
 
 class Parent {
@@ -45,7 +45,7 @@
   }
 
   test_differentLibrary_valid_onlyOverride() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'package:meta/meta.dart';
 
 class Parent {
@@ -65,7 +65,7 @@
   }
 
   test_differentLibrary_valid_overrideAndUse() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'package:meta/meta.dart';
 
 class Parent {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
index 2e35506..a14ecc8 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_template_member_test.dart
@@ -22,7 +22,7 @@
     super.setUp();
 
     var angularMetaPath = '/packages/angular_meta';
-    newFile('$angularMetaPath/lib/angular_meta.dart', content: r'''
+    newFile2('$angularMetaPath/lib/angular_meta.dart', r'''
 library angular.meta;
 
 const _VisibleForTemplate visibleForTemplate = const _VisibleForTemplate();
@@ -40,13 +40,13 @@
   }
 
   test_export() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 
 @visibleForTemplate
 int fn0() => 1;
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 export 'lib1.dart' show fn0;
 ''');
 
@@ -55,14 +55,14 @@
   }
 
   test_functionInExtension() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 extension E on List {
   @visibleForTemplate
   int m() => 1;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   E([]).m();
@@ -76,14 +76,14 @@
   }
 
   test_functionInExtension_fromTemplate() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 extension E on List {
   @visibleForTemplate
   int m() => 1;
 }
 ''');
-    newFile('$testPackageLibPath/lib1.template.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.template.dart', r'''
 import 'lib1.dart';
 void main() {
   E([]).m();
@@ -95,14 +95,14 @@
   }
 
   test_method() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 class A {
   @visibleForTemplate
   void a(){ }
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 class B {
@@ -117,14 +117,14 @@
   }
 
   test_method_fromTemplate() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 class A {
   @visibleForTemplate
   void a(){ }
 }
 ''');
-    newFile('$testPackageLibPath/lib1.template.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.template.dart', r'''
 import 'lib1.dart';
 
 class B {
@@ -137,7 +137,7 @@
   }
 
   test_namedConstructor() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 class A {
   int _x;
@@ -146,7 +146,7 @@
   A.forTemplate(this._x);
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
@@ -163,7 +163,7 @@
   }
 
   test_propertyAccess() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 class A {
   @visibleForTemplate
@@ -173,7 +173,7 @@
   set b(_) => 7;
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
@@ -190,7 +190,7 @@
   }
 
   test_protectedAndForTemplate_usedAsProtected() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 import 'package:meta/meta.dart';
 class A {
@@ -199,7 +199,7 @@
   void a(){ }
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 class B extends A {
   void b() => new A().a();
@@ -211,7 +211,7 @@
   }
 
   test_protectedAndForTemplate_usedAsTemplate() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 import 'package:meta/meta.dart';
 class A {
@@ -220,7 +220,7 @@
   void a(){ }
 }
 ''');
-    newFile('$testPackageLibPath/lib1.template.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.template.dart', r'''
 import 'lib1.dart';
 void main() {
   new A().a();
@@ -232,13 +232,13 @@
   }
 
   test_topLevelFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 
 @visibleForTemplate
 int fn0() => 1;
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
@@ -253,12 +253,12 @@
   }
 
   test_topLevelVariable() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 @visibleForTemplate
 int a = 7;
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
@@ -273,7 +273,7 @@
   }
 
   test_unnamedConstructor() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:angular_meta/angular_meta.dart';
 class A {
   int _x;
@@ -282,7 +282,7 @@
   A(this._x);
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 import 'lib1.dart';
 
 void main() {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
index 530f0ae..c4ef484 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_visible_for_testing_member_test.dart
@@ -26,7 +26,7 @@
   }
 
   test_export_hide() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 
 @visibleForTesting
@@ -35,7 +35,7 @@
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart' hide A;
 ''');
 
@@ -44,7 +44,7 @@
   }
 
   test_export_show() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 
 @visibleForTesting
@@ -53,7 +53,7 @@
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 export 'a.dart' show A;
 ''');
 
@@ -62,14 +62,14 @@
   }
 
   test_fromIntegrationTestDirectory() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/integration_test/test.dart', content: r'''
+    newFile2('$testPackageRootPath/integration_test/test.dart', r'''
 import '../lib1.dart';
 class B {
   void b() => new A().a();
@@ -81,14 +81,14 @@
   }
 
   test_fromTestDirectory() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/test/test.dart', content: r'''
+    newFile2('$testPackageRootPath/test/test.dart', r'''
 import '../lib1.dart';
 class B {
   void b() => new A().a();
@@ -100,14 +100,14 @@
   }
 
   test_fromTestDriverDirectory() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/test_driver/test.dart', content: r'''
+    newFile2('$testPackageRootPath/test_driver/test.dart', r'''
 import '../lib1.dart';
 class B {
   void b() => new A().a();
@@ -119,14 +119,14 @@
   }
 
   test_fromTestingDirectory() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/testing/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/testing/lib1.dart', r'''
 import '../lib1.dart';
 class C {
   void b() => new A().a();
@@ -138,14 +138,14 @@
   }
 
   test_functionInExtension() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 extension E on List {
   @visibleForTesting
   int m() => 1;
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   E([]).m();
@@ -159,14 +159,14 @@
   }
 
   test_functionInExtension_fromTestDirectory() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 extension E on List {
   @visibleForTesting
   int m() => 1;
 }
 ''');
-    newFile('$testPackageRootPath/test/test.dart', content: r'''
+    newFile2('$testPackageRootPath/test/test.dart', r'''
 import '../lib1.dart';
 void main() {
   E([]).m();
@@ -178,14 +178,14 @@
   }
 
   test_getter() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   int get a => 7;
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   new A().a;
@@ -199,7 +199,7 @@
   }
 
   test_import_hide() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 
 @visibleForTesting
@@ -208,7 +208,7 @@
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart' hide A;
 
 void f(B _) {}
@@ -219,7 +219,7 @@
   }
 
   test_import_show() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 
 @visibleForTesting
@@ -228,7 +228,7 @@
 class B {}
 ''');
 
-    newFile('$testPackageLibPath/b.dart', content: r'''
+    newFile2('$testPackageLibPath/b.dart', r'''
 import 'a.dart' show A;
 
 void f(A _) {}
@@ -242,14 +242,14 @@
   }
 
   test_method() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 class B {
   void b() => new A().a();
@@ -263,7 +263,7 @@
   }
 
   test_mixin() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 mixin M {
   @visibleForTesting
@@ -271,7 +271,7 @@
 }
 class C with M {}
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   C().m();
@@ -285,7 +285,7 @@
   }
 
   test_namedConstructor() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   int _x;
@@ -294,7 +294,7 @@
   A.forTesting(this._x);
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   new A.forTesting(0);
@@ -311,7 +311,7 @@
   }
 
   test_protectedAndForTesting_usedAsProtected() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
@@ -319,7 +319,7 @@
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 class B extends A {
   void b() => new A().a();
@@ -331,7 +331,7 @@
   }
 
   test_protectedAndForTesting_usedAsTesting() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @protected
@@ -339,7 +339,7 @@
   void a(){ }
 }
 ''');
-    newFile('$testPackageRootPath/test/test1.dart', content: r'''
+    newFile2('$testPackageRootPath/test/test1.dart', r'''
 import '../lib1.dart';
 void main() {
   new A().a();
@@ -351,14 +351,14 @@
   }
 
   test_setter() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   @visibleForTesting
   set b(_) => 7;
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   new A().b = 6;
@@ -372,12 +372,12 @@
   }
 
   test_topLevelFunction() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 @visibleForTesting
 int fn0() => 1;
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   fn0();
@@ -391,12 +391,12 @@
   }
 
   test_topLevelVariable() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 @visibleForTesting
 int a = 7;
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   a;
@@ -410,7 +410,7 @@
   }
 
   test_unnamedConstructor() async {
-    newFile('$testPackageRootPath/lib1.dart', content: r'''
+    newFile2('$testPackageRootPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   int _x;
@@ -419,7 +419,7 @@
   A(this._x);
 }
 ''');
-    newFile('$testPackageRootPath/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/lib2.dart', r'''
 import 'lib1.dart';
 void main() {
   new A(0);
diff --git a/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart b/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
index e089c34..c6166de 100644
--- a/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart
@@ -18,7 +18,7 @@
 @reflectiveTest
 class MissingRequiredParamTest extends PubPackageResolutionTest {
   test_constructor_legacy_argumentGiven() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A({required int a});
 }
@@ -34,7 +34,7 @@
   }
 
   test_constructor_legacy_missingArgument() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A({required int a});
 }
@@ -162,7 +162,7 @@
   }
 
   test_function_legacy_argumentGiven() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo({required int a}) {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -176,7 +176,7 @@
   }
 
   test_function_legacy_missingArgument() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo({required int a}) {}
 ''');
     await assertErrorsInCode(r'''
@@ -216,7 +216,7 @@
   }
 
   test_method_inOtherLib() async {
-    newFile('$testPackageLibPath/a_lib.dart', content: r'''
+    newFile2('$testPackageLibPath/a_lib.dart', r'''
 class A {
   void m({required int a}) {}
 }
@@ -232,7 +232,7 @@
   }
 
   test_method_legacy_argumentGiven() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo({required int a}) {}
 }
@@ -248,7 +248,7 @@
   }
 
   test_method_legacy_missingArgument() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void foo({required int a}) {}
 }
@@ -454,13 +454,13 @@
   }
 
   test_method_inOtherLib() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 class A {
   void m({@Required('must specify an `a`') int a}) {}
 }
 ''');
-    newFile('$testPackageLibPath/test.dart', content: r'''
+    newFile2('$testPackageLibPath/test.dart', r'''
 import 'a.dart';
 f() {
   new A().m();
diff --git a/pkg/analyzer/test/src/diagnostics/missing_return_test.dart b/pkg/analyzer/test/src/diagnostics/missing_return_test.dart
index 4c1104b..be7dce8 100644
--- a/pkg/analyzer/test/src/diagnostics/missing_return_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/missing_return_test.dart
@@ -36,7 +36,7 @@
   }
 
   test_function_sync_block_Never() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 Never foo() {
   throw 0;
 }
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_deferred_class_test.dart
index b8a8c67..e45b0bc 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_deferred_class_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class MixinDeferredClassTest extends PubPackageResolutionTest {
   test_classTypeAlias() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
@@ -31,7 +31,7 @@
   }
 
   test_enum() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {}
 ''');
     await assertErrorsInCode('''
@@ -45,7 +45,7 @@
   }
 
   test_mixin_deferred_class() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_inference_no_possible_substitution_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_inference_no_possible_substitution_test.dart
index 2ba1557..d2fd8ed 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_inference_no_possible_substitution_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_inference_no_possible_substitution_test.dart
@@ -22,7 +22,7 @@
 class MixinInferenceNoPossibleSubstitutionTest extends PubPackageResolutionTest
     with MixinInferenceNoPossibleSubstitutionTestCases {
   test_valid_nonNullableMixins_legacyApplication() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 
 mixin B<T> on A<T> {}
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
index beb970a..20036a2 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_of_non_class_test.dart
@@ -125,7 +125,7 @@
   }
 
   test_undefined_ignore_part_exists_uriGenerated_nameIgnorable() async {
-    newFile('$testPackageLibPath/a.g.dart', content: r'''
+    newFile2('$testPackageLibPath/a.g.dart', r'''
 part of 'test.dart';
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_on_sealed_class_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_on_sealed_class_test.dart
index c12044a..e03b2cd 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_on_sealed_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_on_sealed_class_test.dart
@@ -28,7 +28,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -50,12 +50,12 @@
   }
 
   test_withinPackageLibDirectory_OK() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
 
-    newFile('$testPackageLibPath/src/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/src/lib2.dart', r'''
 import '../lib1.dart';
 mixin Bar on Foo {}
 ''');
@@ -68,12 +68,12 @@
   }
 
   test_withinPackageTestDirectory_OK() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
 
-    newFile('$testPackageRootPath/test/lib2.dart', content: r'''
+    newFile2('$testPackageRootPath/test/lib2.dart', r'''
 import 'package:test/lib1.dart';
 mixin Bar on Foo {}
 ''');
@@ -86,13 +86,13 @@
   }
 
   test_withinPart_OK() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 import 'package:meta/meta.dart';
 part 'part1.dart';
 @sealed class Foo {}
 ''');
 
-    newFile('$testPackageLibPath/part1.dart', content: r'''
+    newFile2('$testPackageLibPath/part1.dart', r'''
 part of 'lib1.dart';
 mixin Bar on Foo {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/new_with_non_type_test.dart b/pkg/analyzer/test/src/diagnostics/new_with_non_type_test.dart
index 6cf08fb..9fccc5a 100644
--- a/pkg/analyzer/test/src/diagnostics/new_with_non_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/new_with_non_type_test.dart
@@ -28,7 +28,7 @@
   }
 
   test_imported() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class B {}
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/new_with_undefined_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/new_with_undefined_constructor_test.dart
index 4a7c777..e059e0f 100644
--- a/pkg/analyzer/test/src/diagnostics/new_with_undefined_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/new_with_undefined_constructor_test.dart
@@ -49,7 +49,7 @@
   }
 
   test_default_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {
   A.name() {}
 }
@@ -127,7 +127,7 @@
   }
 
   test_named_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {
   A() {}
 }
@@ -144,7 +144,7 @@
   }
 
   test_private_named() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A._named() {}
 }
@@ -160,7 +160,7 @@
   }
 
   test_private_named_genericClass_noTypeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A._named() {}
 }
@@ -176,7 +176,7 @@
   }
 
   test_private_named_genericClass_withTypeArguments() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A._named() {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart b/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
index 1d80a8d..7a8ae3f 100644
--- a/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/no_default_super_constructor_test.dart
@@ -80,7 +80,7 @@
   }
 
   test_super_requiredNamed_legacySubclass_explicitConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A({required String s});
 }
@@ -96,7 +96,7 @@
   }
 
   test_super_requiredNamed_legacySubclass_implicitConstructor() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A({required String s});
 }O
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_case_expression_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_case_expression_from_deferred_library_test.dart
index 9c6dd7a..be174947 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_case_expression_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_case_expression_from_deferred_library_test.dart
@@ -17,7 +17,7 @@
 class NonConstantCaseExpressionFromDeferredLibraryTest
     extends PubPackageResolutionTest {
   test_nested() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 const int c = 0;
 ''');
 
@@ -40,7 +40,7 @@
   }
 
   test_simple() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 const int c = 0;
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_from_deferred_library_test.dart
index bde3524..e0c8d12 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_from_deferred_library_test.dart
@@ -17,7 +17,7 @@
 class NonConstantDefaultValueFromDeferredLibraryTest
     extends PubPackageResolutionTest {
   test_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const V = 1;
 ''');
@@ -34,7 +34,7 @@
   }
 
   test_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 const V = 1;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart
index 69fcfac..66cd709 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart
@@ -62,7 +62,7 @@
   }
 
   test_constructor_inDifferentFile() async {
-    newFile('/test/lib/a.dart', content: '''
+    newFile2('/test/lib/a.dart', '''
 import 'b.dart';
 const v = const MyClass();
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
index 080f941..304ab6d 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_list_element_from_deferred_library_test.dart
@@ -23,7 +23,7 @@
   @failingTest
   test_const_ifElement_thenTrue_deferredElse() async {
     // reports wrong error code (which is not crucial to fix)
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -38,7 +38,7 @@
   }
 
   test_const_ifElement_thenTrue_deferredThen() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -53,7 +53,7 @@
   }
 
   test_const_topLevel_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -67,7 +67,7 @@
   }
 
   test_const_topLevel_deferred_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
index cc4d444..0ca45d8 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_key_from_deferred_library_test.dart
@@ -22,7 +22,7 @@
   @failingTest
   test_const_ifElement_thenTrue_deferredElse() async {
 // reports wrong error code
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -35,7 +35,7 @@
   }
 
   test_const_ifElement_thenTrue_deferredThen() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -48,7 +48,7 @@
   }
 
   test_const_topLevel_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -60,7 +60,7 @@
   }
 
   test_const_topLevel_deferred_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
index aec5701..5cc04b3 100644
--- a/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_constant_map_value_from_deferred_library_test.dart
@@ -23,7 +23,7 @@
   @failingTest
   test_const_ifElement_thenTrue_elseDeferred() async {
     // reports wrong error code
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -36,7 +36,7 @@
   }
 
   test_const_ifElement_thenTrue_thenDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -49,7 +49,7 @@
   }
 
   test_const_topLevel_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -61,7 +61,7 @@
   }
 
   test_const_topLevel_deferred_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
diff --git a/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart b/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
index 42aa615..3bc5532 100644
--- a/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_null_opt_out_test.dart
@@ -24,7 +24,7 @@
   }
 
   test_assignment_indexExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void operator[]=(int a, int b) {}
 }
@@ -53,7 +53,7 @@
   }
 
   test_assignment_prefixedIdentifier_instanceTarget_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -81,7 +81,7 @@
   }
 
   test_assignment_prefixedIdentifier_instanceTarget_extension_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   void set foo(int _) {}
@@ -110,7 +110,7 @@
   }
 
   test_assignment_prefixedIdentifier_staticTarget_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int foo = 0;
 }
@@ -138,7 +138,7 @@
   }
 
   test_assignment_prefixedIdentifier_staticTarget_extension_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {
   static int foo = 0;
 }
@@ -166,7 +166,7 @@
   }
 
   test_assignment_prefixedIdentifier_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo = 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -192,7 +192,7 @@
   }
 
   test_assignment_propertyAccess_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -220,7 +220,7 @@
   }
 
   test_assignment_propertyAccess_extension_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   void set foo(int a) {}
@@ -249,7 +249,7 @@
   }
 
   test_assignment_propertyAccess_extensionOverride_setter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   void set foo(int a) {}
@@ -278,7 +278,7 @@
   }
 
   test_assignment_propertyAccess_superTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -308,7 +308,7 @@
   }
 
   test_assignment_simpleIdentifier_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo = 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -334,7 +334,7 @@
   }
 
   test_binaryExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int operator+(int a) => 0;
 }
@@ -356,7 +356,7 @@
   }
 
   test_functionExpressionInvocation() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int Function(int, int?)? foo;
 ''');
     await assertNoErrorsInCode(r'''
@@ -379,7 +379,7 @@
   }
 
   test_functionExpressionInvocation_call() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int call(int a, int? b) => 0;
 }
@@ -404,7 +404,7 @@
   }
 
   test_functionExpressionInvocation_extension_staticTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {
   static int Function(int) get foo => (_) => 0;
 }
@@ -429,7 +429,7 @@
   }
 
   test_instanceCreation() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A(int a, int? b);
 }
@@ -452,7 +452,7 @@
   }
 
   test_instanceCreation_generic() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T> {
   A(T a, T? b);
 }
@@ -476,7 +476,7 @@
   }
 
   test_instanceCreation_generic_instantiateToBounds() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<T extends num> {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -491,7 +491,7 @@
   }
 
   test_methodInvocation_extension_functionTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on void Function() {
   int foo(int a) => 0;
 }
@@ -516,7 +516,7 @@
   }
 
   test_methodInvocation_extension_interfaceTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {
   int foo(int a) => 0;
 }
@@ -541,7 +541,7 @@
   }
 
   test_methodInvocation_extension_nullTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   int foo(int a) => 0;
@@ -569,7 +569,7 @@
   }
 
   test_methodInvocation_extension_staticTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {
   static int foo(int a) => 0;
 }
@@ -594,7 +594,7 @@
   }
 
   test_methodInvocation_extensionOverride() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E on int {
   int foo(int a) => 0;
 }
@@ -619,7 +619,7 @@
   }
 
   test_methodInvocation_function() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo(int a, int? b) => 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -642,7 +642,7 @@
   }
 
   test_methodInvocation_function_prefixed() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo(int a, int? b) => 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -665,7 +665,7 @@
   }
 
   test_methodInvocation_method_cascade() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -690,7 +690,7 @@
   }
 
   test_methodInvocation_method_interfaceTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -715,7 +715,7 @@
   }
 
   test_methodInvocation_method_nullTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -742,7 +742,7 @@
   }
 
   test_methodInvocation_method_staticTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int foo(int a, int? b) => 0;
 }
@@ -767,7 +767,7 @@
   }
 
   test_methodInvocation_method_superTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a, int? b) => 0;
 }
@@ -821,7 +821,7 @@
   }
 
   test_postfixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A operator+(int a) => this;
 }
@@ -842,7 +842,7 @@
   }
 
   test_prefixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int operator-() => 0;
 }
@@ -863,7 +863,7 @@
   }
 
   test_read_indexExpression_class() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int operator[](int a) => 0;
 }
@@ -884,7 +884,7 @@
   }
 
   test_read_prefixedIdentifier_instanceTarget_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo;
 }
@@ -908,7 +908,7 @@
   }
 
   test_read_prefixedIdentifier_instanceTarget_extension_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   int get foo => 0;
@@ -933,7 +933,7 @@
   }
 
   test_read_prefixedIdentifier_staticTarget_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int foo;
 }
@@ -957,7 +957,7 @@
   }
 
   test_read_prefixedIdentifier_staticTarget_class_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int foo(int a) => 0;
 }
@@ -981,7 +981,7 @@
   }
 
   test_read_prefixedIdentifier_staticTarget_extension_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E {
   static int foo;
 }
@@ -1005,7 +1005,7 @@
   }
 
   test_read_prefixedIdentifier_staticTarget_extension_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E {
   static int foo(int a) => 0;
 }
@@ -1029,7 +1029,7 @@
   }
 
   test_read_prefixedIdentifier_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo = 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -1051,7 +1051,7 @@
   }
 
   test_read_propertyAccessor_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -1075,7 +1075,7 @@
   }
 
   test_read_propertyAccessor_class_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo() => 0;
 }
@@ -1099,7 +1099,7 @@
   }
 
   test_read_propertyAccessor_extensionOverride_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   int get foo => 0;
@@ -1124,7 +1124,7 @@
   }
 
   test_read_propertyAccessor_superTarget() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -1150,7 +1150,7 @@
   }
 
   test_read_simpleIdentifier_class_field() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo = 0;
 }
@@ -1173,7 +1173,7 @@
   }
 
   test_read_simpleIdentifier_class_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int foo(int a) => 0;
 }
@@ -1196,7 +1196,7 @@
   }
 
   test_read_simpleIdentifier_extension_getter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   int get foo => 0;
@@ -1220,7 +1220,7 @@
   }
 
   test_read_simpleIdentifier_extension_method() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {}
 extension E on A {
   int foo(int a) => 0;
@@ -1244,7 +1244,7 @@
   }
 
   test_read_simpleIdentifier_topLevelVariable() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int foo = 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -1263,7 +1263,7 @@
   }
 
   test_superConstructorInvocation() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   A(int a, int? b);
 }
diff --git a/pkg/analyzer/test/src/diagnostics/not_iterable_spread_test.dart b/pkg/analyzer/test/src/diagnostics/not_iterable_spread_test.dart
index d968410..c992263 100644
--- a/pkg/analyzer/test/src/diagnostics/not_iterable_spread_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/not_iterable_spread_test.dart
@@ -108,6 +108,14 @@
       error(CompileTimeErrorCode.NOT_ITERABLE_SPREAD, 43, 1),
     ]);
   }
+
+  test_spread_map_in_iterable_context() async {
+    await assertErrorsInCode('''
+List<int> f() => [...{1: 2, 3: 4}];
+''', [
+      error(CompileTimeErrorCode.NOT_ITERABLE_SPREAD, 21, 12),
+    ]);
+  }
 }
 
 @reflectiveTest
diff --git a/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart b/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart
index e26ae88..2aa3af9 100644
--- a/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/part_of_different_library_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PartOfDifferentLibraryTest extends PubPackageResolutionTest {
   test_name() async {
-    newFile('$testPackageLibPath/part.dart', content: "part of lub;");
+    newFile2('$testPackageLibPath/part.dart', "part of lub;");
     await assertErrorsInCode('''
 library lib;
 part 'part.dart';
diff --git a/pkg/analyzer/test/src/diagnostics/part_of_non_part_test.dart b/pkg/analyzer/test/src/diagnostics/part_of_non_part_test.dart
index a03e62c..9f69cdc 100644
--- a/pkg/analyzer/test/src/diagnostics/part_of_non_part_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/part_of_non_part_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PartOfNonPartTest extends PubPackageResolutionTest {
   test_part_of_non_part() async {
-    newFile('$testPackageLibPath/l2.dart', content: '''
+    newFile2('$testPackageLibPath/l2.dart', '''
 library l2;
 ''');
     await assertErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart b/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
index 55ef355..855cc07 100644
--- a/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/prefix_collides_with_top_level_member_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PrefixCollidesWithTopLevelMemberTest extends PubPackageResolutionTest {
   test_functionTypeAlias() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 class A{}
 ''');
@@ -30,7 +30,7 @@
   }
 
   test_no_collision() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 class A {}''');
     await assertNoErrorsInCode(r'''
@@ -44,7 +44,7 @@
   }
 
   test_topLevelFunction() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 class A{}
 ''');
@@ -58,7 +58,7 @@
   }
 
   test_topLevelVariable() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 class A{}
 ''');
@@ -72,7 +72,7 @@
   }
 
   test_type() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 class A{}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart b/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
index 1979034..3ae3ccc 100644
--- a/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/prefix_identifier_not_followed_by_dot_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PrefixIdentifierNotFollowedByDotTest extends PubPackageResolutionTest {
   test_assignment_compound_in_method() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -32,7 +32,7 @@
   }
 
   test_assignment_compound_not_in_method() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -46,7 +46,7 @@
   }
 
   test_assignment_in_method() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -81,7 +81,7 @@
   }
 
   test_assignment_not_in_method() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -95,7 +95,7 @@
   }
 
   test_compoundAssignment() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -109,7 +109,7 @@
   }
 
   test_conditionalMethodInvocation() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 g() {}
 ''');
@@ -124,7 +124,7 @@
   }
 
   test_conditionalPropertyAccess_call_loadLibrary() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -139,7 +139,7 @@
   }
 
   test_conditionalPropertyAccess_get() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 var x;
 ''');
@@ -154,7 +154,7 @@
   }
 
   test_conditionalPropertyAccess_get_loadLibrary() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -168,7 +168,7 @@
   }
 
   test_conditionalPropertyAccess_set() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 var x;
 ''');
@@ -183,7 +183,7 @@
   }
 
   test_conditionalPropertyAccess_set_loadLibrary() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
@@ -197,7 +197,7 @@
   }
 
   test_prefix_not_followed_by_dot() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 ''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart b/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart
index 60dea5a..53a4ceb 100644
--- a/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PrivateCollisionInMixinApplicationTest extends PubPackageResolutionTest {
   test_class_interfaceAndMixin_same() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -31,7 +31,7 @@
   }
 
   test_class_mixinAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -51,7 +51,7 @@
   }
 
   test_class_mixinAndMixin_indirect() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -72,7 +72,7 @@
   }
 
   test_class_mixinAndMixin_withoutExtends() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -92,7 +92,7 @@
   }
 
   test_class_staticAndInstanceElement() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static void _foo() {}
 }
@@ -110,7 +110,7 @@
   }
 
   test_class_staticElements() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static void _foo() {}
 }
@@ -128,7 +128,7 @@
   }
 
   test_class_superclassAndMixin_getter2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   int get _foo => 0;
 }
@@ -148,7 +148,7 @@
   }
 
   test_class_superclassAndMixin_method2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -185,7 +185,7 @@
   }
 
   test_class_superclassAndMixin_setter2() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   set _foo(int _) {}
 }
@@ -205,7 +205,7 @@
   }
 
   test_classTypeAlias_mixinAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -225,7 +225,7 @@
   }
 
   test_classTypeAlias_mixinAndMixin_indirect() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -246,7 +246,7 @@
   }
 
   test_classTypeAlias_superclassAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void _foo() {}
 }
@@ -266,7 +266,7 @@
   }
 
   test_enum_getter_mixinAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin A {
   int get _foo => 0;
 }
@@ -288,7 +288,7 @@
   }
 
   test_enum_method_interfaceAndMixin_same() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin A {
   void _foo() {}
 }
@@ -305,7 +305,7 @@
   }
 
   test_enum_method_mixinAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin A {
   void _foo() {}
 }
@@ -327,7 +327,7 @@
   }
 
   test_enum_method_staticAndInstanceElement() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin A {
   static void _foo() {}
 }
@@ -347,7 +347,7 @@
   }
 
   test_enum_setter_mixinAndMixin() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 mixin A {
   set _foo(int _) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/private_setter_test.dart b/pkg/analyzer/test/src/diagnostics/private_setter_test.dart
index 2768242..1ab1e89 100644
--- a/pkg/analyzer/test/src/diagnostics/private_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/private_setter_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class PrivateSetterTest extends PubPackageResolutionTest {
   test_typeLiteral_privateField_differentLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static int _foo = 0;
 }
@@ -58,7 +58,7 @@
   }
 
   test_typeLiteral_privateSetter_differentLibrary_hasGetter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static set _foo(int _) {}
 
@@ -89,7 +89,7 @@
   }
 
   test_typeLiteral_privateSetter_differentLibrary_noGetter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   static set _foo(int _) {}
 }
diff --git a/pkg/analyzer/test/src/diagnostics/recursive_compile_time_constant_test.dart b/pkg/analyzer/test/src/diagnostics/recursive_compile_time_constant_test.dart
index e65cbff..6ce6a7e 100644
--- a/pkg/analyzer/test/src/diagnostics/recursive_compile_time_constant_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/recursive_compile_time_constant_test.dart
@@ -73,9 +73,9 @@
   }
 
   test_fromMapLiteral() async {
-    newFile(
+    newFile2(
       '$testPackageLibPath/constants.dart',
-      content: r'''
+      r'''
 const int x = y;
 const int y = x;
 ''',
diff --git a/pkg/analyzer/test/src/diagnostics/return_of_invalid_type_test.dart b/pkg/analyzer/test/src/diagnostics/return_of_invalid_type_test.dart
index 1a11708..3b54f2e 100644
--- a/pkg/analyzer/test/src/diagnostics/return_of_invalid_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/return_of_invalid_type_test.dart
@@ -546,6 +546,14 @@
       error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_METHOD, 23, 3),
     ]);
   }
+
+  test_spread_iterable_in_map_context() async {
+    await assertErrorsInCode('''
+Map<int, int> f() => {...[1, 2, 3, 4]};
+''', [
+      error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 21, 17),
+    ]);
+  }
 }
 
 @reflectiveTest
diff --git a/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart b/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
index 47c4e1a..aa0b7e5 100644
--- a/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/sdk_version_async_exported_from_core_test.dart
@@ -32,7 +32,7 @@
   }
 
   test_equals_explicitImportOfExportingLibrary() async {
-    newFile('$testPackageLibPath/exporter.dart', content: '''
+    newFile2('$testPackageLibPath/exporter.dart', '''
 export 'dart:async';
 ''');
     await verifyVersion('2.1.0', '''
@@ -49,7 +49,7 @@
   }
 
   test_equals_implicitImportOfCore_inPart() async {
-    newFile('/lib.dart', content: '''
+    newFile2('/lib.dart', '''
 library lib;
 ''');
     await verifyVersion('2.1.0', '''
@@ -78,7 +78,7 @@
   }
 
   test_lessThan_explicitImportOfExportingLibrary() async {
-    newFile('$testPackageLibPath/exporter.dart', content: '''
+    newFile2('$testPackageLibPath/exporter.dart', '''
 export 'dart:async';
 ''');
     await verifyVersion('2.0.0', '''
@@ -97,7 +97,7 @@
   }
 
   test_lessThan_implicitImportOfCore_inPart() async {
-    newFile('/lib.dart', content: '''
+    newFile2('/lib.dart', '''
 library lib;
 ''');
     await verifyVersion('2.0.0', '''
diff --git a/pkg/analyzer/test/src/diagnostics/set_element_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/set_element_from_deferred_library_test.dart
index e5e1fd7..3aade1c 100644
--- a/pkg/analyzer/test/src/diagnostics/set_element_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/set_element_from_deferred_library_test.dart
@@ -21,7 +21,7 @@
   @failingTest
   test_const_ifElement_thenTrue_elseDeferred() async {
     // reports wrong error code
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -33,7 +33,7 @@
   }
 
   test_const_ifElement_thenTrue_thenDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -45,7 +45,7 @@
   }
 
   test_const_topLevel_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -56,7 +56,7 @@
   }
 
   test_const_topLevel_deferred_nested() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int c = 1;''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
diff --git a/pkg/analyzer/test/src/diagnostics/shared_deferred_prefix_test.dart b/pkg/analyzer/test/src/diagnostics/shared_deferred_prefix_test.dart
index 9574bc5..fbf12c2 100644
--- a/pkg/analyzer/test/src/diagnostics/shared_deferred_prefix_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/shared_deferred_prefix_test.dart
@@ -16,11 +16,11 @@
 @reflectiveTest
 class SharedDeferredPrefixTest extends PubPackageResolutionTest {
   test_hasSharedDeferredPrefix() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 f1() {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 library lib2;
 f2() {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/spread_expression_from_deferred_library_test.dart b/pkg/analyzer/test/src/diagnostics/spread_expression_from_deferred_library_test.dart
index cf83fc1..69b8519 100644
--- a/pkg/analyzer/test/src/diagnostics/spread_expression_from_deferred_library_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/spread_expression_from_deferred_library_test.dart
@@ -19,7 +19,7 @@
 
 mixin SpreadExpressionFromDeferredLibraryTestCases on PubPackageResolutionTest {
   test_inList_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const List c = [];''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -32,7 +32,7 @@
   }
 
   test_inList_deferred_notConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const List c = [];''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -42,7 +42,7 @@
   }
 
   test_inList_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const List c = [];''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
@@ -52,7 +52,7 @@
   }
 
   test_inMap_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Map c = <int, int>{};''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -65,7 +65,7 @@
   }
 
   test_inMap_notConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Map c = <int, int>{};''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -75,7 +75,7 @@
   }
 
   test_inMap_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Map c = <int, int>{};''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
@@ -85,7 +85,7 @@
   }
 
   test_inSet_deferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Set c = <int>{};''');
     await assertErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -98,7 +98,7 @@
   }
 
   test_inSet_notConst() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Set c = <int>{};''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' deferred as a;
@@ -108,7 +108,7 @@
   }
 
   test_inSet_notDeferred() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const Set c = <int>{};''');
     await assertNoErrorsInCode(r'''
 import 'lib1.dart' as a;
diff --git a/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart b/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
index 9322aa2..c58a45c 100644
--- a/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/subtype_of_sealed_class_test.dart
@@ -28,7 +28,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -48,7 +48,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -68,7 +68,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -89,7 +89,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed mixin Foo {}
 ''');
@@ -110,7 +110,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed mixin Foo {}
 ''');
@@ -130,7 +130,7 @@
       meta: true,
     );
 
-    newFile('$workspaceRootPath/foo/lib/foo.dart', content: r'''
+    newFile2('$workspaceRootPath/foo/lib/foo.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -156,7 +156,7 @@
   }
 
   test_withinPackageLibDirectory_OK() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -172,7 +172,7 @@
   }
 
   test_withinPackageTestDirectory_OK() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'package:meta/meta.dart';
 @sealed class Foo {}
 ''');
@@ -192,13 +192,13 @@
     var libPath = '$testPackageLibPath/a.dart';
     var partPath = '$testPackageLibPath/b.dart';
 
-    newFile(libPath, content: r'''
+    newFile2(libPath, r'''
 import 'package:meta/meta.dart';
 part 'b.dart';
 @sealed class Foo {}
 ''');
 
-    newFile(partPath, content: r'''
+    newFile2(partPath, r'''
 part of 'a.dart';
 class Bar1 extends Foo {}
 class Bar2 implements Foo {}
diff --git a/pkg/analyzer/test/src/diagnostics/subtype_of_struct_class_test.dart b/pkg/analyzer/test/src/diagnostics/subtype_of_struct_class_test.dart
index 0d24687..e48f5fe 100644
--- a/pkg/analyzer/test/src/diagnostics/subtype_of_struct_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/subtype_of_struct_class_test.dart
@@ -75,7 +75,7 @@
   }
 
   test_implements_struct_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 import 'dart:ffi';
 class S extends Struct {}
 ''');
@@ -116,7 +116,7 @@
   }
 
   test_with_struct_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 import 'dart:ffi';
 class S extends Struct {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/throw_of_invalid_type_test.dart b/pkg/analyzer/test/src/diagnostics/throw_of_invalid_type_test.dart
index 3cbef8b..6acba98 100644
--- a/pkg/analyzer/test/src/diagnostics/throw_of_invalid_type_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/throw_of_invalid_type_test.dart
@@ -24,7 +24,7 @@
   }
 
   test_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 int a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
index 3a78473..93c3e4e 100644
--- a/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/top_level_instance_getter_test.dart
@@ -47,7 +47,7 @@
   }
 
   test_field_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A {
   int f = 0;
 }
@@ -293,7 +293,7 @@
   }
 
   test_implicitlyTyped_new_explicit_type_params_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class B<T> {
   B(x);
 }
@@ -352,7 +352,7 @@
   }
 
   test_implicitlyTyped_new_not_generic_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class B {
   B(x);
 }
@@ -369,7 +369,7 @@
   }
 
   test_implicitlyTyped_new_prefixed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class B<T> {
   B(T x);
 }
diff --git a/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart b/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
index b432e45..d46f4ea 100644
--- a/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/type_annotation_deferred_class_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class TypeAnnotationDeferredClassTest extends PubPackageResolutionTest {
   test_annotation_typeArgument() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class D {}
 ''');
     await assertErrorsInCode('''
@@ -31,7 +31,7 @@
   }
 
   test_asExpression() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -45,7 +45,7 @@
   }
 
   test_catchClause() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -61,7 +61,7 @@
   }
 
   test_fieldFormalParameter() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -76,7 +76,7 @@
   }
 
   test_functionDeclaration_returnType() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -89,7 +89,7 @@
   }
 
   test_functionTypedFormalParameter_returnType() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -101,7 +101,7 @@
   }
 
   test_isExpression() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -116,7 +116,7 @@
   }
 
   test_methodDeclaration_returnType() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -130,7 +130,7 @@
   }
 
   test_simpleFormalParameter() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -142,7 +142,7 @@
   }
 
   test_typeArgumentList() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -156,7 +156,7 @@
   }
 
   test_typeArgumentList2() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -171,7 +171,7 @@
   }
 
   test_typeParameter_bound() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
@@ -183,7 +183,7 @@
   }
 
   test_variableDeclarationList() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 library lib1;
 class A {}''');
     await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart b/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
index a4c3dd6..3f52554 100644
--- a/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/type_argument_not_matching_bounds_test.dart
@@ -49,7 +49,7 @@
   }
 
   test_extends_optIn_fromOptOut_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<X extends int> {}
 ''');
 
@@ -62,7 +62,7 @@
   }
 
   test_extends_optIn_fromOptOut_otherTypeParameter() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo<T extends U, U>() {
 }
 ''');
@@ -81,7 +81,7 @@
   }
 
   test_extensionOverride_optIn_fromOptOut_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 extension E<X extends int> on List<X> {
   void m() {}
 }
@@ -146,7 +146,7 @@
   }
 
   test_instanceCreation_optIn_fromOptOut_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A<X extends int> {}
 ''');
 
@@ -222,7 +222,7 @@
   }
 
   test_methodInvocation_optIn_fromOptOut_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class A {
   void m<X extends int>() {}
 ''');
@@ -340,7 +340,7 @@
   }
 
   test_redirectingConstructor_optIn_fromOptOut_Null() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'test.dart';
 
 class A<X extends int> implements B {}
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
index 8c78d5c..49bc006 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_class_test.dart
@@ -67,7 +67,7 @@
   }
 
   test_ignore_part_exists_uriGenerated_nameIgnorable() async {
-    newFile('$testPackageLibPath/a.g.dart', content: r'''
+    newFile2('$testPackageLibPath/a.g.dart', r'''
 part of 'test.dart';
 ''');
 
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart
index cf1eba2..52e9002 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_hidden_name_test.dart
@@ -20,7 +20,7 @@
 
 mixin UndefinedHiddenNameTestCases on PubPackageResolutionTest {
   test_export() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode(r'''
 export 'lib1.dart' hide a;
 ''', [
@@ -29,7 +29,7 @@
   }
 
   test_import() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode(r'''
 import 'lib1.dart' hide a;
 ''', [
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
index c484dd0..89d58bb 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
@@ -371,7 +371,7 @@
   }
 
   test_private_getter() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 class A {
   var _foo;
@@ -389,7 +389,7 @@
   }
 
   test_private_setter() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 library lib;
 class A {
   var _foo;
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
index 9c11a5e..bc446a2 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_method_test.dart
@@ -38,7 +38,7 @@
   }
 
   test_definedInPrivateExtension() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class B {}
 
 extension _ on B {
@@ -57,7 +57,7 @@
   }
 
   test_definedInUnnamedExtension() async {
-    newFile('$testPackageLibPath/lib.dart', content: '''
+    newFile2('$testPackageLibPath/lib.dart', '''
 class C {}
 
 extension on C {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
index e9c6092..8cb6a74 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_prefixed_name_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class UndefinedPrefixedNameTest extends PubPackageResolutionTest {
   test_getterContext() async {
-    newFile('$testPackageLibPath/lib.dart');
+    newFile2('$testPackageLibPath/lib.dart', '');
     await assertErrorsInCode('''
 import 'lib.dart' as p;
 f() => p.c;
@@ -26,7 +26,7 @@
   }
 
   test_new() async {
-    newFile('$testPackageLibPath/lib.dart', content: '');
+    newFile2('$testPackageLibPath/lib.dart', '');
     await assertErrorsInCode(r'''
 import 'lib.dart' as p;
 void f() {
@@ -38,7 +38,7 @@
   }
 
   test_setterContext() async {
-    newFile('$testPackageLibPath/lib.dart');
+    newFile2('$testPackageLibPath/lib.dart', '');
     await assertErrorsInCode('''
 import 'lib.dart' as p;
 f() {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
index df6bcf4..0aedd03 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_setter_test.dart
@@ -151,7 +151,7 @@
 
 mixin UndefinedSetterTestCases on PubPackageResolutionTest {
   test_importWithPrefix_defined() async {
-    newFile('$testPackageLibPath/lib.dart', content: r'''
+    newFile2('$testPackageLibPath/lib.dart', r'''
 library lib;
 set y(int value) {}''');
     await assertNoErrorsInCode(r'''
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart
index f486367..5839381 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_shown_name_test.dart
@@ -20,7 +20,7 @@
 
 mixin UndefinedShownNameTestCases on PubPackageResolutionTest {
   test_export() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode(r'''
 export 'lib1.dart' show a;
 ''', [
@@ -29,7 +29,7 @@
   }
 
   test_import() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode(r'''
 import 'lib1.dart' show a;
 ''', [
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart
index 0735628..443694b 100644
--- a/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart
@@ -221,7 +221,7 @@
 class UnnecessaryCastTestWithNullSafety extends PubPackageResolutionTest
     with UnnecessaryCastTestCases {
   test_interfaceType_star_toNone() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 int a = 0;
 ''');
@@ -240,7 +240,7 @@
   }
 
   test_interfaceType_star_toQuestion() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.7
 int a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
index 431f22d..7f08baa 100644
--- a/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class UnnecessaryImportTest extends PubPackageResolutionTest {
   test_annotationOnDirective() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {
   const A() {}
 }
@@ -28,10 +28,10 @@
   }
 
   test_as() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart';
 class B {}
 ''');
@@ -43,10 +43,10 @@
   }
 
   test_as_differentPrefixes() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart';
 class B {}
 ''');
@@ -58,10 +58,10 @@
   }
 
   test_as_equalPrefixes_referenced() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -72,13 +72,13 @@
   }
 
   test_as_equalPrefixes_referenced_via_export() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
-    newFile('$testPackageLibPath/lib3.dart', content: r'''
+    newFile2('$testPackageLibPath/lib3.dart', r'''
 export 'lib2.dart';
 ''');
     await assertNoErrorsInCode(r'''
@@ -89,10 +89,10 @@
   }
 
   test_as_equalPrefixes_unreferenced() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -103,7 +103,7 @@
   }
 
   test_as_show_multipleElements() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
@@ -114,7 +114,7 @@
   }
 
   test_as_showTopLevelFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class One {}
 topLevelFunction() {}
 ''');
@@ -128,7 +128,7 @@
   }
 
   test_as_showTopLevelFunction_multipleDirectives() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class One {}
 topLevelFunction() {}
 ''');
@@ -144,7 +144,7 @@
   }
 
   test_as_systemShadowing() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class File {}
 ''');
     await assertNoErrorsInCode('''
@@ -155,10 +155,10 @@
   }
 
   test_as_unnecessary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart';
 class B {}
 ''');
@@ -172,7 +172,7 @@
   }
 
   test_duplicteImport_differentPrefix() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 class B {}
 ''');
@@ -184,10 +184,10 @@
   }
 
   test_hide() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart' hide A;
 class B {}
 ''');
@@ -199,7 +199,7 @@
   }
 
   test_systemShadowing() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class File {}
 ''');
     await assertNoErrorsInCode('''
@@ -210,10 +210,10 @@
   }
 
   test_unnecessaryImport() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart';
 class B {}
 ''');
@@ -227,10 +227,10 @@
   }
 
   test_unnecessaryImport_sameUri() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: '''
+    newFile2('$testPackageLibPath/lib2.dart', '''
 export 'lib1.dart';
 class B {}
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_non_null_assertion_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_non_null_assertion_test.dart
index 5114424..dd5dc92 100644
--- a/pkg/analyzer/test/src/diagnostics/unnecessary_non_null_assertion_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_non_null_assertion_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class UnnecessaryNonNullAssertionTest extends PubPackageResolutionTest {
   test_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var x = 0;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_null_comparison_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_null_comparison_test.dart
index 33b4b6a..05e6462 100644
--- a/pkg/analyzer/test/src/diagnostics/unnecessary_null_comparison_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_null_comparison_test.dart
@@ -28,7 +28,7 @@
   }
 
   test_equal_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var a = 0;
 ''');
@@ -91,7 +91,7 @@
   }
 
   test_notEqual_legacy() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 // @dart = 2.5
 var a = 0;
 ''');
diff --git a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
index 8cce111..3279925 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class UnusedImportTest extends PubPackageResolutionTest {
   test_annotationOnDirective() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {
   const A() {}
 }
@@ -28,7 +28,7 @@
   }
 
   test_as() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
     await assertErrorsInCode(r'''
@@ -41,10 +41,10 @@
   }
 
   test_as_equalPrefixes_referenced() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -56,13 +56,13 @@
   }
 
   test_as_equalPrefixes_referenced_via_export() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
-    newFile('$testPackageLibPath/lib3.dart', content: r'''
+    newFile2('$testPackageLibPath/lib3.dart', r'''
 export 'lib2.dart';
 ''');
     await assertNoErrorsInCode(r'''
@@ -74,10 +74,10 @@
   }
 
   test_as_equalPrefixes_unreferenced() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class B {}
 ''');
     await assertErrorsInCode(r'''
@@ -90,7 +90,7 @@
   }
 
   test_as_show_multipleElements() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
@@ -102,7 +102,7 @@
   }
 
   test_as_showTopLevelFunction() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class One {}
 topLevelFunction() {}
 ''');
@@ -121,7 +121,7 @@
   }
 
   test_as_showTopLevelFunction_multipleDirectives() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class One {}
 topLevelFunction() {}
 ''');
@@ -139,7 +139,7 @@
   }
 
   test_as_systemLibrary() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class File {}
 ''');
     await assertErrorsInCode(r'''
@@ -158,11 +158,11 @@
   }
 
   test_export() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 export 'lib2.dart';
 class One {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 class Two {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -172,15 +172,15 @@
   }
 
   test_export2() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 export 'lib2.dart';
 class One {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 export 'lib3.dart';
 class Two {}
 ''');
-    newFile('$testPackageLibPath/lib3.dart', content: r'''
+    newFile2('$testPackageLibPath/lib3.dart', r'''
 class Three {}
 ''');
     await assertNoErrorsInCode(r'''
@@ -190,15 +190,15 @@
   }
 
   test_export_infiniteLoop() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 export 'lib2.dart';
 class One {}
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 export 'lib3.dart';
 class Two {}
 ''');
-    newFile('$testPackageLibPath/lib3.dart', content: r'''
+    newFile2('$testPackageLibPath/lib3.dart', r'''
 export 'lib2.dart';
 class Three {}
 ''');
@@ -209,7 +209,7 @@
   }
 
   test_extension_instance_call() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on int {
   int call(int x) => 0;
 }
@@ -224,7 +224,7 @@
   }
 
   test_extension_instance_getter() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String get empty => '';
 }
@@ -239,7 +239,7 @@
   }
 
   test_extension_instance_method() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String empty() => '';
 }
@@ -254,7 +254,7 @@
   }
 
   test_extension_instance_operator_binary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String operator -(String s) => this;
 }
@@ -269,7 +269,7 @@
   }
 
   test_extension_instance_operator_index() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on int {
   int operator [](int i) => 0;
 }
@@ -284,7 +284,7 @@
   }
 
   test_extension_instance_operator_unary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   void operator -() {}
 }
@@ -299,7 +299,7 @@
   }
 
   test_extension_instance_setter() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   void set foo(int i) {}
 }
@@ -314,7 +314,7 @@
   }
 
   test_extension_override_getter() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String get empty => '';
 }
@@ -329,7 +329,7 @@
   }
 
   test_extension_prefixed_isUsed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String empty() => '';
 }
@@ -344,7 +344,7 @@
   }
 
   test_extension_prefixed_notUsed() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String empty() => '';
 }
@@ -357,7 +357,7 @@
   }
 
   test_extension_static_field() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   static const String empty = '';
 }
@@ -372,7 +372,7 @@
   }
 
   test_hide() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 ''');
     await assertErrorsInCode(r'''
@@ -392,7 +392,7 @@
   }
 
   test_metadata() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const x = 0;
 ''');
     await assertNoErrorsInCode(r'''
@@ -406,12 +406,12 @@
   }
 
   test_multipleExtensions() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String a() => '';
 }
 ''');
-    newFile('$testPackageLibPath/lib2.dart', content: r'''
+    newFile2('$testPackageLibPath/lib2.dart', r'''
 extension E on String {
   String b() => '';
 }
@@ -429,7 +429,7 @@
   }
 
   test_show() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
@@ -443,7 +443,7 @@
   }
 
   test_systemLibrary() async {
-    newFile('$testPackageLibPath/lib1.dart', content: '''
+    newFile2('$testPackageLibPath/lib1.dart', '''
 class File {}
 ''');
     await assertErrorsInCode(r'''
@@ -456,7 +456,7 @@
   }
 
   test_unusedImport() async {
-    newFile('$testPackageLibPath/lib1.dart');
+    newFile2('$testPackageLibPath/lib1.dart', '');
     await assertErrorsInCode(r'''
 import 'lib1.dart';
 ''', [
diff --git a/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart b/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
index 2f968cd..3f0c9a4 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_shown_name_test.dart
@@ -16,7 +16,7 @@
 @reflectiveTest
 class UnusedShownNameTest extends PubPackageResolutionTest {
   test_extension_instance_method_unused() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String empty() => '';
 }
@@ -34,7 +34,7 @@
   }
 
   test_extension_instance_method_used() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 extension E on String {
   String empty() => '';
 }
@@ -49,7 +49,7 @@
   }
 
   test_referenced_prefixed_assignmentExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -63,7 +63,7 @@
   }
 
   test_referenced_prefixed_postfixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -77,7 +77,7 @@
   }
 
   test_referenced_prefixed_prefixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -91,7 +91,7 @@
   }
 
   test_referenced_unprefixed_assignmentExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -105,7 +105,7 @@
   }
 
   test_referenced_unprefixed_postfixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -119,7 +119,7 @@
   }
 
   test_referenced_unprefixed_prefixExpression() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 var a = 0;
 ''');
 
@@ -133,7 +133,7 @@
   }
 
   test_unreferenced() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
@@ -157,7 +157,7 @@
   }
 
   test_unusedShownName_as() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 ''');
@@ -170,7 +170,7 @@
   }
 
   test_unusedShownName_duplicates() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 class A {}
 class B {}
 class C {}
@@ -188,7 +188,7 @@
   }
 
   test_unusedShownName_topLevelVariable() async {
-    newFile('$testPackageLibPath/lib1.dart', content: r'''
+    newFile2('$testPackageLibPath/lib1.dart', r'''
 const int var1 = 1;
 const int var2 = 2;
 const int var3 = 3;
diff --git a/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart b/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
index 7fb0b41..b411c0c 100644
--- a/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/uri_does_not_exist_test.dart
@@ -43,7 +43,7 @@
   }
 
   test_import_appears_after_deleting_target() async {
-    String filePath = newFile('$testPackageLibPath/target.dart').path;
+    String filePath = newFile2('$testPackageLibPath/target.dart', '').path;
 
     await assertErrorsInCode('''
 import 'target.dart';
@@ -72,7 +72,7 @@
       error(CompileTimeErrorCode.URI_DOES_NOT_EXIST, 7, 13),
     ]);
 
-    newFile('$testPackageLibPath/target.dart');
+    newFile2('$testPackageLibPath/target.dart', '');
 
     // Make sure the error goes away.
     // TODO(brianwilkerson) The error does not go away, possibly because the
diff --git a/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart b/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
index 5d90e76..b02ead8 100644
--- a/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
+++ b/pkg/analyzer/test/src/hint/sdk_constraint_extractor_test.dart
@@ -18,7 +18,7 @@
 class SdkConstraintExtractorTest with ResourceProviderMixin {
   SdkConstraintExtractor extractorFor(String pubspecContent) {
     String pubspecPath = '/pkg/test/pubspec.yaml';
-    File pubspecFile = newFile(pubspecPath, content: pubspecContent);
+    File pubspecFile = newFile2(pubspecPath, pubspecContent);
     return SdkConstraintExtractor(pubspecFile);
   }
 
diff --git a/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart b/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
index 5beaead..6e1f3c9 100644
--- a/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
+++ b/pkg/analyzer/test/src/lint/linter/linter_context_impl_test.dart
@@ -244,7 +244,7 @@
   }
 
   void test_true_computeDependencies() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 0;
 ''');
 
@@ -285,7 +285,7 @@
 
   void test_true_importedClass_defaultValue() async {
     var aPath = convertPath('$testPackageLibPath/a.dart');
-    newFile(aPath, content: r'''
+    newFile2(aPath, r'''
 class A {
   final int a;
   const A({int b = 1}) : a = b * 2;
@@ -334,7 +334,7 @@
   }
 
   void test_listLiteral_true_computeDependencies() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 0;
 ''');
 
@@ -499,7 +499,7 @@
   }
 
   test_hasValue_constantReference_imported() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 const a = 42;
 ''');
     await resolve('''
diff --git a/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart b/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart
index 0520a63..37080e4 100644
--- a/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart
+++ b/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart
@@ -46,7 +46,7 @@
   }
 
   test_class_getter_different_importScope() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 set foo(int _) {}
 ''');
     await resolve('''
@@ -116,7 +116,7 @@
   }
 
   test_class_getter_requested_importScope() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 int get foo => 0;
 ''');
     await resolve('''
@@ -276,7 +276,7 @@
   }
 
   test_class_method_requested_importScope() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 void foo() {}
 ''');
     await resolve('''
@@ -530,7 +530,7 @@
   }
 
   test_class_setter_requested_importScope() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 set foo(int _) {}
 ''');
     await resolve('''
diff --git a/pkg/analyzer/test/src/pubspec/diagnostics/asset_does_not_exist_test.dart b/pkg/analyzer/test/src/pubspec/diagnostics/asset_does_not_exist_test.dart
index 8cd2803..00030c8 100644
--- a/pkg/analyzer/test/src/pubspec/diagnostics/asset_does_not_exist_test.dart
+++ b/pkg/analyzer/test/src/pubspec/diagnostics/asset_does_not_exist_test.dart
@@ -25,7 +25,7 @@
   }
 
   test_assetDoesNotExist_path_inRoot_noError() {
-    newFile('/sample/assets/my_icon.png');
+    newFile2('/sample/assets/my_icon.png', '');
     assertNoErrors('''
 name: sample
 flutter:
@@ -35,7 +35,7 @@
   }
 
   test_assetDoesNotExist_path_inSubdir_noError() {
-    newFile('/sample/assets/images/2.0x/my_icon.png');
+    newFile2('/sample/assets/images/2.0x/my_icon.png', '');
     assertNoErrors('''
 name: sample
 flutter:
diff --git a/pkg/analyzer/test/src/pubspec/diagnostics/asset_field_not_list_test.dart b/pkg/analyzer/test/src/pubspec/diagnostics/asset_field_not_list_test.dart
index 89b9c89..d0ca77d 100644
--- a/pkg/analyzer/test/src/pubspec/diagnostics/asset_field_not_list_test.dart
+++ b/pkg/analyzer/test/src/pubspec/diagnostics/asset_field_not_list_test.dart
@@ -32,7 +32,7 @@
   }
 
   test_assetFieldNotList_noError() {
-    newFile('/sample/assets/my_icon.png');
+    newFile2('/sample/assets/my_icon.png', '');
     assertNoErrors('''
 name: sample
 flutter:
diff --git a/pkg/analyzer/test/src/pubspec/diagnostics/asset_not_string_test.dart b/pkg/analyzer/test/src/pubspec/diagnostics/asset_not_string_test.dart
index dd68fb2..298d360 100644
--- a/pkg/analyzer/test/src/pubspec/diagnostics/asset_not_string_test.dart
+++ b/pkg/analyzer/test/src/pubspec/diagnostics/asset_not_string_test.dart
@@ -36,7 +36,7 @@
   }
 
   test_assetNotString_noError() {
-    newFile('/sample/assets/my_icon.png');
+    newFile2('/sample/assets/my_icon.png', '');
     assertNoErrors('''
 name: sample
 flutter:
diff --git a/pkg/analyzer/test/src/pubspec/diagnostics/flutter_field_not_map_test.dart b/pkg/analyzer/test/src/pubspec/diagnostics/flutter_field_not_map_test.dart
index 85f587b..09e5955 100644
--- a/pkg/analyzer/test/src/pubspec/diagnostics/flutter_field_not_map_test.dart
+++ b/pkg/analyzer/test/src/pubspec/diagnostics/flutter_field_not_map_test.dart
@@ -36,7 +36,7 @@
   }
 
   test_flutterFieldNotMap_noError() {
-    newFile('/sample/assets/my_icon.png');
+    newFile2('/sample/assets/my_icon.png', '');
     assertNoErrors('''
 name: sample
 flutter:
diff --git a/pkg/analyzer/test/src/services/available_declarations_test.dart b/pkg/analyzer/test/src/services/available_declarations_test.dart
index 8626c96..ded4f5a 100644
--- a/pkg/analyzer/test/src/services/available_declarations_test.dart
+++ b/pkg/analyzer/test/src/services/available_declarations_test.dart
@@ -66,7 +66,7 @@
         buffer.writeln('    - $experiment');
       }
     }
-    newFile(analysisOptionsPath, content: buffer.toString());
+    newFile2(analysisOptionsPath, buffer.toString());
 
     createAnalysisContexts();
   }
@@ -99,7 +99,7 @@
   ) {
     newPackageConfigJsonFile(
       directoryPath,
-      content: config.toContent(
+      config.toContent(
         toUriStr: toUriStr,
       ),
     );
@@ -121,7 +121,7 @@
 @reflectiveTest
 class AvailableDeclarationsTest extends _Base {
   test_changesStream_noDuplicates() async {
-    newFile('/home/aaa/lib/a.dart', content: 'class A {}');
+    newFile2('/home/aaa/lib/a.dart', 'class A {}');
 
     newPubspecYamlFile('/home/bbb', r'''
 dependencies:
@@ -131,7 +131,7 @@
       '/home/bbb',
       PackageConfigFileBuilder()..add(name: 'aaa', rootPath: '/home/aaa'),
     );
-    newFile('/home/bbb/lib/b.dart', content: 'class B {}');
+    newFile2('/home/bbb/lib/b.dart', 'class B {}');
 
     newPubspecYamlFile('/home/ccc', r'''
 dependencies:
@@ -141,7 +141,7 @@
       '/home/ccc',
       PackageConfigFileBuilder()..add(name: 'aaa', rootPath: '/home/aaa'),
     );
-    newFile('/home/ccc/lib/c.dart', content: 'class C {}');
+    newFile2('/home/ccc/lib/c.dart', 'class C {}');
 
     createAnalysisContexts();
 
@@ -166,7 +166,7 @@
   }
 
   test_discardContexts() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class A {}
 ''');
 
@@ -189,7 +189,7 @@
   }
 
   test_getContext() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 ''');
@@ -198,7 +198,7 @@
   }
 
   test_getLibrary() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -212,7 +212,7 @@
   }
 
   test_getLibrary_export_notExisting() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 export 'b.dart';
 class A {}
 ''');
@@ -231,7 +231,7 @@
       convertPath('/home/test/lib'),
     );
 
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 export 'foo/a.dart';
 class A {}
 ''');
@@ -245,13 +245,13 @@
   }
 
   test_readByteStore() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart' show A;
 part 'b.dart';
 class C {}
@@ -296,10 +296,10 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part 'a.dart';
 class B {}
 ''');
@@ -316,7 +316,7 @@
       ]),
     ]);
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A2 {}
 ''');
     tracker.changeFile(a);
@@ -342,15 +342,15 @@
     var c = convertPath('/home/test/lib/c.dart');
     var d = convertPath('/home/test/lib/d.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 export 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 export 'c.dart';
 class B {}
 ''');
-    newFile(d, content: r'''
+    newFile2(d, r'''
 class D {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -376,7 +376,7 @@
       ]),
     ]);
 
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
     tracker.changeFile(c);
@@ -417,7 +417,7 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 ''');
     var declarationsContext = tracker.addContext(testAnalysisContext);
@@ -430,7 +430,7 @@
     ]);
     _assertHasNoLibrary('package:test/b.dart');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class B {}
 ''');
     tracker.changeFile(b);
@@ -461,11 +461,11 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 class A {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -483,7 +483,7 @@
       ]),
     ]);
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B {}
 ''');
@@ -509,7 +509,7 @@
   test_added_part_withoutLibrary() async {
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 ''');
     tracker.changeFile(b);
@@ -531,7 +531,7 @@
     tracker.addContext(testContext);
     await _doAllTrackerWork();
 
-    newFile(filePath, content: 'class A {}');
+    newFile2(filePath, 'class A {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -546,7 +546,7 @@
       relevanceTags: ['ElementKind.CLASS', 'package:test/test.dart::A'],
     );
 
-    newFile(filePath, content: 'class B {}');
+    newFile2(filePath, 'class B {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -583,7 +583,7 @@
     tracker.addContext(testContext);
     await _doAllTrackerWork();
 
-    newFile(filePath, content: 'class A {}');
+    newFile2(filePath, 'class A {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -598,7 +598,7 @@
       relevanceTags: ['ElementKind.CLASS', 'package:aaa/a.dart::A'],
     );
 
-    newFile(filePath, content: 'class B {}');
+    newFile2(filePath, 'class B {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -620,7 +620,7 @@
     tracker.addContext(testAnalysisContext);
     await _doAllTrackerWork();
 
-    newFile(filePath, content: 'class A {}');
+    newFile2(filePath, 'class A {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -635,7 +635,7 @@
       relevanceTags: ['ElementKind.CLASS', 'dart:math::A'],
     );
 
-    newFile(filePath, content: 'class B {}');
+    newFile2(filePath, 'class B {}');
     uriToLibrary.clear();
     tracker.changeFile(filePath);
     await _doAllTrackerWork();
@@ -657,18 +657,18 @@
     var c = convertPath('/home/test/lib/c.dart');
     var d = convertPath('/home/test/lib/d.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 export 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 export 'c.dart';
 class B {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
-    newFile(d, content: r'''
+    newFile2(d, r'''
 class D {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -733,8 +733,8 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: '');
-    newFile(b, content: '');
+    newFile2(a, '');
+    newFile2(b, '');
     tracker.addContext(testAnalysisContext);
 
     await _doAllTrackerWork();
@@ -753,10 +753,10 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 ''');
     tracker.addContext(testAnalysisContext);
@@ -778,15 +778,15 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -825,7 +825,7 @@
   test_deleted_part_withoutLibrary() async {
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 ''');
     tracker.addContext(testAnalysisContext);
@@ -841,18 +841,18 @@
     var c = convertPath('/home/test/lib/c.dart');
     var d = convertPath('/home/test/lib/d.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 export 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 export 'c.dart';
 class B {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
-    newFile(d, content: r'''
+    newFile2(d, r'''
 class D {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -888,7 +888,7 @@
       ]),
     ]);
 
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C2 {}
 ''');
     tracker.changeFile(c);
@@ -931,13 +931,13 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class B {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 export 'a.dart';
 export 'b.dart';
 class C {}
@@ -959,10 +959,10 @@
 
     changes.clear();
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A2 {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class B2 {}
 ''');
     tracker.changeFile(a);
@@ -998,10 +998,10 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 class B {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -1018,7 +1018,7 @@
       ]),
     ]);
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A2 {}
 ''');
     tracker.changeFile(a);
@@ -1041,11 +1041,11 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B {}
 ''');
@@ -1067,7 +1067,7 @@
       relevanceTags: ['ElementKind.CLASS', 'package:test/a.dart::B'],
     );
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 class A2 {}
 ''');
@@ -1093,7 +1093,7 @@
   test_updated_library_to_part() async {
     var a = convertPath('/home/test/lib/a.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -1105,7 +1105,7 @@
       ]),
     ]);
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part of nothing;
 class A {}
 ''');
@@ -1113,7 +1113,7 @@
     await _doAllTrackerWork();
     _assertHasNoLibrary('package:test/a.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 class A2 {}
 ''');
     tracker.changeFile(a);
@@ -1130,15 +1130,15 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B {}
 ''');
-    newFile(c, content: r'''
+    newFile2(c, r'''
 class C {}
 ''');
     tracker.addContext(testAnalysisContext);
@@ -1158,7 +1158,7 @@
       ]),
     ]);
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B2 {}
 ''');
@@ -1184,11 +1184,11 @@
     var a = convertPath('/home/test/lib/a.dart');
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part of unknown;
 class A {}
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 export 'a.dart';
 class B {}
 ''');
@@ -1202,7 +1202,7 @@
       ]),
     ]);
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part of unknown;
 class A2 {}
 ''');
@@ -1219,7 +1219,7 @@
   test_updated_part_withoutLibrary() async {
     var b = convertPath('/home/test/lib/b.dart');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B {}
 ''');
@@ -1229,7 +1229,7 @@
     _assertHasNoLibrary('package:test/a.dart');
     _assertHasNoLibrary('package:test/b.dart');
 
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 class B2 {}
 ''');
@@ -1244,7 +1244,7 @@
 @reflectiveTest
 class DartdocInfoTest extends _Base {
   test_samePackage() async {
-    File file = newFile('/home/aaa/lib/definition.dart', content: '''
+    File file = newFile2('/home/aaa/lib/definition.dart', '''
 /// {@template foo}
 /// Body of the template.
 /// {@endtemplate}
@@ -1273,7 +1273,7 @@
 @reflectiveTest
 class DeclarationTest extends _Base {
   test_CLASS() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class A {}
 
 abstract class B {}
@@ -1323,7 +1323,7 @@
   }
 
   test_class_FIELD() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {
   static int f1 = 0;
 
@@ -1428,7 +1428,7 @@
   }
 
   test_class_GETTER() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {
   static int get g1 => 0;
 
@@ -1485,7 +1485,7 @@
   }
 
   test_class_METHOD() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {
   static void m1() {}
 
@@ -1573,7 +1573,7 @@
   }
 
   test_class_SETTER() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {
   static set s1(int value) {}
 
@@ -1642,7 +1642,7 @@
   }
 
   test_CLASS_TYPE_ALIAS() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 mixin M {}
 
 class A = Object with M;
@@ -1684,7 +1684,7 @@
   }
 
   test_CONSTRUCTOR() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {
   int f1;
   int f2;
@@ -1789,7 +1789,7 @@
   }
 
   test_ENUM() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 enum A {v}
 
 @deprecated
@@ -1829,7 +1829,7 @@
   }
 
   test_ENUM_CONSTANT() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 enum MyEnum {
   a,
 
@@ -1886,7 +1886,7 @@
 
   test_EXTENSION() async {
     createAnalysisOptionsFile(experiments: [EnableString.extension_methods]);
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 extension A on String {}
 
 extension on String {}
@@ -1929,7 +1929,7 @@
   }
 
   test_FUNCTION() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 void a() {}
 
 @deprecated
@@ -2013,7 +2013,7 @@
   }
 
   test_FUNCTION_defaultArgumentList() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 void a() {}
 
 void b(int a, double bb, String ccc) {}
@@ -2080,7 +2080,7 @@
   }
 
   test_FUNCTION_TYPE_ALIAS() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 typedef A = void Function();
 
 @deprecated
@@ -2193,7 +2193,7 @@
   }
 
   test_FUNCTION_TYPE_ALIAS_noFunction() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 typedef A = ;
 ''');
 
@@ -2205,7 +2205,7 @@
   }
 
   test_FUNCTION_TYPE_ALIAS_old() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 typedef void A();
 
 @deprecated
@@ -2318,7 +2318,7 @@
   }
 
   test_GETTER() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 int get a => 0;
 
 @deprecated
@@ -2361,12 +2361,12 @@
   }
 
   test_library_isDeprecated() async {
-    newFile('/home/test/lib/a.dart', content: '');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', '');
+    newFile2('/home/test/lib/b.dart', r'''
 @deprecated
 library my.lib;
 ''');
-    newFile('/home/test/lib/c.dart', content: r'''
+    newFile2('/home/test/lib/c.dart', r'''
 @Deprecated('description')
 library my.lib;
 ''');
@@ -2380,7 +2380,7 @@
   }
 
   test_library_partDirective_empty() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 part ' ';
 
 class A {}
@@ -2399,7 +2399,7 @@
   }
 
   test_library_partDirective_incomplete() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 part
 
 class A {}
@@ -2418,15 +2418,15 @@
   }
 
   test_library_parts() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 part of 'test.dart';
 class A {}
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 part of 'test.dart';
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 part 'a.dart';
 part 'b.dart';
 class C {}
@@ -2448,12 +2448,12 @@
   }
 
   test_library_publicOnly() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 part of 'test.dart';
 class A {}
 class _A {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 part 'a.dart';
 class B {}
 class _B {}
@@ -2472,12 +2472,12 @@
   }
 
   test_library_publicOnly_enum() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 part of 'test.dart';
 enum A {a, _a}
 enum _A {a, _a}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 part 'a.dart';
 enum B {b, _b}
 enum _B {b, _b}
@@ -2501,7 +2501,7 @@
 
 class B {}
 ''';
-    var testPath = newFile('/home/test/lib/test.dart', content: code).path;
+    var testPath = newFile2('/home/test/lib/test.dart', code).path;
 
     tracker.addContext(testAnalysisContext);
     await _doAllTrackerWork();
@@ -2530,7 +2530,7 @@
   }
 
   test_MIXIN() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 mixin A {}
 
 @deprecated
@@ -2571,7 +2571,7 @@
   }
 
   test_SETTER() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 set a(int value) {}
 
 @deprecated
@@ -2623,7 +2623,7 @@
   }
 
   test_TYPE_ALIAS() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 typedef A = double;
 
 @deprecated
@@ -2678,7 +2678,7 @@
   }
 
   test_VARIABLE() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 int a;
 
 @deprecated
@@ -2748,7 +2748,7 @@
 @reflectiveTest
 class ExportTest extends _Base {
   test_classTypeAlias() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 mixin M {}
 class A = Object with M;
 ''');
@@ -2762,12 +2762,12 @@
   }
 
   test_combinators_hide() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 class C {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart' hide B;
 class D {}
 ''');
@@ -2788,12 +2788,12 @@
   }
 
   test_combinators_show() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 class C {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart' show B;
 class D {}
 ''');
@@ -2811,11 +2811,11 @@
   }
 
   test_combinators_show_enum() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 enum E1 {a}
 enum E2 {b}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart' show E1;
 ''');
     tracker.addContext(testAnalysisContext);
@@ -2829,15 +2829,15 @@
   }
 
   test_cycle() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 export 'b.dart';
 class A {}
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'b.dart';
 class C {}
 ''');
@@ -2877,7 +2877,7 @@
   }
 
   test_enum() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 enum E1 {a, b}
 enum E2 {a, b}
 ''');
@@ -2897,7 +2897,7 @@
   }
 
   test_function() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 int foo() => 0;
 int bar() => 0;
 ''');
@@ -2911,7 +2911,7 @@
   }
 
   test_functionTypeAlias() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 typedef F = int Function();
 ''');
     tracker.addContext(testAnalysisContext);
@@ -2923,7 +2923,7 @@
   }
 
   test_missing() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart';
 class C {}
 ''');
@@ -2938,14 +2938,14 @@
   }
 
   test_sequence() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'b.dart';
 class C {}
 ''');
@@ -2982,11 +2982,11 @@
   }
 
   test_shadowedByLocal() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart';
 
 mixin B {}
@@ -3003,11 +3003,11 @@
   }
 
   test_simple() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 ''');
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 export 'a.dart';
 class C {}
 ''');
@@ -3028,7 +3028,7 @@
   }
 
   test_variable() async {
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 int foo = 0;
 ''');
     tracker.addContext(testAnalysisContext);
@@ -3047,9 +3047,9 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a);
-    newFile(b);
-    newFile(c);
+    newFile2(a, '');
+    newFile2(b, '');
+    newFile2(c, '');
 
     var context = tracker.addContext(testAnalysisContext);
     await _doAllTrackerWork();
@@ -3078,13 +3078,13 @@
     var b = convertPath('/home/test/lib/b.dart');
     var c = convertPath('/home/test/lib/c.dart');
 
-    newFile(a, content: r'''
+    newFile2(a, r'''
 part 'b.dart';
 ''');
-    newFile(b, content: r'''
+    newFile2(b, r'''
 part of 'a.dart';
 ''');
-    newFile(c);
+    newFile2(c, '');
 
     var context = tracker.addContext(testAnalysisContext);
     await _doAllTrackerWork();
@@ -3100,14 +3100,14 @@
   }
 
   test_pub() async {
-    newFile('/home/aaa/lib/a.dart', content: 'class A {}');
-    newFile('/home/aaa/lib/src/a2.dart', content: 'class A2 {}');
+    newFile2('/home/aaa/lib/a.dart', 'class A {}');
+    newFile2('/home/aaa/lib/src/a2.dart', 'class A2 {}');
 
-    newFile('/home/bbb/lib/b.dart', content: 'class B {}');
-    newFile('/home/bbb/lib/src/b2.dart', content: 'class B2 {}');
+    newFile2('/home/bbb/lib/b.dart', 'class B {}');
+    newFile2('/home/bbb/lib/src/b2.dart', 'class B2 {}');
 
-    newFile('/home/ccc/lib/c.dart', content: 'class C {}');
-    newFile('/home/ccc/lib/src/c2.dart', content: 'class C2 {}');
+    newFile2('/home/ccc/lib/c.dart', 'class C {}');
+    newFile2('/home/ccc/lib/src/c2.dart', 'class C2 {}');
 
     newPubspecYamlFile('/home/test', r'''
 name: test
@@ -3116,10 +3116,10 @@
 dev_dependencies:
   bbb: any
 ''');
-    newFile('/home/test/lib/t.dart', content: 'class T {}');
-    newFile('/home/test/lib/src/t2.dart', content: 'class T2 {}');
-    newFile('/home/test/bin/t3.dart', content: 'class T3 {}');
-    newFile('/home/test/test/t4.dart', content: 'class T4 {}');
+    newFile2('/home/test/lib/t.dart', 'class T {}');
+    newFile2('/home/test/lib/src/t2.dart', 'class T2 {}');
+    newFile2('/home/test/bin/t3.dart', 'class T3 {}');
+    newFile2('/home/test/test/t4.dart', 'class T4 {}');
 
     newPubspecYamlFile('/home/test/samples/basic', r'''
 name: test
@@ -3127,7 +3127,7 @@
   ccc: any
   test: any
 ''');
-    newFile('/home/test/samples/basic/lib/s.dart', content: 'class S {}');
+    newFile2('/home/test/samples/basic/lib/s.dart', 'class S {}');
 
     writeTestPackageConfig(
       PackageConfigFileBuilder()
@@ -3283,7 +3283,7 @@
   }
 
   test_sdk_excludesPrivate() async {
-    newFile('/home/test/lib/test.dart', content: '');
+    newFile2('/home/test/lib/test.dart', '');
 
     var context = tracker.addContext(testAnalysisContext);
     await _doAllTrackerWork();
@@ -3297,15 +3297,15 @@
   }
 
   test_setDependencies() async {
-    newFile('/home/aaa/lib/a.dart', content: r'''
+    newFile2('/home/aaa/lib/a.dart', r'''
 export 'src/a2.dart' show A2;
 class A1 {}
 ''');
-    newFile('/home/aaa/lib/src/a2.dart', content: r'''
+    newFile2('/home/aaa/lib/src/a2.dart', r'''
 class A2 {}
 class A3 {}
 ''');
-    newFile('/home/bbb/lib/b.dart', content: r'''
+    newFile2('/home/bbb/lib/b.dart', r'''
 class B {}
 ''');
 
@@ -3315,9 +3315,9 @@
         ..add(name: 'bbb', rootPath: '/home/bbb'),
     );
 
-    newFile('/home/test/lib/t.dart', content: 'class T {}');
-    newFile('/home/test/lib/src/t2.dart', content: 'class T2 {}');
-    newFile('/home/test/test/t3.dart', content: 'class T3 {}');
+    newFile2('/home/test/lib/t.dart', 'class T {}');
+    newFile2('/home/test/lib/src/t2.dart', 'class T2 {}');
+    newFile2('/home/test/test/t3.dart', 'class T3 {}');
 
     var context = tracker.addContext(testAnalysisContext);
     context.setDependencies({
@@ -3410,10 +3410,10 @@
   }
 
   test_setDependencies_twice() async {
-    newFile('/home/aaa/lib/a.dart', content: r'''
+    newFile2('/home/aaa/lib/a.dart', r'''
 class A {}
 ''');
-    newFile('/home/bbb/lib/b.dart', content: r'''
+    newFile2('/home/bbb/lib/b.dart', r'''
 class B {}
 ''');
 
@@ -3423,7 +3423,7 @@
         ..add(name: 'bbb', rootPath: '/home/bbb'),
     );
 
-    newFile('/home/test/lib/test.dart', content: r'''
+    newFile2('/home/test/lib/test.dart', r'''
 class C {}
 ''');
 
@@ -3488,9 +3488,9 @@
     var b = convertPath('/home/test/bin/b.dart');
     var c = convertPath('/home/test/bin/c.dart');
 
-    newFile(a, content: 'class A {}');
-    newFile(b, content: 'class B {}');
-    newFile(c, content: 'class C {}');
+    newFile2(a, 'class A {}');
+    newFile2(b, 'class B {}');
+    newFile2(c, 'class C {}');
     await testAnalysisContext.currentSession.getFile2(a);
     await testAnalysisContext.currentSession.getFile2(b);
     await testAnalysisContext.currentSession.getFile2(c);
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 869a97a..43204fb 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -267,6 +267,7 @@
   void _writeClassElement(ClassElement e) {
     _writeIndentedLine(() {
       _writeIf(e.isAbstract && !e.isMixin, 'abstract ');
+      _writeIf(e.isMacro, 'macro ');
       _writeIf(!e.isSimplyBounded, 'notSimplyBounded ');
 
       if (e.isEnum) {
@@ -923,3 +924,10 @@
 
   _Replacement(this.offset, this.end, this.text);
 }
+
+extension on ClassElement {
+  bool get isMacro {
+    final self = this;
+    return self is ClassElementImpl && self.isMacro;
+  }
+}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/elements_base.dart
similarity index 78%
rename from pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
rename to pkg/analyzer/test/src/summary/elements_base.dart
index 60ab80c..5404c18 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/elements_base.dart
@@ -1,53 +1,68 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:typed_data';
 
+import 'package:analyzer/dart/analysis/declared_variables.dart';
 import 'package:analyzer/dart/analysis/features.dart';
 import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/context/context.dart';
 import 'package:analyzer/src/dart/analysis/session.dart';
 import 'package:analyzer/src/dart/element/class_hierarchy.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
+import 'package:analyzer/src/dart/sdk/sdk.dart';
 import 'package:analyzer/src/generated/engine.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/generated/utilities_dart.dart';
+import 'package:analyzer/src/source/package_map_resolver.dart';
 import 'package:analyzer/src/summary2/bundle_reader.dart';
 import 'package:analyzer/src/summary2/informative_data.dart';
 import 'package:analyzer/src/summary2/link.dart';
 import 'package:analyzer/src/summary2/linked_element_factory.dart';
 import 'package:analyzer/src/summary2/reference.dart';
+import 'package:analyzer/src/test_utilities/mock_sdk.dart';
+import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
 import 'package:analyzer/src/util/uri.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../../util/feature_sets.dart';
-import 'element_text.dart';
-import 'resynthesize_common.dart';
 import 'test_strategies.dart';
 
-main() {
-  defineReflectiveSuite(() {
-    defineReflectiveTests(ResynthesizeAstKeepLinkingTest);
-    defineReflectiveTests(ResynthesizeAstFromBytesTest);
-    // defineReflectiveTests(ApplyCheckElementTextReplacements);
-  });
-}
-
+/// A base for testing building elements.
 @reflectiveTest
-class ApplyCheckElementTextReplacements {
-  test_applyReplacements() {
-    applyCheckElementTextReplacements();
-  }
-}
-
-@reflectiveTest
-abstract class ResynthesizeAst2Test extends AbstractResynthesizeTest
-    with ResynthesizeTestCases {
+abstract class ElementsBaseTest with ResourceProviderMixin {
   /// The shared SDK bundle, computed once and shared among test invocations.
   static _SdkBundle? _sdkBundle;
 
+  /// The set of features enabled in this test.
+  FeatureSet featureSet = FeatureSets.latestWithExperiments;
+
+  DeclaredVariables declaredVariables = DeclaredVariables();
+  late final SourceFactory sourceFactory;
+  late final FolderBasedDartSdk sdk;
+
+  ElementsBaseTest() {
+    var sdkRoot = newFolder('/sdk');
+    createMockSdk(
+      resourceProvider: resourceProvider,
+      root: sdkRoot,
+    );
+    sdk = FolderBasedDartSdk(resourceProvider, sdkRoot);
+
+    sourceFactory = SourceFactory([
+      DartUriResolver(sdk),
+      PackageMapUriResolver(resourceProvider, {
+        'test': [
+          getFolder('/home/test/lib'),
+        ],
+      }),
+      ResourceUriResolver(resourceProvider),
+    ]);
+  }
+
   /// We need to test both cases - when we keep linking libraries (happens for
   /// new or invalidated libraries), and when we load libraries from bytes
   /// (happens internally in Blaze or when we have cached summaries).
@@ -94,13 +109,27 @@
     );
   }
 
-  @override
-  Future<LibraryElementImpl> checkLibrary(String text,
-      {bool allowErrors = false, bool dumpSummaries = false}) async {
-    var source = addTestSource(text);
+  String get testFilePath => '$testPackageLibPath/test.dart';
+
+  String get testPackageLibPath => '$testPackageRootPath/lib';
+
+  String get testPackageRootPath => '/home/test';
+
+  void addSource(String path, String contents) {
+    newFile2(path, contents);
+  }
+
+  Future<LibraryElementImpl> buildLibrary(
+    String text, {
+    bool allowErrors = false,
+    bool dumpSummaries = false,
+  }) async {
+    var testFile = newFile2(testFilePath, text);
+    var testUri = sourceFactory.pathToUri(testFile.path)!;
+    var testSource = sourceFactory.forUri2(testUri)!;
 
     var inputLibraries = <LinkInputLibrary>[];
-    _addNonDartLibraries({}, inputLibraries, source);
+    _addNonDartLibraries({}, inputLibraries, testSource);
 
     var unitsInformativeBytes = <Uri, Uint8List>{};
     for (var inputLibrary in inputLibraries) {
@@ -146,11 +175,7 @@
       );
     }
 
-    return elementFactory.libraryOfUri2('${source.uri}');
-  }
-
-  void setUp() {
-    featureSet = FeatureSets.latestWithExperiments;
+    return elementFactory.libraryOfUri2('$testUri');
   }
 
   void _addLibraryUnits(
@@ -264,18 +289,6 @@
   }
 }
 
-@reflectiveTest
-class ResynthesizeAstFromBytesTest extends ResynthesizeAst2Test {
-  @override
-  bool get keepLinkingLibraries => false;
-}
-
-@reflectiveTest
-class ResynthesizeAstKeepLinkingTest extends ResynthesizeAst2Test {
-  @override
-  bool get keepLinkingLibraries => true;
-}
-
 class _AnalysisSessionForLinking implements AnalysisSessionImpl {
   @override
   final ClassHierarchy classHierarchy = ClassHierarchy();
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/elements_test.dart
similarity index 93%
rename from pkg/analyzer/test/src/summary/resynthesize_common.dart
rename to pkg/analyzer/test/src/summary/elements_test.dart
index edd5540..c9ce53b 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/elements_test.dart
@@ -1,97 +1,49 @@
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analyzer/dart/analysis/declared_variables.dart';
-import 'package:analyzer/dart/analysis/features.dart';
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
-import 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/dart/sdk/sdk.dart';
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/source/package_map_resolver.dart';
-import 'package:analyzer/src/test_utilities/mock_sdk.dart';
-import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../../util/feature_sets.dart';
 import 'element_text.dart';
+import 'elements_base.dart';
 
-/// Abstract base class for resynthesizing and comparing elements.
-///
-/// The return type separator: →
-abstract class AbstractResynthesizeTest with ResourceProviderMixin {
-  /// The set of features enabled in this test.
-  late FeatureSet featureSet;
-
-  DeclaredVariables declaredVariables = DeclaredVariables();
-  late final SourceFactory sourceFactory;
-  late final FolderBasedDartSdk sdk;
-
-  late Source testSource;
-  Set<Source> otherLibrarySources = <Source>{};
-
-  AbstractResynthesizeTest() {
-    var sdkRoot = newFolder('/sdk');
-    createMockSdk(
-      resourceProvider: resourceProvider,
-      root: sdkRoot,
-    );
-    sdk = FolderBasedDartSdk(resourceProvider, sdkRoot);
-
-    sourceFactory = SourceFactory(
-      [
-        DartUriResolver(sdk),
-        PackageMapUriResolver(resourceProvider, {
-          'test': [
-            getFolder('/home/test/lib'),
-          ],
-        }),
-        ResourceUriResolver(resourceProvider),
-      ],
-    );
-  }
-
-  String get testFilePath => '$testPackageLibPath/test.dart';
-
-  String get testPackageLibPath => '$testPackageRootPath/lib';
-
-  String get testPackageRootPath => '/home/test';
-
-  void addLibrary(String uri) {
-    var source = sourceFactory.forUri(uri)!;
-    otherLibrarySources.add(source);
-  }
-
-  Source addLibrarySource(String filePath, String contents) {
-    var source = addSource(filePath, contents);
-    otherLibrarySources.add(source);
-    return source;
-  }
-
-  Source addSource(String path, String contents) {
-    var file = newFile(path, content: contents);
-    var uri = sourceFactory.pathToUri(file.path)!;
-    return sourceFactory.forUri2(uri)!;
-  }
-
-  Source addTestSource(String code, [Uri? uri]) {
-    testSource = addSource(testFilePath, code);
-    return testSource;
-  }
-
-  Future<LibraryElementImpl> checkLibrary(String text,
-      {bool allowErrors = false});
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(ElementsKeepLinkingTest);
+    defineReflectiveTests(ElementsFromBytesTest);
+    // defineReflectiveTests(ApplyCheckElementTextReplacements);
+  });
 }
 
-/// Mixin containing test cases exercising summary resynthesis.  Intended to be
-/// applied to a class implementing [AbstractResynthesizeTest].
-mixin ResynthesizeTestCases on AbstractResynthesizeTest {
+@reflectiveTest
+class ApplyCheckElementTextReplacements {
+  test_applyReplacements() {
+    applyCheckElementTextReplacements();
+  }
+}
+
+@reflectiveTest
+class ElementsFromBytesTest extends ElementsTest {
+  @override
+  bool get keepLinkingLibraries => false;
+}
+
+@reflectiveTest
+class ElementsKeepLinkingTest extends ElementsTest {
+  @override
+  bool get keepLinkingLibraries => true;
+}
+
+abstract class ElementsTest extends ElementsBaseTest {
   test_class_abstract() async {
-    var library = await checkLibrary('abstract class C {}');
+    var library = await buildLibrary('abstract class C {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -103,7 +55,7 @@
   }
 
   test_class_constructor_const() async {
-    var library = await checkLibrary('class C { const C(); }');
+    var library = await buildLibrary('class C { const C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -115,7 +67,7 @@
   }
 
   test_class_constructor_const_external() async {
-    var library = await checkLibrary('class C { external const C(); }');
+    var library = await buildLibrary('class C { external const C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -127,7 +79,7 @@
   }
 
   test_class_constructor_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   /**
    * Docs
@@ -146,7 +98,7 @@
   }
 
   test_class_constructor_explicit_named() async {
-    var library = await checkLibrary('class C { C.foo(); }');
+    var library = await buildLibrary('class C { C.foo(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -160,7 +112,7 @@
   }
 
   test_class_constructor_explicit_type_params() async {
-    var library = await checkLibrary('class C<T, U> { C(); }');
+    var library = await buildLibrary('class C<T, U> { C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -177,7 +129,7 @@
   }
 
   test_class_constructor_explicit_unnamed() async {
-    var library = await checkLibrary('class C { C(); }');
+    var library = await buildLibrary('class C { C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -189,7 +141,7 @@
   }
 
   test_class_constructor_external() async {
-    var library = await checkLibrary('class C { external C(); }');
+    var library = await buildLibrary('class C { external C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -201,7 +153,7 @@
   }
 
   test_class_constructor_factory() async {
-    var library = await checkLibrary('class C { factory C() => throw 0; }');
+    var library = await buildLibrary('class C { factory C() => throw 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -214,7 +166,7 @@
 
   test_class_constructor_field_formal_dynamic_dynamic() async {
     var library =
-        await checkLibrary('class C { dynamic x; C(dynamic this.x); }');
+        await buildLibrary('class C { dynamic x; C(dynamic this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -241,7 +193,7 @@
   }
 
   test_class_constructor_field_formal_dynamic_typed() async {
-    var library = await checkLibrary('class C { dynamic x; C(int this.x); }');
+    var library = await buildLibrary('class C { dynamic x; C(int this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -268,7 +220,7 @@
   }
 
   test_class_constructor_field_formal_dynamic_untyped() async {
-    var library = await checkLibrary('class C { dynamic x; C(this.x); }');
+    var library = await buildLibrary('class C { dynamic x; C(this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -295,7 +247,7 @@
   }
 
   test_class_constructor_field_formal_functionTyped_noReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   var x;
   C(this.x(double b));
@@ -330,7 +282,7 @@
   }
 
   test_class_constructor_field_formal_functionTyped_withReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   var x;
   C(int this.x(double b));
@@ -365,7 +317,7 @@
   }
 
   test_class_constructor_field_formal_functionTyped_withReturnType_generic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   Function() f;
   C(List<U> this.f<T, U>(T t));
@@ -404,7 +356,7 @@
 
   test_class_constructor_field_formal_multiple_matching_fields() async {
     // This is a compile-time error but it should still analyze consistently.
-    var library = await checkLibrary('class C { C(this.x); int x; String x; }',
+    var library = await buildLibrary('class C { C(this.x); int x; String x; }',
         allowErrors: true);
     checkElementText(library, r'''
 library
@@ -443,7 +395,7 @@
   test_class_constructor_field_formal_no_matching_field() async {
     // This is a compile-time error but it should still analyze consistently.
     var library =
-        await checkLibrary('class C { C(this.x); }', allowErrors: true);
+        await buildLibrary('class C { C(this.x); }', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -459,7 +411,7 @@
   }
 
   test_class_constructor_field_formal_typed_dynamic() async {
-    var library = await checkLibrary('class C { num x; C(dynamic this.x); }',
+    var library = await buildLibrary('class C { num x; C(dynamic this.x); }',
         allowErrors: true);
     checkElementText(library, r'''
 library
@@ -487,7 +439,7 @@
   }
 
   test_class_constructor_field_formal_typed_typed() async {
-    var library = await checkLibrary('class C { num x; C(int this.x); }');
+    var library = await buildLibrary('class C { num x; C(int this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -514,7 +466,7 @@
   }
 
   test_class_constructor_field_formal_typed_untyped() async {
-    var library = await checkLibrary('class C { num x; C(this.x); }');
+    var library = await buildLibrary('class C { num x; C(this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -541,7 +493,7 @@
   }
 
   test_class_constructor_field_formal_untyped_dynamic() async {
-    var library = await checkLibrary('class C { var x; C(dynamic this.x); }');
+    var library = await buildLibrary('class C { var x; C(dynamic this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -568,7 +520,7 @@
   }
 
   test_class_constructor_field_formal_untyped_typed() async {
-    var library = await checkLibrary('class C { var x; C(int this.x); }');
+    var library = await buildLibrary('class C { var x; C(int this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -595,7 +547,7 @@
   }
 
   test_class_constructor_field_formal_untyped_untyped() async {
-    var library = await checkLibrary('class C { var x; C(this.x); }');
+    var library = await buildLibrary('class C { var x; C(this.x); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -622,7 +574,7 @@
   }
 
   test_class_constructor_fieldFormal_named_noDefault() async {
-    var library = await checkLibrary('class C { int x; C({this.x}); }');
+    var library = await buildLibrary('class C { int x; C({this.x}); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -649,7 +601,7 @@
   }
 
   test_class_constructor_fieldFormal_named_withDefault() async {
-    var library = await checkLibrary('class C { int x; C({this.x: 42}); }');
+    var library = await buildLibrary('class C { int x; C({this.x: 42}); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -680,7 +632,7 @@
   }
 
   test_class_constructor_fieldFormal_optional_noDefault() async {
-    var library = await checkLibrary('class C { int x; C([this.x]); }');
+    var library = await buildLibrary('class C { int x; C([this.x]); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -707,7 +659,7 @@
   }
 
   test_class_constructor_fieldFormal_optional_withDefault() async {
-    var library = await checkLibrary('class C { int x; C([this.x = 42]); }');
+    var library = await buildLibrary('class C { int x; C([this.x = 42]); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -738,7 +690,7 @@
   }
 
   test_class_constructor_implicit_type_params() async {
-    var library = await checkLibrary('class C<T, U> {}');
+    var library = await buildLibrary('class C<T, U> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -755,7 +707,7 @@
   }
 
   test_class_constructor_initializers_assertInvocation() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C(int x) : assert(x >= 42);
 }
@@ -791,7 +743,7 @@
   }
 
   test_class_constructor_initializers_assertInvocation_message() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C(int x) : assert(x >= 42, 'foo');
 }
@@ -830,7 +782,7 @@
   }
 
   test_class_constructor_initializers_field() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x;
   const C() : x = 42;
@@ -863,7 +815,7 @@
   }
 
   test_class_constructor_initializers_field_notConst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x;
   const C() : x = foo();
@@ -908,7 +860,7 @@
   }
 
   test_class_constructor_initializers_field_optionalPositionalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   final int _f;
   const A([int f = 0]) : _f = f;
@@ -949,7 +901,7 @@
   }
 
   test_class_constructor_initializers_field_withParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x;
   const C(int p) : x = 1 + p;
@@ -994,7 +946,7 @@
   }
 
   test_class_constructor_initializers_genericFunctionType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A();
 }
@@ -1065,7 +1017,7 @@
   }
 
   test_class_constructor_initializers_superInvocation_argumentContextType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(List<String> values);
 }
@@ -1105,7 +1057,7 @@
   }
 
   test_class_constructor_initializers_superInvocation_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A.aaa(int p);
 }
@@ -1150,7 +1102,7 @@
   }
 
   test_class_constructor_initializers_superInvocation_named_underscore() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A._();
 }
@@ -1188,7 +1140,7 @@
   }
 
   test_class_constructor_initializers_superInvocation_namedExpression() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A.aaa(a, {int b});
 }
@@ -1245,7 +1197,7 @@
   }
 
   test_class_constructor_initializers_superInvocation_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(int p);
 }
@@ -1285,7 +1237,7 @@
   }
 
   test_class_constructor_initializers_thisInvocation_argumentContextType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(List<String> values);
   const A.empty() : this(const []);
@@ -1322,7 +1274,7 @@
   }
 
   test_class_constructor_initializers_thisInvocation_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C() : this.named(1, 'bbb');
   const C.named(int a, String b);
@@ -1366,7 +1318,7 @@
   }
 
   test_class_constructor_initializers_thisInvocation_namedExpression() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C() : this.named(1, b: 2);
   const C.named(a, {int b});
@@ -1418,7 +1370,7 @@
   }
 
   test_class_constructor_initializers_thisInvocation_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C.named() : this(1, 'bbb');
   const C(int a, String b);
@@ -1457,7 +1409,7 @@
   }
 
   test_class_constructor_parameters_super_explicitType_function() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(Object? a);
 }
@@ -1495,7 +1447,7 @@
   }
 
   test_class_constructor_parameters_super_explicitType_interface() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(num a);
 }
@@ -1527,7 +1479,7 @@
   }
 
   test_class_constructor_parameters_super_explicitType_interface_nullable() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(num? a);
 }
@@ -1559,7 +1511,7 @@
   }
 
   test_class_constructor_parameters_super_invalid_topFunction() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f(super.a) {}
 ''');
     checkElementText(library, r'''
@@ -1576,7 +1528,7 @@
   }
 
   test_class_constructor_parameters_super_optionalNamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A({required int a, required double b});
 }
@@ -1617,7 +1569,7 @@
   }
 
   test_class_constructor_parameters_super_optionalNamed_unresolved() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A({required int a});
 }
@@ -1649,7 +1601,7 @@
   }
 
   test_class_constructor_parameters_super_optionalNamed_unresolved2() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(int a);
 }
@@ -1681,7 +1633,7 @@
   }
 
   test_class_constructor_parameters_super_optionalPositional() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(int a, double b);
 }
@@ -1722,7 +1674,7 @@
   }
 
   test_class_constructor_parameters_super_requiredNamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A({required int a, required double b});
 }
@@ -1768,7 +1720,7 @@
   }
 
   test_class_constructor_parameters_super_requiredPositional() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(int a, double b);
 }
@@ -1809,7 +1761,7 @@
   }
 
   test_class_constructor_parameters_super_requiredPositional_unresolved() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 
 class B extends A {
@@ -1836,7 +1788,7 @@
   }
 
   test_class_constructor_parameters_super_requiredPositional_unresolved2() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A({required int a})
 }
@@ -1868,7 +1820,7 @@
   }
 
   test_class_constructor_params() async {
-    var library = await checkLibrary('class C { C(x, int y); }');
+    var library = await buildLibrary('class C { C(x, int y); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -1885,7 +1837,7 @@
   }
 
   test_class_constructor_redirected_factory_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   factory C() = D.named;
   C._();
@@ -1916,7 +1868,7 @@
   }
 
   test_class_constructor_redirected_factory_named_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   factory C() = D<U, T>.named;
   C._();
@@ -1961,7 +1913,7 @@
   }
 
   test_class_constructor_redirected_factory_named_generic_viaTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef A<T, U> = C<T, U>;
 class B<T, U> {
   factory B() = A<U, T>.named;
@@ -2016,13 +1968,13 @@
   }
 
   test_class_constructor_redirected_factory_named_imported() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D.named() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 class C {
   factory C() = D.named;
@@ -2046,13 +1998,13 @@
   }
 
   test_class_constructor_redirected_factory_named_imported_generic() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D.named() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 class C<T, U> {
   factory C() = D<U, T>.named;
@@ -2083,13 +2035,13 @@
   }
 
   test_class_constructor_redirected_factory_named_prefixed() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D.named() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 class C {
   factory C() = foo.D.named;
@@ -2113,13 +2065,13 @@
   }
 
   test_class_constructor_redirected_factory_named_prefixed_generic() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D.named() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 class C<T, U> {
   factory C() = foo.D<U, T>.named;
@@ -2150,7 +2102,7 @@
   }
 
   test_class_constructor_redirected_factory_named_unresolved_class() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<E> {
   factory C() = D.named<E>;
 }
@@ -2169,7 +2121,7 @@
   }
 
   test_class_constructor_redirected_factory_named_unresolved_constructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class D {}
 class C<E> {
   factory C() = D.named<E>;
@@ -2192,7 +2144,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   factory C() = D;
   C._();
@@ -2221,7 +2173,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   factory C() = D<U, T>;
   C._();
@@ -2264,7 +2216,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_generic_viaTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef A<T, U> = C<T, U>;
 class B<T, U> {
   factory B() = A<U, T>;
@@ -2313,13 +2265,13 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 class C {
   factory C() = D;
@@ -2343,13 +2295,13 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported_generic() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 class C<T, U> {
   factory C() = D<U, T>;
@@ -2380,14 +2332,14 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_imported_viaTypeAlias() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 typedef A = B;
 class B extends C {
   B() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 class C {
   factory C() = A;
@@ -2411,13 +2363,13 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D extends C {
   D() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 class C {
   factory C() = foo.D;
@@ -2441,13 +2393,13 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed_generic() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 class D<T, U> extends C<U, T> {
   D() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 class C<T, U> {
   factory C() = foo.D<U, T>;
@@ -2478,14 +2430,14 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_prefixed_viaTypeAlias() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 import 'test.dart';
 typedef A = B;
 class B extends C {
   B() : super._();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 class C {
   factory C() = foo.A;
@@ -2509,7 +2461,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_unresolved() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<E> {
   factory C() = D<E>;
 }
@@ -2528,7 +2480,7 @@
   }
 
   test_class_constructor_redirected_factory_unnamed_viaTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef A = C;
 class B {
   factory B() = A;
@@ -2561,7 +2513,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C.named();
   const C() : this.named();
@@ -2594,7 +2546,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_named_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   const C.named();
   const C() : this.named();
@@ -2630,7 +2582,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_named_notConst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C.named();
   C() : this.named();
@@ -2651,7 +2603,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   const C();
   const C.named() : this();
@@ -2679,7 +2631,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_unnamed_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   const C();
   const C.named() : this();
@@ -2710,7 +2662,7 @@
   }
 
   test_class_constructor_redirected_thisInvocation_unnamed_notConst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C();
   C.named() : this();
@@ -2731,7 +2683,7 @@
   }
 
   test_class_constructor_superConstructor_generic_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   A.named(T a);
 }
@@ -2765,7 +2717,7 @@
   }
 
   test_class_constructor_superConstructor_notGeneric_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A.named();
 }
@@ -2791,7 +2743,7 @@
   }
 
   test_class_constructor_superConstructor_notGeneric_unnamed_explicit() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 class B extends A {
   B() : super();
@@ -2813,7 +2765,7 @@
   }
 
   test_class_constructor_superConstructor_notGeneric_unnamed_implicit() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 class B extends A {
   B();
@@ -2835,7 +2787,7 @@
   }
 
   test_class_constructor_superConstructor_notGeneric_unnamed_implicit2() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 class B extends A {}
 ''');
@@ -2855,7 +2807,7 @@
   }
 
   test_class_constructor_unnamed_implicit() async {
-    var library = await checkLibrary('class C {}');
+    var library = await buildLibrary('class C {}');
     checkElementText(
         library,
         r'''
@@ -2871,7 +2823,7 @@
   }
 
   test_class_constructor_withCycles_const() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x;
   const C() : x = const D();
@@ -2949,7 +2901,7 @@
   }
 
   test_class_constructor_withCycles_nonConst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x;
   C() : x = new D();
@@ -2985,7 +2937,7 @@
   }
 
   test_class_constructors_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C.foo();
 }
@@ -3007,7 +2959,7 @@
   }
 
   test_class_constructors_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C();
 }
@@ -3027,7 +2979,7 @@
   }
 
   test_class_constructors_unnamed_new() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C.new();
 }
@@ -3049,7 +3001,7 @@
   }
 
   test_class_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /**
  * Docs
  */
@@ -3066,7 +3018,7 @@
   }
 
   test_class_documented_mix() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /**
  * aaa
  */
@@ -3131,7 +3083,7 @@
   }
 
   test_class_documented_tripleSlash() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// first
 /// second
 /// third
@@ -3148,7 +3100,7 @@
   }
 
   test_class_documented_with_references() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /**
  * Docs referring to [D] and [E]
  */
@@ -3174,7 +3126,7 @@
   }
 
   test_class_documented_with_windows_line_endings() async {
-    var library = await checkLibrary('/**\r\n * Docs\r\n */\r\nclass C {}');
+    var library = await buildLibrary('/**\r\n * Docs\r\n */\r\nclass C {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3187,7 +3139,7 @@
   }
 
   test_class_documented_withLeadingNotDocumentation() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -3205,7 +3157,7 @@
   }
 
   test_class_documented_withMetadata() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// Comment 1
 /// Comment 2
 @Annotation()
@@ -3333,7 +3285,7 @@
   }
 
   test_class_field_abstract() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class C {
   abstract int i;
 }
@@ -3360,7 +3312,7 @@
   }
 
   test_class_field_const() async {
-    var library = await checkLibrary('class C { static const int i = 0; }');
+    var library = await buildLibrary('class C { static const int i = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3383,7 +3335,7 @@
 
   test_class_field_const_late() async {
     var library =
-        await checkLibrary('class C { static late const int i = 0; }');
+        await buildLibrary('class C { static late const int i = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3405,7 +3357,7 @@
   }
 
   test_class_field_covariant() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   covariant int x;
 }''');
@@ -3431,7 +3383,7 @@
   }
 
   test_class_field_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   /**
    * Docs
@@ -3461,7 +3413,7 @@
   }
 
   test_class_field_external() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class C {
   external int i;
 }
@@ -3488,7 +3440,7 @@
   }
 
   test_class_field_final_hasInitializer_hasConstConstructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x = 42;
   const C();
@@ -3515,7 +3467,7 @@
   }
 
   test_class_field_final_hasInitializer_hasConstConstructor_genericFunctionType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A();
 }
@@ -3600,7 +3552,7 @@
   }
 
   test_class_field_final_hasInitializer_noConstConstructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x = 42;
 }
@@ -3622,7 +3574,7 @@
   }
 
   test_class_field_final_withSetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   final int foo;
   A(this.foo);
@@ -3655,7 +3607,7 @@
   }
 
   test_class_field_formal_param_inferred_type_implicit() async {
-    var library = await checkLibrary('class C extends D { var v; C(this.v); }'
+    var library = await buildLibrary('class C extends D { var v; C(this.v); }'
         ' abstract class D { int get v; }');
     checkElementText(library, r'''
 library
@@ -3694,7 +3646,7 @@
   }
 
   test_class_field_implicit_type() async {
-    var library = await checkLibrary('class C { var x; }');
+    var library = await buildLibrary('class C { var x; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3717,7 +3669,7 @@
   }
 
   test_class_field_implicit_type_late() async {
-    var library = await checkLibrary('class C { late var x; }');
+    var library = await buildLibrary('class C { late var x; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3740,7 +3692,7 @@
   }
 
   test_class_field_inferred_type_nonStatic_explicit_initialized() async {
-    var library = await checkLibrary('class C { num v = 0; }');
+    var library = await buildLibrary('class C { num v = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3763,7 +3715,7 @@
   }
 
   test_class_field_inferred_type_nonStatic_implicit_initialized() async {
-    var library = await checkLibrary('class C { var v = 0; }');
+    var library = await buildLibrary('class C { var v = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3786,7 +3738,7 @@
   }
 
   test_class_field_inferred_type_nonStatic_implicit_uninitialized() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'class C extends D { var v; } abstract class D { int get v; }');
     checkElementText(library, r'''
 library
@@ -3821,7 +3773,7 @@
   }
 
   test_class_field_inferred_type_nonStatic_inherited_resolveInitializer() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 abstract class A {
   const A();
@@ -3880,7 +3832,7 @@
   }
 
   test_class_field_inferred_type_static_implicit_initialized() async {
-    var library = await checkLibrary('class C { static var v = 0; }');
+    var library = await buildLibrary('class C { static var v = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -3903,7 +3855,7 @@
   }
 
   test_class_field_inheritedContextType_double() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class A {
   const A();
   double get foo;
@@ -3945,7 +3897,7 @@
   }
 
   test_class_field_propagatedType_const_noDep() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static const x = 0;
 }''');
@@ -3970,8 +3922,8 @@
   }
 
   test_class_field_propagatedType_final_dep_inLib() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'final a = 1;');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'final a = 1;');
+    var library = await buildLibrary('''
 import "a.dart";
 class C {
   final b = a / 2;
@@ -3996,7 +3948,7 @@
 
   test_class_field_propagatedType_final_dep_inPart() async {
     addSource('$testPackageLibPath/a.dart', 'part of lib; final a = 1;');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library lib;
 part "a.dart";
 class C {
@@ -4029,7 +3981,7 @@
   }
 
   test_class_field_propagatedType_final_noDep_instance() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final x = 0;
 }''');
@@ -4050,7 +4002,7 @@
   }
 
   test_class_field_propagatedType_final_noDep_static() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static final x = 0;
 }''');
@@ -4071,7 +4023,7 @@
   }
 
   test_class_field_static() async {
-    var library = await checkLibrary('class C { static int i; }');
+    var library = await buildLibrary('class C { static int i; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4094,7 +4046,7 @@
   }
 
   test_class_field_static_final_hasConstConstructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static final f = 0;
   const C();
@@ -4117,7 +4069,7 @@
   }
 
   test_class_field_static_final_untyped() async {
-    var library = await checkLibrary('class C { static final x = 0; }');
+    var library = await buildLibrary('class C { static final x = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4135,7 +4087,7 @@
   }
 
   test_class_field_static_late() async {
-    var library = await checkLibrary('class C { static late int i; }');
+    var library = await buildLibrary('class C { static late int i; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4158,7 +4110,7 @@
   }
 
   test_class_field_type_inferred_Never() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   var a = throw 42;
 }
@@ -4191,7 +4143,7 @@
 var a = 0;
 ''');
 
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 class C {
   var b = a;
@@ -4222,7 +4174,7 @@
   }
 
   test_class_field_typed() async {
-    var library = await checkLibrary('class C { int x = 0; }');
+    var library = await buildLibrary('class C { int x = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4245,7 +4197,7 @@
   }
 
   test_class_field_untyped() async {
-    var library = await checkLibrary('class C { var x = 0; }');
+    var library = await buildLibrary('class C { var x = 0; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4268,7 +4220,7 @@
   }
 
   test_class_fields() async {
-    var library = await checkLibrary('class C { int i; int j; }');
+    var library = await buildLibrary('class C { int i; int j; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4300,7 +4252,7 @@
   }
 
   test_class_fields_late() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   late int foo;
 }
@@ -4327,7 +4279,7 @@
   }
 
   test_class_fields_late_final() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   late final int foo;
 }
@@ -4354,7 +4306,7 @@
   }
 
   test_class_fields_late_final_initialized() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   late final int foo = 0;
 }
@@ -4376,7 +4328,7 @@
   }
 
   test_class_fields_late_inference_usingSuper_methodInvocation() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   int foo() => 0;
 }
@@ -4415,7 +4367,7 @@
   }
 
   test_class_fields_late_inference_usingSuper_propertyAccess() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   int get foo => 0;
 }
@@ -4457,7 +4409,7 @@
   }
 
   test_class_getter_abstract() async {
-    var library = await checkLibrary('abstract class C { int get x; }');
+    var library = await buildLibrary('abstract class C { int get x; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4475,7 +4427,7 @@
   }
 
   test_class_getter_external() async {
-    var library = await checkLibrary('class C { external int get x; }');
+    var library = await buildLibrary('class C { external int get x; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4493,7 +4445,7 @@
   }
 
   test_class_getter_implicit_return_type() async {
-    var library = await checkLibrary('class C { get x => null; }');
+    var library = await buildLibrary('class C { get x => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4511,7 +4463,7 @@
   }
 
   test_class_getter_native() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int get x() native;
 }
@@ -4533,7 +4485,7 @@
   }
 
   test_class_getter_static() async {
-    var library = await checkLibrary('class C { static int get x => null; }');
+    var library = await buildLibrary('class C { static int get x => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4552,7 +4504,7 @@
 
   test_class_getters() async {
     var library =
-        await checkLibrary('class C { int get x => null; get y => null; }');
+        await buildLibrary('class C { int get x => null; get y => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4574,7 +4526,7 @@
   }
 
   test_class_implicitField_getterFirst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int get x => 0;
   void set x(int value) {}
@@ -4602,7 +4554,7 @@
   }
 
   test_class_implicitField_setterFirst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   void set x(int value) {}
   int get x => 0;
@@ -4630,7 +4582,7 @@
   }
 
   test_class_interfaces() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C implements D, E {}
 class D {}
 class E {}
@@ -4655,7 +4607,7 @@
   }
 
   test_class_interfaces_Function() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 class B {}
 class C implements A, Function, B {}
@@ -4680,7 +4632,7 @@
   }
 
   test_class_interfaces_unresolved() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'class C implements X, Y, Z {} class X {} class Z {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -4703,7 +4655,7 @@
   }
 
   test_class_method_abstract() async {
-    var library = await checkLibrary('abstract class C { f(); }');
+    var library = await buildLibrary('abstract class C { f(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4718,7 +4670,7 @@
   }
 
   test_class_method_async() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 class C {
   Future f() async {}
@@ -4740,7 +4692,7 @@
   }
 
   test_class_method_asyncStar() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 class C {
   Stream f() async* {}
@@ -4762,7 +4714,7 @@
   }
 
   test_class_method_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   /**
    * Docs
@@ -4784,7 +4736,7 @@
   }
 
   test_class_method_external() async {
-    var library = await checkLibrary('class C { external f(); }');
+    var library = await buildLibrary('class C { external f(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4799,7 +4751,7 @@
   }
 
   test_class_method_hasImplicitReturnType_false() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int m() => 0;
 }
@@ -4810,7 +4762,7 @@
   }
 
   test_class_method_hasImplicitReturnType_true() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   m() => 0;
 }
@@ -4821,7 +4773,7 @@
   }
 
   test_class_method_inferred_type_nonStatic_implicit_param() async {
-    var library = await checkLibrary('class C extends D { void f(value) {} }'
+    var library = await buildLibrary('class C extends D { void f(value) {} }'
         ' abstract class D { void f(int value); }');
     checkElementText(library, r'''
 library
@@ -4851,7 +4803,7 @@
   }
 
   test_class_method_inferred_type_nonStatic_implicit_return() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C extends D {
   f() => null;
 }
@@ -4881,7 +4833,7 @@
   }
 
   test_class_method_namedAsSupertype() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 class B extends A {
   void A() {}
@@ -4906,7 +4858,7 @@
   }
 
   test_class_method_native() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int m() native;
 }
@@ -4925,7 +4877,7 @@
   }
 
   test_class_method_params() async {
-    var library = await checkLibrary('class C { f(x, y) {} }');
+    var library = await buildLibrary('class C { f(x, y) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4945,7 +4897,7 @@
   }
 
   test_class_method_static() async {
-    var library = await checkLibrary('class C { static f() {} }');
+    var library = await buildLibrary('class C { static f() {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -4960,7 +4912,7 @@
   }
 
   test_class_method_syncStar() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   Iterable<int> f() sync* {
     yield 42;
@@ -4981,7 +4933,7 @@
   }
 
   test_class_method_type_parameter() async {
-    var library = await checkLibrary('class C { T f<T, U>(U u) => null; }');
+    var library = await buildLibrary('class C { T f<T, U>(U u) => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5002,7 +4954,7 @@
   }
 
   test_class_method_type_parameter_in_generic_class() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   V f<V, W>(T t, U u, W w) => null;
 }
@@ -5036,7 +4988,7 @@
   }
 
   test_class_method_type_parameter_with_function_typed_parameter() async {
-    var library = await checkLibrary('class C { void f<T, U>(T x(U u)) {} }');
+    var library = await buildLibrary('class C { void f<T, U>(T x(U u)) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5060,7 +5012,7 @@
   }
 
   test_class_methods() async {
-    var library = await checkLibrary('class C { f() {} g() {} }');
+    var library = await buildLibrary('class C { f() {} g() {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5077,7 +5029,7 @@
   }
 
   test_class_mixins() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C extends D with E, F, G {}
 class D {}
 class E {}
@@ -5113,7 +5065,7 @@
   }
 
   test_class_mixins_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class Z extends A with B<int>, C<double> {}
 class A {}
 class B<B1> {}
@@ -5150,7 +5102,7 @@
   }
 
   test_class_mixins_unresolved() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'class C extends Object with X, Y, Z {} class X {} class Z {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -5176,7 +5128,7 @@
   test_class_notSimplyBounded_circularity_via_typedef() async {
     // C's type parameter T is not simply bounded because its bound, F, expands
     // to `dynamic F(C)`, which refers to C.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends F> {}
 typedef F(C value);
 ''');
@@ -5205,7 +5157,7 @@
   test_class_notSimplyBounded_circularity_with_type_params() async {
     // C's type parameter T is simply bounded because even though it refers to
     // C, it specifies a bound.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C<dynamic>> {}
 ''');
     checkElementText(library, r'''
@@ -5223,7 +5175,7 @@
   }
 
   test_class_notSimplyBounded_complex_by_cycle_class() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends D> {}
 class D<T extends C> {}
 ''');
@@ -5249,7 +5201,7 @@
   }
 
   test_class_notSimplyBounded_complex_by_cycle_typedef_functionType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef C<T extends D> = void Function();
 typedef D<T extends C> = void Function();
 ''');
@@ -5277,7 +5229,7 @@
   }
 
   test_class_notSimplyBounded_complex_by_cycle_typedef_interfaceType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef C<T extends D> = List<T>;
 typedef D<T extends C> = List<T>;
 ''');
@@ -5301,7 +5253,7 @@
   }
 
   test_class_notSimplyBounded_complex_by_reference_to_cycle() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends D> {}
 class D<T extends D> {}
 ''');
@@ -5327,7 +5279,7 @@
   }
 
   test_class_notSimplyBounded_complex_by_use_of_parameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends D<T>> {}
 class D<T> {}
 ''');
@@ -5354,7 +5306,7 @@
   test_class_notSimplyBounded_dependency_with_type_params() async {
     // C's type parameter T is simply bounded because even though it refers to
     // non-simply-bounded type D, it specifies a bound.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends D<dynamic>> {}
 class D<T extends D<T>> {}
 ''');
@@ -5380,7 +5332,7 @@
   }
 
   test_class_notSimplyBounded_function_typed_bound_complex_via_parameter_type() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends void Function(T)> {}
 ''');
     checkElementText(library, r'''
@@ -5399,7 +5351,7 @@
 
   test_class_notSimplyBounded_function_typed_bound_complex_via_parameter_type_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends void Function(T)> {}
 ''');
     checkElementText(library, r'''
@@ -5417,7 +5369,7 @@
   }
 
   test_class_notSimplyBounded_function_typed_bound_complex_via_return_type() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends T Function()> {}
 ''');
     checkElementText(library, r'''
@@ -5435,7 +5387,7 @@
   }
 
   test_class_notSimplyBounded_function_typed_bound_simple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends void Function()> {}
 ''');
     checkElementText(library, r'''
@@ -5456,7 +5408,7 @@
     // C's type parameter T has a bound of F, which is a circular typedef.  This
     // is illegal in Dart, but we need to make sure it doesn't lead to a crash
     // or infinite loop.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends F> {}
 typedef F(G value);
 typedef G(F value);
@@ -5491,7 +5443,7 @@
   }
 
   test_class_notSimplyBounded_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C> {}
 ''');
     checkElementText(library, r'''
@@ -5511,7 +5463,7 @@
   test_class_notSimplyBounded_simple_because_non_generic() async {
     // If no type parameters are specified, then the class is simply bounded, so
     // there is no reason to assign it a slot.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {}
 ''');
     checkElementText(library, r'''
@@ -5525,7 +5477,7 @@
   }
 
   test_class_notSimplyBounded_simple_by_lack_of_cycles() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends D> {}
 class D<T> {}
 ''');
@@ -5552,7 +5504,7 @@
   test_class_notSimplyBounded_simple_by_syntax() async {
     // If no bounds are specified, then the class is simply bounded by syntax
     // alone, so there is no reason to assign it a slot.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {}
 ''');
     checkElementText(library, r'''
@@ -5570,7 +5522,7 @@
 
   test_class_operator() async {
     var library =
-        await checkLibrary('class C { C operator+(C other) => null; }');
+        await buildLibrary('class C { C operator+(C other) => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5588,7 +5540,7 @@
   }
 
   test_class_operator_equal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   bool operator==(Object other) => false;
 }
@@ -5611,7 +5563,7 @@
 
   test_class_operator_external() async {
     var library =
-        await checkLibrary('class C { external C operator+(C other); }');
+        await buildLibrary('class C { external C operator+(C other); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5629,7 +5581,7 @@
   }
 
   test_class_operator_greater_equal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   bool operator>=(C other) => false;
 }
@@ -5652,7 +5604,7 @@
 
   test_class_operator_index() async {
     var library =
-        await checkLibrary('class C { bool operator[](int i) => null; }');
+        await buildLibrary('class C { bool operator[](int i) => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5670,7 +5622,7 @@
   }
 
   test_class_operator_index_set() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   void operator[]=(int i, bool v) {}
 }
@@ -5694,7 +5646,7 @@
   }
 
   test_class_operator_less_equal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   bool operator<=(C other) => false;
 }
@@ -5716,7 +5668,7 @@
   }
 
   test_class_ref_nullability_none() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {}
 C c;
 ''');
@@ -5742,7 +5694,7 @@
   }
 
   test_class_ref_nullability_question() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {}
 C? c;
 ''');
@@ -5769,7 +5721,7 @@
 
   test_class_ref_nullability_star() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {}
 C c;
 ''');
@@ -5796,7 +5748,7 @@
 
   test_class_setter_abstract() async {
     var library =
-        await checkLibrary('abstract class C { void set x(int value); }');
+        await buildLibrary('abstract class C { void set x(int value); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5818,7 +5770,7 @@
 
   test_class_setter_covariant() async {
     var library =
-        await checkLibrary('class C { void set x(covariant int value); }');
+        await buildLibrary('class C { void set x(covariant int value); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5840,7 +5792,7 @@
 
   test_class_setter_external() async {
     var library =
-        await checkLibrary('class C { external void set x(int value); }');
+        await buildLibrary('class C { external void set x(int value); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5861,7 +5813,7 @@
   }
 
   test_class_setter_implicit_param_type() async {
-    var library = await checkLibrary('class C { void set x(value) {} }');
+    var library = await buildLibrary('class C { void set x(value) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5882,7 +5834,7 @@
   }
 
   test_class_setter_implicit_return_type() async {
-    var library = await checkLibrary('class C { set x(int value) {} }');
+    var library = await buildLibrary('class C { set x(int value) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -5903,7 +5855,7 @@
   }
 
   test_class_setter_inferred_type_conflictingInheritance() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   int t;
 }
@@ -5976,7 +5928,7 @@
 
   test_class_setter_inferred_type_nonStatic_implicit_param() async {
     var library =
-        await checkLibrary('class C extends D { void set f(value) {} }'
+        await buildLibrary('class C extends D { void set f(value) {} }'
             ' abstract class D { void set f(int value); }');
     checkElementText(library, r'''
 library
@@ -6012,7 +5964,7 @@
   }
 
   test_class_setter_inferred_type_static_implicit_return() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static set f(int value) {}
 }
@@ -6037,7 +5989,7 @@
   }
 
   test_class_setter_invalid_named_parameter() async {
-    var library = await checkLibrary('class C { void set x({a}) {} }');
+    var library = await buildLibrary('class C { void set x({a}) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6058,7 +6010,7 @@
   }
 
   test_class_setter_invalid_no_parameter() async {
-    var library = await checkLibrary('class C { void set x() {} }');
+    var library = await buildLibrary('class C { void set x() {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6076,7 +6028,7 @@
   }
 
   test_class_setter_invalid_optional_parameter() async {
-    var library = await checkLibrary('class C { void set x([a]) {} }');
+    var library = await buildLibrary('class C { void set x([a]) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6097,7 +6049,7 @@
   }
 
   test_class_setter_invalid_too_many_parameters() async {
-    var library = await checkLibrary('class C { void set x(a, b) {} }');
+    var library = await buildLibrary('class C { void set x(a, b) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6120,7 +6072,7 @@
   }
 
   test_class_setter_native() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   void set x(int value) native;
 }
@@ -6146,7 +6098,7 @@
 
   test_class_setter_static() async {
     var library =
-        await checkLibrary('class C { static void set x(int value) {} }');
+        await buildLibrary('class C { static void set x(int value) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6167,7 +6119,7 @@
   }
 
   test_class_setters() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   void set x(int value) {}
   set y(value) {}
@@ -6200,7 +6152,7 @@
   }
 
   test_class_supertype() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C extends D {}
 class D {}
 ''');
@@ -6220,7 +6172,7 @@
   }
 
   test_class_supertype_typeArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C extends D<int, double> {}
 class D<T1, T2> {}
 ''');
@@ -6247,7 +6199,7 @@
   }
 
   test_class_supertype_typeArguments_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {}
 class B extends A<B> {}
 ''');
@@ -6272,7 +6224,7 @@
   }
 
   test_class_supertype_unresolved() async {
-    var library = await checkLibrary('class C extends D {}', allowErrors: true);
+    var library = await buildLibrary('class C extends D {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -6284,7 +6236,7 @@
   }
 
   test_class_typeParameters() async {
-    var library = await checkLibrary('class C<T, U> {}');
+    var library = await buildLibrary('class C<T, U> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6301,7 +6253,7 @@
   }
 
   test_class_typeParameters_bound() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends Object, U extends D> {}
 class D {}
 ''');
@@ -6326,7 +6278,7 @@
   }
 
   test_class_typeParameters_cycle_1of1() async {
-    var library = await checkLibrary('class C<T extends T> {}');
+    var library = await buildLibrary('class C<T extends T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6342,7 +6294,7 @@
   }
 
   test_class_typeParameters_cycle_2of3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<T extends V, U, V extends T> {}
 ''');
     checkElementText(library, r'''
@@ -6365,7 +6317,7 @@
   }
 
   test_class_typeParameters_defaultType_cycle_genericFunctionType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T extends void Function(A)> {}
 ''');
     checkElementText(library, r'''
@@ -6383,7 +6335,7 @@
   }
 
   test_class_typeParameters_defaultType_cycle_genericFunctionType2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<T extends void Function<U extends C>()> {}
 ''');
     checkElementText(library, r'''
@@ -6402,7 +6354,7 @@
 
   test_class_typeParameters_defaultType_functionTypeAlias_contravariant_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<X> = void Function(X);
 
 class A<X extends F<X>> {}
@@ -6439,7 +6391,7 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_contravariant_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<X> = void Function(X);
 
 class A<X extends F<X>> {}
@@ -6476,7 +6428,7 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_covariant_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<X> = X Function();
 
 class A<X extends F<X>> {}
@@ -6510,7 +6462,7 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_invariant_legacy() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<X> = X Function(X);
 
 class A<X extends F<X>> {}
@@ -6547,7 +6499,7 @@
   }
 
   test_class_typeParameters_defaultType_functionTypeAlias_invariant_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<X> = X Function(X);
 
 class A<X extends F<X>> {}
@@ -6585,7 +6537,7 @@
 
   test_class_typeParameters_defaultType_genericFunctionType_both_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends X Function(X)> {}
 ''');
     checkElementText(library, r'''
@@ -6603,7 +6555,7 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_both_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends X Function(X)> {}
 ''');
     checkElementText(library, r'''
@@ -6622,7 +6574,7 @@
 
   test_class_typeParameters_defaultType_genericFunctionType_contravariant_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends void Function(X)> {}
 ''');
     checkElementText(library, r'''
@@ -6640,7 +6592,7 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_contravariant_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends void Function(X)> {}
 ''');
     checkElementText(library, r'''
@@ -6658,7 +6610,7 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_covariant_legacy() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends X Function()> {}
 ''');
     checkElementText(library, r'''
@@ -6676,7 +6628,7 @@
   }
 
   test_class_typeParameters_defaultType_genericFunctionType_covariant_nullSafe() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<X extends X Function()> {}
 ''');
     checkElementText(library, r'''
@@ -6694,7 +6646,7 @@
   }
 
   test_class_typeParameters_defaultType_typeAlias_interface_contravariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<X> = List<void Function(X)>;
 
 class B<X extends A<X>> {}
@@ -6726,7 +6678,7 @@
   }
 
   test_class_typeParameters_defaultType_typeAlias_interface_covariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<X> = Map<X, int>;
 
 class B<X extends A<X>> {}
@@ -6758,7 +6710,7 @@
   }
 
   test_class_typeParameters_f_bound_complex() async {
-    var library = await checkLibrary('class C<T extends List<U>, U> {}');
+    var library = await buildLibrary('class C<T extends List<U>, U> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6776,7 +6728,7 @@
   }
 
   test_class_typeParameters_f_bound_simple() async {
-    var library = await checkLibrary('class C<T extends U, U> {}');
+    var library = await buildLibrary('class C<T extends U, U> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6794,7 +6746,7 @@
   }
 
   test_class_typeParameters_variance_contravariant() async {
-    var library = await checkLibrary('class C<in T> {}');
+    var library = await buildLibrary('class C<in T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6809,7 +6761,7 @@
   }
 
   test_class_typeParameters_variance_covariant() async {
-    var library = await checkLibrary('class C<out T> {}');
+    var library = await buildLibrary('class C<out T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6824,7 +6776,7 @@
   }
 
   test_class_typeParameters_variance_invariant() async {
-    var library = await checkLibrary('class C<inout T> {}');
+    var library = await buildLibrary('class C<inout T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6839,7 +6791,7 @@
   }
 
   test_class_typeParameters_variance_multiple() async {
-    var library = await checkLibrary('class C<inout T, in U, out V> {}');
+    var library = await buildLibrary('class C<inout T, in U, out V> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -6858,7 +6810,7 @@
   }
 
   test_classAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C = D with E, F, G;
 class D {}
 class E {}
@@ -6901,7 +6853,7 @@
   }
 
   test_classAlias_abstract() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class C = D with E;
 class D {}
 class E {}
@@ -6934,7 +6886,7 @@
   }
 
   test_classAlias_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /**
  * Docs
  */
@@ -6972,7 +6924,7 @@
   }
 
   test_classAlias_documented_tripleSlash() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// aaa
 /// b
 /// cc
@@ -7010,7 +6962,7 @@
   }
 
   test_classAlias_documented_withLeadingNonDocumentation() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -7048,7 +7000,7 @@
   }
 
   test_classAlias_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class Z = A with B<int>, C<double>;
 class A {}
 class B<B1> {}
@@ -7092,7 +7044,7 @@
   }
 
   test_classAlias_notSimplyBounded_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C> = D with E;
 class D {}
 class E {}
@@ -7131,7 +7083,7 @@
   test_classAlias_notSimplyBounded_simple_no_type_parameter_bound() async {
     // If no bounds are specified, then the class is simply bounded by syntax
     // alone, so there is no reason to assign it a slot.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> = D with E;
 class D {}
 class E {}
@@ -7169,7 +7121,7 @@
   test_classAlias_notSimplyBounded_simple_non_generic() async {
     // If no type parameters are specified, then the class is simply bounded, so
     // there is no reason to assign it a slot.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C = D with E;
 class D {}
 class E {}
@@ -7202,14 +7154,14 @@
   }
 
   test_classAlias_with_const_constructors() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class Base {
   const Base._priv();
   const Base();
   const Base.named();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "a.dart";
 class M {}
 class MixinApp = Base with M;
@@ -7255,7 +7207,7 @@
   }
 
   test_classAlias_with_forwarding_constructors() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class Base {
   bool x = true;
   Base._priv();
@@ -7270,7 +7222,7 @@
   factory Base.fact2() = Base.noArgs;
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "a.dart";
 class M {}
 class MixinApp = Base with M;
@@ -7442,7 +7394,7 @@
   }
 
   test_classAlias_with_forwarding_constructors_type_substitution() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class Base<T> {
   Base.ctor(T t, List<T> l);
 }
@@ -7508,7 +7460,7 @@
   }
 
   test_classAlias_with_forwarding_constructors_type_substitution_complex() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class Base<T> {
   Base.ctor(T t, List<T> l);
 }
@@ -7577,7 +7529,7 @@
   }
 
   test_classAlias_with_mixin_members() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C = D with E;
 class D {}
 class E {
@@ -7639,7 +7591,7 @@
   }
 
   test_classes() async {
-    var library = await checkLibrary('class C {} class D {}');
+    var library = await buildLibrary('class C {} class D {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -7654,7 +7606,7 @@
   }
 
   test_closure_executable_with_return_type_from_closure() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f() {
   print(() {});
   print(() => () => 0);
@@ -7670,7 +7622,7 @@
   }
 
   test_closure_generic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 final f = <U, V>(U x, V y) => y;
 ''');
     checkElementText(library, r'''
@@ -7688,7 +7640,7 @@
   test_closure_in_variable_declaration_in_part() async {
     addSource('$testPackageLibPath/a.dart',
         'part of lib; final f = (int i) => i.toDouble();');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library lib;
 part "a.dart";
 ''');
@@ -7709,7 +7661,7 @@
   }
 
   test_codeRange_class() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class Raw {}
 
 /// Comment 1.
@@ -7823,7 +7775,7 @@
   }
 
   test_codeRange_class_namedMixin() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 
 class B {}
@@ -8017,7 +7969,7 @@
   }
 
   test_codeRange_constructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C();
 
@@ -8142,7 +8094,7 @@
   }
 
   test_codeRange_constructor_factory() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   factory C() => throw 0;
 
@@ -8267,7 +8219,7 @@
   }
 
   test_codeRange_enum() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   aaa, bbb, ccc
 }
@@ -8373,7 +8325,7 @@
   }
 
   test_codeRange_extensions() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 
 extension Raw on A {}
@@ -8489,7 +8441,7 @@
   }
 
   test_codeRange_field() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int withInit = 1;
 
@@ -8571,7 +8523,7 @@
   }
 
   test_codeRange_field_annotations() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   /// Comment 1.
   /// Comment 2.
@@ -8820,7 +8772,7 @@
   }
 
   test_codeRange_function() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void raw() {}
 
 /// Comment 1.
@@ -8928,7 +8880,7 @@
   }
 
   test_codeRange_functionTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef Raw();
 
 /// Comment 1.
@@ -9048,7 +9000,7 @@
   }
 
   test_codeRange_genericTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef Raw = Function();
 
 /// Comment 1.
@@ -9168,7 +9120,7 @@
   }
 
   test_codeRange_method() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   void raw() {}
 
@@ -9284,7 +9236,7 @@
   }
 
   test_codeRange_parameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 main({int a = 1, int b, int c = 2}) {}
 ''');
     checkElementText(library, r'''
@@ -9312,7 +9264,7 @@
   }
 
   test_codeRange_parameter_annotations() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 main(@Object() int a, int b, @Object() int c) {}
 ''');
     checkElementText(library, r'''
@@ -9354,7 +9306,7 @@
   }
 
   test_codeRange_topLevelVariable() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 int withInit = 1 + 2 * 3;
 
 int withoutInit;
@@ -9428,7 +9380,7 @@
   }
 
   test_codeRange_topLevelVariable_annotations() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// Comment 1.
 /// Comment 2.
 int hasDocComment, hasDocComment2;
@@ -9669,7 +9621,7 @@
   }
 
   test_codeRange_type_parameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {}
 void f<U extends num> {}
 ''');
@@ -9704,7 +9656,7 @@
   }
 
   test_compilationUnit_nnbd_disabled_via_dart_directive() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // @dart=2.2
 ''');
     expect(library.isNonNullableByDefault, isFalse);
@@ -9712,17 +9664,17 @@
 
   test_compilationUnit_nnbd_disabled_via_feature_set() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('');
+    var library = await buildLibrary('');
     expect(library.isNonNullableByDefault, isFalse);
   }
 
   test_compilationUnit_nnbd_enabled() async {
-    var library = await checkLibrary('');
+    var library = await buildLibrary('');
     expect(library.isNonNullableByDefault, isTrue);
   }
 
   test_const_asExpression() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const num a = 0;
 const b = a as int;
 ''');
@@ -9761,7 +9713,7 @@
   }
 
   test_const_assignmentExpression() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 const b = (a += 1);
 ''');
@@ -9806,7 +9758,7 @@
   }
 
   test_const_cascadeExpression() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0..isEven..abs();
 ''');
     checkElementText(library, r'''
@@ -9847,7 +9799,7 @@
   }
 
   test_const_classField() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static const int f1 = 1;
   static const int f2 = C.f1, f3 = C.f2;
@@ -9908,7 +9860,7 @@
   }
 
   test_const_constructor_inferred_args() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   final T t;
   const C(this.t);
@@ -10020,7 +9972,7 @@
   }
 
   test_const_constructorReference() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   A.named();
 }
@@ -10061,7 +10013,7 @@
   }
 
   test_const_finalField_hasConstConstructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   final int f = 42;
   const C();
@@ -10088,7 +10040,7 @@
   }
 
   test_const_functionExpression_typeArgumentTypes() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f<T>(T a) {}
 
 const void Function(int) v = f;
@@ -10123,7 +10075,7 @@
   }
 
   test_const_functionReference() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f<T>(T a) {}
 const v = f<int>;
 ''');
@@ -10167,7 +10119,7 @@
   }
 
   test_const_indexExpression() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = [0];
 const b = 0;
 const c = a[b];
@@ -10222,7 +10174,7 @@
   }
 
   test_const_inference_downward_list() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class P<T> {
   const P();
 }
@@ -10326,7 +10278,7 @@
   }
 
   test_const_invalid_field_const() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static const f = 1 + foo();
 }
@@ -10371,7 +10323,7 @@
   }
 
   test_const_invalid_field_final() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   final f = 1 + foo();
 }
@@ -10397,7 +10349,7 @@
   }
 
   test_const_invalid_functionExpression() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const v = () { return 0; };
 ''');
     checkElementText(library, r'''
@@ -10424,7 +10376,7 @@
   }
 
   test_const_invalid_functionExpression_nested() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const v = () { return 0; } + 2;
 ''');
     checkElementText(library, r'''
@@ -10460,7 +10412,7 @@
 
   @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44522')
   test_const_invalid_intLiteral() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int x = 0x;
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -10469,7 +10421,7 @@
   }
 
   test_const_invalid_topLevel() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = 1 + foo();
 int foo() => 42;
 ''', allowErrors: true);
@@ -10508,7 +10460,7 @@
   }
 
   test_const_invalid_typeMismatch() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int a = 0;
 const bool b = a + 5;
 ''', allowErrors: true);
@@ -10546,7 +10498,7 @@
   }
 
   test_const_invokeConstructor_generic_named() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<K, V> {
   const C.named(K k, V v);
 }
@@ -10627,12 +10579,12 @@
   }
 
   test_const_invokeConstructor_generic_named_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C.named(K k, V v);
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = const C<int, String>.named(1, '222');
 ''');
@@ -10697,12 +10649,12 @@
   }
 
   test_const_invokeConstructor_generic_named_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C.named(K k, V v);
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C<int, String>.named(1, '222');
 ''');
@@ -10775,7 +10727,7 @@
   }
 
   test_const_invokeConstructor_generic_noTypeArguments() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<K, V> {
   const C();
 }
@@ -10820,7 +10772,7 @@
   }
 
   test_const_invokeConstructor_generic_unnamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<K, V> {
   const C();
 }
@@ -10881,12 +10833,12 @@
   }
 
   test_const_invokeConstructor_generic_unnamed_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = const C<int, String>();
 ''');
@@ -10938,12 +10890,12 @@
   }
 
   test_const_invokeConstructor_generic_unnamed_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C<K, V> {
   const C();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C<int, String>();
 ''');
@@ -11003,7 +10955,7 @@
   }
 
   test_const_invokeConstructor_named() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   const C.named(bool a, int b, int c, {String d, double e});
 }
@@ -11088,12 +11040,12 @@
   }
 
   test_const_invokeConstructor_named_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   const C.named();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = const C.named();
 ''');
@@ -11132,12 +11084,12 @@
   }
 
   test_const_invokeConstructor_named_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   const C.named();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C.named();
 ''');
@@ -11184,7 +11136,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {}
 const V = const C.named();
 ''', allowErrors: true);
@@ -11225,7 +11177,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const V = const C.named();
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -11264,11 +11216,11 @@
   }
 
   test_const_invokeConstructor_named_unresolved3() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C.named();
 ''', allowErrors: true);
@@ -11315,8 +11267,8 @@
   }
 
   test_const_invokeConstructor_named_unresolved4() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/a.dart', '');
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C.named();
 ''', allowErrors: true);
@@ -11363,7 +11315,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved5() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const V = const p.C.named();
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -11407,7 +11359,7 @@
   }
 
   test_const_invokeConstructor_named_unresolved6() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<T> {}
 const V = const C.named();
 ''', allowErrors: true);
@@ -11451,7 +11403,7 @@
   }
 
   test_const_invokeConstructor_unnamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   const C();
 }
@@ -11489,12 +11441,12 @@
   }
 
   test_const_invokeConstructor_unnamed_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   const C();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = const C();
 ''');
@@ -11528,12 +11480,12 @@
   }
 
   test_const_invokeConstructor_unnamed_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   const C();
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C();
 ''');
@@ -11575,7 +11527,7 @@
   }
 
   test_const_invokeConstructor_unnamed_unresolved() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const V = const C();
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -11606,8 +11558,8 @@
   }
 
   test_const_invokeConstructor_unnamed_unresolved2() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/a.dart', '');
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = const p.C();
 ''', allowErrors: true);
@@ -11649,7 +11601,7 @@
   }
 
   test_const_invokeConstructor_unnamed_unresolved3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const V = const p.C();
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -11688,7 +11640,7 @@
   }
 
   test_const_isExpression() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = 0;
 const b = a is int;
 ''');
@@ -11727,7 +11679,7 @@
   }
 
   test_const_length_ofClassConstField() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static const String F = '';
 }
@@ -11779,12 +11731,12 @@
   }
 
   test_const_length_ofClassConstField_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static const String F = '';
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const int v = C.F.length;
 ''');
@@ -11823,12 +11775,12 @@
   }
 
   test_const_length_ofClassConstField_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static const String F = '';
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const int v = p.C.F.length;
 ''');
@@ -11874,7 +11826,7 @@
   }
 
   test_const_length_ofStringLiteral() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = 'abc'.length;
 ''');
     checkElementText(library, r'''
@@ -11900,7 +11852,7 @@
   }
 
   test_const_length_ofTopLevelVariable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const String S = 'abc';
 const v = S.length;
 ''');
@@ -11937,10 +11889,10 @@
   }
 
   test_const_length_ofTopLevelVariable_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 const String S = 'abc';
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const v = S.length;
 ''');
@@ -11972,10 +11924,10 @@
   }
 
   test_const_length_ofTopLevelVariable_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 const String S = 'abc';
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const v = p.S.length;
 ''');
@@ -12014,7 +11966,7 @@
   }
 
   test_const_length_staticMethod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static int length() => 42;
 }
@@ -12053,7 +12005,7 @@
   }
 
   test_const_list_if() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>[if (true) 1];
 ''');
     checkElementText(library, r'''
@@ -12096,7 +12048,7 @@
   }
 
   test_const_list_if_else() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>[if (true) 1 else 2];
 ''');
     checkElementText(library, r'''
@@ -12146,7 +12098,7 @@
     // The summary needs to contain enough information so that when the constant
     // is resynthesized, the constant value can get the type that was computed
     // by type inference.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const [1];
 ''');
     checkElementText(library, r'''
@@ -12172,7 +12124,7 @@
   }
 
   test_const_list_spread() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>[...<int>[1]];
 ''');
     checkElementText(library, r'''
@@ -12225,7 +12177,7 @@
   }
 
   test_const_list_spread_null_aware() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>[...?<int>[1]];
 ''');
     checkElementText(library, r'''
@@ -12278,7 +12230,7 @@
   }
 
   test_const_map_if() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int, int>{if (true) 1: 2};
 ''');
     checkElementText(library, r'''
@@ -12336,7 +12288,7 @@
     // The summary needs to contain enough information so that when the constant
     // is resynthesized, the constant value can get the type that was computed
     // by type inference.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const {1: 1.0};
 ''');
     checkElementText(library, r'''
@@ -12368,7 +12320,7 @@
   }
 
   test_const_map_spread() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int, int>{...<int, int>{1: 2}};
 ''');
     checkElementText(library, r'''
@@ -12440,7 +12392,7 @@
   }
 
   test_const_map_spread_null_aware() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int, int>{...?<int, int>{1: 2}};
 ''');
     checkElementText(library, r'''
@@ -12512,7 +12464,7 @@
   }
 
   test_const_methodInvocation() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 T f<T>(T a) => a;
 const b = f<int>(0);
 ''');
@@ -12564,7 +12516,7 @@
   }
 
   test_const_parameterDefaultValue_initializingFormal_functionTyped() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   final x;
   const C({this.x: foo});
@@ -12600,7 +12552,7 @@
   }
 
   test_const_parameterDefaultValue_initializingFormal_named() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   final x;
   const C({this.x: 1 + 2});
@@ -12639,7 +12591,7 @@
   }
 
   test_const_parameterDefaultValue_initializingFormal_positional() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   final x;
   const C([this.x = 1 + 2]);
@@ -12678,7 +12630,7 @@
   }
 
   test_const_parameterDefaultValue_normal() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   const C.positional([p = 1 + 2]);
   const C.named({p: 1 + 2});
@@ -12779,7 +12731,7 @@
   }
 
   test_const_postfixExpression_increment() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 const b = a++;
 ''');
@@ -12817,7 +12769,7 @@
   }
 
   test_const_postfixExpression_nullCheck() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int? a = 0;
 const b = a!;
 ''');
@@ -12851,7 +12803,7 @@
   }
 
   test_const_prefixExpression_class_unaryMinus() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 const b = -a;
 ''');
@@ -12885,13 +12837,13 @@
   }
 
   test_const_prefixExpression_extension_unaryMinus() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 extension E on Object {
   int operator -() => 0;
 }
 const a = const Object();
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 const b = -a;
 ''');
@@ -12919,7 +12871,7 @@
   }
 
   test_const_prefixExpression_increment() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 const b = ++a;
 ''');
@@ -12957,7 +12909,7 @@
   }
 
   test_const_reference_staticField() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static const int F = 42;
 }
@@ -13003,12 +12955,12 @@
   }
 
   test_const_reference_staticField_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static const int F = 42;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = C.F;
 ''');
@@ -13040,12 +12992,12 @@
   }
 
   test_const_reference_staticField_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static const int F = 42;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = p.C.F;
 ''');
@@ -13084,7 +13036,7 @@
   }
 
   test_const_reference_staticMethod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   static int m(int a, String b) => 42;
 }
@@ -13128,12 +13080,12 @@
   }
 
   test_const_reference_staticMethod_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static int m(int a, String b) => 42;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = C.m;
 ''');
@@ -13165,12 +13117,12 @@
   }
 
   test_const_reference_staticMethod_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {
   static int m(int a, String b) => 42;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = p.C.m;
 ''');
@@ -13209,7 +13161,7 @@
   }
 
   test_const_reference_staticMethod_ofExtension() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 extension E on A {
   static void f() {}
@@ -13252,7 +13204,7 @@
   }
 
   test_const_reference_topLevelFunction() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 foo() {}
 const V = foo;
 ''');
@@ -13277,7 +13229,7 @@
   }
 
   test_const_reference_topLevelFunction_generic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 R foo<P, R>(P p) {}
 const V = foo;
 ''');
@@ -13308,10 +13260,10 @@
   }
 
   test_const_reference_topLevelFunction_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 foo() {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const V = foo;
 ''');
@@ -13335,10 +13287,10 @@
   }
 
   test_const_reference_topLevelFunction_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 foo() {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const V = p.foo;
 ''');
@@ -13370,7 +13322,7 @@
   }
 
   test_const_reference_topLevelVariable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const A = 1;
 const B = A + 2;
 ''');
@@ -13408,10 +13360,10 @@
   }
 
   test_const_reference_topLevelVariable_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 const A = 1;
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const B = A + 2;
 ''');
@@ -13443,10 +13395,10 @@
   }
 
   test_const_reference_topLevelVariable_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 const A = 1;
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const B = p.A + 2;
 ''');
@@ -13486,7 +13438,7 @@
   }
 
   test_const_reference_type() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {}
 class D<T> {}
 enum E {a, b, c}
@@ -13674,7 +13626,7 @@
   }
 
   test_const_reference_type_functionType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F();
 class C {
   final f = <F>[];
@@ -13702,12 +13654,12 @@
   }
 
   test_const_reference_type_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {}
 enum E {a, b, c}
 typedef F(int a, String b);
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const vClass = C;
 const vEnum = E;
@@ -13751,12 +13703,12 @@
   }
 
   test_const_reference_type_imported_withPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C {}
 enum E {a, b, c}
 typedef F(int a, String b);
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const vClass = p.C;
 const vEnum = p.E;
@@ -13824,7 +13776,7 @@
   }
 
   test_const_reference_type_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C<T> {
   final f = <T>[];
 }
@@ -13849,7 +13801,7 @@
   }
 
   test_const_reference_unresolved_prefix0() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const V = foo;
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -13870,7 +13822,7 @@
   }
 
   test_const_reference_unresolved_prefix1() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {}
 const V = C.foo;
 ''', allowErrors: true);
@@ -13904,10 +13856,10 @@
   }
 
   test_const_reference_unresolved_prefix2() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class C {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'foo.dart' as p;
 const V = p.C.foo;
 ''', allowErrors: true);
@@ -13946,7 +13898,7 @@
   }
 
   test_const_set_if() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>{if (true) 1};
 ''');
     checkElementText(library, r'''
@@ -13993,7 +13945,7 @@
     // The summary needs to contain enough information so that when the constant
     // is resynthesized, the constant value can get the type that was computed
     // by type inference.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const {1};
 ''');
     checkElementText(library, r'''
@@ -14020,7 +13972,7 @@
   }
 
   test_const_set_spread() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>{...<int>{1}};
 ''');
     checkElementText(library, r'''
@@ -14075,7 +14027,7 @@
   }
 
   test_const_set_spread_null_aware() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const Object x = const <int>{...?<int>{1}};
 ''');
     checkElementText(library, r'''
@@ -14130,7 +14082,7 @@
   }
 
   test_const_topLevel_binary() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vEqual = 1 == 2;
 const vAnd = true && false;
 const vOr = false || true;
@@ -14447,7 +14399,7 @@
   }
 
   test_const_topLevel_conditional() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vConditional = (1 == 2) ? 11 : 22;
 ''');
     checkElementText(library, r'''
@@ -14489,7 +14441,7 @@
   }
 
   test_const_topLevel_identical() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vIdentical = (1 == 2) ? 11 : 22;
 ''');
     checkElementText(library, r'''
@@ -14531,7 +14483,7 @@
   }
 
   test_const_topLevel_ifNull() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vIfNull = 1 ?? 2.0;
 ''');
     checkElementText(library, r'''
@@ -14559,7 +14511,7 @@
   }
 
   test_const_topLevel_literal() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vNull = null;
 const vBoolFalse = false;
 const vBoolTrue = true;
@@ -14720,7 +14672,7 @@
   }
 
   test_const_topLevel_methodInvocation_questionPeriod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int? a = 0;
 const b = a?.toString();
 ''');
@@ -14761,7 +14713,7 @@
   }
 
   test_const_topLevel_methodInvocation_questionPeriodPeriod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int? a = 0;
 const b = a?..toString();
 ''');
@@ -14805,7 +14757,7 @@
   }
 
   test_const_topLevel_nullSafe_nullAware_propertyAccess() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const String? a = '';
 
 const List<int?> b = [
@@ -14849,7 +14801,7 @@
   }
 
   test_const_topLevel_parenthesis() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const int v1 = (1 + 2) * 3;
 const int v2 = -(1 + 2);
 const int v3 = ('aaa' + 'bbb').length;
@@ -14940,7 +14892,7 @@
   }
 
   test_const_topLevel_prefix() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vNotEqual = 1 != 2;
 const vNot = !true;
 const vNegate = -1;
@@ -15007,7 +14959,7 @@
   }
 
   test_const_topLevel_super() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vSuper = super;
 ''');
     checkElementText(library, r'''
@@ -15027,7 +14979,7 @@
   }
 
   test_const_topLevel_this() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vThis = this;
 ''');
     checkElementText(library, r'''
@@ -15047,7 +14999,7 @@
   }
 
   test_const_topLevel_throw() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const c = throw 42;
 ''');
     checkElementText(library, r'''
@@ -15071,7 +15023,7 @@
 
   test_const_topLevel_throw_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const c = throw 42;
 ''');
     checkElementText(library, r'''
@@ -15094,7 +15046,7 @@
   }
 
   test_const_topLevel_typedList() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vNull = const <Null>[];
 const vDynamic = const <dynamic>[1, 2, 3];
 const vInterfaceNoTypeParameters = const <int>[1, 2, 3];
@@ -15287,8 +15239,8 @@
   }
 
   test_const_topLevel_typedList_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    var library = await buildLibrary(r'''
 import 'a.dart';
 const v = const <C>[];
 ''');
@@ -15323,8 +15275,8 @@
   }
 
   test_const_topLevel_typedList_importedWithPrefix() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    var library = await buildLibrary(r'''
 import 'a.dart' as p;
 const v = const <p.C>[];
 ''');
@@ -15367,7 +15319,7 @@
   }
 
   test_const_topLevel_typedList_typedefArgument() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef int F(String id);
 const v = const <F>[];
 ''');
@@ -15409,7 +15361,7 @@
   }
 
   test_const_topLevel_typedMap() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vDynamic1 = const <dynamic, int>{};
 const vDynamic2 = const <int, dynamic>{};
 const vInterface = const <int, String>{};
@@ -15542,7 +15494,7 @@
   }
 
   test_const_topLevel_typedSet() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const vDynamic1 = const <dynamic>{};
 const vInterface = const <int>{};
 const vInterfaceWithTypeArguments = const <List<String>>{};
@@ -15629,7 +15581,7 @@
   }
 
   test_const_topLevel_untypedList() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = const [1, 2, 3];
 ''');
     checkElementText(library, r'''
@@ -15661,7 +15613,7 @@
   }
 
   test_const_topLevel_untypedMap() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = const {0: 'aaa', 1: 'bbb', 2: 'ccc'};
 ''');
     checkElementText(library, r'''
@@ -15706,7 +15658,7 @@
   }
 
   test_const_topLevel_untypedSet() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = const {0, 1, 2};
 ''');
     checkElementText(library, r'''
@@ -15739,7 +15691,7 @@
   }
 
   test_const_typeLiteral() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const v = List<int>;
 ''');
     checkElementText(library, r'''
@@ -15774,7 +15726,7 @@
   }
 
   test_constExpr_pushReference_enum_field() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {a, b, c}
 final vValue = E.a;
 final vValues = E.values;
@@ -15884,7 +15836,7 @@
   }
 
   test_constExpr_pushReference_enum_method() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {a}
 final vToString = E.a.toString();
 ''');
@@ -15940,7 +15892,7 @@
   }
 
   test_constExpr_pushReference_field_simpleIdentifier() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static const a = b;
   static const b = null;
@@ -15976,7 +15928,7 @@
   }
 
   test_constExpr_pushReference_staticMethod_simpleIdentifier() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static const a = m;
   static m() {}
@@ -16007,7 +15959,7 @@
   }
 
   test_defaultValue_eliminateTypeParameters() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const X({List<T> a = const []});
 }
@@ -16039,7 +15991,7 @@
 
   test_defaultValue_eliminateTypeParameters_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const X({List<T> a = const []});
 }
@@ -16070,7 +16022,7 @@
   }
 
   test_defaultValue_genericFunction() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef void F<T>(T v);
 
 void defaultF<T>(T v) {}
@@ -16138,7 +16090,7 @@
   }
 
   test_defaultValue_genericFunctionType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A();
 }
@@ -16200,7 +16152,7 @@
   }
 
   test_defaultValue_inFunctionTypedFormalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f( g({a: 0 is int}) ) {}
 ''');
     checkElementText(library, r'''
@@ -16233,7 +16185,7 @@
 
   test_defaultValue_methodMember_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f([Comparator<T> compare = Comparable.compare]) {}
 ''');
     checkElementText(library, r'''
@@ -16269,7 +16221,7 @@
   }
 
   test_defaultValue_refersToExtension_method_inside() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 extension E on A {
   static void f() {}
@@ -16303,7 +16255,7 @@
   }
 
   test_defaultValue_refersToGenericClass() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T1, T2> {
   const B();
 }
@@ -16353,7 +16305,7 @@
   }
 
   test_defaultValue_refersToGenericClass_constructor() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T> {
   const B();
 }
@@ -16401,7 +16353,7 @@
   }
 
   test_defaultValue_refersToGenericClass_constructor2() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class A<T> {}
 class B<T> implements A<T> {
   const B();
@@ -16461,7 +16413,7 @@
 
   test_defaultValue_refersToGenericClass_constructor2_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class A<T> {}
 class B<T> implements A<T> {
   const B();
@@ -16521,7 +16473,7 @@
 
   test_defaultValue_refersToGenericClass_constructor_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T> {
   const B();
 }
@@ -16569,7 +16521,7 @@
   }
 
   test_defaultValue_refersToGenericClass_functionG() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T> {
   const B();
 }
@@ -16614,7 +16566,7 @@
   }
 
   test_defaultValue_refersToGenericClass_methodG() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T> {
   const B();
 }
@@ -16664,7 +16616,7 @@
   }
 
   test_defaultValue_refersToGenericClass_methodG_classG() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T1, T2> {
   const B();
 }
@@ -16719,7 +16671,7 @@
   }
 
   test_defaultValue_refersToGenericClass_methodNG() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class B<T> {
   const B();
 }
@@ -16770,7 +16722,7 @@
   }
 
   test_duplicateDeclaration_class() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 class A {
   var x;
@@ -16818,7 +16770,7 @@
   }
 
   test_duplicateDeclaration_classTypeAlias() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 class B {}
 class X = A with M;
@@ -16873,7 +16825,7 @@
   }
 
   test_duplicateDeclaration_enum() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {a, b}
 enum E {c, d, e}
 ''');
@@ -17027,7 +16979,7 @@
   }
 
   test_duplicateDeclaration_extension() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 extension E on A {}
 extension E on A {
@@ -17077,7 +17029,7 @@
   }
 
   test_duplicateDeclaration_function() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f() {}
 void f(int a) {}
 void f([int b, double c]) {}
@@ -17104,7 +17056,7 @@
   }
 
   test_duplicateDeclaration_functionTypeAlias() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F();
 typedef void F(int a);
 typedef void F([int b, double c]);
@@ -17137,7 +17089,7 @@
   }
 
   test_duplicateDeclaration_mixin() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin A {}
 mixin A {
   var x;
@@ -17191,7 +17143,7 @@
   }
 
   test_duplicateDeclaration_topLevelVariable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 bool x;
 var x;
 var x = 1;
@@ -17242,7 +17194,7 @@
   }
 
   test_enum_constant_inference() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T> {
   int(1), string('2');
   const E(T a);
@@ -17334,7 +17286,7 @@
 
   /// Test that a constant named `_name` renames the synthetic `name` field.
   test_enum_constant_name() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   _name;
 }
@@ -17385,7 +17337,7 @@
   }
 
   test_enum_constant_typeArguments() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T> {
   v<double>(42);
   const E(T a);
@@ -17459,7 +17411,7 @@
   }
 
   test_enum_constant_underscore() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   _
 }
@@ -17510,7 +17462,7 @@
   }
 
   test_enum_constructor_factory_named() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   factory E.named() => v;
@@ -17565,7 +17517,7 @@
   }
 
   test_enum_constructor_factory_unnamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   factory E() => v;
@@ -17617,7 +17569,7 @@
   }
 
   test_enum_constructor_fieldFormal_functionTyped_withReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   final x;
@@ -17681,7 +17633,7 @@
   }
 
   test_enum_constructor_fieldFormal_multiple_matching_fields() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   v;
   final int x;
@@ -17747,7 +17699,7 @@
   }
 
   test_enum_constructor_fieldFormal_no_matching_field() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   v;
   const E(this.x);
@@ -17803,7 +17755,7 @@
   }
 
   test_enum_constructor_fieldFormal_typed_typed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   v;
   final num x;
@@ -17864,7 +17816,7 @@
   }
 
   test_enum_constructor_fieldFormal_untyped_typed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   final x;
@@ -17925,7 +17877,7 @@
   }
 
   test_enum_constructor_fieldFormal_untyped_untyped() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   final x;
@@ -17986,7 +17938,7 @@
   }
 
   test_enum_constructor_generative_named() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v.named(42);
   const E.named(int a);
@@ -18052,7 +18004,7 @@
   }
 
   test_enum_constructor_generative_unnamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v(42);
   const E(int a);
@@ -18111,7 +18063,7 @@
   }
 
   test_enum_constructor_initializer() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T> {
   v;
   final int x;
@@ -18203,7 +18155,7 @@
   }
 
   test_enum_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -18256,7 +18208,7 @@
   }
 
   test_enum_field() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   final foo = 42;
@@ -18316,7 +18268,7 @@
   }
 
   test_enum_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E{
   v;
   int get foo => 0;
@@ -18372,7 +18324,7 @@
   }
 
   test_enum_interfaces() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class I {}
 enum E implements I {
   v;
@@ -18430,7 +18382,7 @@
   }
 
   test_enum_interfaces_generic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class I<T> {}
 enum E<U> implements I<U> {
   v;
@@ -18496,7 +18448,7 @@
   }
 
   test_enum_interfaces_unresolved() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class X {}
 class Z {}
 enum E implements X, Y, Z {
@@ -18559,7 +18511,7 @@
   }
 
   test_enum_method() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T> {
   v;
   int foo<U>(T t, U u) => 0;
@@ -18626,7 +18578,7 @@
   }
 
   test_enum_method_toString() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   v;
   String toString() => 'E';
@@ -18681,7 +18633,7 @@
   }
 
   test_enum_mixins() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {}
 enum E with M {
   v;
@@ -18741,7 +18693,7 @@
   }
 
   test_enum_mixins_inference() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M1<T> {}
 mixin M2<T> on M1<T> {}
 enum E with M1<int>, M2 {
@@ -18814,7 +18766,7 @@
   }
 
   test_enum_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E{
   v;
   set foo(int _) {}
@@ -18873,7 +18825,7 @@
   }
 
   test_enum_typeParameters() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<T> {
   v
 }
@@ -18929,7 +18881,7 @@
   }
 
   test_enum_typeParameters_bound() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<T extends num, U extends T> {
   v
 }
@@ -18989,7 +18941,7 @@
   }
 
   test_enum_typeParameters_cycle_1of1() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<T extends T> {}
 ''');
     checkElementText(library, r'''
@@ -19019,7 +18971,7 @@
   }
 
   test_enum_typeParameters_cycle_2of3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T extends V, U extends num, V extends T> {}
 ''');
     checkElementText(library, r'''
@@ -19055,7 +19007,7 @@
   }
 
   test_enum_typeParameters_defaultType_cycle_genericFunctionType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E<T extends void Function(E)> {}
 ''');
     checkElementText(library, r'''
@@ -19085,7 +19037,7 @@
   }
 
   test_enum_typeParameters_variance_contravariant() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<in T> {}
 ''');
     checkElementText(library, r'''
@@ -19114,7 +19066,7 @@
   }
 
   test_enum_typeParameters_variance_covariant() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<out T> {}
 ''');
     checkElementText(library, r'''
@@ -19143,7 +19095,7 @@
   }
 
   test_enum_typeParameters_variance_invariant() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<inout T> {}
 ''');
     checkElementText(library, r'''
@@ -19172,7 +19124,7 @@
   }
 
   test_enum_typeParameters_variance_multiple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E<inout T, in U, out V> {}
 ''');
     checkElementText(library, r'''
@@ -19205,7 +19157,7 @@
   }
 
   test_enum_value_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   /**
    * aaa
@@ -19284,7 +19236,7 @@
   }
 
   test_enum_value_documented_withMetadata() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {
   /**
    * aaa
@@ -19394,7 +19346,7 @@
   }
 
   test_enum_values() async {
-    var library = await checkLibrary('enum E { v1, v2 }');
+    var library = await buildLibrary('enum E { v1, v2 }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -19463,7 +19415,7 @@
   }
 
   test_enums() async {
-    var library = await checkLibrary('enum E1 { v1 } enum E2 { v2 }');
+    var library = await buildLibrary('enum E1 { v1 } enum E2 { v2 }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -19548,7 +19500,7 @@
   }
 
   test_error_extendsEnum() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {a, b, c}
 
 class M {}
@@ -19697,7 +19649,7 @@
   }
 
   test_executable_parameter_type_typedef() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F(int p);
 main(F f) {}
 ''');
@@ -19723,8 +19675,8 @@
   }
 
   test_export_class() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -19739,12 +19691,12 @@
   }
 
   test_export_class_type_alias() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class C = _D with _E;
 class _D {}
 class _E {}
 ''');
-    var library = await checkLibrary('export "a.dart";');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -19762,10 +19714,10 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -19789,10 +19741,10 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -19816,10 +19768,10 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -19840,8 +19792,8 @@
   }
 
   test_export_function() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'f() {}');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'f() {}');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -19856,8 +19808,8 @@
   }
 
   test_export_getter() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'get f() => null;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'get f() => null;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -19867,13 +19819,13 @@
   }
 
   test_export_hide() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
 class D {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 export 'a.dart' hide A, C;
 ''');
     checkElementText(
@@ -19893,13 +19845,13 @@
   }
 
   test_export_multiple_combinators() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
 class D {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 export 'a.dart' hide A show C;
 ''');
     checkElementText(
@@ -19919,8 +19871,8 @@
   }
 
   test_export_setter() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'void set f(value) {}');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'void set f(value) {}');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -19935,13 +19887,13 @@
   }
 
   test_export_show() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A {}
 class B {}
 class C {}
 class D {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 export 'a.dart' show A, C;
 ''');
     checkElementText(
@@ -19961,11 +19913,11 @@
   }
 
   test_export_show_getter_setter() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 get f => null;
 void set f(value) {}
 ''');
-    var library = await checkLibrary('export "a.dart" show f;');
+    var library = await buildLibrary('export "a.dart" show f;');
     checkElementText(
         library,
         r'''
@@ -19983,8 +19935,8 @@
   }
 
   test_export_typedef() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'typedef F();');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'typedef F();');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -19999,15 +19951,15 @@
   }
 
   test_export_uri() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 export 'foo.dart';
 ''');
     expect(library.exports[0].uri, 'foo.dart');
   }
 
   test_export_variable() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'var x;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'var x;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -20023,8 +19975,8 @@
   }
 
   test_export_variable_const() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'const x = 0;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'const x = 0;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -20039,8 +19991,8 @@
   }
 
   test_export_variable_final() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'final x = 0;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'final x = 0;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(
         library,
         r'''
@@ -20058,15 +20010,15 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/bar.dart', r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addSource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'bar.dart';
 class B extends A {}
 ''');
@@ -20091,15 +20043,15 @@
       'dart.library.io': 'true',
       'dart.library.html': 'false',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/bar.dart', r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addSource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'bar.dart';
 class B extends A {}
 ''');
@@ -20124,15 +20076,15 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/bar.dart', r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    addSource('$testPackageLibPath/bar.dart', r'''
 export 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'bar.dart';
 class B extends A {}
 ''');
@@ -20153,9 +20105,9 @@
   }
 
   test_exports() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library a;');
-    addLibrarySource('$testPackageLibPath/b.dart', 'library b;');
-    var library = await checkLibrary('export "a.dart"; export "b.dart";');
+    addSource('$testPackageLibPath/a.dart', 'library a;');
+    addSource('$testPackageLibPath/b.dart', 'library b;');
+    var library = await buildLibrary('export "a.dart"; export "b.dart";');
     checkElementText(
         library,
         r'''
@@ -20170,7 +20122,7 @@
   }
 
   test_expr_invalid_typeParameter_asPrefix() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   final f = T.k;
 }
@@ -20195,7 +20147,7 @@
   }
 
   test_extension_documented_tripleSlash() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// aaa
 /// bbbb
 /// cc
@@ -20211,7 +20163,7 @@
   }
 
   test_extension_field_inferredType_const() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 extension E on int {
   static const x = 0;
 }''');
@@ -20235,7 +20187,7 @@
   }
 
   test_function_async() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 Future f() async {}
 ''');
@@ -20251,7 +20203,7 @@
   }
 
   test_function_asyncStar() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 Stream f() async* {}
 ''');
@@ -20267,7 +20219,7 @@
   }
 
   test_function_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -20284,7 +20236,7 @@
   }
 
   test_function_entry_point() async {
-    var library = await checkLibrary('main() {}');
+    var library = await buildLibrary('main() {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20295,8 +20247,8 @@
   }
 
   test_function_entry_point_in_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library a; main() {}');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'library a; main() {}');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -20306,8 +20258,8 @@
   }
 
   test_function_entry_point_in_export_hidden() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library a; main() {}');
-    var library = await checkLibrary('export "a.dart" hide main;');
+    addSource('$testPackageLibPath/a.dart', 'library a; main() {}');
+    var library = await buildLibrary('export "a.dart" hide main;');
     checkElementText(library, r'''
 library
   exports
@@ -20320,7 +20272,7 @@
 
   test_function_entry_point_in_part() async {
     addSource('$testPackageLibPath/a.dart', 'part of my.lib; main() {}');
-    var library = await checkLibrary('library my.lib; part "a.dart";');
+    var library = await buildLibrary('library my.lib; part "a.dart";');
     checkElementText(library, r'''
 library
   name: my.lib
@@ -20335,7 +20287,7 @@
   }
 
   test_function_external() async {
-    var library = await checkLibrary('external f();');
+    var library = await buildLibrary('external f();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20346,7 +20298,7 @@
   }
 
   test_function_hasImplicitReturnType_false() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 int f() => 0;
 ''');
     var f = library.definingCompilationUnit.functions.single;
@@ -20354,7 +20306,7 @@
   }
 
   test_function_hasImplicitReturnType_true() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f() => 0;
 ''');
     var f = library.definingCompilationUnit.functions.single;
@@ -20362,7 +20314,7 @@
   }
 
   test_function_parameter_const() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f(const x) {}
 ''');
     checkElementText(library, r'''
@@ -20378,7 +20330,7 @@
   }
 
   test_function_parameter_fieldFormal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f(int this.a) {}
 ''');
     checkElementText(library, r'''
@@ -20395,7 +20347,7 @@
   }
 
   test_function_parameter_fieldFormal_default() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f({int this.a: 42}) {}
 ''');
     checkElementText(library, r'''
@@ -20416,7 +20368,7 @@
   }
 
   test_function_parameter_fieldFormal_functionTyped() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f(int this.a(int b)) {}
 ''');
     checkElementText(library, r'''
@@ -20436,7 +20388,7 @@
   }
 
   test_function_parameter_final() async {
-    var library = await checkLibrary('f(final x) {}');
+    var library = await buildLibrary('f(final x) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20450,7 +20402,7 @@
   }
 
   test_function_parameter_kind_named() async {
-    var library = await checkLibrary('f({x}) {}');
+    var library = await buildLibrary('f({x}) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20464,7 +20416,7 @@
   }
 
   test_function_parameter_kind_positional() async {
-    var library = await checkLibrary('f([x]) {}');
+    var library = await buildLibrary('f([x]) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20478,7 +20430,7 @@
   }
 
   test_function_parameter_kind_required() async {
-    var library = await checkLibrary('f(x) {}');
+    var library = await buildLibrary('f(x) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20492,7 +20444,7 @@
   }
 
   test_function_parameter_parameters() async {
-    var library = await checkLibrary('f(g(x, y)) {}');
+    var library = await buildLibrary('f(g(x, y)) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20511,7 +20463,7 @@
   }
 
   test_function_parameter_return_type() async {
-    var library = await checkLibrary('f(int g()) {}');
+    var library = await buildLibrary('f(int g()) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20525,7 +20477,7 @@
   }
 
   test_function_parameter_return_type_void() async {
-    var library = await checkLibrary('f(void g()) {}');
+    var library = await buildLibrary('f(void g()) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20539,7 +20491,7 @@
   }
 
   test_function_parameter_type() async {
-    var library = await checkLibrary('f(int i) {}');
+    var library = await buildLibrary('f(int i) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20553,7 +20505,7 @@
   }
 
   test_function_parameters() async {
-    var library = await checkLibrary('f(x, y) {}');
+    var library = await buildLibrary('f(x, y) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20569,7 +20521,7 @@
   }
 
   test_function_return_type() async {
-    var library = await checkLibrary('int f() => null;');
+    var library = await buildLibrary('int f() => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20580,7 +20532,7 @@
   }
 
   test_function_return_type_implicit() async {
-    var library = await checkLibrary('f() => null;');
+    var library = await buildLibrary('f() => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20591,7 +20543,7 @@
   }
 
   test_function_return_type_void() async {
-    var library = await checkLibrary('void f() {}');
+    var library = await buildLibrary('void f() {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20602,7 +20554,7 @@
   }
 
   test_function_type_parameter() async {
-    var library = await checkLibrary('T f<T, U>(U u) => null;');
+    var library = await buildLibrary('T f<T, U>(U u) => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20619,7 +20571,7 @@
   }
 
   test_function_type_parameter_with_function_typed_parameter() async {
-    var library = await checkLibrary('void f<T, U>(T x(U u)) {}');
+    var library = await buildLibrary('void f<T, U>(T x(U u)) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20639,7 +20591,7 @@
   }
 
   test_function_typed_parameter_implicit() async {
-    var library = await checkLibrary('f(g()) => null;');
+    var library = await buildLibrary('f(g()) => null;');
     expect(
         library
             .definingCompilationUnit.functions[0].parameters[0].hasImplicitType,
@@ -20647,7 +20599,7 @@
   }
 
   test_functions() async {
-    var library = await checkLibrary('f() {} g() {}');
+    var library = await buildLibrary('f() {} g() {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -20660,7 +20612,7 @@
   }
 
   test_functionTypeAlias_enclosingElements() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F<T>(int a);
 ''');
     var unit = library.definingCompilationUnit;
@@ -20681,7 +20633,7 @@
   }
 
   test_functionTypeAlias_type_element() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef T F<T>();
 F<int> a;
 ''');
@@ -20693,7 +20645,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_contravariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F<T>(T a);
 ''');
     checkElementText(library, r'''
@@ -20714,7 +20666,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_contravariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F1<T>(T a);
 typedef F1<T> F2<T>();
 ''');
@@ -20746,7 +20698,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_contravariant3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1<T> F2<T>();
 typedef void F1<T>(T a);
 ''');
@@ -20778,7 +20730,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_covariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef T F<T>();
 ''');
     checkElementText(library, r'''
@@ -20796,7 +20748,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_covariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef List<T> F<T>();
 ''');
     checkElementText(library, r'''
@@ -20814,7 +20766,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_covariant3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef T F1<T>();
 typedef F1<T> F2<T>();
 ''');
@@ -20843,7 +20795,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_covariant4() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F1<T>(T a);
 typedef void F2<T>(F1<T> a);
 ''');
@@ -20878,7 +20830,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_invariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef T F<T>(T a);
 ''');
     checkElementText(library, r'''
@@ -20899,7 +20851,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_invariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef T F1<T>();
 typedef F1<T> F2<T>(T a);
 ''');
@@ -20931,7 +20883,7 @@
   }
 
   test_functionTypeAlias_typeParameters_variance_unrelated() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F<T>(int a);
 ''');
     checkElementText(library, r'''
@@ -20952,7 +20904,7 @@
   }
 
   test_futureOr() async {
-    var library = await checkLibrary('import "dart:async"; FutureOr<int> x;');
+    var library = await buildLibrary('import "dart:async"; FutureOr<int> x;');
     checkElementText(library, r'''
 library
   imports
@@ -20977,7 +20929,7 @@
 
   test_futureOr_const() async {
     var library =
-        await checkLibrary('import "dart:async"; const x = FutureOr;');
+        await buildLibrary('import "dart:async"; const x = FutureOr;');
     checkElementText(library, r'''
 library
   imports
@@ -21003,7 +20955,7 @@
   }
 
   test_futureOr_inferred() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "dart:async";
 FutureOr<int> f() => null;
 var x = f();
@@ -21049,7 +21001,7 @@
   }
 
   test_generic_function_type_nullability_none() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void Function() f;
 ''');
     checkElementText(library, r'''
@@ -21070,7 +21022,7 @@
   }
 
   test_generic_function_type_nullability_question() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void Function()? f;
 ''');
     checkElementText(library, r'''
@@ -21092,7 +21044,7 @@
 
   test_generic_function_type_nullability_star() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void Function() f;
 ''');
     checkElementText(library, r'''
@@ -21113,7 +21065,7 @@
   }
 
   test_generic_gClass_gMethodStatic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   static void m<V, W>(V v, W w) {
     void f<X, Y>(V v, W w, X x, Y y) {
@@ -21148,7 +21100,7 @@
   }
 
   test_genericFunction_asFunctionReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int Function(int a, String b) f() => null;
 ''');
     checkElementText(library, r'''
@@ -21161,7 +21113,7 @@
   }
 
   test_genericFunction_asFunctionTypedParameterReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f(int Function(int a, String b) p(num c)) => null;
 ''');
     checkElementText(library, r'''
@@ -21180,7 +21132,7 @@
   }
 
   test_genericFunction_asGenericFunctionReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F = void Function(String a) Function(int b);
 ''');
     checkElementText(library, r'''
@@ -21198,7 +21150,7 @@
   }
 
   test_genericFunction_asMethodReturnType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   int Function(int a, String b) m() => null;
 }
@@ -21217,7 +21169,7 @@
   }
 
   test_genericFunction_asParameterType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f(int Function(int a, String b) p) => null;
 ''');
     checkElementText(library, r'''
@@ -21233,7 +21185,7 @@
   }
 
   test_genericFunction_asTopLevelVariableType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int Function(int a, String b) v;
 ''');
     checkElementText(library, r'''
@@ -21254,7 +21206,7 @@
   }
 
   test_genericFunction_asTypeArgument_ofAnnotation_class() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21328,7 +21280,7 @@
   }
 
   test_genericFunction_asTypeArgument_ofAnnotation_topLevelVariable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21410,7 +21362,7 @@
   }
 
   test_genericFunction_asTypeArgument_parameters_optionalNamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21495,7 +21447,7 @@
   }
 
   test_genericFunction_asTypeArgument_parameters_optionalPositional() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21580,7 +21532,7 @@
   }
 
   test_genericFunction_asTypeArgument_parameters_requiredNamed() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21665,7 +21617,7 @@
   }
 
   test_genericFunction_asTypeArgument_parameters_requiredPositional() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -21744,7 +21696,7 @@
   }
 
   test_genericFunction_boundOf_typeParameter_ofMixin() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin B<X extends void Function()> {}
 ''');
     checkElementText(library, r'''
@@ -21764,7 +21716,7 @@
   }
 
   test_genericFunction_typeArgument_ofSuperclass_ofClassAlias() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {}
 mixin M {}
 class B = A<void Function()> with M;
@@ -21805,7 +21757,7 @@
   }
 
   test_genericFunction_typeParameter_asTypedefArgument() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1 = Function<V1>(F2<V1>);
 typedef F2<V2> = V2 Function();
 ''');
@@ -21836,7 +21788,7 @@
   }
 
   test_genericTypeAlias_enclosingElements() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = void Function<U>(int a);
 ''');
     var unit = library.definingCompilationUnit;
@@ -21861,7 +21813,7 @@
   }
 
   test_genericTypeAlias_recursive() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<X extends F> = Function(F);
 ''');
     checkElementText(library, r'''
@@ -21883,7 +21835,7 @@
   }
 
   test_getter_async() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 Future<int> get foo async => 0;
 ''');
     checkElementText(library, r'''
@@ -21899,7 +21851,7 @@
   }
 
   test_getter_asyncStar() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 Stream<int> get foo async* {}
 ''');
@@ -21918,7 +21870,7 @@
   }
 
   test_getter_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -21938,7 +21890,7 @@
   }
 
   test_getter_external() async {
-    var library = await checkLibrary('external int get x;');
+    var library = await buildLibrary('external int get x;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -21952,7 +21904,7 @@
   }
 
   test_getter_inferred_type_nonStatic_implicit_return() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'class C extends D { get f => null; } abstract class D { int get f; }');
     checkElementText(library, r'''
 library
@@ -21982,7 +21934,7 @@
   }
 
   test_getter_syncStar() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 Iterator<int> get foo sync* {}
 ''');
     checkElementText(library, r'''
@@ -21998,7 +21950,7 @@
   }
 
   test_getters() async {
-    var library = await checkLibrary('int get x => null; get y => null;');
+    var library = await buildLibrary('int get x => null; get y => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -22016,7 +21968,7 @@
   }
 
   test_implicitCallTearoff() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   void call() {}
 }
@@ -22074,7 +22026,7 @@
   }
 
   test_implicitConstructor_named_const() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   final Object x;
   const C.named(this.x);
@@ -22134,7 +22086,7 @@
 
   test_implicitTopLevelVariable_getterFirst() async {
     var library =
-        await checkLibrary('int get x => 0; void set x(int value) {}');
+        await buildLibrary('int get x => 0; void set x(int value) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -22154,7 +22106,7 @@
 
   test_implicitTopLevelVariable_setterFirst() async {
     var library =
-        await checkLibrary('void set x(int value) {} int get x => 0;');
+        await buildLibrary('void set x(int value) {} int get x => 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -22176,10 +22128,10 @@
     declaredVariables = DeclaredVariables.fromMap({
       'dart.library.io': 'false',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -22207,10 +22159,10 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -22238,10 +22190,10 @@
       'dart.library.io': 'true',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 import 'foo.dart'
   if (dart.library.io == 'true') 'foo_io.dart'
   if (dart.library.html == 'true') 'foo_html.dart';
@@ -22269,10 +22221,10 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 import 'foo.dart'
   if (dart.library.io) 'foo_io.dart'
   if (dart.library.html) 'foo_html.dart';
@@ -22300,10 +22252,10 @@
       'dart.library.io': 'false',
       'dart.library.html': 'true',
     });
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_io.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/foo_html.dart', 'class A {}');
-    var library = await checkLibrary(r'''
+    addSource('$testPackageLibPath/foo.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_io.dart', 'class A {}');
+    addSource('$testPackageLibPath/foo_html.dart', 'class A {}');
+    var library = await buildLibrary(r'''
 import 'foo.dart'
   if (dart.library.io == 'true') 'foo_io.dart'
   if (dart.library.html == 'true') 'foo_html.dart';
@@ -22327,7 +22279,7 @@
   }
 
   test_import_dartCore_explicit() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'dart:core';
 import 'dart:math';
 ''');
@@ -22341,7 +22293,7 @@
   }
 
   test_import_dartCore_implicit() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'dart:math';
 ''');
     checkElementText(library, r'''
@@ -22353,8 +22305,8 @@
   }
 
   test_import_deferred() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'f() {}');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'f() {}');
+    var library = await buildLibrary('''
 import 'a.dart' deferred as p;
 ''');
     checkElementText(library, r'''
@@ -22366,8 +22318,7 @@
   }
 
   test_import_export() async {
-    addLibrary('dart:async');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'dart:async' as i1;
 export 'dart:math';
 import 'dart:async' as i2;
@@ -22390,8 +22341,7 @@
   }
 
   test_import_hide() async {
-    addLibrary('dart:async');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'dart:async' hide Stream, Completer; Future f;
 ''');
     checkElementText(library, r'''
@@ -22416,7 +22366,7 @@
   }
 
   test_import_invalidUri_metadata() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 @foo
 import 'ht:';
 ''');
@@ -22445,8 +22395,7 @@
   }
 
   test_import_multiple_combinators() async {
-    addLibrary('dart:async');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "dart:async" hide Stream show Future;
 Future f;
 ''');
@@ -22473,8 +22422,8 @@
   }
 
   test_import_prefixed() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library a; class C {}');
-    var library = await checkLibrary('import "a.dart" as a; a.C c;');
+    addSource('$testPackageLibPath/a.dart', 'library a; class C {}');
+    var library = await buildLibrary('import "a.dart" as a; a.C c;');
 
     expect(library.imports[0].prefix!.nameOffset, 19);
     expect(library.imports[0].prefix!.nameLength, 1);
@@ -22499,7 +22448,7 @@
   }
 
   test_import_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'test.dart' as p;
 class C {}
 class D extends p.C {} // Prevent "unused import" warning
@@ -22525,8 +22474,7 @@
   }
 
   test_import_show() async {
-    addLibrary('dart:async');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "dart:async" show Future, Stream;
 Future f;
 Stream s;
@@ -22562,7 +22510,7 @@
   }
 
   test_import_show_offsetEnd() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "dart:math" show e, pi;
 ''');
     var import = library.imports[0];
@@ -22572,17 +22520,17 @@
   }
 
   test_import_uri() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart';
 ''');
     expect(library.imports[0].uri, 'foo.dart');
   }
 
   test_imports() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library a; class C {}');
-    addLibrarySource('$testPackageLibPath/b.dart', 'library b; class D {}');
+    addSource('$testPackageLibPath/a.dart', 'library a; class C {}');
+    addSource('$testPackageLibPath/b.dart', 'library b; class D {}');
     var library =
-        await checkLibrary('import "a.dart"; import "b.dart"; C c; D d;');
+        await buildLibrary('import "a.dart"; import "b.dart"; C c; D d;');
     checkElementText(library, r'''
 library
   imports
@@ -22613,7 +22561,7 @@
   }
 
   test_infer_generic_typedef_complex() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T> = D<T,U> Function<U>();
 class C<V> {
   const C(F<V> f);
@@ -22693,7 +22641,7 @@
   }
 
   test_infer_generic_typedef_simple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = D<T> Function<T>();
 class C {
   const C(F f);
@@ -22761,7 +22709,7 @@
   }
 
   test_infer_instanceCreation_fromArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 
 class B extends A {}
@@ -22809,7 +22757,7 @@
   }
 
   test_infer_property_set() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   B b;
 }
@@ -22887,7 +22835,7 @@
 
   test_inference_issue_32394() async {
     // Test the type inference involved in dartbug.com/32394
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = y.map((a) => a.toString());
 var y = [3];
 var z = x.toList();
@@ -22928,7 +22876,7 @@
   }
 
   test_inference_map() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int p;
 }
@@ -22979,7 +22927,7 @@
   test_inferred_function_type_for_variable_in_generic_function() async {
     // In the code below, `x` has an inferred type of `() => int`, with 2
     // (unused) type parameters from the enclosing top level function.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f<U, V>() {
   var x = () => 0;
 }
@@ -22999,7 +22947,7 @@
   test_inferred_function_type_in_generic_class_constructor() async {
     // In the code below, `() => () => 0` has an inferred return type of
     // `() => int`, with 2 (unused) type parameters from the enclosing class.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<U, V> {
   final x;
   C() : x = (() => () => 0);
@@ -23029,7 +22977,7 @@
   test_inferred_function_type_in_generic_class_getter() async {
     // In the code below, `() => () => 0` has an inferred return type of
     // `() => int`, with 2 (unused) type parameters from the enclosing class.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<U, V> {
   get x => () => () => 0;
 }
@@ -23059,7 +23007,7 @@
     // In the code below, `() => () => 0` has an inferred return type of
     // `() => int`, with 3 (unused) type parameters from the enclosing class
     // and method.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   f<U, V>() {
     print(() => () => 0);
@@ -23088,7 +23036,7 @@
   test_inferred_function_type_in_generic_class_setter() async {
     // In the code below, `() => () => 0` has an inferred return type of
     // `() => int`, with 2 (unused) type parameters from the enclosing class.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<U, V> {
   void set x(value) {
     print(() => () => 0);
@@ -23122,7 +23070,7 @@
   test_inferred_function_type_in_generic_closure() async {
     // In the code below, `<U, V>() => () => 0` has an inferred return type of
     // `() => int`, with 3 (unused) type parameters.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f<T>() {
   print(/*<U, V>*/() => () => 0);
 }
@@ -23141,7 +23089,7 @@
   test_inferred_generic_function_type_in_generic_closure() async {
     // In the code below, `<U, V>() => <W, X, Y, Z>() => 0` has an inferred
     // return type of `() => int`, with 7 (unused) type parameters.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f<T>() {
   print(/*<U, V>*/() => /*<W, X, Y, Z>*/() => 0);
 }
@@ -23158,7 +23106,7 @@
   }
 
   test_inferred_type_functionExpressionInvocation_oppositeOrder() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   static final foo = bar(1.2);
   static final bar = baz();
@@ -23190,7 +23138,7 @@
   }
 
   test_inferred_type_initializer_cycle() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 var a = b + 1;
 var b = c + 2;
 var c = a + 3;
@@ -23244,7 +23192,7 @@
   }
 
   test_inferred_type_is_typedef() async {
-    var library = await checkLibrary('typedef int F(String s);'
+    var library = await buildLibrary('typedef int F(String s);'
         ' class C extends D { var v; }'
         ' abstract class D { F get v; }');
     checkElementText(library, r'''
@@ -23294,7 +23242,7 @@
 
   test_inferred_type_nullability_class_ref_none() async {
     addSource('$testPackageLibPath/a.dart', 'int f() => 0;');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 var x = f();
 ''');
@@ -23319,7 +23267,7 @@
 
   test_inferred_type_nullability_class_ref_question() async {
     addSource('$testPackageLibPath/a.dart', 'int? f() => 0;');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 var x = f();
 ''');
@@ -23344,7 +23292,7 @@
 
   test_inferred_type_nullability_function_type_none() async {
     addSource('$testPackageLibPath/a.dart', 'void Function() f() => () {};');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 var x = f();
 ''');
@@ -23369,7 +23317,7 @@
 
   test_inferred_type_nullability_function_type_question() async {
     addSource('$testPackageLibPath/a.dart', 'void Function()? f() => () {};');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 var x = f();
 ''');
@@ -23393,7 +23341,7 @@
   }
 
   test_inferred_type_refers_to_bound_type_param() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> extends D<int, T> {
   var v;
 }
@@ -23444,7 +23392,7 @@
   }
 
   test_inferred_type_refers_to_function_typed_param_of_typedef() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef void F(int g(String s));
 h(F f) => null;
 var v = h((y) {});
@@ -23485,7 +23433,7 @@
   }
 
   test_inferred_type_refers_to_function_typed_parameter_type_generic_class() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> extends D<U, int> {
   void f(int x, g) {}
 }
@@ -23539,16 +23487,16 @@
   }
 
   test_inferred_type_refers_to_function_typed_parameter_type_other_lib() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 import 'b.dart';
 abstract class D extends E {}
 ''');
-    addLibrarySource('$testPackageLibPath/b.dart', '''
+    addSource('$testPackageLibPath/b.dart', '''
 abstract class E {
   void f(int x, int g(String s));
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'a.dart';
 class C extends D {
   void f(int x, g) {}
@@ -23577,7 +23525,7 @@
   }
 
   test_inferred_type_refers_to_method_function_typed_parameter_type() async {
-    var library = await checkLibrary('class C extends D { void f(int x, g) {} }'
+    var library = await buildLibrary('class C extends D { void f(int x, g) {} }'
         ' abstract class D { void f(int x, int g(String s)); }');
     checkElementText(library, r'''
 library
@@ -23614,7 +23562,7 @@
   }
 
   test_inferred_type_refers_to_nested_function_typed_param() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f(void g(int x, void h())) => null;
 var v = f((x, y) {});
 ''');
@@ -23647,7 +23595,7 @@
   }
 
   test_inferred_type_refers_to_nested_function_typed_param_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 f({void g(int x, void h())}) => null;
 var v = f(g: (x, y) {});
 ''');
@@ -23680,7 +23628,7 @@
   }
 
   test_inferred_type_refers_to_setter_function_typed_parameter_type() async {
-    var library = await checkLibrary('class C extends D { void set f(g) {} }'
+    var library = await buildLibrary('class C extends D { void set f(g) {} }'
         ' abstract class D { void set f(int g(String s)); }');
     checkElementText(library, r'''
 library
@@ -23725,7 +23673,7 @@
   m(Stream p) {}
 }
 ''');
-    LibraryElement library = await checkLibrary(r'''
+    LibraryElement library = await buildLibrary(r'''
 import 'a.dart';
 class B extends A {
   m(p) {}
@@ -23761,7 +23709,7 @@
   }
 
   test_inferredType_implicitCreation() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   A();
   A.named();
@@ -23803,13 +23751,13 @@
   }
 
   test_inferredType_implicitCreation_prefixed() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A {
   A();
   A.named();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 var a1 = foo.A();
 var a2 = foo.A.named();
@@ -23845,7 +23793,7 @@
   test_inferredType_usesSyntheticFunctionType_functionTypedParam() async {
     // AnalysisContext does not set the enclosing element for the synthetic
     // FunctionElement created for the [f, g] type argument.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 int f(int x(String y)) => null;
 String g(int x(String y)) => null;
 var v = [f, g];
@@ -23885,7 +23833,7 @@
   }
 
   test_inheritance_errors() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 abstract class A {
   int m();
 }
@@ -23942,7 +23890,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure() async {
-    var library = await checkLibrary('var v = () => 0;');
+    var library = await buildLibrary('var v = () => 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -23961,7 +23909,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_await_dynamic() async {
-    var library = await checkLibrary('var v = (f) async => await f;');
+    var library = await buildLibrary('var v = (f) async => await f;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -23980,7 +23928,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_await_future3_int() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 var v = (Future<Future<Future<int>>> f) async => await f;
 ''');
@@ -24005,7 +23953,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_await_future_int() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 var v = (Future<int> f) async => await f;
 ''');
@@ -24029,7 +23977,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_await_future_noArg() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'dart:async';
 var v = (Future f) async => await f;
 ''');
@@ -24053,7 +24001,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_field() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   var v = () => 0;
 }
@@ -24080,7 +24028,7 @@
   }
 
   test_initializer_executable_with_return_type_from_closure_local() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f() {
   int u = 0;
   var v = () => 0;
@@ -24097,7 +24045,7 @@
 
   test_instanceInference_operator_equal_legacy_from_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    addLibrarySource('$testPackageLibPath/legacy.dart', r'''
+    addSource('$testPackageLibPath/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
   bool operator==(other) => false;
@@ -24109,7 +24057,7 @@
   bool operator==(int other) => false;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'legacy.dart';
 class X1 extends LegacyDefault  {
   bool operator==(other) => false;
@@ -24164,7 +24112,7 @@
   }
 
   test_instanceInference_operator_equal_legacy_from_legacy_nullSafe() async {
-    addLibrarySource('$testPackageLibPath/legacy.dart', r'''
+    addSource('$testPackageLibPath/legacy.dart', r'''
 // @dart = 2.7
 class LegacyDefault {
   bool operator==(other) => false;
@@ -24176,7 +24124,7 @@
   bool operator==(int other) => false;
 }
 ''');
-    addLibrarySource('$testPackageLibPath/nullSafe.dart', r'''
+    addSource('$testPackageLibPath/nullSafe.dart', r'''
 class NullSafeDefault {
   bool operator==(other) => false;
 }
@@ -24187,7 +24135,7 @@
   bool operator==(int other) => false;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 // @dart = 2.7
 import 'legacy.dart';
 import 'nullSafe.dart';
@@ -24251,7 +24199,7 @@
   }
 
   test_instanceInference_operator_equal_nullSafe_from_nullSafe() async {
-    addLibrarySource('$testPackageLibPath/nullSafe.dart', r'''
+    addSource('$testPackageLibPath/nullSafe.dart', r'''
 class NullSafeDefault {
   bool operator==(other) => false;
 }
@@ -24262,7 +24210,7 @@
   bool operator==(int other) => false;
 }
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'nullSafe.dart';
 class X1 extends NullSafeDefault {
   bool operator==(other) => false;
@@ -24317,7 +24265,7 @@
   }
 
   test_instantiateToBounds_boundRefersToEarlierTypeArgument() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<S extends num, T extends C<S, T>> {}
 C c;
 ''');
@@ -24350,7 +24298,7 @@
   }
 
   test_instantiateToBounds_boundRefersToItself() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C<T>> {}
 C c;
 var c2 = new C();
@@ -24408,7 +24356,7 @@
 
   test_instantiateToBounds_boundRefersToItself_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C<T>> {}
 C c;
 var c2 = new C();
@@ -24465,7 +24413,7 @@
   }
 
   test_instantiateToBounds_boundRefersToLaterTypeArgument() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends C<T, U>, U extends num> {}
 C c;
 ''');
@@ -24498,14 +24446,14 @@
   }
 
   test_instantiateToBounds_functionTypeAlias_reexported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class O {}
 typedef T F<T extends O>(T p);
 ''');
-    addLibrarySource('$testPackageLibPath/b.dart', r'''
+    addSource('$testPackageLibPath/b.dart', r'''
 export 'a.dart' show F;
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'b.dart';
 class C {
   F f() => null;
@@ -24530,7 +24478,7 @@
   }
 
   test_instantiateToBounds_functionTypeAlias_simple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T extends num>(T p);
 F f;
 ''');
@@ -24573,7 +24521,7 @@
   }
 
   test_instantiateToBounds_genericFunctionAsBound() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {}
 class B<T extends int Function(), U extends A<T>> {}
 B b;
@@ -24613,7 +24561,7 @@
   }
 
   test_instantiateToBounds_genericTypeAlias_simple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T extends num> = S Function<S>(T p);
 F f;
 ''');
@@ -24658,7 +24606,7 @@
   }
 
   test_instantiateToBounds_issue38498() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<R extends B> {
   final values = <B>[];
 }
@@ -24692,7 +24640,7 @@
   }
 
   test_instantiateToBounds_simple() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends num> {}
 C c;
 ''');
@@ -24722,12 +24670,12 @@
   }
 
   test_invalid_annotation_prefixed_constructor() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "a.dart" as a;
 @a.A.named
 class C {}
@@ -24766,12 +24714,12 @@
   }
 
   test_invalid_annotation_unprefixed_constructor() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A {
   const A.named();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "a.dart";
 @A.named
 class C {}
@@ -24805,7 +24753,7 @@
   }
 
   test_invalid_importPrefix_asTypeArgument() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'dart:async' as ppp;
 class C {
   List<ppp> v;
@@ -24835,9 +24783,9 @@
   }
 
   test_invalid_nameConflict_imported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'V() {}');
-    addLibrarySource('$testPackageLibPath/b.dart', 'V() {}');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'V() {}');
+    addSource('$testPackageLibPath/b.dart', 'V() {}');
+    var library = await buildLibrary('''
 import 'a.dart';
 import 'b.dart';
 foo([p = V]) {}
@@ -24863,13 +24811,13 @@
   }
 
   test_invalid_nameConflict_imported_exported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'V() {}');
-    addLibrarySource('$testPackageLibPath/b.dart', 'V() {}');
-    addLibrarySource('$testPackageLibPath/c.dart', r'''
+    addSource('$testPackageLibPath/a.dart', 'V() {}');
+    addSource('$testPackageLibPath/b.dart', 'V() {}');
+    addSource('$testPackageLibPath/c.dart', r'''
 export 'a.dart';
 export 'b.dart';
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'c.dart';
 foo([p = V]) {}
 ''');
@@ -24893,7 +24841,7 @@
   }
 
   test_invalid_nameConflict_local() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 foo([p = V]) {}
 V() {}
 var V;
@@ -24929,7 +24877,7 @@
   }
 
   test_invalid_setterParameter_fieldFormalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   int foo;
   void set bar(this.foo) {}
@@ -24965,7 +24913,7 @@
   }
 
   test_invalid_setterParameter_fieldFormalParameter_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   set x(this.x) {}
 }
@@ -24991,7 +24939,7 @@
   }
 
   test_invalidUris() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import ':[invaliduri]';
 import ':[invaliduri]:foo.dart';
 import 'a1.dart';
@@ -25029,7 +24977,7 @@
   }
 
   test_library() async {
-    var library = await checkLibrary('');
+    var library = await buildLibrary('');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25037,7 +24985,7 @@
   }
 
   test_library_documented_lines() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// aaa
 /// bbb
 library test;
@@ -25052,7 +25000,7 @@
   }
 
   test_library_documented_stars() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /**
  * aaa
  * bbb
@@ -25068,7 +25016,7 @@
   }
 
   test_library_name_with_spaces() async {
-    var library = await checkLibrary('library foo . bar ;');
+    var library = await buildLibrary('library foo . bar ;');
     checkElementText(library, r'''
 library
   name: foo.bar
@@ -25078,7 +25026,7 @@
   }
 
   test_library_named() async {
-    var library = await checkLibrary('library foo.bar;');
+    var library = await buildLibrary('library foo.bar;');
     checkElementText(library, r'''
 library
   name: foo.bar
@@ -25088,7 +25036,7 @@
   }
 
   test_localFunctions() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 f() {
   f1() {}
   {
@@ -25106,7 +25054,7 @@
   }
 
   test_localFunctions_inConstructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   C() {
     f() {}
@@ -25124,7 +25072,7 @@
   }
 
   test_localFunctions_inMethod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   m() {
     f() {}
@@ -25145,7 +25093,7 @@
   }
 
   test_localFunctions_inTopLevelGetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 get g {
   f() {}
 }
@@ -25163,7 +25111,7 @@
   }
 
   test_localLabels_inConstructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   C() {
     aaa: while (true) {}
@@ -25185,7 +25133,7 @@
   }
 
   test_localLabels_inMethod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   m() {
     aaa: while (true) {}
@@ -25210,7 +25158,7 @@
   }
 
   test_localLabels_inTopLevelFunction() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 main() {
   aaa: while (true) {}
   bbb: switch (42) {
@@ -25229,7 +25177,7 @@
   }
 
   test_main_class() async {
-    var library = await checkLibrary('class main {}');
+    var library = await buildLibrary('class main {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25242,7 +25190,7 @@
 
   test_main_class_alias() async {
     var library =
-        await checkLibrary('class main = C with D; class C {} class D {}');
+        await buildLibrary('class main = C with D; class C {} class D {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25271,9 +25219,9 @@
   }
 
   test_main_class_alias_via_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart',
+    addSource('$testPackageLibPath/a.dart',
         'class main = C with D; class C {} class D {}');
-    var library = await checkLibrary('export "a.dart";');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -25283,8 +25231,8 @@
   }
 
   test_main_class_via_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class main {}');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'class main {}');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -25294,7 +25242,7 @@
   }
 
   test_main_getter() async {
-    var library = await checkLibrary('get main => null;');
+    var library = await buildLibrary('get main => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25308,8 +25256,8 @@
   }
 
   test_main_getter_via_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'get main => null;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'get main => null;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -25319,7 +25267,7 @@
   }
 
   test_main_typedef() async {
-    var library = await checkLibrary('typedef main();');
+    var library = await buildLibrary('typedef main();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25332,8 +25280,8 @@
   }
 
   test_main_typedef_via_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'typedef main();');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'typedef main();');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -25343,7 +25291,7 @@
   }
 
   test_main_variable() async {
-    var library = await checkLibrary('var main;');
+    var library = await buildLibrary('var main;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -25362,8 +25310,8 @@
   }
 
   test_main_variable_via_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'var main;');
-    var library = await checkLibrary('export "a.dart";');
+    addSource('$testPackageLibPath/a.dart', 'var main;');
+    var library = await buildLibrary('export "a.dart";');
     checkElementText(library, r'''
 library
   exports
@@ -25373,7 +25321,7 @@
   }
 
   test_metadata_class_field_first() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 class C {
   @a
@@ -25425,7 +25373,7 @@
   }
 
   test_metadata_class_scope() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -25496,7 +25444,7 @@
   }
 
   test_metadata_classDeclaration() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 const b = null;
 @a
@@ -25546,7 +25494,7 @@
   }
 
   test_metadata_classTypeAlias() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'const a = null; @a class C = D with E; class D {} class E {}');
     checkElementText(library, r'''
 library
@@ -25594,7 +25542,7 @@
   }
 
   test_metadata_constructor_call_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A.named(int _);
 }
@@ -25643,7 +25591,7 @@
   }
 
   test_metadata_constructor_call_named_generic_inference() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A.named(T _);
 }
@@ -25702,7 +25650,7 @@
   }
 
   test_metadata_constructor_call_named_generic_typeArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A.named();
 }
@@ -25759,7 +25707,7 @@
   }
 
   test_metadata_constructor_call_named_generic_typeArguments_disabledGenericMetadata() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A.named();
 }
@@ -25816,12 +25764,12 @@
   }
 
   test_metadata_constructor_call_named_prefixed() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A {
   const A.named(int _);
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 @foo.A.named(0)
 class C {}
@@ -25867,12 +25815,12 @@
   }
 
   test_metadata_constructor_call_named_prefixed_generic_inference() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A.named(T _);
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "foo.dart" as foo;
 @foo.A.named(0)
 class C {}
@@ -25922,12 +25870,12 @@
   }
 
   test_metadata_constructor_call_named_prefixed_generic_typeArguments() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A.named();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "foo.dart" as foo;
 @foo.A<int>.named()
 class C {}
@@ -25983,7 +25931,7 @@
   }
 
   test_metadata_constructor_call_named_synthetic_ofClassAlias_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A.named();
 }
@@ -26064,7 +26012,7 @@
   }
 
   test_metadata_constructor_call_unnamed() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(int _);
 }
@@ -26103,7 +26051,7 @@
   }
 
   test_metadata_constructor_call_unnamed_generic_inference() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A(T _);
 }
@@ -26148,7 +26096,7 @@
   }
 
   test_metadata_constructor_call_unnamed_generic_typeArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   const A();
 }
@@ -26196,9 +26144,9 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', 'class A { const A(_); }');
+    addSource('$testPackageLibPath/foo.dart', 'class A { const A(_); }');
     var library =
-        await checkLibrary('import "foo.dart" as foo; @foo.A(0) class C {}');
+        await buildLibrary('import "foo.dart" as foo; @foo.A(0) class C {}');
     checkElementText(library, r'''
 library
   imports
@@ -26235,12 +26183,12 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed_generic_inference() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A(T _);
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "foo.dart" as foo;
 @foo.A(0)
 class C {}
@@ -26283,12 +26231,12 @@
   }
 
   test_metadata_constructor_call_unnamed_prefixed_generic_typeArguments() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 class A<T> {
   const A();
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import "foo.dart" as foo;
 @foo.A<int>()
 class C {}
@@ -26337,7 +26285,7 @@
   }
 
   test_metadata_constructor_call_unnamed_synthetic_ofClassAlias_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A();
 }
@@ -26400,7 +26348,7 @@
 
   test_metadata_constructor_call_with_args() async {
     var library =
-        await checkLibrary('class A { const A(x); } @A(null) class C {}');
+        await buildLibrary('class A { const A(x); } @A(null) class C {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -26434,7 +26382,7 @@
 
   test_metadata_constructorDeclaration_named() async {
     var library =
-        await checkLibrary('const a = null; class C { @a C.named(); }');
+        await buildLibrary('const a = null; class C { @a C.named(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -26466,7 +26414,7 @@
   }
 
   test_metadata_constructorDeclaration_unnamed() async {
-    var library = await checkLibrary('const a = null; class C { @a C(); }');
+    var library = await buildLibrary('const a = null; class C { @a C(); }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -26496,7 +26444,7 @@
   }
 
   test_metadata_enum_constant() async {
-    var library = await checkLibrary('const a = 42; enum E { @a v }');
+    var library = await buildLibrary('const a = 42; enum E { @a v }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -26561,7 +26509,7 @@
   }
 
   test_metadata_enum_constant_instanceCreation() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   final dynamic value;
   const A(this.value);
@@ -26707,7 +26655,7 @@
   }
 
   test_metadata_enum_constant_self() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   @v
   v
@@ -26767,7 +26715,7 @@
   }
 
   test_metadata_enum_constructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 42;
 enum E {
   v;
@@ -26839,7 +26787,7 @@
   }
 
   test_metadata_enum_method() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 42;
 enum E {
   v;
@@ -26914,7 +26862,7 @@
   }
 
   test_metadata_enum_scope() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -27021,7 +26969,7 @@
   }
 
   test_metadata_enum_typeParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = 42;
 enum E<@a T> {
   v
@@ -27096,7 +27044,7 @@
   }
 
   test_metadata_enumDeclaration() async {
-    var library = await checkLibrary('const a = 42; @a enum E { v }');
+    var library = await buildLibrary('const a = 42; @a enum E { v }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27161,8 +27109,8 @@
   }
 
   test_metadata_exportDirective() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '');
-    var library = await checkLibrary('@a export "foo.dart"; const a = null;');
+    addSource('$testPackageLibPath/foo.dart', '');
+    var library = await buildLibrary('@a export "foo.dart"; const a = null;');
     checkElementText(library, r'''
 library
   metadata
@@ -27198,7 +27146,7 @@
   }
 
   test_metadata_extension_scope() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -27267,7 +27215,7 @@
   }
 
   test_metadata_extensionDeclaration() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 class A {}
 @a
@@ -27315,7 +27263,7 @@
   }
 
   test_metadata_fieldDeclaration() async {
-    var library = await checkLibrary('const a = null; class C { @a int x; }');
+    var library = await buildLibrary('const a = null; class C { @a int x; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27356,7 +27304,7 @@
   }
 
   test_metadata_fieldFormalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 class C {
   var x;
@@ -27407,7 +27355,7 @@
   }
 
   test_metadata_fieldFormalParameter_withDefault() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'const a = null; class C { var x; C([@a this.x = null]); }');
     checkElementText(library, r'''
 library
@@ -27457,7 +27405,7 @@
   }
 
   test_metadata_functionDeclaration_function() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 @a
 f() {}
@@ -27490,7 +27438,7 @@
   }
 
   test_metadata_functionDeclaration_getter() async {
-    var library = await checkLibrary('const a = null; @a get f => null;');
+    var library = await buildLibrary('const a = null; @a get f => null;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27520,7 +27468,7 @@
   }
 
   test_metadata_functionDeclaration_setter() async {
-    var library = await checkLibrary('const a = null; @a set f(value) {}');
+    var library = await buildLibrary('const a = null; @a set f(value) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27553,7 +27501,7 @@
   }
 
   test_metadata_functionTypeAlias() async {
-    var library = await checkLibrary('const a = null; @a typedef F();');
+    var library = await buildLibrary('const a = null; @a typedef F();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27584,7 +27532,7 @@
   }
 
   test_metadata_functionTypedFormalParameter() async {
-    var library = await checkLibrary('const a = null; f(@a g()) {}');
+    var library = await buildLibrary('const a = null; f(@a g()) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27616,7 +27564,7 @@
   }
 
   test_metadata_functionTypedFormalParameter_withDefault() async {
-    var library = await checkLibrary('const a = null; f([@a g() = null]) {}');
+    var library = await buildLibrary('const a = null; f([@a g() = null]) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27652,7 +27600,7 @@
   }
 
   test_metadata_genericTypeAlias() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 const b = null;
 @a
@@ -27703,7 +27651,7 @@
   }
 
   test_metadata_importDirective() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 @a
 import "dart:math";
 const a = 0;
@@ -27743,7 +27691,7 @@
   }
 
   test_metadata_importDirective_hasShow() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 @a
 import "dart:math" show Random;
 
@@ -27786,7 +27734,7 @@
   }
 
   test_metadata_inAliasedElement_formalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = 42;
 typedef F = void Function(@a int first)
 ''');
@@ -27823,7 +27771,7 @@
   }
 
   test_metadata_inAliasedElement_formalParameter2() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = 42;
 typedef F = void Function(int foo(@a int bar))
 ''');
@@ -27863,7 +27811,7 @@
   }
 
   test_metadata_inAliasedElement_typeParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = 42;
 typedef F = void Function<@a T>(int first)
 ''');
@@ -27902,7 +27850,7 @@
   }
 
   test_metadata_invalid_classDeclaration() async {
-    var library = await checkLibrary('f(_) {} @f(42) class C {}');
+    var library = await buildLibrary('f(_) {} @f(42) class C {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -27935,7 +27883,7 @@
   }
 
   test_metadata_libraryDirective() async {
-    var library = await checkLibrary('@a library L; const a = null;');
+    var library = await buildLibrary('@a library L; const a = null;');
     checkElementText(library, r'''
 library
   name: L
@@ -27964,7 +27912,7 @@
 
   test_metadata_methodDeclaration_getter() async {
     var library =
-        await checkLibrary('const a = null; class C { @a get m => null; }');
+        await buildLibrary('const a = null; class C { @a get m => null; }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -28000,7 +27948,7 @@
   }
 
   test_metadata_methodDeclaration_method() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 const b = null;
 class C {
@@ -28056,7 +28004,7 @@
   }
 
   test_metadata_methodDeclaration_method_mixin() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 const b = null;
 mixin M {
@@ -28114,7 +28062,7 @@
   }
 
   test_metadata_methodDeclaration_setter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 class C {
   @a
@@ -28159,7 +28107,7 @@
   }
 
   test_metadata_mixin_scope() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -28232,7 +28180,7 @@
   }
 
   test_metadata_mixinDeclaration() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = null;
 const b = null;
 @a
@@ -28284,7 +28232,7 @@
   }
 
   test_metadata_offsets_onClass() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -28330,7 +28278,7 @@
   }
 
   test_metadata_offsets_onClassConstructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {
@@ -28378,7 +28326,7 @@
   }
 
   test_metadata_offsets_onClassGetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {
@@ -28421,7 +28369,7 @@
   }
 
   test_metadata_offsets_onClassMethod() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {
@@ -28482,7 +28430,7 @@
   }
 
   test_metadata_offsets_onClassSetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {
@@ -28536,7 +28484,7 @@
   }
 
   test_metadata_offsets_onClassTypeAlias() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {}
@@ -28605,7 +28553,7 @@
   }
 
   test_metadata_offsets_onEnum() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -28739,7 +28687,7 @@
   }
 
   test_metadata_offsets_onExtension() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -28783,7 +28731,7 @@
   }
 
   test_metadata_offsets_onFieldDeclaration() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 class A {
@@ -28870,7 +28818,7 @@
   }
 
   test_metadata_offsets_onLibrary() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 /// Some documentation.
 @foo
 library my.lib;
@@ -28905,7 +28853,7 @@
   }
 
   test_metadata_offsets_onMixin() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -28953,7 +28901,7 @@
   }
 
   test_metadata_offsets_onTypeAlias_classic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29011,7 +28959,7 @@
   }
 
   test_metadata_offsets_onTypeAlias_genericFunctionType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29087,7 +29035,7 @@
 part of my.lib;
 ''');
 
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library my.lib;
 
 @foo
@@ -29136,7 +29084,7 @@
   }
 
   test_metadata_offsets_onUnitFunction() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29195,7 +29143,7 @@
   }
 
   test_metadata_offsets_onUnitGetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29230,7 +29178,7 @@
   }
 
   test_metadata_offsets_onUnitSetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29276,7 +29224,7 @@
   }
 
   test_metadata_offsets_onUnitVariable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const foo = 0;
 
 @foo
@@ -29336,7 +29284,7 @@
 
   test_metadata_partDirective() async {
     addSource('$testPackageLibPath/foo.dart', 'part of L;');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library L;
 @a
 part 'foo.dart';
@@ -29376,7 +29324,7 @@
     addSource('$testPackageLibPath/b.dart', r'''
 part of 'test.dart';
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 part 'a.dart';
 part 'b.dart';
 ''');
@@ -29387,8 +29335,8 @@
   }
 
   test_metadata_prefixed_variable() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'const b = null;');
-    var library = await checkLibrary('import "a.dart" as a; @a.b class C {}');
+    addSource('$testPackageLibPath/a.dart', 'const b = null;');
+    var library = await buildLibrary('import "a.dart" as a; @a.b class C {}');
     checkElementText(library, r'''
 library
   imports
@@ -29418,7 +29366,7 @@
   }
 
   test_metadata_simpleFormalParameter() async {
-    var library = await checkLibrary('const a = null; f(@a x) {}');
+    var library = await buildLibrary('const a = null; f(@a x) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29450,7 +29398,7 @@
   }
 
   test_metadata_simpleFormalParameter_method() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 
 class C {
@@ -29492,7 +29440,7 @@
   }
 
   test_metadata_simpleFormalParameter_unit_setter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 
 set foo(@a int x) {}
@@ -29529,7 +29477,7 @@
   }
 
   test_metadata_simpleFormalParameter_withDefault() async {
-    var library = await checkLibrary('const a = null; f([@a x = null]) {}');
+    var library = await buildLibrary('const a = null; f([@a x = null]) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29565,7 +29513,7 @@
   }
 
   test_metadata_superFormalParameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 
 class A {
@@ -29617,7 +29565,7 @@
   }
 
   test_metadata_topLevelVariableDeclaration() async {
-    var library = await checkLibrary('const a = null; @a int v;');
+    var library = await buildLibrary('const a = null; @a int v;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29652,7 +29600,7 @@
   }
 
   test_metadata_typeParameter_ofClass() async {
-    var library = await checkLibrary('const a = null; class C<@a T> {}');
+    var library = await buildLibrary('const a = null; class C<@a T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29685,7 +29633,7 @@
   }
 
   test_metadata_typeParameter_ofClassTypeAlias() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 const a = null;
 class C<@a T> = D with E;
 class D {}
@@ -29739,7 +29687,7 @@
   }
 
   test_metadata_typeParameter_ofFunction() async {
-    var library = await checkLibrary('const a = null; f<@a T>() {}');
+    var library = await buildLibrary('const a = null; f<@a T>() {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29770,7 +29718,7 @@
   }
 
   test_metadata_typeParameter_ofTypedef() async {
-    var library = await checkLibrary('const a = null; typedef F<@a T>();');
+    var library = await buildLibrary('const a = null; typedef F<@a T>();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -29804,7 +29752,7 @@
   }
 
   test_metadata_unit_topLevelVariable_first() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 const a = 0;
 @a
 int x = 0;
@@ -29848,7 +29796,7 @@
   }
 
   test_metadata_value_class_staticField() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   static const x = 0;
 }
@@ -29895,7 +29843,7 @@
   }
 
   test_metadata_value_enum_constant() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 enum E {a, b, c}
 @E.b
 class C {}
@@ -30010,7 +29958,7 @@
   }
 
   test_metadata_value_extension_staticField() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 extension E on int {
   static const x = 0;
 }
@@ -30057,12 +30005,12 @@
   }
 
   test_metadata_value_prefix_extension_staticField() async {
-    addLibrarySource('$testPackageLibPath/foo.dart', '''
+    addSource('$testPackageLibPath/foo.dart', '''
 extension E on int {
   static const x = 0;
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'foo.dart' as foo;
 @foo.E.x
 class C {}
@@ -30101,7 +30049,7 @@
   }
 
   test_methodInvocation_implicitCall() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   double call() => 0.0;
 }
@@ -30149,7 +30097,7 @@
   }
 
   test_mixin() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 class B {}
 class C {}
@@ -30226,7 +30174,7 @@
   }
 
   test_mixin_field_inferredType_final() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 mixin M {
   final x = 0;
 }''');
@@ -30249,7 +30197,7 @@
   }
 
   test_mixin_first() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {}
 ''');
 
@@ -30261,7 +30209,7 @@
   }
 
   test_mixin_implicitObjectSuperclassConstraint() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {}
 ''');
     checkElementText(library, r'''
@@ -30278,7 +30226,7 @@
 
   test_mixin_inference_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 class B extends A<int> with M {}
@@ -30315,7 +30263,7 @@
   }
 
   test_mixin_inference_nullSafety() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 class B extends A<int> with M {}
@@ -30352,13 +30300,13 @@
   }
 
   test_mixin_inference_nullSafety2() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 
 mixin B<T> on A<T> {}
 mixin C<T> on A<T> {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 // @dart=2.8
 import 'a.dart';
 
@@ -30384,11 +30332,11 @@
   }
 
   test_mixin_inference_nullSafety_mixed_inOrder() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 class A<T> {}
 mixin M<U> on A<U> {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 // @dart = 2.8
 import 'a.dart';
 class B extends A<int> with M {}
@@ -30413,12 +30361,12 @@
 
   @FailingTest(reason: 'Out-of-order inference is not specified yet')
   test_mixin_inference_nullSafety_mixed_outOfOrder() async {
-    addLibrarySource('$testPackageLibPath/a.dart', r'''
+    addSource('$testPackageLibPath/a.dart', r'''
 // @dart = 2.8
 class A<T> {}
 mixin M<U> on A<U> {}
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 
 class B extends A<int> with M {}
@@ -30432,7 +30380,7 @@
   }
 
   test_mixin_method_namedAsConstraint() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 mixin B on A {
   void A() {}
@@ -30458,7 +30406,7 @@
   }
 
   test_mixin_typeParameters_variance_contravariant() async {
-    var library = await checkLibrary('mixin M<in T> {}');
+    var library = await buildLibrary('mixin M<in T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -30475,7 +30423,7 @@
   }
 
   test_mixin_typeParameters_variance_covariant() async {
-    var library = await checkLibrary('mixin M<out T> {}');
+    var library = await buildLibrary('mixin M<out T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -30492,7 +30440,7 @@
   }
 
   test_mixin_typeParameters_variance_invariant() async {
-    var library = await checkLibrary('mixin M<inout T> {}');
+    var library = await buildLibrary('mixin M<inout T> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -30509,7 +30457,7 @@
   }
 
   test_mixin_typeParameters_variance_multiple() async {
-    var library = await checkLibrary('mixin M<inout T, in U, out V> {}');
+    var library = await buildLibrary('mixin M<inout T, in U, out V> {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -30530,12 +30478,12 @@
   }
 
   test_nameConflict_exportedAndLocal() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    addLibrarySource('$testPackageLibPath/c.dart', '''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    addSource('$testPackageLibPath/c.dart', '''
 export 'a.dart';
 class C {}
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'c.dart';
 C v = null;
 ''');
@@ -30559,13 +30507,13 @@
   }
 
   test_nameConflict_exportedAndLocal_exported() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    addLibrarySource('$testPackageLibPath/c.dart', '''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    addSource('$testPackageLibPath/c.dart', '''
 export 'a.dart';
 class C {}
 ''');
-    addLibrarySource('$testPackageLibPath/d.dart', 'export "c.dart";');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/d.dart', 'export "c.dart";');
+    var library = await buildLibrary('''
 import 'd.dart';
 C v = null;
 ''');
@@ -30589,17 +30537,17 @@
   }
 
   test_nameConflict_exportedAndParted() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    addLibrarySource('$testPackageLibPath/b.dart', '''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    addSource('$testPackageLibPath/b.dart', '''
 part of lib;
 class C {}
 ''');
-    addLibrarySource('$testPackageLibPath/c.dart', '''
+    addSource('$testPackageLibPath/c.dart', '''
 library lib;
 export 'a.dart';
 part 'b.dart';
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 import 'c.dart';
 C v = null;
 ''');
@@ -30627,9 +30575,9 @@
       return;
     }
 
-    addLibrarySource('$testPackageLibPath/a.dart', 'class A {}');
-    addLibrarySource('$testPackageLibPath/b.dart', 'export "/a.dart";');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'class A {}');
+    addSource('$testPackageLibPath/b.dart', 'export "/a.dart";');
+    var library = await buildLibrary('''
 import 'a.dart';
 import 'b.dart';
 A v = null;
@@ -30655,7 +30603,7 @@
   }
 
   test_nameOffset_class_constructor() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   A();
   A.named();
@@ -30675,7 +30623,7 @@
   }
 
   test_nameOffset_class_constructor_parameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   A(int a);
 }
@@ -30694,7 +30642,7 @@
   }
 
   test_nameOffset_class_field() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   int foo = 0;
 }
@@ -30721,7 +30669,7 @@
   }
 
   test_nameOffset_class_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   int get foo => 0;
 }
@@ -30743,7 +30691,7 @@
   }
 
   test_nameOffset_class_method() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   void foo<T>(int a) {}
 }
@@ -30767,7 +30715,7 @@
   }
 
   test_nameOffset_class_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {
   set foo(int x) {}
 }
@@ -30792,7 +30740,7 @@
   }
 
   test_nameOffset_class_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {}
 ''');
     checkElementText(library, r'''
@@ -30809,7 +30757,7 @@
   }
 
   test_nameOffset_extension_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 extension E<T> on int {}
 ''');
     checkElementText(library, r'''
@@ -30824,7 +30772,7 @@
   }
 
   test_nameOffset_function_functionTypedFormal_parameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f(void f<U>(int a)) {}
 ''');
     checkElementText(library, r'''
@@ -30845,7 +30793,7 @@
   }
 
   test_nameOffset_function_functionTypedFormal_parameter2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f({required void f<U>(int a)}) {}
 ''');
     checkElementText(library, r'''
@@ -30866,7 +30814,7 @@
   }
 
   test_nameOffset_function_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f<T>() {}
 ''');
     checkElementText(library, r'''
@@ -30881,7 +30829,7 @@
   }
 
   test_nameOffset_functionTypeAlias_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F<T>();
 ''');
     checkElementText(library, r'''
@@ -30899,7 +30847,7 @@
   }
 
   test_nameOffset_genericTypeAlias_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = void Function();
 ''');
     checkElementText(library, r'''
@@ -30917,7 +30865,7 @@
   }
 
   test_nameOffset_mixin_typeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M<T> {}
 ''');
     checkElementText(library, r'''
@@ -30936,7 +30884,7 @@
   }
 
   test_nameOffset_unit_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int get foo => 0;
 ''');
     checkElementText(library, r'''
@@ -30952,7 +30900,7 @@
   }
 
   test_nested_generic_functions_in_generic_class_with_function_typed_params() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   void g<V, W>() {
     void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) {
@@ -30982,7 +30930,7 @@
   }
 
   test_nested_generic_functions_in_generic_class_with_local_variables() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   void g<V, W>() {
     void h<X, Y>() {
@@ -31018,7 +30966,7 @@
   }
 
   test_nested_generic_functions_with_function_typed_param() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f<T, U>() {
   void g<V, W>() {
     void h<X, Y>(void p(T t, U u, V v, W w, X x, Y y)) {
@@ -31039,7 +30987,7 @@
   }
 
   test_nested_generic_functions_with_local_variables() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f<T, U>() {
   void g<V, W>() {
     void h<X, Y>() {
@@ -31066,7 +31014,7 @@
   }
 
   test_new_typedef_function_notSimplyBounded_functionType_returnType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = G Function();
 typedef G = F Function();
 ''');
@@ -31086,7 +31034,7 @@
   }
 
   test_new_typedef_function_notSimplyBounded_functionType_returnType_viaInterfaceType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = List<F> Function();
 ''');
     checkElementText(library, r'''
@@ -31101,7 +31049,7 @@
   }
 
   test_new_typedef_function_notSimplyBounded_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T extends F> = void Function();
 ''');
     checkElementText(library, r'''
@@ -31120,7 +31068,7 @@
   }
 
   test_new_typedef_function_notSimplyBounded_simple_no_bounds() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T> = void Function();
 ''');
     checkElementText(library, r'''
@@ -31138,7 +31086,7 @@
   }
 
   test_new_typedef_function_notSimplyBounded_simple_non_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = void Function();
 ''');
     checkElementText(library, r'''
@@ -31153,7 +31101,7 @@
   }
 
   test_new_typedef_nonFunction_notSimplyBounded_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F<T extends F> = List<int>;
 ''');
     checkElementText(library, r'''
@@ -31170,7 +31118,7 @@
   }
 
   test_new_typedef_nonFunction_notSimplyBounded_viaInterfaceType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = List<F>;
 ''');
     checkElementText(library, r'''
@@ -31183,7 +31131,7 @@
   }
 
   test_nonSynthetic_class_field() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   int foo = 0;
 }
@@ -31218,7 +31166,7 @@
   }
 
   test_nonSynthetic_class_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   int get foo => 0;
 }
@@ -31246,7 +31194,7 @@
   }
 
   test_nonSynthetic_class_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class C {
   set foo(int value) {}
 }
@@ -31278,7 +31226,7 @@
   }
 
   test_nonSynthetic_enum() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 enum E {
   a, b
 }
@@ -31361,7 +31309,7 @@
   }
 
   test_nonSynthetic_extension_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 extension E on int {
   int get foo => 0;
 }
@@ -31387,7 +31335,7 @@
   }
 
   test_nonSynthetic_extension_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 extension E on int {
   set foo(int value) {}
 }
@@ -31417,7 +31365,7 @@
   }
 
   test_nonSynthetic_mixin_field() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {
   int foo = 0;
 }
@@ -31454,7 +31402,7 @@
   }
 
   test_nonSynthetic_mixin_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {
   int get foo => 0;
 }
@@ -31484,7 +31432,7 @@
   }
 
   test_nonSynthetic_mixin_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 mixin M {
   set foo(int value) {}
 }
@@ -31518,7 +31466,7 @@
   }
 
   test_nonSynthetic_unit_getter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int get foo => 0;
 ''');
     checkElementText(
@@ -31539,7 +31487,7 @@
   }
 
   test_nonSynthetic_unit_getterSetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int get foo => 0;
 set foo(int value) {}
 ''');
@@ -31568,7 +31516,7 @@
   }
 
   test_nonSynthetic_unit_setter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 set foo(int value) {}
 ''');
     checkElementText(
@@ -31593,7 +31541,7 @@
   }
 
   test_nonSynthetic_unit_variable() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 int foo = 0;
 ''');
     checkElementText(
@@ -31621,7 +31569,7 @@
   }
 
   test_parameter() async {
-    var library = await checkLibrary('void main(int p) {}');
+    var library = await buildLibrary('void main(int p) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -31635,7 +31583,7 @@
   }
 
   test_parameter_covariant_explicit_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   void m({covariant A a}) {}
 }
@@ -31657,7 +31605,7 @@
   }
 
   test_parameter_covariant_explicit_positional() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   void m([covariant A a]) {}
 }
@@ -31679,7 +31627,7 @@
   }
 
   test_parameter_covariant_explicit_required() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   void m(covariant A a) {}
 }
@@ -31701,7 +31649,7 @@
   }
 
   test_parameter_covariant_inherited() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   void f(covariant T t) {}
 }
@@ -31745,7 +31693,7 @@
   }
 
   test_parameter_covariant_inherited_named() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   void m({covariant A a}) {}
 }
@@ -31781,7 +31729,7 @@
   }
 
   test_parameter_parameters() async {
-    var library = await checkLibrary('class C { f(g(x, y)) {} }');
+    var library = await buildLibrary('class C { f(g(x, y)) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -31804,7 +31752,7 @@
   }
 
   test_parameter_parameters_in_generic_class() async {
-    var library = await checkLibrary('class C<A, B> { f(A g(B x)) {} }');
+    var library = await buildLibrary('class C<A, B> { f(A g(B x)) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -31830,7 +31778,7 @@
   }
 
   test_parameter_return_type() async {
-    var library = await checkLibrary('class C { f(int g()) {} }');
+    var library = await buildLibrary('class C { f(int g()) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -31848,7 +31796,7 @@
   }
 
   test_parameter_return_type_void() async {
-    var library = await checkLibrary('class C { f(void g()) {} }');
+    var library = await buildLibrary('class C { f(void g()) {} }');
     checkElementText(library, r'''
 library
   definingUnit
@@ -31866,7 +31814,7 @@
   }
 
   test_parameter_typeParameters() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 void f(T a<T, U>(U u)) {}
 ''');
     checkElementText(library, r'''
@@ -31890,7 +31838,7 @@
   test_parameterTypeNotInferred_constructor() async {
     // Strong mode doesn't do type inference on constructor parameters, so it's
     // ok that we don't store inferred type info for them in summaries.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   C.positional([x = 1]);
   C.named({x: 1});
@@ -31928,7 +31876,7 @@
   test_parameterTypeNotInferred_initializingFormal() async {
     // Strong mode doesn't do type inference on initializing formals, so it's
     // ok that we don't store inferred type info for them in summaries.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   var x;
   C.positional([this.x = 1]);
@@ -31980,7 +31928,7 @@
   test_parameterTypeNotInferred_staticMethod() async {
     // Strong mode doesn't do type inference on parameters of static methods,
     // so it's ok that we don't store inferred type info for them in summaries.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {
   static void positional([x = 1]) {}
   static void named({x: 1}) {}
@@ -32019,7 +31967,7 @@
     // Strong mode doesn't do type inference on parameters of top level
     // functions, so it's ok that we don't store inferred type info for them in
     // summaries.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void positional([x = 1]) {}
 void named({x: 1}) {}
 ''');
@@ -32049,7 +31997,7 @@
   }
 
   test_part_emptyUri() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 part '';
 class B extends A {}
 ''');
@@ -32070,7 +32018,7 @@
   }
 
   test_part_uri() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 part 'foo.dart';
 ''');
     expect(library.parts[0].uri, 'foo.dart');
@@ -32080,7 +32028,7 @@
     addSource('$testPackageLibPath/a.dart', 'part of my.lib;');
     addSource('$testPackageLibPath/b.dart', 'part of my.lib;');
     var library =
-        await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
+        await buildLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
 library
   name: my.lib
@@ -32094,7 +32042,7 @@
 
   test_parts_invalidUri() async {
     addSource('$testPackageLibPath/foo/bar.dart', 'part of my.lib;');
-    var library = await checkLibrary('library my.lib; part "foo/";');
+    var library = await buildLibrary('library my.lib; part "foo/";');
     checkElementText(library, r'''
 library
   name: my.lib
@@ -32107,7 +32055,7 @@
 
   test_parts_invalidUri_nullStringValue() async {
     addSource('$testPackageLibPath/foo/bar.dart', 'part of my.lib;');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 library my.lib;
 part "${foo}/bar.dart";
 ''');
@@ -32120,7 +32068,7 @@
   }
 
   test_propagated_type_refers_to_closure() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f() {
   var x = () => 0;
   var y = x;
@@ -32136,7 +32084,7 @@
   }
 
   test_setter_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -32159,7 +32107,7 @@
   }
 
   test_setter_external() async {
-    var library = await checkLibrary('external void set x(int value);');
+    var library = await buildLibrary('external void set x(int value);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32176,7 +32124,7 @@
   }
 
   test_setter_inferred_type_top_level_implicit_return() async {
-    var library = await checkLibrary('set f(int value) {}');
+    var library = await buildLibrary('set f(int value) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32194,7 +32142,7 @@
 
   test_setters() async {
     var library =
-        await checkLibrary('void set x(int value) {} set y(value) {}');
+        await buildLibrary('void set x(int value) {} set y(value) {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32218,7 +32166,7 @@
   }
 
   test_syntheticFunctionType_genericClosure() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 final v = f() ? <T>(T t) => 0 : <T>(T t) => 1;
 bool f() => true;
 ''');
@@ -32238,7 +32186,7 @@
   }
 
   test_syntheticFunctionType_genericClosure_inGenericFunction() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f<T, U>(bool b) {
   final v = b ? <V>(T t, U u, V v) => 0 : <V>(T t, U u, V v) => 1;
 }
@@ -32259,7 +32207,7 @@
   }
 
   test_syntheticFunctionType_inGenericClass() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T, U> {
   var v = f() ? (T t, U u) => 0 : (T t, U u) => 1;
 }
@@ -32295,7 +32243,7 @@
   }
 
   test_syntheticFunctionType_inGenericFunction() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void f<T, U>(bool b) {
   var v = b ? (T t, U u) => 0 : (T t, U u) => 1;
 }
@@ -32316,7 +32264,7 @@
   }
 
   test_syntheticFunctionType_noArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 final v = f() ? () => 0 : () => 1;
 bool f() => true;
 ''');
@@ -32336,7 +32284,7 @@
   }
 
   test_syntheticFunctionType_withArguments() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 final v = f() ? (int x, String y) => 0 : (int x, String y) => 1;
 bool f() => true;
 ''');
@@ -32356,7 +32304,7 @@
   }
 
   test_top_level_variable_external() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 external int i;
 ''');
     checkElementText(library, r'''
@@ -32377,7 +32325,7 @@
   }
 
   test_type_arguments_explicit_dynamic_dynamic() async {
-    var library = await checkLibrary('Map<dynamic, dynamic> m;');
+    var library = await buildLibrary('Map<dynamic, dynamic> m;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32396,7 +32344,7 @@
   }
 
   test_type_arguments_explicit_dynamic_int() async {
-    var library = await checkLibrary('Map<dynamic, int> m;');
+    var library = await buildLibrary('Map<dynamic, int> m;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32415,7 +32363,7 @@
   }
 
   test_type_arguments_explicit_String_dynamic() async {
-    var library = await checkLibrary('Map<String, dynamic> m;');
+    var library = await buildLibrary('Map<String, dynamic> m;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32434,7 +32382,7 @@
   }
 
   test_type_arguments_explicit_String_int() async {
-    var library = await checkLibrary('Map<String, int> m;');
+    var library = await buildLibrary('Map<String, int> m;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32453,7 +32401,7 @@
   }
 
   test_type_arguments_implicit() async {
-    var library = await checkLibrary('Map m;');
+    var library = await buildLibrary('Map m;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32472,7 +32420,7 @@
   }
 
   test_type_dynamic() async {
-    var library = await checkLibrary('dynamic d;');
+    var library = await buildLibrary('dynamic d;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -32491,7 +32439,7 @@
   }
 
   test_type_inference_assignmentExpression_references_onTopLevelVariable() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var a = () {
   b += 0;
   return 0;
@@ -32525,8 +32473,8 @@
   }
 
   test_type_inference_based_on_loadLibrary() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', '');
+    var library = await buildLibrary('''
 import 'a.dart' deferred as a;
 var x = a.loadLibrary;
 ''');
@@ -32550,12 +32498,12 @@
   }
 
   test_type_inference_classField_fromNullSafe_toLegacy() async {
-    addLibrarySource('$testPackageLibPath/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
 class E {
   static final a = 0;
 }
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // @dart = 2.9
 import 'a.dart';
 final v = E.a;
@@ -32575,7 +32523,7 @@
   }
 
   test_type_inference_closure_with_function_typed_parameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = (int f(String x)) => 0;
 ''');
     checkElementText(library, r'''
@@ -32596,7 +32544,7 @@
   }
 
   test_type_inference_closure_with_function_typed_parameter_new() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = (int Function(String) f) => 0;
 ''');
     checkElementText(library, r'''
@@ -32617,9 +32565,9 @@
   }
 
   test_type_inference_depends_on_exported_variable() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
-    addLibrarySource('$testPackageLibPath/b.dart', 'var x = 0;');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addSource('$testPackageLibPath/b.dart', 'var x = 0;');
+    var library = await buildLibrary('''
 import 'a.dart';
 var y = x;
 ''');
@@ -32643,7 +32591,7 @@
   }
 
   test_type_inference_field_depends_onFieldFormal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   T value;
 
@@ -32697,7 +32645,7 @@
   }
 
   test_type_inference_field_depends_onFieldFormal_withMixinApp() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   T value;
 
@@ -32788,7 +32736,7 @@
   }
 
   test_type_inference_fieldFormal_depends_onField() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A<T> {
   var f = 0;
   A(this.f);
@@ -32823,7 +32771,7 @@
   }
 
   test_type_inference_instanceCreation_notGeneric() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   A(_);
 }
@@ -32866,9 +32814,9 @@
   }
 
   test_type_inference_multiplyDefinedElement() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    addLibrarySource('$testPackageLibPath/b.dart', 'class C {}');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    addSource('$testPackageLibPath/b.dart', 'class C {}');
+    var library = await buildLibrary('''
 import 'a.dart';
 import 'b.dart';
 var v = C;
@@ -32894,7 +32842,7 @@
   }
 
   test_type_inference_nested_function() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = (t) => (u) => t + u;
 ''');
     checkElementText(library, r'''
@@ -32915,7 +32863,7 @@
   }
 
   test_type_inference_nested_function_with_parameter_types() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = (int t) => (int u) => t + u;
 ''');
     checkElementText(library, r'''
@@ -32936,7 +32884,7 @@
   }
 
   test_type_inference_of_closure_with_default_value() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var x = ([y: 0]) => y;
 ''');
     checkElementText(library, r'''
@@ -32957,7 +32905,7 @@
   }
 
   test_type_inference_topVariable_depends_onFieldFormal() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 
 class B extends A {}
@@ -33013,7 +32961,7 @@
   }
 
   test_type_inference_using_extension_getter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 extension on String {
   int get foo => 0;
 }
@@ -33046,7 +32994,7 @@
   }
 
   test_type_invalid_topLevelVariableElement_asType() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T extends V> {}
 typedef V F(V p);
 V f(V p) {}
@@ -33102,7 +33050,7 @@
   }
 
   test_type_invalid_topLevelVariableElement_asTypeArgument() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 var V;
 static List<V> V2;
 ''', allowErrors: true);
@@ -33133,7 +33081,7 @@
   }
 
   test_type_invalid_typeParameter_asPrefix() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   m(T.K p) {}
 }
@@ -33158,7 +33106,7 @@
   }
 
   test_type_invalid_unresolvedPrefix() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 p.C v;
 ''', allowErrors: true);
     checkElementText(library, r'''
@@ -33180,7 +33128,7 @@
 
   test_type_never_disableNnbd() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('Never d;');
+    var library = await buildLibrary('Never d;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33199,7 +33147,7 @@
   }
 
   test_type_never_enableNnbd() async {
-    var library = await checkLibrary('Never d;');
+    var library = await buildLibrary('Never d;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33218,7 +33166,7 @@
   }
 
   test_type_param_ref_nullability_none() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   T t;
 }
@@ -33248,7 +33196,7 @@
   }
 
   test_type_param_ref_nullability_question() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   T? t;
 }
@@ -33279,7 +33227,7 @@
 
   test_type_param_ref_nullability_star() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   T t;
 }
@@ -33309,7 +33257,7 @@
   }
 
   test_type_reference_lib_to_lib() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C {}
 enum E { v }
 typedef F();
@@ -33406,7 +33354,7 @@
     addSource('$testPackageLibPath/a.dart',
         'part of l; class C {} enum E { v } typedef F();');
     var library =
-        await checkLibrary('library l; part "a.dart"; C c; E e; F f;');
+        await buildLibrary('library l; part "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   name: l
@@ -33499,7 +33447,7 @@
 
   test_type_reference_part_to_lib() async {
     addSource('$testPackageLibPath/a.dart', 'part of l; C c; E e; F f;');
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'library l; part "a.dart"; class C {} enum E { v } typedef F();');
     checkElementText(library, r'''
 library
@@ -33596,7 +33544,7 @@
         'part of l; class C {} enum E { v } typedef F();');
     addSource('$testPackageLibPath/b.dart', 'part of l; C c; E e; F f;');
     var library =
-        await checkLibrary('library l; part "a.dart"; part "b.dart";');
+        await buildLibrary('library l; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
 library
   name: l
@@ -33691,7 +33639,7 @@
   test_type_reference_part_to_part() async {
     addSource('$testPackageLibPath/a.dart',
         'part of l; class C {} enum E { v } typedef F(); C c; E e; F f;');
-    var library = await checkLibrary('library l; part "a.dart";');
+    var library = await buildLibrary('library l; part "a.dart";');
     checkElementText(library, r'''
 library
   name: l
@@ -33783,7 +33731,7 @@
   }
 
   test_type_reference_to_class() async {
-    var library = await checkLibrary('class C {} C c;');
+    var library = await buildLibrary('class C {} C c;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33806,7 +33754,7 @@
   }
 
   test_type_reference_to_class_with_type_arguments() async {
-    var library = await checkLibrary('class C<T, U> {} C<int, String> c;');
+    var library = await buildLibrary('class C<T, U> {} C<int, String> c;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33834,7 +33782,7 @@
   }
 
   test_type_reference_to_class_with_type_arguments_implicit() async {
-    var library = await checkLibrary('class C<T, U> {} C c;');
+    var library = await buildLibrary('class C<T, U> {} C c;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33862,7 +33810,7 @@
   }
 
   test_type_reference_to_enum() async {
-    var library = await checkLibrary('enum E { v } E e;');
+    var library = await buildLibrary('enum E { v } E e;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -33920,9 +33868,9 @@
   }
 
   test_type_reference_to_import() async {
-    addLibrarySource(
+    addSource(
         '$testPackageLibPath/a.dart', 'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -33964,10 +33912,10 @@
   }
 
   test_type_reference_to_import_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
-    addLibrarySource(
+    addSource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addSource(
         '$testPackageLibPath/b.dart', 'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34009,11 +33957,11 @@
   }
 
   test_type_reference_to_import_export_export() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'export "b.dart";');
-    addLibrarySource('$testPackageLibPath/b.dart', 'export "c.dart";');
-    addLibrarySource(
+    addSource('$testPackageLibPath/a.dart', 'export "b.dart";');
+    addSource('$testPackageLibPath/b.dart', 'export "c.dart";');
+    addSource(
         '$testPackageLibPath/c.dart', 'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34055,11 +34003,11 @@
   }
 
   test_type_reference_to_import_export_export_in_subdirs() async {
-    addLibrarySource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
-    addLibrarySource('$testPackageLibPath/a/b/b.dart', 'export "../c/c.dart";');
-    addLibrarySource('$testPackageLibPath/a/c/c.dart',
+    addSource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
+    addSource('$testPackageLibPath/a/b/b.dart', 'export "../c/c.dart";');
+    addSource('$testPackageLibPath/a/c/c.dart',
         'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a/a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34101,10 +34049,10 @@
   }
 
   test_type_reference_to_import_export_in_subdirs() async {
-    addLibrarySource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
-    addLibrarySource('$testPackageLibPath/a/b/b.dart',
+    addSource('$testPackageLibPath/a/a.dart', 'export "b/b.dart";');
+    addSource('$testPackageLibPath/a/b/b.dart',
         'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a/a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a/a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34146,10 +34094,10 @@
   }
 
   test_type_reference_to_import_part() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'library l; part "b.dart";');
+    addSource('$testPackageLibPath/a.dart', 'library l; part "b.dart";');
     addSource('$testPackageLibPath/b.dart',
         'part of l; class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34191,11 +34139,11 @@
   }
 
   test_type_reference_to_import_part2() async {
-    addLibrarySource('$testPackageLibPath/a.dart',
+    addSource('$testPackageLibPath/a.dart',
         'library l; part "p1.dart"; part "p2.dart";');
     addSource('$testPackageLibPath/p1.dart', 'part of l; class C1 {}');
     addSource('$testPackageLibPath/p2.dart', 'part of l; class C2 {}');
-    var library = await checkLibrary('import "a.dart"; C1 c1; C2 c2;');
+    var library = await buildLibrary('import "a.dart"; C1 c1; C2 c2;');
     checkElementText(library, r'''
 library
   imports
@@ -34225,11 +34173,10 @@
   }
 
   test_type_reference_to_import_part_in_subdir() async {
-    addLibrarySource(
-        '$testPackageLibPath/a/b.dart', 'library l; part "c.dart";');
+    addSource('$testPackageLibPath/a/b.dart', 'library l; part "c.dart";');
     addSource('$testPackageLibPath/a/c.dart',
         'part of l; class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a/b.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a/b.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34271,9 +34218,9 @@
   }
 
   test_type_reference_to_import_relative() async {
-    addLibrarySource(
+    addSource(
         '$testPackageLibPath/a.dart', 'class C {} enum E { v } typedef F();');
-    var library = await checkLibrary('import "a.dart"; C c; E e; F f;');
+    var library = await buildLibrary('import "a.dart"; C c; E e; F f;');
     checkElementText(library, r'''
 library
   imports
@@ -34315,7 +34262,7 @@
   }
 
   test_type_reference_to_typedef() async {
-    var library = await checkLibrary('typedef F(); F f;');
+    var library = await buildLibrary('typedef F(); F f;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -34343,7 +34290,7 @@
 
   test_type_reference_to_typedef_with_type_arguments() async {
     var library =
-        await checkLibrary('typedef U F<T, U>(T t); F<int, String> f;');
+        await buildLibrary('typedef U F<T, U>(T t); F<int, String> f;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -34387,7 +34334,7 @@
   }
 
   test_type_reference_to_typedef_with_type_arguments_implicit() async {
-    var library = await checkLibrary('typedef U F<T, U>(T t); F f;');
+    var library = await buildLibrary('typedef U F<T, U>(T t); F f;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -34431,7 +34378,7 @@
   }
 
   test_type_unresolved() async {
-    var library = await checkLibrary('C c;', allowErrors: true);
+    var library = await buildLibrary('C c;', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -34450,7 +34397,7 @@
   }
 
   test_type_unresolved_prefixed() async {
-    var library = await checkLibrary('import "dart:core" as core; core.C c;',
+    var library = await buildLibrary('import "dart:core" as core; core.C c;',
         allowErrors: true);
     checkElementText(library, r'''
 library
@@ -34472,7 +34419,7 @@
   }
 
   test_typeAlias_parameter_typeParameters() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F(T a<T, U>(U u));
 ''');
     checkElementText(library, r'''
@@ -34496,7 +34443,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_contravariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = void Function(T);
 ''');
     checkElementText(library, r'''
@@ -34517,7 +34464,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_contravariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1<T> = void Function(T);
 typedef F2<T> = F1<T> Function();
 ''');
@@ -34549,7 +34496,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_covariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = T Function();
 ''');
     checkElementText(library, r'''
@@ -34567,7 +34514,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_covariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = List<T> Function();
 ''');
     checkElementText(library, r'''
@@ -34585,7 +34532,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_covariant3() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1<T> = T Function();
 typedef F2<T> = F1<T> Function();
 ''');
@@ -34614,7 +34561,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_covariant4() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1<T> = void Function(T);
 typedef F2<T> = void Function(F1<T>);
 ''');
@@ -34649,7 +34596,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_invalid() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A {}
 typedef F<T> = void Function(A<int>);
 ''');
@@ -34675,7 +34622,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_invalid2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F = void Function();
 typedef G<T> = void Function(F<int>);
 ''');
@@ -34702,7 +34649,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_invariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = T Function(T);
 ''');
     checkElementText(library, r'''
@@ -34723,7 +34670,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_invariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F1<T> = T Function();
 typedef F2<T> = F1<T> Function(T);
 ''');
@@ -34755,7 +34702,7 @@
   }
 
   test_typeAlias_typeParameters_variance_function_unrelated() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef F<T> = void Function(int);
 ''');
     checkElementText(library, r'''
@@ -34776,7 +34723,7 @@
   }
 
   test_typeAlias_typeParameters_variance_interface_contravariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = List<void Function(T)>;
 ''');
     checkElementText(library, r'''
@@ -34792,7 +34739,7 @@
   }
 
   test_typeAlias_typeParameters_variance_interface_contravariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = void Function(T);
 typedef B<T> = List<A<T>>;
 ''');
@@ -34819,7 +34766,7 @@
   }
 
   test_typeAlias_typeParameters_variance_interface_covariant() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = List<T>;
 ''');
     checkElementText(library, r'''
@@ -34835,7 +34782,7 @@
   }
 
   test_typeAlias_typeParameters_variance_interface_covariant2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = Map<int, T>;
 typedef B<T> = List<A<T>>;
 ''');
@@ -34857,7 +34804,7 @@
   }
 
   test_typedef_function_generic() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'typedef F<T> = int Function<S>(List<S> list, num Function<A>(A), T);');
     checkElementText(library, r'''
 library
@@ -34883,7 +34830,7 @@
   }
 
   test_typedef_function_generic_asFieldType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef Foo<S> = S Function<T>(T x);
 class A {
   Foo<int> f;
@@ -34935,7 +34882,7 @@
   test_typedef_function_notSimplyBounded_dependency_via_param_type_name_included() async {
     // F is considered "not simply bounded" because it expands to a type that
     // refers to C, which is not simply bounded.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = void Function(C c);
 class C<T extends C<T>> {}
 ''');
@@ -34964,7 +34911,7 @@
   test_typedef_function_notSimplyBounded_dependency_via_param_type_name_omitted() async {
     // F is considered "not simply bounded" because it expands to a type that
     // refers to C, which is not simply bounded.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = void Function(C);
 class C<T extends C<T>> {}
 ''');
@@ -34993,7 +34940,7 @@
   test_typedef_function_notSimplyBounded_dependency_via_return_type() async {
     // F is considered "not simply bounded" because it expands to a type that
     // refers to C, which is not simply bounded.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef F = C Function();
 class C<T extends C<T>> {}
 ''');
@@ -35018,7 +34965,7 @@
 
   test_typedef_function_typeParameters_f_bound_simple() async {
     var library =
-        await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
+        await buildLibrary('typedef F<T extends U, U> = U Function(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35042,7 +34989,7 @@
   test_typedef_function_typeParameters_f_bound_simple_legacy() async {
     featureSet = FeatureSets.language_2_9;
     var library =
-        await checkLibrary('typedef F<T extends U, U> = U Function(T t);');
+        await buildLibrary('typedef F<T extends U, U> = U Function(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35064,7 +35011,7 @@
   }
 
   test_typedef_legacy_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -35085,7 +35032,7 @@
   test_typedef_legacy_notSimplyBounded_dependency_via_param_type() async {
     // F is considered "not simply bounded" because it expands to a type that
     // refers to C, which is not simply bounded.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef void F(C c);
 class C<T extends C<T>> {}
 ''');
@@ -35114,7 +35061,7 @@
   test_typedef_legacy_notSimplyBounded_dependency_via_return_type() async {
     // F is considered "not simply bounded" because it expands to a type that
     // refers to C, which is not simply bounded.
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef C F();
 class C<T extends C<T>> {}
 ''');
@@ -35138,7 +35085,7 @@
   }
 
   test_typedef_legacy_notSimplyBounded_self() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef void F<T extends F>();
 ''');
     checkElementText(library, r'''
@@ -35157,7 +35104,7 @@
   }
 
   test_typedef_legacy_notSimplyBounded_simple_because_non_generic() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 typedef void F();
 ''');
     checkElementText(library, r'''
@@ -35172,7 +35119,7 @@
   }
 
   test_typedef_legacy_notSimplyBounded_simple_no_bounds() async {
-    var library = await checkLibrary('typedef void F<T>();');
+    var library = await buildLibrary('typedef void F<T>();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35188,7 +35135,7 @@
   }
 
   test_typedef_legacy_parameter_hasImplicitType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef void F(int a, b, [int c, d]);
 ''');
     var F = library.definingCompilationUnit.typeAliases.single;
@@ -35201,7 +35148,7 @@
   }
 
   test_typedef_legacy_parameter_parameters() async {
-    var library = await checkLibrary('typedef F(g(x, y));');
+    var library = await buildLibrary('typedef F(g(x, y));');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35222,7 +35169,7 @@
   }
 
   test_typedef_legacy_parameter_parameters_in_generic_class() async {
-    var library = await checkLibrary('typedef F<A, B>(A g(B x));');
+    var library = await buildLibrary('typedef F<A, B>(A g(B x));');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35246,7 +35193,7 @@
   }
 
   test_typedef_legacy_parameter_return_type() async {
-    var library = await checkLibrary('typedef F(int g());');
+    var library = await buildLibrary('typedef F(int g());');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35262,7 +35209,7 @@
   }
 
   test_typedef_legacy_parameter_type() async {
-    var library = await checkLibrary('typedef F(int i);');
+    var library = await buildLibrary('typedef F(int i);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35278,7 +35225,7 @@
   }
 
   test_typedef_legacy_parameter_type_generic() async {
-    var library = await checkLibrary('typedef F<T>(T t);');
+    var library = await buildLibrary('typedef F<T>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35297,7 +35244,7 @@
   }
 
   test_typedef_legacy_parameters() async {
-    var library = await checkLibrary('typedef F(x, y);');
+    var library = await buildLibrary('typedef F(x, y);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35315,7 +35262,7 @@
   }
 
   test_typedef_legacy_parameters_named() async {
-    var library = await checkLibrary('typedef F({y, z, x});');
+    var library = await buildLibrary('typedef F({y, z, x});');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35335,7 +35282,7 @@
   }
 
   test_typedef_legacy_return_type() async {
-    var library = await checkLibrary('typedef int F();');
+    var library = await buildLibrary('typedef int F();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35348,7 +35295,7 @@
   }
 
   test_typedef_legacy_return_type_generic() async {
-    var library = await checkLibrary('typedef T F<T>();');
+    var library = await buildLibrary('typedef T F<T>();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35364,7 +35311,7 @@
   }
 
   test_typedef_legacy_return_type_implicit() async {
-    var library = await checkLibrary('typedef F();');
+    var library = await buildLibrary('typedef F();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35377,7 +35324,7 @@
   }
 
   test_typedef_legacy_return_type_void() async {
-    var library = await checkLibrary('typedef void F();');
+    var library = await buildLibrary('typedef void F();');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35390,7 +35337,7 @@
   }
 
   test_typedef_legacy_typeParameters() async {
-    var library = await checkLibrary('typedef U F<T, U>(T t);');
+    var library = await buildLibrary('typedef U F<T, U>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35411,7 +35358,7 @@
   }
 
   test_typedef_legacy_typeParameters_bound() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'typedef U F<T extends Object, U extends D>(T t); class D {}');
     checkElementText(library, r'''
 library
@@ -35439,7 +35386,7 @@
   }
 
   test_typedef_legacy_typeParameters_bound_recursive() async {
-    var library = await checkLibrary('typedef void F<T extends F>();');
+    var library = await buildLibrary('typedef void F<T extends F>();');
     // Typedefs cannot reference themselves.
     checkElementText(library, r'''
 library
@@ -35457,7 +35404,7 @@
   }
 
   test_typedef_legacy_typeParameters_bound_recursive2() async {
-    var library = await checkLibrary('typedef void F<T extends List<F>>();');
+    var library = await buildLibrary('typedef void F<T extends List<F>>();');
     // Typedefs cannot reference themselves.
     checkElementText(library, r'''
 library
@@ -35475,7 +35422,7 @@
   }
 
   test_typedef_legacy_typeParameters_f_bound_complex() async {
-    var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
+    var library = await buildLibrary('typedef U F<T extends List<U>, U>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35498,7 +35445,7 @@
 
   test_typedef_legacy_typeParameters_f_bound_complex_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('typedef U F<T extends List<U>, U>(T t);');
+    var library = await buildLibrary('typedef U F<T extends List<U>, U>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35520,7 +35467,7 @@
   }
 
   test_typedef_legacy_typeParameters_f_bound_simple() async {
-    var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
+    var library = await buildLibrary('typedef U F<T extends U, U>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35543,7 +35490,7 @@
 
   test_typedef_legacy_typeParameters_f_bound_simple_legacy() async {
     featureSet = FeatureSets.language_2_9;
-    var library = await checkLibrary('typedef U F<T extends U, U>(T t);');
+    var library = await buildLibrary('typedef U F<T extends U, U>(T t);');
     checkElementText(library, r'''
 library
   definingUnit
@@ -35569,7 +35516,7 @@
     reason: 'Type dynamic is special, no support for its aliases yet',
   )
   test_typedef_nonFunction_aliasElement_dynamic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = dynamic;
 void f(A a) {}
 ''');
@@ -35581,7 +35528,7 @@
   }
 
   test_typedef_nonFunction_aliasElement_functionType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A1 = void Function();
 typedef A2<R> = R Function();
 void f1(A1 a) {}
@@ -35622,7 +35569,7 @@
   }
 
   test_typedef_nonFunction_aliasElement_interfaceType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A1 = List<int>;
 typedef A2<T, U> = Map<T, U>;
 void f1(A1 a) {}
@@ -35666,7 +35613,7 @@
     reason: 'Type Never is special, no support for its aliases yet',
   )
   test_typedef_nonFunction_aliasElement_never() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A1 = Never;
 typedef A2<T> = Never?;
 void f1(A1 a) {}
@@ -35682,7 +35629,7 @@
   }
 
   test_typedef_nonFunction_aliasElement_typeParameterType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = T;
 void f<U>(A<U> a) {}
 ''');
@@ -35715,7 +35662,7 @@
     reason: 'Type void is special, no support for its aliases yet',
   )
   test_typedef_nonFunction_aliasElement_void() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = void;
 void f(A a) {}
 ''');
@@ -35727,7 +35674,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_interfaceType_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X<T> = A<int, T>;
 class A<T, U> {}
 class B implements X<String> {}
@@ -35762,7 +35709,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_interfaceType_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X<T> = A<T>?;
 class A<T> {}
 class B {}
@@ -35801,7 +35748,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_interfaceType_question2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X<T> = A<T?>;
 class A<T> {}
 class B {}
@@ -35844,7 +35791,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_Never_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Never;
 class A implements X {}
 ''');
@@ -35862,7 +35809,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_Null_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Null;
 class A implements X {}
 ''');
@@ -35880,7 +35827,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_typeParameterType() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X<T> = T;
 class A {}
 class B {}
@@ -35915,7 +35862,7 @@
   }
 
   test_typedef_nonFunction_asInterfaceType_void() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = void;
 class A {}
 class B {}
@@ -35944,7 +35891,7 @@
   }
 
   test_typedef_nonFunction_asMixinType_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int>;
 class A<T> {}
 class B with X {}
@@ -35973,7 +35920,7 @@
   }
 
   test_typedef_nonFunction_asMixinType_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int>?;
 class A<T> {}
 mixin M1 {}
@@ -36015,7 +35962,7 @@
   }
 
   test_typedef_nonFunction_asMixinType_question2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int?>;
 class A<T> {}
 mixin M1 {}
@@ -36059,7 +36006,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_Never_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Never;
 class A extends X {}
 ''');
@@ -36077,7 +36024,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int>;
 class A<T> {}
 class B extends X {}
@@ -36107,7 +36054,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_none_viaTypeParameter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X<T> = T;
 class A<T> {}
 class B extends X<A<int>> {}
@@ -36142,7 +36089,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_Null_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Null;
 class A extends X {}
 ''');
@@ -36160,7 +36107,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int>?;
 class A<T> {}
 class D extends X {}
@@ -36185,7 +36132,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_interfaceType_question2() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = A<int?>;
 class A<T> {}
 class D extends X {}
@@ -36215,7 +36162,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_Never_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Never;
 class A extends X {}
 ''');
@@ -36233,7 +36180,7 @@
   }
 
   test_typedef_nonFunction_asSuperType_Null_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef X = Null;
 class A extends X {}
 ''');
@@ -36251,7 +36198,7 @@
   }
 
   test_typedef_nonFunction_using_dynamic() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = dynamic;
 void f(A a) {}
 ''');
@@ -36272,7 +36219,7 @@
 
   test_typedef_nonFunction_using_interface_disabled() async {
     featureSet = FeatureSets.language_2_12;
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = int;
 void f(A a) {}
 ''');
@@ -36297,7 +36244,7 @@
   }
 
   test_typedef_nonFunction_using_interface_noTypeParameters() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = int;
 void f(A a) {}
 ''');
@@ -36318,10 +36265,10 @@
   }
 
   test_typedef_nonFunction_using_interface_noTypeParameters_legacy() async {
-    newFile('/a.dart', content: r'''
+    newFile2('/a.dart', r'''
 typedef A = List<int>;
 ''');
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 // @dart = 2.9
 import 'a.dart';
 void f(A a) {}
@@ -36341,7 +36288,7 @@
   }
 
   test_typedef_nonFunction_using_interface_noTypeParameters_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = int?;
 void f(A a) {}
 ''');
@@ -36362,7 +36309,7 @@
   }
 
   test_typedef_nonFunction_using_interface_withTypeParameters() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = Map<int, T>;
 void f(A<String> a) {}
 ''');
@@ -36388,7 +36335,7 @@
   }
 
   test_typedef_nonFunction_using_Never_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = Never;
 void f(A a) {}
 ''');
@@ -36408,7 +36355,7 @@
   }
 
   test_typedef_nonFunction_using_Never_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = Never?;
 void f(A a) {}
 ''');
@@ -36428,7 +36375,7 @@
   }
 
   test_typedef_nonFunction_using_typeParameter_none() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = T;
 void f1(A a) {}
 void f2(A<int> a) {}
@@ -36460,7 +36407,7 @@
   }
 
   test_typedef_nonFunction_using_typeParameter_question() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A<T> = T?;
 void f1(A a) {}
 void f2(A<int> a) {}
@@ -36492,7 +36439,7 @@
   }
 
   test_typedef_nonFunction_using_void() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 typedef A = void;
 void f(A a) {}
 ''');
@@ -36512,7 +36459,7 @@
   }
 
   test_typedefs() async {
-    var library = await checkLibrary('f() {} g() {}');
+    var library = await buildLibrary('f() {} g() {}');
     checkElementText(library, r'''
 library
   definingUnit
@@ -36525,7 +36472,7 @@
   }
 
   test_unit_implicitVariable_getterFirst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 int get x => 0;
 void set x(int value) {}
 ''');
@@ -36547,7 +36494,7 @@
   }
 
   test_unit_implicitVariable_setterFirst() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 void set x(int value) {}
 int get x => 0;
 ''');
@@ -36569,7 +36516,7 @@
   }
 
   test_unit_variable_final_withSetter() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 final int foo = 0;
 set foo(int newValue) {}
 ''');
@@ -36591,7 +36538,7 @@
   }
 
   test_unresolved_annotation_instanceCreation_argument_super() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(_);
 }
@@ -36631,7 +36578,7 @@
   }
 
   test_unresolved_annotation_instanceCreation_argument_this() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {
   const A(_);
 }
@@ -36672,7 +36619,7 @@
 
   test_unresolved_annotation_namedConstructorCall_noClass() async {
     var library =
-        await checkLibrary('@foo.bar() class C {}', allowErrors: true);
+        await buildLibrary('@foo.bar() class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36704,7 +36651,7 @@
 
   test_unresolved_annotation_namedConstructorCall_noConstructor() async {
     var library =
-        await checkLibrary('@String.foo() class C {}', allowErrors: true);
+        await buildLibrary('@String.foo() class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36735,7 +36682,7 @@
   }
 
   test_unresolved_annotation_prefixedIdentifier_badPrefix() async {
-    var library = await checkLibrary('@foo.bar class C {}', allowErrors: true);
+    var library = await buildLibrary('@foo.bar class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36763,7 +36710,7 @@
   }
 
   test_unresolved_annotation_prefixedIdentifier_noDeclaration() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'import "dart:async" as foo; @foo.bar class C {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -36796,7 +36743,7 @@
 
   test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() async {
     var library =
-        await checkLibrary('@foo.bar.baz() class C {}', allowErrors: true);
+        await buildLibrary('@foo.bar.baz() class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36832,7 +36779,7 @@
   }
 
   test_unresolved_annotation_prefixedNamedConstructorCall_noClass() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'import "dart:async" as foo; @foo.bar.baz() class C {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -36872,7 +36819,7 @@
   }
 
   test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'import "dart:async" as foo; @foo.Future.bar() class C {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -36913,7 +36860,7 @@
 
   test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() async {
     var library =
-        await checkLibrary('@foo.bar() class C {}', allowErrors: true);
+        await buildLibrary('@foo.bar() class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36944,7 +36891,7 @@
   }
 
   test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() async {
-    var library = await checkLibrary(
+    var library = await buildLibrary(
         'import "dart:async" as foo; @foo.bar() class C {}',
         allowErrors: true);
     checkElementText(library, r'''
@@ -36979,7 +36926,7 @@
   }
 
   test_unresolved_annotation_simpleIdentifier() async {
-    var library = await checkLibrary('@foo class C {}', allowErrors: true);
+    var library = await buildLibrary('@foo class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -36999,9 +36946,9 @@
   }
 
   test_unresolved_annotation_simpleIdentifier_multiplyDefined() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'const v = 0;');
-    addLibrarySource('$testPackageLibPath/b.dart', 'const v = 0;');
-    var library = await checkLibrary('''
+    addSource('$testPackageLibPath/a.dart', 'const v = 0;');
+    addSource('$testPackageLibPath/b.dart', 'const v = 0;');
+    var library = await buildLibrary('''
 import 'a.dart';
 import 'b.dart';
 
@@ -37030,7 +36977,7 @@
   }
 
   test_unresolved_annotation_unnamedConstructorCall_noClass() async {
-    var library = await checkLibrary('@foo() class C {}', allowErrors: true);
+    var library = await buildLibrary('@foo() class C {}', allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -37053,7 +37000,7 @@
   }
 
   test_unresolved_export() async {
-    var library = await checkLibrary("export 'foo.dart';", allowErrors: true);
+    var library = await buildLibrary("export 'foo.dart';", allowErrors: true);
     checkElementText(library, r'''
 library
   exports
@@ -37063,7 +37010,7 @@
   }
 
   test_unresolved_import() async {
-    var library = await checkLibrary("import 'foo.dart';", allowErrors: true);
+    var library = await buildLibrary("import 'foo.dart';", allowErrors: true);
     var importedLibrary = library.imports[0].importedLibrary!;
     expect(importedLibrary.loadLibraryFunction, isNotNull);
     expect(importedLibrary.publicNamespace, isNotNull);
@@ -37077,7 +37024,7 @@
   }
 
   test_unresolved_part() async {
-    var library = await checkLibrary("part 'foo.dart';", allowErrors: true);
+    var library = await buildLibrary("part 'foo.dart';", allowErrors: true);
     checkElementText(library, r'''
 library
   definingUnit
@@ -37087,7 +37034,7 @@
   }
 
   test_unused_type_parameter() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class C<T> {
   void f() {}
 }
@@ -37131,7 +37078,7 @@
   }
 
   test_variable() async {
-    var library = await checkLibrary('int x = 0;');
+    var library = await buildLibrary('int x = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37150,7 +37097,7 @@
   }
 
   test_variable_const() async {
-    var library = await checkLibrary('const int i = 0;');
+    var library = await buildLibrary('const int i = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37168,7 +37115,7 @@
   }
 
   test_variable_const_late() async {
-    var library = await checkLibrary('late const int i = 0;');
+    var library = await buildLibrary('late const int i = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37186,7 +37133,7 @@
   }
 
   test_variable_documented() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 // Extra comment so doc comment offset != 0
 /**
  * Docs
@@ -37211,7 +37158,7 @@
   }
 
   test_variable_final() async {
-    var library = await checkLibrary('final int x = 0;');
+    var library = await buildLibrary('final int x = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37229,7 +37176,7 @@
 part of my.lib;
 void set x(int _) {}
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library my.lib;
 part 'a.dart';
 int get x => 42;''');
@@ -37263,7 +37210,7 @@
 part of my.lib;
 int get x => 42;
 ''');
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 library my.lib;
 part 'a.dart';
 void set x(int _) {}
@@ -37298,7 +37245,7 @@
     addSource(
         '$testPackageLibPath/b.dart', 'part of my.lib; void set x(int _) {}');
     var library =
-        await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
+        await buildLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
 library
   name: my.lib
@@ -37326,7 +37273,7 @@
   }
 
   test_variable_implicit() async {
-    var library = await checkLibrary('int get x => 0;');
+    var library = await buildLibrary('int get x => 0;');
 
     // We intentionally don't check the text, because we want to test
     // requesting individual elements, not all accessors/variables at once.
@@ -37341,7 +37288,7 @@
   }
 
   test_variable_implicit_type() async {
-    var library = await checkLibrary('var x;');
+    var library = await buildLibrary('var x;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37360,7 +37307,7 @@
   }
 
   test_variable_inferred_type_implicit_initialized() async {
-    var library = await checkLibrary('var v = 0;');
+    var library = await buildLibrary('var v = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37379,7 +37326,7 @@
   }
 
   test_variable_initializer() async {
-    var library = await checkLibrary('int v = 0;');
+    var library = await buildLibrary('int v = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37398,7 +37345,7 @@
   }
 
   test_variable_initializer_final() async {
-    var library = await checkLibrary('final int v = 0;');
+    var library = await buildLibrary('final int v = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37412,7 +37359,7 @@
   }
 
   test_variable_initializer_final_untyped() async {
-    var library = await checkLibrary('final v = 0;');
+    var library = await buildLibrary('final v = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37426,7 +37373,7 @@
   }
 
   test_variable_initializer_staticMethod_ofExtension() async {
-    var library = await checkLibrary('''
+    var library = await buildLibrary('''
 class A {}
 extension E on A {
   static int f() => 0;
@@ -37461,7 +37408,7 @@
   }
 
   test_variable_initializer_untyped() async {
-    var library = await checkLibrary('var v = 0;');
+    var library = await buildLibrary('var v = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37480,7 +37427,7 @@
   }
 
   test_variable_late() async {
-    var library = await checkLibrary('late int x = 0;');
+    var library = await buildLibrary('late int x = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37499,7 +37446,7 @@
   }
 
   test_variable_late_final() async {
-    var library = await checkLibrary('late final int x;');
+    var library = await buildLibrary('late final int x;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37518,7 +37465,7 @@
   }
 
   test_variable_late_final_initialized() async {
-    var library = await checkLibrary('late final int x = 0;');
+    var library = await buildLibrary('late final int x = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37532,7 +37479,7 @@
   }
 
   test_variable_propagatedType_const_noDep() async {
-    var library = await checkLibrary('const i = 0;');
+    var library = await buildLibrary('const i = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37550,8 +37497,8 @@
   }
 
   test_variable_propagatedType_final_dep_inLib() async {
-    addLibrarySource('$testPackageLibPath/a.dart', 'final a = 1;');
-    var library = await checkLibrary('import "a.dart"; final b = a / 2;');
+    addSource('$testPackageLibPath/a.dart', 'final a = 1;');
+    var library = await buildLibrary('import "a.dart"; final b = a / 2;');
     checkElementText(library, r'''
 library
   imports
@@ -37569,7 +37516,7 @@
   test_variable_propagatedType_final_dep_inPart() async {
     addSource('$testPackageLibPath/a.dart', 'part of lib; final a = 1;');
     var library =
-        await checkLibrary('library lib; part "a.dart"; final b = a / 2;');
+        await buildLibrary('library lib; part "a.dart"; final b = a / 2;');
     checkElementText(library, r'''
 library
   name: lib
@@ -37593,7 +37540,7 @@
   }
 
   test_variable_propagatedType_final_noDep() async {
-    var library = await checkLibrary('final i = 0;');
+    var library = await buildLibrary('final i = 0;');
     checkElementText(library, r'''
 library
   definingUnit
@@ -37608,10 +37555,9 @@
 
   test_variable_propagatedType_implicit_dep() async {
     // The propagated type is defined in a library that is not imported.
-    addLibrarySource('$testPackageLibPath/a.dart', 'class C {}');
-    addLibrarySource(
-        '$testPackageLibPath/b.dart', 'import "a.dart"; C f() => null;');
-    var library = await checkLibrary('import "b.dart"; final x = f();');
+    addSource('$testPackageLibPath/a.dart', 'class C {}');
+    addSource('$testPackageLibPath/b.dart', 'import "a.dart"; C f() => null;');
+    var library = await buildLibrary('import "b.dart"; final x = f();');
     checkElementText(library, r'''
 library
   imports
@@ -37631,7 +37577,7 @@
         '$testPackageLibPath/a.dart', 'part of my.lib; void set x(int _) {}');
     addSource('$testPackageLibPath/b.dart', 'part of my.lib; int get x => 42;');
     var library =
-        await checkLibrary('library my.lib; part "a.dart"; part "b.dart";');
+        await buildLibrary('library my.lib; part "a.dart"; part "b.dart";');
     checkElementText(library, r'''
 library
   name: my.lib
@@ -37659,7 +37605,7 @@
   }
 
   test_variable_type_inferred_Never() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 var a = throw 42;
 ''');
 
@@ -37681,7 +37627,7 @@
   }
 
   test_variable_type_inferred_noInitializer() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 var a;
 ''');
 
@@ -37708,7 +37654,7 @@
 var a = 0;
 ''');
 
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 import 'a.dart';
 var b = a;
 ''');
@@ -37733,7 +37679,7 @@
   }
 
   test_variableInitializer_contextType_after_astRewrite() async {
-    var library = await checkLibrary(r'''
+    var library = await buildLibrary(r'''
 class A<T> {
   const A();
 }
@@ -37775,7 +37721,7 @@
   }
 
   test_variables() async {
-    var library = await checkLibrary('int i; int j;');
+    var library = await buildLibrary('int i; int j;');
     checkElementText(library, r'''
 library
   definingUnit
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
new file mode 100644
index 0000000..1495f4e
--- /dev/null
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -0,0 +1,77 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'element_text.dart';
+import 'elements_base.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(MacroElementsKeepLinkingTest);
+    defineReflectiveTests(MacroElementsFromBytesTest);
+  });
+}
+
+@reflectiveTest
+class MacroElementsFromBytesTest extends MacroElementsTest {
+  @override
+  bool get keepLinkingLibraries => false;
+}
+
+@reflectiveTest
+class MacroElementsKeepLinkingTest extends MacroElementsTest {
+  @override
+  bool get keepLinkingLibraries => true;
+}
+
+class MacroElementsTest extends ElementsBaseTest {
+  @override
+  bool get keepLinkingLibraries => false;
+
+  test_class_macro() async {
+    var library = await buildLibrary(r'''
+macro class A {}
+''');
+    checkElementText(library, r'''
+library
+  definingUnit
+    classes
+      macro class A @12
+        constructors
+          synthetic @-1
+''');
+  }
+
+  test_classAlias_macro() async {
+    var library = await buildLibrary(r'''
+mixin M {}
+macro class A = Object with M;
+''');
+    checkElementText(library, r'''
+library
+  definingUnit
+    classes
+      macro class alias A @23
+        supertype: Object
+        mixins
+          M
+        constructors
+          synthetic const @-1
+            constantInitializers
+              SuperConstructorInvocation
+                superKeyword: super @0
+                argumentList: ArgumentList
+                  leftParenthesis: ( @0
+                  rightParenthesis: ) @0
+                staticElement: dart:core::@class::Object::@constructor::•
+    mixins
+      mixin M @6
+        superclassConstraints
+          Object
+        constructors
+          synthetic @-1
+''');
+  }
+}
diff --git a/pkg/analyzer/test/src/summary/test_all.dart b/pkg/analyzer/test/src/summary/test_all.dart
index 3c8974e..f944535 100644
--- a/pkg/analyzer/test/src/summary/test_all.dart
+++ b/pkg/analyzer/test/src/summary/test_all.dart
@@ -6,18 +6,20 @@
 
 import 'api_signature_test.dart' as api_signature;
 import 'dependency_walker_test.dart' as dependency_walker;
+import 'elements_test.dart' as elements;
 import 'flat_buffers_test.dart' as flat_buffers;
 import 'in_summary_source_test.dart' as in_summary_source;
-import 'resynthesize_ast2_test.dart' as resynthesize_ast2;
+import 'macro_test.dart' as macro;
 import 'top_level_inference_test.dart' as top_level_inference;
 
 main() {
   defineReflectiveSuite(() {
     api_signature.main();
     dependency_walker.main();
+    elements.main();
     flat_buffers.main();
     in_summary_source.main();
-    resynthesize_ast2.main();
+    macro.main();
     top_level_inference.main();
   }, name: 'summary');
 }
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index 5cc3ab8..d78fbd0 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -1246,7 +1246,7 @@
   }
 
   test_initializer_extractProperty_explicitlyTyped_differentLibraryCycle() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   int f = 0;
 }
@@ -1314,7 +1314,7 @@
   }
 
   test_initializer_extractProperty_explicitlyTyped_sameLibraryCycle() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'test.dart'; // just do make it part of the library cycle
 class C {
   int f = 0;
@@ -1344,7 +1344,7 @@
   }
 
   test_initializer_extractProperty_implicitlyTyped_differentLibraryCycle() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 class C {
   var f = 0;
 }
@@ -1412,7 +1412,7 @@
   }
 
   test_initializer_extractProperty_implicitlyTyped_sameLibraryCycle() async {
-    newFile('$testPackageLibPath/a.dart', content: r'''
+    newFile2('$testPackageLibPath/a.dart', r'''
 import 'test.dart'; // just do make it part of the library cycle
 class C {
   var f = 0;
@@ -5979,7 +5979,7 @@
   }
 
   test_method_OK_single_private_linkThroughOtherLibraryOfCycle() async {
-    newFile('$testPackageLibPath/other.dart', content: r'''
+    newFile2('$testPackageLibPath/other.dart', r'''
 import 'test.dart';
 class B extends A2 {}
 ''');
@@ -6163,7 +6163,7 @@
   }
 
   Future<LibraryElement> _encodeDecodeLibrary(String text) async {
-    newFile(testFilePath, content: text);
+    newFile2(testFilePath, text);
 
     var path = convertPath(testFilePath);
     var analysisSession = contextFor(path).currentSession;
diff --git a/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart b/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
index f6afa71..cbdca46 100644
--- a/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
+++ b/pkg/analyzer/test/src/summary2/ast_text_printer_test.dart
@@ -25,7 +25,7 @@
   code = code.replaceAll('\r\n', '\n');
   code = code.replaceAll('\r', '\n');
 
-  var path = base.newFile('/home/test/lib/test.dart', content: code).path;
+  var path = base.newFile2('/home/test/lib/test.dart', code).path;
 
   ParseResult parseResult;
   try {
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index 0b8f745..db57448 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -248,7 +248,7 @@
   }
 
   test_conversionAndDynamicInvoke() async {
-    newFile('$testPackageLibPath/helper.dart', content: r'''
+    newFile2('$testPackageLibPath/helper.dart', r'''
 dynamic toString = (int x) => x + 42;
 dynamic hashCode = "hello";
 ''');
@@ -2787,7 +2787,7 @@
   }
 
   test_privateOverride() async {
-    newFile('$testPackageLibPath/helper.dart', content: r'''
+    newFile2('$testPackageLibPath/helper.dart', r'''
 import 'test.dart' as main;
 
 class Base {
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 279763f..e04aa1c 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -2579,11 +2579,11 @@
   }
 
   test_inferConstsTransitively() async {
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 const b1 = 2;
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 import 'b.dart';
 const a1 = m2;
@@ -2740,7 +2740,7 @@
   }
 
   test_inferFromVariablesInCycleLibsWhenFlagIsOn() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 var x = 2; // ok to infer
 ''');
@@ -2759,7 +2759,7 @@
   }
 
   test_inferFromVariablesInCycleLibsWhenFlagIsOn2() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 class A { static var x = 2; }
 ''');
@@ -2778,7 +2778,7 @@
   }
 
   test_inferFromVariablesInNonCycleImportsWithFlag() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 var x = 2;
 ''');
 
@@ -2797,7 +2797,7 @@
   }
 
   test_inferFromVariablesInNonCycleImportsWithFlag2() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 class A { static var x = 2; }
 ''');
 
@@ -3352,11 +3352,11 @@
   }
 
   test_inferStaticsTransitively() async {
-    newFile('$testPackageLibPath/b.dart', content: '''
+    newFile2('$testPackageLibPath/b.dart', '''
 final b1 = 2;
 ''');
 
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 import 'b.dart';
 final a1 = m2;
@@ -3396,7 +3396,7 @@
   }
 
   test_inferStaticsTransitively3() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 const a1 = 3;
 const a2 = 4;
 class A {
@@ -3426,7 +3426,7 @@
   }
 
   test_inferStaticsWithMethodInvocations() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 m3(String a, String b, [a1,a2]) {}
 ''');
 
@@ -3566,7 +3566,7 @@
   }
 
   test_inferTypeRegardlessOfDeclarationOrderOrCycles() async {
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 
 class B extends A { }
@@ -3694,7 +3694,7 @@
 
   test_inferTypesOnGenericInstantiationsInLibraryCycle() async {
     // Note: this is a regression test for bug #48.
-    newFile('$testPackageLibPath/a.dart', content: '''
+    newFile2('$testPackageLibPath/a.dart', '''
 import 'test.dart';
 abstract class I<E> {
   A<E> m(a, String f(v, int e));
diff --git a/pkg/analyzer/test/src/workspace/basic_test.dart b/pkg/analyzer/test/src/workspace/basic_test.dart
index 2d08778..c239300 100644
--- a/pkg/analyzer/test/src/workspace/basic_test.dart
+++ b/pkg/analyzer/test/src/workspace/basic_test.dart
@@ -32,7 +32,7 @@
   }
 
   void test_contains_differentWorkspace() {
-    newFile('/workspace2/project/lib/file.dart');
+    newFile2('/workspace2/project/lib/file.dart', '');
 
     var package = findPackage('/workspace/project/lib/code.dart')!;
     expect(
@@ -42,7 +42,7 @@
   }
 
   void test_contains_sameWorkspace() {
-    newFile('/workspace/project/lib/file2.dart');
+    newFile2('/workspace/project/lib/file2.dart', '');
 
     var package = findPackage('/workspace/project/lib/code.dart')!;
     expect(
@@ -60,7 +60,7 @@
   }
 
   void test_findPackageFor_includedFile() {
-    newFile('/workspace/project/lib/file.dart');
+    newFile2('/workspace/project/lib/file.dart', '');
 
     var package = findPackage('/workspace/project/lib/file.dart')!;
     expect(package, isNotNull);
@@ -69,7 +69,7 @@
   }
 
   void test_findPackageFor_unrelatedFile() {
-    newFile('/workspace/project/lib/file.dart');
+    newFile2('/workspace/project/lib/file.dart', '');
 
     var package = findPackage('/workspace2/project/lib/file.dart');
     expect(package, isNull);
diff --git a/pkg/analyzer/test/src/workspace/bazel_test.dart b/pkg/analyzer/test/src/workspace/bazel_test.dart
index bdfa730..7c01cc1 100644
--- a/pkg/analyzer/test/src/workspace/bazel_test.dart
+++ b/pkg/analyzer/test/src/workspace/bazel_test.dart
@@ -27,14 +27,14 @@
   late final BazelFileUriResolver resolver;
 
   void setUp() {
-    newFile('/workspace/WORKSPACE');
+    newFile2('/workspace/WORKSPACE', '');
     newFolder('/workspace/bazel-genfiles');
     workspace =
         BazelWorkspace.find(resourceProvider, convertPath('/workspace'))!;
     resolver = BazelFileUriResolver(workspace);
-    newFile('/workspace/test.dart');
-    newFile('/workspace/bazel-bin/gen1.dart');
-    newFile('/workspace/bazel-genfiles/gen2.dart');
+    newFile2('/workspace/test.dart', '');
+    newFile2('/workspace/bazel-bin/gen1.dart', '');
+    newFile2('/workspace/bazel-genfiles/gen2.dart', '');
     expect(workspace.isBazel, isTrue);
   }
 
@@ -560,7 +560,7 @@
       if (path.endsWith('/')) {
         newFolder(path.substring(0, path.length - 1));
       } else {
-        newFile(path);
+        newFile2(path, '');
       }
     }
     workspace =
@@ -635,10 +635,10 @@
 
   void test_contains_samePackage() {
     _setUpPackage();
-    final targetFile = newFile('/ws/some/code/lib/code2.dart');
-    final targetFile2 = newFile('/ws/some/code/lib/src/code3.dart');
-    final targetBinFile = newFile('/ws/some/code/bin/code.dart');
-    final targetTestFile = newFile('/ws/some/code/test/code_test.dart');
+    final targetFile = newFile2('/ws/some/code/lib/code2.dart', '');
+    final targetFile2 = newFile2('/ws/some/code/lib/src/code3.dart', '');
+    final targetBinFile = newFile2('/ws/some/code/bin/code.dart', '');
+    final targetTestFile = newFile2('/ws/some/code/test/code_test.dart', '');
 
     expect(package!.contains(_testSource(targetFile.path)), isTrue);
     expect(package!.contains(_testSource(targetFile2.path)), isTrue);
@@ -648,8 +648,8 @@
 
   void test_contains_samePackage_summarySource() {
     _setUpPackage();
-    newFile('/ws/some/code/lib/code2.dart');
-    newFile('/ws/some/code/lib/src/code3.dart');
+    newFile2('/ws/some/code/lib/code2.dart', '');
+    newFile2('/ws/some/code/lib/src/code3.dart', '');
     final file2Source = _inSummarySource('package:some.code/code2.dart');
     final file3Source = _inSummarySource('package:some.code/src/code2.dart');
 
@@ -659,8 +659,8 @@
 
   void test_contains_subPackage() {
     _setUpPackage();
-    newFile('/ws/some/code/testing/BUILD');
-    newFile('/ws/some/code/testing/lib/testing.dart');
+    newFile2('/ws/some/code/testing/BUILD', '');
+    newFile2('/ws/some/code/testing/lib/testing.dart', '');
 
     expect(
       package!.contains(
@@ -701,8 +701,8 @@
   void test_findPackageFor_inBlazeOut_notPackage() {
     var path =
         convertPath('/ws/blaze-out/k8-opt/bin/news/lib/news_base.pb.dart');
-    newFile('/ws/news/BUILD', content: '');
-    newFile(path, content: '');
+    newFile2('/ws/news/BUILD', '');
+    newFile2(path, '');
     workspace = BazelWorkspace.find(resourceProvider, path)!;
 
     var package = workspace.findPackageFor(path);
@@ -718,7 +718,7 @@
       resourceProvider,
       convertPath('/ws/some/code'),
     )!;
-    final targetFile = newFile('/ws/some/code/lib/code.dart');
+    final targetFile = newFile2('/ws/some/code/lib/code.dart', '');
 
     package = workspace.findPackageFor(targetFile.path);
     expect(package, isNull);
@@ -811,7 +811,7 @@
       if (path.endsWith('/')) {
         newFolder(path.substring(0, path.length - 1));
       } else {
-        newFile(path);
+        newFile2(path, '');
       }
     }
   }
@@ -1055,7 +1055,7 @@
 
   void test_find_null_symlinkPrefix() {
     String prefix = BazelWorkspace.defaultSymlinkPrefix;
-    newFile('/workspace/WORKSPACE');
+    newFile2('/workspace/WORKSPACE', '');
     var workspace = BazelWorkspace.find(
         resourceProvider, convertPath('/workspace/my/module'))!;
     expect(workspace.root, convertPath('/workspace'));
@@ -1126,7 +1126,7 @@
       if (path.endsWith('/')) {
         newFolder(path.substring(0, path.length - 1));
       } else {
-        newFile(path);
+        newFile2(path, '');
       }
     }
   }
diff --git a/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart b/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart
index 84faee8..23817f4 100644
--- a/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart
+++ b/pkg/analyzer/test/src/workspace/bazel_watcher_test.dart
@@ -280,7 +280,7 @@
       if (path.endsWith('/')) {
         newFolder(path.substring(0, path.length - 1));
       } else {
-        newFile(path);
+        newFile2(path, '');
       }
     }
   }
diff --git a/pkg/analyzer/test/src/workspace/gn_test.dart b/pkg/analyzer/test/src/workspace/gn_test.dart
index 1672d60..4b041cb 100644
--- a/pkg/analyzer/test/src/workspace/gn_test.dart
+++ b/pkg/analyzer/test/src/workspace/gn_test.dart
@@ -20,8 +20,8 @@
 class GnWorkspacePackageTest with ResourceProviderMixin {
   void test_contains_differentPackageInWorkspace() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    var targetFile = newFile('/ws/some/code/lib/code.dart');
+    newFile2('/ws/some/code/BUILD.gn', '');
+    var targetFile = newFile2('/ws/some/code/lib/code.dart', '');
 
     var package = workspace.findPackageFor(targetFile.path)!;
     // A file that is _not_ in this package is not required to have a BUILD.gn
@@ -34,8 +34,8 @@
 
   void test_contains_differentWorkspace() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    var targetFile = newFile('/ws/some/code/lib/code.dart');
+    newFile2('/ws/some/code/BUILD.gn', '');
+    var targetFile = newFile2('/ws/some/code/lib/code.dart', '');
 
     var package = workspace.findPackageFor(targetFile.path)!;
     expect(package.contains(TestSource(convertPath('/ws2/some/file.dart'))),
@@ -44,12 +44,12 @@
 
   void test_contains_samePackage() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    var targetFile = newFile('/ws/some/code/lib/code.dart');
-    var targetFile2 = newFile('/ws/some/code/lib/code2.dart');
-    var targetFile3 = newFile('/ws/some/code/lib/src/code3.dart');
-    var targetBinFile = newFile('/ws/some/code/bin/code.dart');
-    var targetTestFile = newFile('/ws/some/code/test/code_test.dart');
+    newFile2('/ws/some/code/BUILD.gn', '');
+    var targetFile = newFile2('/ws/some/code/lib/code.dart', '');
+    var targetFile2 = newFile2('/ws/some/code/lib/code2.dart', '');
+    var targetFile3 = newFile2('/ws/some/code/lib/src/code3.dart', '');
+    var targetBinFile = newFile2('/ws/some/code/bin/code.dart', '');
+    var targetTestFile = newFile2('/ws/some/code/test/code_test.dart', '');
 
     var package = workspace.findPackageFor(targetFile.path)!;
     expect(package.contains(TestSource(targetFile2.path)), isTrue);
@@ -60,10 +60,10 @@
 
   void test_contains_subPackage() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    newFile('/ws/some/code/lib/code.dart');
-    newFile('/ws/some/code/testing/BUILD.gn');
-    newFile('/ws/some/code/testing/lib/testing.dart');
+    newFile2('/ws/some/code/BUILD.gn', '');
+    newFile2('/ws/some/code/lib/code.dart', '');
+    newFile2('/ws/some/code/testing/BUILD.gn', '');
+    newFile2('/ws/some/code/testing/lib/testing.dart', '');
 
     var package =
         workspace.findPackageFor(convertPath('/ws/some/code/lib/code.dart'))!;
@@ -75,8 +75,8 @@
 
   void test_findPackageFor_buildFileExists() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    var targetFile = newFile('/ws/some/code/lib/code.dart');
+    newFile2('/ws/some/code/BUILD.gn', '');
+    var targetFile = newFile2('/ws/some/code/lib/code.dart', '');
 
     var package = workspace.findPackageFor(targetFile.path)!;
     expect(package.root, convertPath('/ws/some/code'));
@@ -85,7 +85,7 @@
 
   void test_findPackageFor_missingBuildFile() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/lib/code.dart');
+    newFile2('/ws/some/code/lib/code.dart', '');
 
     var package =
         workspace.findPackageFor(convertPath('/ws/some/code/lib/code.dart'));
@@ -94,8 +94,8 @@
 
   void test_packagesAvailableTo() {
     GnWorkspace workspace = _buildStandardGnWorkspace();
-    newFile('/ws/some/code/BUILD.gn');
-    var libraryPath = newFile('/ws/some/code/lib/code.dart').path;
+    newFile2('/ws/some/code/BUILD.gn', '');
+    var libraryPath = newFile2('/ws/some/code/lib/code.dart', '').path;
     var package = workspace.findPackageFor(libraryPath)!;
     var packageMap = package.packagesAvailableTo(libraryPath);
     expect(packageMap.keys, unorderedEquals(['p1', 'workspace']));
@@ -104,10 +104,10 @@
   GnWorkspace _buildStandardGnWorkspace() {
     newFolder('/ws/.jiri_root');
     String buildDir = convertPath('out/debug-x87_128');
-    newFile('/ws/.fx-build-dir', content: '$buildDir\n');
-    newFile(
+    newFile2('/ws/.fx-build-dir', '$buildDir\n');
+    newFile2(
         '/ws/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -160,9 +160,11 @@
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
     String buildDir = convertPath('out/debug-x87_128');
-    newFile('/workspace/.fx-build-dir', content: '$buildDir\n');
-    newFile(
-        '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json');
+    newFile2('/workspace/.fx-build-dir', '$buildDir\n');
+    newFile2(
+      '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
+      '',
+    );
     var workspace = GnWorkspace.find(
         resourceProvider, convertPath('/workspace/some/code'))!;
     expect(workspace.root, convertPath('/workspace'));
@@ -173,12 +175,12 @@
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
     String buildDir = convertPath('out/debug-x87_128');
-    newFile('/workspace/.fx-build-dir', content: '$buildDir\n');
+    newFile2('/workspace/.fx-build-dir', '$buildDir\n');
     String packageLocation = convertPath('/workspace/this/is/the/package');
     Uri packageUri = resourceProvider.pathContext.toUri(packageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -202,12 +204,12 @@
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
     String buildDir = convertPath('/workspace/out/debug-x87_128');
-    newFile('/workspace/.fx-build-dir', content: '$buildDir\n');
+    newFile2('/workspace/.fx-build-dir', '$buildDir\n');
     String packageLocation = convertPath('/workspace/this/is/the/package');
     Uri packageUri = resourceProvider.pathContext.toUri(packageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -232,9 +234,9 @@
     newPubspecYamlFile('/workspace/some/code', '');
     String packageLocation = convertPath('/workspace/this/is/the/package');
     Uri packageUri = resourceProvider.pathContext.toUri(packageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -257,12 +259,12 @@
     newFolder('/workspace/.jiri_root');
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
-    newFile('/workspace/.fx-build-dir', content: '');
+    newFile2('/workspace/.fx-build-dir', '');
     String packageLocation = convertPath('/workspace/this/is/the/package');
     Uri packageUri = resourceProvider.pathContext.toUri(packageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -286,12 +288,12 @@
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
     String buildDir = convertPath('out/release-y22_256');
-    newFile('/workspace/.fx-build-dir', content: '$buildDir\n');
+    newFile2('/workspace/.fx-build-dir', '$buildDir\n');
     String packageLocation = convertPath('/workspace/this/is/the/package');
     Uri packageUri = resourceProvider.pathContext.toUri(packageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -305,9 +307,9 @@
     String otherPackageLocation = convertPath('/workspace/here/too');
     Uri otherPackageUri =
         resourceProvider.pathContext.toUri(otherPackageLocation);
-    newFile(
+    newFile2(
         '/workspace/out/release-y22_256/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -331,12 +333,12 @@
     newFolder('/workspace/some/code');
     newPubspecYamlFile('/workspace/some/code', '');
     String buildDir = convertPath('out/debug-x87_128');
-    newFile('/workspace/.fx-build-dir', content: '$buildDir\n');
+    newFile2('/workspace/.fx-build-dir', '$buildDir\n');
     String packageOneLocation = convertPath('/workspace/this/is/the/package');
     Uri packageOneUri = resourceProvider.pathContext.toUri(packageOneLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
@@ -350,9 +352,9 @@
     String packageTwoLocation =
         convertPath('/workspace/this/is/the/other/package');
     Uri packageTwoUri = resourceProvider.pathContext.toUri(packageTwoLocation);
-    newFile(
+    newFile2(
         '/workspace/out/debug-x87_128/dartlang/gen/some/code/foo_test_package_config.json',
-        content: '''{
+        '''{
   "configVersion": 2,
   "packages": [
     {
diff --git a/pkg/analyzer/test/src/workspace/package_build_test.dart b/pkg/analyzer/test/src/workspace/package_build_test.dart
index f262445..5300110 100644
--- a/pkg/analyzer/test/src/workspace/package_build_test.dart
+++ b/pkg/analyzer/test/src/workspace/package_build_test.dart
@@ -58,8 +58,8 @@
       convertPath('/workspace'),
     )!;
     resolver = PackageBuildFileUriResolver(workspace);
-    newFile('/workspace/test.dart');
-    newFile('/workspace/.dart_tool/build/generated/project/gen.dart');
+    newFile2('/workspace/test.dart', '');
+    newFile2('/workspace/.dart_tool/build/generated/project/gen.dart', '');
     expect(workspace.isBazel, isFalse);
   }
 
@@ -134,7 +134,7 @@
   Uri addPackageSource(String path, String uriStr, {bool create = true}) {
     Uri uri = Uri.parse(uriStr);
     final file = create
-        ? newFile(path)
+        ? newFile2(path, '')
         : resourceProvider.getResource(convertPath(path)) as File;
     packageUriResolver.add(uri, file);
     return uri;
@@ -199,7 +199,7 @@
       if (path.endsWith('/')) {
         newFolder(path.substring(0, path.length - 1));
       } else {
-        newFile(path);
+        newFile2(path, '');
       }
     }
     workspace = PackageBuildWorkspace.find(
@@ -283,10 +283,10 @@
 
   test_contains_fileUri_generated() {
     var myGeneratedPath = '$myPackageGeneratedPath/my/test/a.dart';
-    newFile(myGeneratedPath, content: '');
+    newFile2(myGeneratedPath, '');
 
     var fooGeneratedPath = '$myPackageGeneratedPath/foo/test/a.dart';
-    newFile(fooGeneratedPath, content: '');
+    newFile2(fooGeneratedPath, '');
 
     expect(
       myPackage.contains(
@@ -401,8 +401,8 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final libFile =
-        newFile('/workspace/.dart_tool/build/generated/project/lib/file.dart');
+    final libFile = newFile2(
+        '/workspace/.dart_tool/build/generated/project/lib/file.dart', '');
     expect(
         workspace.builtFile(convertPath('lib/file.dart'), 'project'), libFile);
   }
@@ -414,7 +414,7 @@
         _createWorkspace('/workspace', ['project', 'foo']);
 
     final libFile =
-        newFile('/workspace/.dart_tool/build/generated/foo/lib/file.dart');
+        newFile2('/workspace/.dart_tool/build/generated/foo/lib/file.dart', '');
     expect(workspace.builtFile(convertPath('lib/file.dart'), 'foo'), libFile);
   }
 
@@ -427,7 +427,7 @@
         _createWorkspace('/workspace', ['project', 'foo']);
 
     // Create a generated file in package:bar.
-    newFile('/workspace/.dart_tool/build/generated/bar/lib/file.dart');
+    newFile2('/workspace/.dart_tool/build/generated/bar/lib/file.dart', '');
 
     // Bar not in packages, file should not be returned.
     expect(workspace.builtFile('lib/file.dart', 'bar'), isNull);
@@ -576,7 +576,7 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final binFile = newFile('/workspace/bin/file.dart');
+    final binFile = newFile2('/workspace/bin/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/bin/file.dart')), binFile);
   }
@@ -587,8 +587,8 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final binFile =
-        newFile('/workspace/.dart_tool/build/generated/project/bin/file.dart');
+    final binFile = newFile2(
+        '/workspace/.dart_tool/build/generated/project/bin/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/bin/file.dart')), binFile);
   }
@@ -599,8 +599,8 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final libFile =
-        newFile('/workspace/.dart_tool/build/generated/project/lib/file.dart');
+    final libFile = newFile2(
+        '/workspace/.dart_tool/build/generated/project/lib/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/lib/file.dart')), libFile);
   }
@@ -611,7 +611,7 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final testFile = newFile('/workspace/test/file.dart');
+    final testFile = newFile2('/workspace/test/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/test/file.dart')), testFile);
   }
@@ -622,8 +622,8 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final testFile =
-        newFile('/workspace/.dart_tool/build/generated/project/test/file.dart');
+    final testFile = newFile2(
+        '/workspace/.dart_tool/build/generated/project/test/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/test/file.dart')), testFile);
   }
@@ -634,7 +634,7 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final webFile = newFile('/workspace/web/file.dart');
+    final webFile = newFile2('/workspace/web/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/web/file.dart')), webFile);
   }
@@ -645,8 +645,8 @@
     PackageBuildWorkspace workspace =
         _createWorkspace('/workspace', ['project']);
 
-    final webFile =
-        newFile('/workspace/.dart_tool/build/generated/project/web/file.dart');
+    final webFile = newFile2(
+        '/workspace/.dart_tool/build/generated/project/web/file.dart', '');
     expect(
         workspace.findFile(convertPath('/workspace/web/file.dart')), webFile);
   }
diff --git a/pkg/analyzer/test/src/workspace/pub_test.dart b/pkg/analyzer/test/src/workspace/pub_test.dart
index 5f68d58..b9ccd89 100644
--- a/pkg/analyzer/test/src/workspace/pub_test.dart
+++ b/pkg/analyzer/test/src/workspace/pub_test.dart
@@ -32,7 +32,7 @@
   }
 
   void test_contains_differentWorkspace() {
-    newFile('/workspace2/project/lib/file.dart');
+    newFile2('/workspace2/project/lib/file.dart', '');
 
     var package = findPackage('/workspace/project/lib/code.dart')!;
     expect(
@@ -42,7 +42,7 @@
   }
 
   void test_contains_sameWorkspace() {
-    newFile('/workspace/project/lib/file2.dart');
+    newFile2('/workspace/project/lib/file2.dart', '');
 
     var package = findPackage('/workspace/project/lib/code.dart')!;
     expect(
@@ -60,7 +60,7 @@
   }
 
   void test_findPackageFor_includedFile() {
-    newFile('/workspace/project/lib/file.dart');
+    newFile2('/workspace/project/lib/file.dart', '');
 
     var package = findPackage('/workspace/project/lib/file.dart')!;
     expect(package.root, convertPath('/workspace'));
@@ -68,7 +68,7 @@
   }
 
   void test_findPackageFor_unrelatedFile() {
-    newFile('/workspace/project/lib/file.dart');
+    newFile2('/workspace/project/lib/file.dart', '');
 
     var package = findPackage('/workspace2/project/lib/file.dart');
     expect(package, isNull);
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index e56d8b6..f72877b 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -443,14 +443,14 @@
         packageConfigBuilder.add(name: packageName, rootPath: packageRootPath);
 
         String pathInLib = uri.pathSegments.skip(1).join('/');
-        newFile(
+        newFile2(
           '$packageRootPath/lib/$pathInLib',
-          content: auxiliaryFiles[uriStr]!,
+          auxiliaryFiles[uriStr]!,
         );
       } else {
-        newFile(
+        newFile2(
           '$testPackageRootPath/$uriStr',
-          content: auxiliaryFiles[uriStr]!,
+          auxiliaryFiles[uriStr]!,
         );
       }
     }
diff --git a/pkg/analyzer_plugin/test/plugin/assist_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/assist_mixin_test.dart
index 4a5899e..924e293 100644
--- a/pkg/analyzer_plugin/test/plugin/assist_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/assist_mixin_test.dart
@@ -30,7 +30,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/completion_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/completion_mixin_test.dart
index 35ecf19..73d620a 100644
--- a/pkg/analyzer_plugin/test/plugin/completion_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/completion_mixin_test.dart
@@ -30,7 +30,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1, content: 'int foo = bar;');
+    newFile2(filePath1, 'int foo = bar;');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/fix_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/fix_mixin_test.dart
index edb6601..192d701 100644
--- a/pkg/analyzer_plugin/test/plugin/fix_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/fix_mixin_test.dart
@@ -34,7 +34,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/folding_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/folding_mixin_test.dart
index ef7d1cd0..795ec0f 100644
--- a/pkg/analyzer_plugin/test/plugin/folding_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/folding_mixin_test.dart
@@ -33,7 +33,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/highlights_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/highlights_mixin_test.dart
index bbf3d1a..45a1964 100644
--- a/pkg/analyzer_plugin/test/plugin/highlights_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/highlights_mixin_test.dart
@@ -33,7 +33,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/kythe_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/kythe_mixin_test.dart
index c1df465..743cf17 100644
--- a/pkg/analyzer_plugin/test/plugin/kythe_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/kythe_mixin_test.dart
@@ -30,7 +30,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/navigation_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/navigation_mixin_test.dart
index 3c29dfb..9934550 100644
--- a/pkg/analyzer_plugin/test/plugin/navigation_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/navigation_mixin_test.dart
@@ -33,7 +33,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/occurrences_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/occurrences_mixin_test.dart
index 319e1bd..88f4153 100644
--- a/pkg/analyzer_plugin/test/plugin/occurrences_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/occurrences_mixin_test.dart
@@ -33,7 +33,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/outline_mixin_test.dart b/pkg/analyzer_plugin/test/plugin/outline_mixin_test.dart
index 5844fde..5d2933c 100644
--- a/pkg/analyzer_plugin/test/plugin/outline_mixin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/outline_mixin_test.dart
@@ -33,7 +33,7 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/plugin/plugin_test.dart b/pkg/analyzer_plugin/test/plugin/plugin_test.dart
index 18d77ba..edbddc7 100644
--- a/pkg/analyzer_plugin/test/plugin/plugin_test.dart
+++ b/pkg/analyzer_plugin/test/plugin/plugin_test.dart
@@ -33,12 +33,12 @@
   void setUp() {
     packagePath1 = convertPath('/package1');
     filePath1 = join(packagePath1, 'lib', 'test.dart');
-    newFile(filePath1);
+    newFile2(filePath1, '');
     contextRoot1 = ContextRoot(packagePath1, <String>[]);
 
     packagePath2 = convertPath('/package2');
     filePath2 = join(packagePath2, 'lib', 'test.dart');
-    newFile(filePath2);
+    newFile2(filePath2, '');
     contextRoot2 = ContextRoot(packagePath2, <String>[]);
 
     channel = MockChannel();
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
index 7ff8493..b52e463 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart
@@ -1866,7 +1866,7 @@
 }
 ''';
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: initialCode);
+    newFile2(path, initialCode);
 
     var builder = await newBuilder();
     await builder.addDartFileEdit(path, (builder) {
@@ -1918,7 +1918,7 @@
 }
 ''';
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: initialCode);
+    newFile2(path, initialCode);
 
     var builder = await newBuilder();
     await builder.addDartFileEdit(path, (builder) {
@@ -1947,7 +1947,7 @@
   Future<void> test_multipleEdits_concurrently() async {
     var initialCode = '00';
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: initialCode);
+    newFile2(path, initialCode);
 
     var builder = await newBuilder();
     var future = Future.wait([
@@ -1965,7 +1965,7 @@
   Future<void> test_multipleEdits_sequentially() async {
     var initialCode = '00';
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: initialCode);
+    newFile2(path, initialCode);
 
     var builder = await newBuilder();
     await builder.addDartFileEdit(path, (builder) {
diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
index 80fcd16..351257e 100644
--- a/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/dart/import_library_element_test.dart
@@ -44,7 +44,7 @@
   }
 
   Future<void> test_withoutPrefix() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
+    newFile2('/home/test/lib/a.dart', 'class A {}');
 
     await _assertImportLibraryElement(
       initialCode: r'''
@@ -56,8 +56,8 @@
   }
 
   Future<void> test_withoutPrefix_exported() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', 'class A {}');
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 ''');
     await _assertImportLibraryElement(
@@ -70,7 +70,7 @@
   }
 
   Future<void> test_withoutPrefix_hasInvalidImport() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
+    newFile2('/home/test/lib/a.dart', 'class A {}');
 
     await _assertImportLibraryElement(
       initialCode: r'''
@@ -83,10 +83,10 @@
   }
 
   Future<void> test_withoutPrefix_referencedNames_sameElements() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 
 class B {}
@@ -104,8 +104,8 @@
   }
 
   Future<void> test_withoutPrefix_twoImports_sameElement() async {
-    newFile('/home/test/lib/a.dart', content: 'class C {}');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', 'class C {}');
+    newFile2('/home/test/lib/b.dart', r'''
 export 'package:test/a.dart';
 ''');
 
@@ -129,7 +129,7 @@
   }
 
   Future<void> test_withPrefix() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
+    newFile2('/home/test/lib/a.dart', 'class A {}');
 
     await _assertImportLibraryElement(
       initialCode: r'''
@@ -142,8 +142,8 @@
   }
 
   Future<void> test_withPrefix_twoImports_sameElement() async {
-    newFile('/home/test/lib/a.dart', content: 'class C {}');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', 'class C {}');
+    newFile2('/home/test/lib/b.dart', r'''
 export 'package:test/a.dart';
 ''');
 
@@ -172,10 +172,10 @@
 @reflectiveTest
 class ImportLibraryElement_newImport_withoutPrefix_Test extends _Base {
   Future<void> test_constructorName_name() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 int foo;
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 class B {
   B.foo();
 }
@@ -202,8 +202,8 @@
   }
 
   Future<void> test_exported() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', 'class A {}');
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 ''');
     await _assertImportLibraryElement(
@@ -217,8 +217,8 @@
   }
 
   Future<void> test_exported_differentUri() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', 'class A {}');
+    newFile2('/home/test/lib/b.dart', r'''
 export 'a.dart';
 ''');
     await _assertImportLibraryElement(
@@ -235,10 +235,10 @@
   }
 
   Future<void> test_methodInvocation_name() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 int foo;
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 class B {
   static void foo() {}
 }
@@ -265,11 +265,11 @@
   }
 
   Future<void> test_noConflict_otherImport_hide() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 ''');
-    newFile('/home/test/lib/b.dart', content: 'class B {}');
+    newFile2('/home/test/lib/b.dart', 'class B {}');
     await _assertImportLibraryElement(
       initialCode: r'''
 import 'package:test/a.dart' hide B;
@@ -284,11 +284,11 @@
   }
 
   Future<void> test_noConflict_otherImport_show() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 class B {}
 ''');
-    newFile('/home/test/lib/b.dart', content: 'class B {}');
+    newFile2('/home/test/lib/b.dart', 'class B {}');
     await _assertImportLibraryElement(
       initialCode: r'''
 import 'package:test/a.dart' show A;
@@ -303,7 +303,7 @@
   }
 
   Future<void> test_noShadow_syntacticScope_localVariable() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 var foo = 0;
 ''');
     await _assertImportLibraryElement(
@@ -335,7 +335,7 @@
   }
 
   Future<void> test_noShadow_syntacticScope_typeParameter() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 class A {}
 ''');
     await _assertImportLibraryElement(
@@ -357,10 +357,10 @@
   }
 
   Future<void> test_prefixedIdentifier_identifier() async {
-    newFile('/home/test/lib/a.dart', content: r'''
+    newFile2('/home/test/lib/a.dart', r'''
 int foo;
 ''');
-    newFile('/home/test/lib/b.dart', content: r'''
+    newFile2('/home/test/lib/b.dart', r'''
 class B {
   static int foo;
 }
@@ -387,7 +387,7 @@
   }
 
   Future<void> test_thisName_notShadowed_localVariable_otherFunction() async {
-    newFile('/home/test/lib/a.dart', content: 'int foo = 0;');
+    newFile2('/home/test/lib/a.dart', 'int foo = 0;');
     await _assertImportLibraryElement(
       initialCode: r'''
 void f() {
@@ -415,8 +415,8 @@
   }
 
   Future<void> test_unrelated() async {
-    newFile('/home/test/lib/a.dart', content: 'class A {}');
-    newFile('/home/test/lib/b.dart', content: 'class B {}');
+    newFile2('/home/test/lib/a.dart', 'class A {}');
+    newFile2('/home/test/lib/b.dart', 'class B {}');
     await _assertImportLibraryElement(
       initialCode: r'''
 import 'package:test/a.dart';
@@ -466,7 +466,7 @@
     }
 
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: initialCode);
+    newFile2(path, initialCode);
 
     var requestedResult =
         await (await session).getLibraryByUri(uriStr) as LibraryElementResult;
diff --git a/pkg/analyzer_plugin/test/src/utilities/completion/completion_target_test.dart b/pkg/analyzer_plugin/test/src/utilities/completion/completion_target_test.dart
index 742f070..62e8adf 100644
--- a/pkg/analyzer_plugin/test/src/utilities/completion/completion_target_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/completion/completion_target_test.dart
@@ -951,7 +951,7 @@
     content = content.substring(0, offset) + content.substring(offset! + 1);
 
     var path = convertPath('/home/test/lib/test.dart');
-    newFile(path, content: content);
+    newFile2(path, content);
 
     var result = await resolveFile(path);
     findElement = FindElement(result.unit);
diff --git a/pkg/analyzer_plugin/test/support/abstract_context.dart b/pkg/analyzer_plugin/test/support/abstract_context.dart
index 9a8066b..9dffef5 100644
--- a/pkg/analyzer_plugin/test/support/abstract_context.dart
+++ b/pkg/analyzer_plugin/test/support/abstract_context.dart
@@ -63,7 +63,7 @@
   String get workspaceRootPath => convertPath('/home');
 
   void addSource(String path, String content) {
-    newFile(path, content: content);
+    newFile2(path, content);
   }
 
   AnalysisContext contextFor(String path) {
@@ -85,16 +85,16 @@
       }
     }
 
-    newFile(testPackageAnalysisOptionsPath, content: buffer.toString());
+    newFile2(testPackageAnalysisOptionsPath, buffer.toString());
   }
 
   @override
-  File newFile(String path, {String content = ''}) {
+  File newFile2(String path, String content) {
     if (_analysisContextCollection != null && !path.endsWith('.dart')) {
       throw StateError('Only dart files can be changed after analysis.');
     }
 
-    return super.newFile(path, content: content);
+    return super.newFile2(path, content);
   }
 
   Future<ResolvedUnitResult> resolveFile(String path) async {
@@ -123,7 +123,7 @@
   }
 
   void writePackageConfig(String path, PackageConfigFileBuilder config) {
-    newFile(path, content: config.toContent(toUriStr: toUriStr));
+    newFile2(path, config.toContent(toUriStr: toUriStr));
   }
 
   void writeTestPackageConfig({
diff --git a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
index ab3e77a..b1e4ddf 100644
--- a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
@@ -653,7 +653,7 @@
   @override
   void setUp() {
     super.setUp();
-    source = newFile('/foo/bar.dart').createSource();
+    source = newFile2('/foo/bar.dart', '').createSource();
     testFile = convertPath('$testPackageRootPath/lib/test.dart');
   }
 }
diff --git a/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart b/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
index 327ebfe..2af7bb7 100644
--- a/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
@@ -1084,8 +1084,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    newFile('$workspaceRootPath/myBar/bar.dart',
-        content: 'class Foo2 { Foo2() { } }');
+    newFile2('$workspaceRootPath/myBar/bar.dart', 'class Foo2 { Foo2() { } }');
     addSource(
         '/proj/testAB.dart', 'import "package:myBar/bar.dart"; class Foo { }');
     addTestSource('class C {foo(){F^}}');
diff --git a/pkg/compiler/lib/src/inferrer/builder_kernel.dart b/pkg/compiler/lib/src/inferrer/builder_kernel.dart
index 937f1c0..aa490af 100644
--- a/pkg/compiler/lib/src/inferrer/builder_kernel.dart
+++ b/pkg/compiler/lib/src/inferrer/builder_kernel.dart
@@ -1977,7 +1977,33 @@
     _state.markInitializationAsIndefinite();
     visit(node.body);
     LocalState stateAfterBody = _state;
-    _state = stateBefore.mergeFlow(_inferrer, stateAfterBody);
+    // If the try block contains a throw, then `stateAfterBody.aborts` will be
+    // true. The catch needs to be aware of the results of inference from the
+    // try block since we may get there via the abortive control flow:
+    //
+    // dynamic x = "bad";
+    // try {
+    //   ...
+    //   x = 0;
+    //   throw ...;
+    // } catch (_) {
+    //   print(x + 42); <-- x may be 0 here.
+    // }
+    //
+    // Note that this will also cause us to ignore aborts due to breaks,
+    // returns, and continues. Since these control flow constructs will not jump
+    // to a catch block, this may cause some types flowing into the catch block
+    // to be wider than necessary:
+    //
+    // dynamic x = "bad";
+    // try {
+    //   x = 0;
+    //   return;
+    // } catch (_) {
+    //   print(x + 42); <-- x cannot be 0 here.
+    // }
+    _state =
+        stateBefore.mergeFlow(_inferrer, stateAfterBody, ignoreAborts: true);
     for (ir.Catch catchBlock in node.catches) {
       LocalState stateBeforeCatch = _state;
       _state = LocalState.childPath(stateBeforeCatch);
@@ -1995,7 +2021,20 @@
     _state.markInitializationAsIndefinite();
     visit(node.body);
     LocalState stateAfterBody = _state;
-    _state = stateBefore.mergeFlow(_inferrer, stateAfterBody);
+    // Even if the try block contains abortive control flow, the finally block
+    // needs to be aware of the results of inference from the try block since we
+    // still reach the finally after abortive control flow:
+    //
+    // dynamic x = "bad";
+    // try {
+    //   ...
+    //   x = 0;
+    //   return;
+    // } finally {
+    //   print(x + 42); <-- x may be 0 here.
+    // }
+    _state =
+        stateBefore.mergeFlow(_inferrer, stateAfterBody, ignoreAborts: true);
     visit(node.finalizer);
     return null;
   }
@@ -2387,11 +2426,12 @@
     }
   }
 
-  LocalState mergeFlow(InferrerEngine inferrer, LocalState other) {
+  LocalState mergeFlow(InferrerEngine inferrer, LocalState other,
+      {bool ignoreAborts: false}) {
     seenReturnOrThrow = false;
     seenBreakOrContinue = false;
 
-    if (other.aborts) {
+    if (!ignoreAborts && other.aborts) {
       return this;
     }
     LocalsHandler locals = _locals.mergeFlow(inferrer, other._locals);
diff --git a/pkg/compiler/lib/src/inferrer/locals_handler.dart b/pkg/compiler/lib/src/inferrer/locals_handler.dart
index ed565ca..06fb529 100644
--- a/pkg/compiler/lib/src/inferrer/locals_handler.dart
+++ b/pkg/compiler/lib/src/inferrer/locals_handler.dart
@@ -221,7 +221,7 @@
     assert(elseScope != null);
 
     // Quick bailout check. If [isThisExposed] or [isIndefinite] is true, we
-    // know the code following won'TypeInformation do anything.
+    // know the code following won't do anything.
     if (isThisExposed) return this;
     if (isIndefinite) return this;
 
diff --git a/pkg/dartdev/lib/src/commands/run.dart b/pkg/dartdev/lib/src/commands/run.dart
index 94b0141..39e5ea4 100644
--- a/pkg/dartdev/lib/src/commands/run.dart
+++ b/pkg/dartdev/lib/src/commands/run.dart
@@ -222,6 +222,8 @@
       final bool debugDds = args['debug-dds'];
 
       bool disableServiceAuthCodes = args['disable-service-auth-codes'];
+      final bool enableServicePortFallback =
+          args['enable-service-port-fallback'];
 
       // If the user wants to start a debugging session we need to do some extra
       // work and spawn a Dart Development Service (DDS) instance. DDS is a VM
@@ -237,6 +239,7 @@
           disableServiceAuthCodes,
           launchDevTools,
           debugDds,
+          enableServicePortFallback,
         )) {
           return errorExitCode;
         }
@@ -274,6 +277,7 @@
     bool disableServiceAuthCodes,
     bool enableDevTools,
     bool debugDds,
+    bool enableServicePortFallback,
   ) async {
     final sdkDir = dirname(sdk.dart);
     final fullSdk = sdkDir.endsWith('bin');
@@ -303,6 +307,7 @@
         enableDevTools.toString(),
         devToolsBinaries,
         debugDds.toString(),
+        enableServicePortFallback.toString(),
       ],
       mode: ProcessStartMode.detachedWithStdio,
     );
diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart
index 40978d9..bf0f031 100644
--- a/pkg/dartdev/test/commands/run_test.dart
+++ b/pkg/dartdev/test/commands/run_test.dart
@@ -333,6 +333,25 @@
     expect(result.exitCode, 0);
   });
 
+  test('--enable-service-port-fallback', () async {
+    final p = project(mainSrc: '''void main() {}''');
+    final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
+    final result = await p.run(
+      [
+        'run',
+        '--enable-vm-service=${server.port}',
+        '--enable-service-port-fallback',
+        p.relativeFilePath,
+      ],
+    );
+    final regexp = RegExp(
+        r'Observatory listening on http:\/\/127.0.0.1:(\d*)\/[a-zA-Z0-9_-]+=\/\n.*');
+    final vmServicePort =
+        int.parse(regexp.firstMatch(result.stdout)!.group(1)!);
+    expect(server.port != vmServicePort, isTrue);
+    await server.close();
+  });
+
   test('without verbose CFE info', () async {
     final p = project(mainSrc: '''void main() {}''');
 
diff --git a/pkg/dds/bin/dds.dart b/pkg/dds/bin/dds.dart
index 2ae2f5a..7e43c19 100644
--- a/pkg/dds/bin/dds.dart
+++ b/pkg/dds/bin/dds.dart
@@ -18,6 +18,7 @@
 ///   - Start DevTools
 ///   - DevTools build directory
 ///   - Enable logging
+///   - Enable service port fallback
 Future<void> main(List<String> args) async {
   if (args.isEmpty) return;
 
@@ -46,6 +47,7 @@
     devToolsBuildDirectory = Uri.file(args[5]);
   }
   final logRequests = args[6] == 'true';
+  final enableServicePortFallback = args[7] == 'true';
   try {
     // TODO(bkonyi): add retry logic similar to that in vmservice_server.dart
     // See https://github.com/dart-lang/sdk/issues/43192.
@@ -61,6 +63,7 @@
             )
           : null,
       logRequests: logRequests,
+      enableServicePortFallback: enableServicePortFallback,
     );
     stderr.write(json.encode({
       'state': 'started',
diff --git a/pkg/dds/lib/dds.dart b/pkg/dds/lib/dds.dart
index 4d8a5e7..7d833ab 100644
--- a/pkg/dds/lib/dds.dart
+++ b/pkg/dds/lib/dds.dart
@@ -37,11 +37,15 @@
   ///
   /// [ipv6] controls whether or not DDS is served via IPv6. IPv4 is enabled by
   /// default.
+  ///
+  /// If [enablesServicePortFallback] is enabled, DDS will attempt to bind to any
+  /// available port if the specified port is unavailable.
   static Future<DartDevelopmentService> startDartDevelopmentService(
     Uri remoteVmServiceUri, {
     Uri? serviceUri,
     bool enableAuthCodes = true,
     bool ipv6 = false,
+    bool enableServicePortFallback = false,
     List<String> cachedUserTags = const [],
     DevToolsConfiguration? devToolsConfiguration,
     bool logRequests = false,
@@ -84,6 +88,7 @@
       ipv6,
       devToolsConfiguration,
       logRequests,
+      enableServicePortFallback,
     );
     await service.startService();
     return service;
diff --git a/pkg/dds/lib/src/dds_impl.dart b/pkg/dds/lib/src/dds_impl.dart
index 000a15b..8de53ff 100644
--- a/pkg/dds/lib/src/dds_impl.dart
+++ b/pkg/dds/lib/src/dds_impl.dart
@@ -59,6 +59,7 @@
     this._ipv6,
     this._devToolsConfiguration,
     this.shouldLogRequests,
+    this._enableServicePortFallback,
   ) {
     _clientManager = ClientManager(this);
     _expressionEvaluator = ExpressionEvaluator(this);
@@ -136,7 +137,7 @@
     final host = uri?.host ??
         (_ipv6 ? InternetAddress.loopbackIPv6 : InternetAddress.loopbackIPv4)
             .host;
-    final port = uri?.port ?? 0;
+    var port = uri?.port ?? 0;
     var pipeline = const Pipeline();
     if (shouldLogRequests) {
       pipeline = pipeline.addMiddleware(
@@ -155,16 +156,25 @@
     late String errorMessage;
     final tmpServer = await runZonedGuarded(
       () async {
-        try {
-          return await io.serve(handler, host, port);
-        } on SocketException catch (e) {
-          errorMessage = e.message;
-          if (e.osError != null) {
-            errorMessage += ' (${e.osError!.message})';
+        Future<HttpServer?> startServer() async {
+          try {
+            return await io.serve(handler, host, port);
+          } on SocketException catch (e) {
+            if (_enableServicePortFallback && port != 0) {
+              // Try again, this time with a random port.
+              port = 0;
+              return await startServer();
+            }
+            errorMessage = e.message;
+            if (e.osError != null) {
+              errorMessage += ' (${e.osError!.message})';
+            }
+            errorMessage += ': ${e.address?.host}:${e.port}';
+            return null;
           }
-          errorMessage += ': ${e.address?.host}:${e.port}';
-          return null;
         }
+
+        return await startServer();
       },
       (error, stack) {
         if (shouldLogRequests) {
@@ -387,6 +397,7 @@
   String? get authCode => _authCode;
   String? _authCode;
 
+  final bool _enableServicePortFallback;
   final bool shouldLogRequests;
 
   Uri get remoteVmServiceUri => _remoteVmServiceUri;
diff --git a/pkg/dds/test/devtools_server/devtools_server_connection_test.dart b/pkg/dds/test/devtools_server/devtools_server_connection_test.dart
new file mode 100644
index 0000000..5bb42a8
--- /dev/null
+++ b/pkg/dds/test/devtools_server/devtools_server_connection_test.dart
@@ -0,0 +1,103 @@
+// Copyright 2022 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:devtools_shared/devtools_test_utils.dart';
+import 'package:test/test.dart';
+
+import 'devtools_server_driver.dart';
+
+// Note: this test is broken out from devtools_server_test.dart so that the
+// tests run faster and we do not have to mark them as slow.
+
+late final DevToolsServerTestController testController;
+
+void main() {
+  testController = DevToolsServerTestController();
+
+  setUp(() async {
+    await testController.setUp();
+  });
+
+  tearDown(() async {
+    await testController.tearDown();
+  });
+
+  for (final bool useVmService in [true, false]) {
+    group('Server (${useVmService ? 'VM Service' : 'API'})', () {
+      test(
+          'DevTools connects back to server API and registers that it is connected',
+          () async {
+        // Register the VM.
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
+
+        // Send a request to launch DevTools in a browser.
+        await testController.sendLaunchDevToolsRequest(
+          useVmService: useVmService,
+        );
+
+        final serverResponse =
+            await testController.waitForClients(requiredConnectionState: true);
+        expect(serverResponse, isNotNull);
+        expect(serverResponse['clients'], hasLength(1));
+        expect(serverResponse['clients'][0]['hasConnection'], isTrue);
+        expect(
+          serverResponse['clients'][0]['vmServiceUri'],
+          testController.appFixture.serviceUri.toString(),
+        );
+      }, timeout: const Timeout.factor(10));
+
+      test('DevTools reports disconnects from a VM', () async {
+        // Register the VM.
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
+
+        // Send a request to launch DevTools in a browser.
+        await testController.sendLaunchDevToolsRequest(
+          useVmService: useVmService,
+        );
+
+        // Wait for the DevTools to inform server that it's connected.
+        await testController.waitForClients(requiredConnectionState: true);
+
+        // Terminate the VM.
+        await testController.appFixture.teardown();
+
+        // Ensure the client is marked as disconnected.
+        final serverResponse = await testController.waitForClients(
+          requiredConnectionState: false,
+        );
+        expect(serverResponse['clients'], hasLength(1));
+        expect(serverResponse['clients'][0]['hasConnection'], isFalse);
+        expect(serverResponse['clients'][0]['vmServiceUri'], isNull);
+      }, timeout: const Timeout.factor(20));
+
+      test('server removes clients that disconnect from the API', () async {
+        final event = await testController.serverStartedEvent.future;
+
+        // Spawn our own Chrome process so we can terminate it.
+        final devToolsUri =
+            'http://${event['params']['host']}:${event['params']['port']}';
+        final chrome = await Chrome.locate()!.start(url: devToolsUri);
+
+        // Wait for DevTools to inform server that it's connected.
+        await testController.waitForClients();
+
+        // Close the browser, which will disconnect DevTools SSE connection
+        // back to the server.
+        chrome.kill();
+
+        // Await a long delay to wait for the SSE client to close.
+        await delay(duration: const Duration(seconds: 15));
+
+        // Ensure the client is completely removed from the list.
+        await testController.waitForClients(expectNone: true);
+      }, timeout: const Timeout.factor(20));
+    });
+  }
+}
diff --git a/pkg/dds/test/devtools_server/devtools_server_driver.dart b/pkg/dds/test/devtools_server/devtools_server_driver.dart
index 99e9191..3a287ca 100644
--- a/pkg/dds/test/devtools_server/devtools_server_driver.dart
+++ b/pkg/dds/test/devtools_server/devtools_server_driver.dart
@@ -6,7 +6,9 @@
 import 'dart:convert';
 import 'dart:io';
 
+import 'package:dds/devtools_server.dart';
 import 'package:devtools_shared/devtools_test_utils.dart';
+import 'package:vm_service/vm_service.dart';
 
 const verbose = true;
 
@@ -91,3 +93,187 @@
     );
   }
 }
+
+class DevToolsServerTestController {
+  static const defaultDelay = Duration(milliseconds: 500);
+
+  late CliAppFixture appFixture;
+
+  late DevToolsServerDriver server;
+
+  final completers = <String, Completer<Map<String, dynamic>>>{};
+
+  /// A broadcast stream controller for streaming events from the server.
+  late StreamController<Map<String, dynamic>> eventController;
+
+  /// A broadcast stream of events from the server.
+  ///
+  /// Listening for "server.started" events on this stream may be unreliable
+  /// because it may have occurred before the test starts. Use the
+  /// [serverStartedEvent] instead.
+  Stream<Map<String, dynamic>> get events => eventController.stream;
+
+  /// Completer that signals when the server started event has been received.
+  late Completer<Map<String, dynamic>> serverStartedEvent;
+
+  final Map<String, String> registeredServices = {};
+
+  /// A list of PIDs for Chrome instances spawned by tests that should be
+  /// cleaned up.
+  final List<int> browserPids = [];
+
+  late StreamSubscription<String> stderrSub;
+
+  late StreamSubscription<Map<String, dynamic>?> stdoutSub;
+
+  Future<void> setUp() async {
+    serverStartedEvent = Completer<Map<String, dynamic>>();
+    eventController = StreamController<Map<String, dynamic>>.broadcast();
+
+    // Start the command-line server.
+    server = await DevToolsServerDriver.create();
+
+    // Fail tests on any stderr.
+    stderrSub = server.stderr.listen((text) => throw 'STDERR: $text');
+    stdoutSub = server.stdout.listen((map) {
+      if (map!.containsKey('id')) {
+        if (map.containsKey('result')) {
+          completers[map['id']]!.complete(map['result']);
+        } else {
+          completers[map['id']]!.completeError(map['error']);
+        }
+      } else if (map.containsKey('event')) {
+        if (map['event'] == 'server.started') {
+          serverStartedEvent.complete(map);
+        }
+        eventController.add(map);
+      }
+    });
+
+    await serverStartedEvent.future;
+    await startApp();
+  }
+
+  Future<void> tearDown() async {
+    browserPids
+      ..forEach((pid) => Process.killPid(pid, ProcessSignal.sigkill))
+      ..clear();
+    await stdoutSub.cancel();
+    await stderrSub.cancel();
+    server.kill();
+    await appFixture.teardown();
+  }
+
+  Future<Map<String, dynamic>> sendLaunchDevToolsRequest({
+    required bool useVmService,
+    String? page,
+    bool notify = false,
+    bool reuseWindows = false,
+  }) async {
+    final launchEvent =
+        events.where((e) => e['event'] == 'client.launch').first;
+    if (useVmService) {
+      await appFixture.serviceConnection.callMethod(
+        registeredServices[DevToolsServer.launchDevToolsService]!,
+        args: {
+          'reuseWindows': reuseWindows,
+          'page': page,
+          'notify': notify,
+        },
+      );
+    } else {
+      await send(
+        'devTools.launch',
+        {
+          'vmServiceUri': appFixture.serviceUri.toString(),
+          'reuseWindows': reuseWindows,
+          'page': page,
+        },
+      );
+    }
+    final response = await launchEvent;
+    final pid = response['params']['pid'];
+    if (pid != null) {
+      browserPids.add(pid);
+    }
+    return response['params'];
+  }
+
+  Future<void> startApp() async {
+    final appUri = Platform.script
+        .resolveUri(Uri.parse('../fixtures/empty_dart_app.dart'));
+    appFixture = await CliAppFixture.create(appUri.path);
+
+    // Track services method names as they're registered.
+    appFixture.serviceConnection
+        .onEvent(EventStreams.kService)
+        .where((e) => e.kind == EventKind.kServiceRegistered)
+        .listen((e) => registeredServices[e.service!] = e.method!);
+    await appFixture.serviceConnection.streamListen(EventStreams.kService);
+  }
+
+  int nextId = 0;
+  Future<Map<String, dynamic>> send(
+    String method, [
+    Map<String, dynamic>? params,
+  ]) {
+    final id = (nextId++).toString();
+    completers[id] = Completer<Map<String, dynamic>>();
+    server.write({'id': id.toString(), 'method': method, 'params': params});
+    return completers[id]!.future;
+  }
+
+  /// Waits for the server's client list to be updated with the expected state,
+  /// and then returns the client list.
+  ///
+  /// It may take time for the servers client list to be updated as the web app
+  /// connects, so this helper just polls and waits for the expected state. If
+  /// the expected state is never found, the test will timeout.
+  Future<Map<String, dynamic>> waitForClients({
+    bool? requiredConnectionState,
+    String? requiredPage,
+    bool expectNone = false,
+    bool useLongTimeout = false,
+    Duration delayDuration = defaultDelay,
+  }) async {
+    late Map<String, dynamic> serverResponse;
+
+    final isOnPage = (client) => client['currentPage'] == requiredPage;
+    final hasConnectionState = (client) => requiredConnectionState ?? false
+        // If we require a connected client, also require a non-null page. This
+        // avoids a race in tests where we may proceed to send messages to a client
+        // that is not fully initialised.
+        ? (client['hasConnection'] && client['currentPage'] != null)
+        : !client['hasConnection'];
+
+    await _waitFor(
+      () async {
+        // Await a short delay to give the client time to connect.
+        await delay();
+
+        serverResponse = await send('client.list');
+        final clients = serverResponse['clients'];
+        return clients is List &&
+            (clients.isEmpty == expectNone) &&
+            (requiredPage == null || clients.any(isOnPage)) &&
+            (requiredConnectionState == null ||
+                clients.any(hasConnectionState));
+      },
+      delayDuration: delayDuration,
+    );
+
+    return serverResponse;
+  }
+
+  Future<void> _waitFor(
+    Future<bool> condition(), {
+    Duration delayDuration = defaultDelay,
+  }) async {
+    while (true) {
+      if (await condition()) {
+        return;
+      }
+      await delay(duration: delayDuration);
+    }
+  }
+}
diff --git a/pkg/dds/test/devtools_server/devtools_server_test.dart b/pkg/dds/test/devtools_server/devtools_server_test.dart
index 2f34765..2a0ce68 100644
--- a/pkg/dds/test/devtools_server/devtools_server_test.dart
+++ b/pkg/dds/test/devtools_server/devtools_server_test.dart
@@ -2,7 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-import 'dart:async';
 import 'dart:convert';
 import 'dart:io';
 
@@ -11,84 +10,34 @@
 import 'package:devtools_shared/devtools_shared.dart';
 import 'package:devtools_shared/devtools_test_utils.dart';
 import 'package:test/test.dart';
-import 'package:vm_service/vm_service.dart';
 
 import 'devtools_server_driver.dart';
 
-late CliAppFixture appFixture;
-late DevToolsServerDriver server;
-final completers = <String, Completer<Map<String, dynamic>>>{};
-
-/// A broadcast stream controller for streaming events from the server.
-late StreamController<Map<String, dynamic>> eventController;
-
-/// A broadcast stream of events from the server.
-///
-/// Listening for "server.started" events on this stream may be unreliable
-/// because it may have occurred before the test starts. Use the
-/// [serverStartedEvent] instead.
-Stream<Map<String, dynamic>> get events => eventController.stream;
-
-/// Completer that signals when the server started event has been received.
-late Completer<Map<String, dynamic>> serverStartedEvent;
-
-final Map<String, String> registeredServices = {};
-
-// A list of PIDs for Chrome instances spawned by tests that should be
-// cleaned up.
-final List<int> browserPids = [];
+late final DevToolsServerTestController testController;
 
 void main() {
-  late StreamSubscription<String> stderrSub;
-  late StreamSubscription<Map<String, dynamic>?> stdoutSub;
+  testController = DevToolsServerTestController();
 
   setUp(() async {
-    serverStartedEvent = Completer<Map<String, dynamic>>();
-    eventController = StreamController<Map<String, dynamic>>.broadcast();
-
-    // Start the command-line server.
-    server = await DevToolsServerDriver.create();
-
-    // Fail tests on any stderr.
-    stderrSub = server.stderr.listen((text) => throw 'STDERR: $text');
-    stdoutSub = server.stdout.listen((map) {
-      if (map!.containsKey('id')) {
-        if (map.containsKey('result')) {
-          completers[map['id']]!.complete(map['result']);
-        } else {
-          completers[map['id']]!.completeError(map['error']);
-        }
-      } else if (map.containsKey('event')) {
-        if (map['event'] == 'server.started') {
-          serverStartedEvent.complete(map);
-        }
-        eventController.add(map);
-      }
-    });
-
-    await serverStartedEvent.future;
-    await _startApp();
+    await testController.setUp();
   });
 
   tearDown(() async {
-    browserPids
-      ..forEach((pid) => Process.killPid(pid, ProcessSignal.sigkill))
-      ..clear();
-    await stdoutSub.cancel();
-    await stderrSub.cancel();
-    server.kill();
-    await appFixture.teardown();
+    await testController.tearDown();
   });
 
   test('registers service', () async {
-    final serverResponse = await _send(
+    final serverResponse = await testController.send(
       'vm.register',
-      {'uri': appFixture.serviceUri.toString()},
+      {'uri': testController.appFixture.serviceUri.toString()},
     );
     expect(serverResponse['success'], isTrue);
 
     // Expect the VM service to see the launchDevTools service registered.
-    expect(registeredServices, contains(DevToolsServer.launchDevToolsService));
+    expect(
+      testController.registeredServices,
+      contains(DevToolsServer.launchDevToolsService),
+    );
   }, timeout: const Timeout.factor(10));
 
   test('can bind to next available port', () async {
@@ -166,13 +115,13 @@
   }, timeout: const Timeout.factor(10));
 
   test('Analytics Survey', () async {
-    var serverResponse = await _send('devTools.survey', {
+    var serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': 'copyAndCreateDevToolsFile',
     });
     expect(serverResponse, isNotNull);
     expect(serverResponse['success'], isTrue);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiSetActiveSurvey,
       'value': 'Q3-2019',
     });
@@ -180,35 +129,35 @@
     expect(serverResponse['success'], isTrue);
     expect(serverResponse['activeSurvey'], 'Q3-2019');
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiIncrementSurveyShownCount,
     });
     expect(serverResponse, isNotNull);
     expect(serverResponse['activeSurvey'], 'Q3-2019');
     expect(serverResponse['surveyShownCount'], 1);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiIncrementSurveyShownCount,
     });
     expect(serverResponse, isNotNull);
     expect(serverResponse['activeSurvey'], 'Q3-2019');
     expect(serverResponse['surveyShownCount'], 2);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiGetSurveyShownCount,
     });
     expect(serverResponse, isNotNull);
     expect(serverResponse['activeSurvey'], 'Q3-2019');
     expect(serverResponse['surveyShownCount'], 2);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiGetSurveyActionTaken,
     });
     expect(serverResponse, isNotNull);
     expect(serverResponse['activeSurvey'], 'Q3-2019');
     expect(serverResponse['surveyActionTaken'], isFalse);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': apiSetSurveyActionTaken,
       'value': json.encode(true),
     });
@@ -216,7 +165,7 @@
     expect(serverResponse['activeSurvey'], 'Q3-2019');
     expect(serverResponse['surveyActionTaken'], isTrue);
 
-    serverResponse = await _send('devTools.survey', {
+    serverResponse = await testController.send('devTools.survey', {
       'surveyRequest': MachineModeCommandHandler.restoreDevToolsFile,
     });
     expect(serverResponse, isNotNull);
@@ -234,128 +183,78 @@
 
   for (final bool useVmService in [true, false]) {
     group('Server (${useVmService ? 'VM Service' : 'API'})', () {
-      test(
-          'DevTools connects back to server API and registers that it is connected',
-          () async {
-        // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
-
-        // Send a request to launch DevTools in a browser.
-        await _sendLaunchDevToolsRequest(useVmService: useVmService);
-
-        final serverResponse =
-            await _waitForClients(requiredConnectionState: true);
-        expect(serverResponse, isNotNull);
-        expect(serverResponse['clients'], hasLength(1));
-        expect(serverResponse['clients'][0]['hasConnection'], isTrue);
-        expect(
-          serverResponse['clients'][0]['vmServiceUri'],
-          appFixture.serviceUri.toString(),
-        );
-      }, timeout: const Timeout.factor(10));
-
       test('can launch on a specific page', () async {
         // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Send a request to launch at a certain page.
-        await _sendLaunchDevToolsRequest(
+        await testController.sendLaunchDevToolsRequest(
           useVmService: useVmService,
           page: 'memory',
         );
 
-        final serverResponse = await _waitForClients(requiredPage: 'memory');
+        final serverResponse =
+            await testController.waitForClients(requiredPage: 'memory');
         expect(serverResponse, isNotNull);
         expect(serverResponse['clients'], hasLength(1));
         expect(serverResponse['clients'][0]['hasConnection'], isTrue);
         expect(
           serverResponse['clients'][0]['vmServiceUri'],
-          appFixture.serviceUri.toString(),
+          testController.appFixture.serviceUri.toString(),
         );
         expect(serverResponse['clients'][0]['currentPage'], 'memory');
       }, timeout: const Timeout.factor(10));
 
       test('can switch page', () async {
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Launch on the memory page and wait for the connection.
-        await _sendLaunchDevToolsRequest(
+        await testController.sendLaunchDevToolsRequest(
           useVmService: useVmService,
           page: 'memory',
         );
-        await _waitForClients(requiredPage: 'memory');
+        await testController.waitForClients(requiredPage: 'memory');
 
         // Re-launch, allowing reuse and with a different page.
-        await _sendLaunchDevToolsRequest(
+        await testController.sendLaunchDevToolsRequest(
           useVmService: useVmService,
           reuseWindows: true,
           page: 'logging',
         );
 
-        final serverResponse = await _waitForClients(requiredPage: 'logging');
+        final serverResponse =
+            await testController.waitForClients(requiredPage: 'logging');
         expect(serverResponse, isNotNull);
         expect(serverResponse['clients'], hasLength(1));
         expect(serverResponse['clients'][0]['hasConnection'], isTrue);
         expect(
           serverResponse['clients'][0]['vmServiceUri'],
-          appFixture.serviceUri.toString(),
+          testController.appFixture.serviceUri.toString(),
         );
         expect(serverResponse['clients'][0]['currentPage'], 'logging');
       }, timeout: const Timeout.factor(20));
 
-      test('DevTools reports disconnects from a VM', () async {
-        // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
-
-        // Send a request to launch DevTools in a browser.
-        await _sendLaunchDevToolsRequest(useVmService: useVmService);
-
-        // Wait for the DevTools to inform server that it's connected.
-        await _waitForClients(requiredConnectionState: true);
-
-        // Terminate the VM.
-        await appFixture.teardown();
-
-        // Ensure the client is marked as disconnected.
-        final serverResponse =
-            await _waitForClients(requiredConnectionState: false);
-        expect(serverResponse['clients'], hasLength(1));
-        expect(serverResponse['clients'][0]['hasConnection'], isFalse);
-        expect(serverResponse['clients'][0]['vmServiceUri'], isNull);
-      }, timeout: const Timeout.factor(20));
-
-      test('server removes clients that disconnect from the API', () async {
-        final event = await serverStartedEvent.future;
-
-        // Spawn our own Chrome process so we can terminate it.
-        final devToolsUri =
-            'http://${event['params']['host']}:${event['params']['port']}';
-        final chrome = await Chrome.locate()!.start(url: devToolsUri);
-
-        // Wait for DevTools to inform server that it's connected.
-        await _waitForClients();
-
-        // Close the browser, which will disconnect DevTools SSE connection
-        // back to the server.
-        chrome.kill();
-
-        // Await a long delay to wait for the SSE client to close.
-        await delay(duration: const Duration(seconds: 20));
-
-        // Ensure the client is completely removed from the list.
-        await _waitForClients(expectNone: true, useLongTimeout: true);
-      }, timeout: const Timeout.factor(20));
-
       test('Server reuses DevTools instance if already connected to same VM',
           () async {
         // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Send a request to launch DevTools in a browser.
-        await _sendLaunchDevToolsRequest(useVmService: useVmService);
+        await testController.sendLaunchDevToolsRequest(
+          useVmService: useVmService,
+        );
 
         {
-          final serverResponse = await _waitForClients(
+          final serverResponse = await testController.waitForClients(
             requiredConnectionState: true,
           );
           expect(serverResponse['clients'], hasLength(1));
@@ -363,7 +262,7 @@
 
         // Request again, allowing reuse, and server emits an event saying the
         // window was reused.
-        final launchResponse = await _sendLaunchDevToolsRequest(
+        final launchResponse = await testController.sendLaunchDevToolsRequest(
           useVmService: useVmService,
           reuseWindows: true,
         );
@@ -372,32 +271,36 @@
         // Ensure there's still only one connection (eg. we didn't spawn a new one
         // we reused the existing one).
         final serverResponse =
-            await _waitForClients(requiredConnectionState: true);
+            await testController.waitForClients(requiredConnectionState: true);
         expect(serverResponse['clients'], hasLength(1));
       }, timeout: const Timeout.factor(20));
 
       test('Server does not reuse DevTools instance if embedded', () async {
         // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Spawn an embedded version of DevTools in a browser.
-        final event = await serverStartedEvent.future;
+        final event = await testController.serverStartedEvent.future;
         final devToolsUri =
             'http://${event['params']['host']}:${event['params']['port']}';
         final launchUrl = '$devToolsUri/?embed=true&page=logging'
-            '&uri=${Uri.encodeQueryComponent(appFixture.serviceUri.toString())}';
+            '&uri=${Uri.encodeQueryComponent(testController.appFixture.serviceUri.toString())}';
         final chrome = await Chrome.locate()!.start(url: launchUrl);
         try {
           {
-            final serverResponse =
-                await _waitForClients(requiredConnectionState: true);
+            final serverResponse = await testController.waitForClients(
+              requiredConnectionState: true,
+            );
             expect(serverResponse['clients'], hasLength(1));
           }
 
           // Send a request to the server to launch and ensure it did
           // not reuse the existing connection. Launch it on a different page
           // so we can easily tell once this one has connected.
-          final launchResponse = await _sendLaunchDevToolsRequest(
+          final launchResponse = await testController.sendLaunchDevToolsRequest(
             useVmService: useVmService,
             reuseWindows: true,
             page: 'memory',
@@ -405,7 +308,7 @@
           expect(launchResponse['reused'], isFalse);
 
           // Ensure there's now two connections.
-          final serverResponse = await _waitForClients(
+          final serverResponse = await testController.waitForClients(
             requiredConnectionState: true,
             requiredPage: 'memory',
           );
@@ -418,26 +321,34 @@
       test('Server reuses DevTools instance if not connected to a VM',
           () async {
         // Register the VM.
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Send a request to launch DevTools in a browser.
-        await _sendLaunchDevToolsRequest(useVmService: useVmService);
+        await testController.sendLaunchDevToolsRequest(
+          useVmService: useVmService,
+        );
 
         // Wait for the DevTools to inform server that it's connected.
-        await _waitForClients(requiredConnectionState: true);
+        await testController.waitForClients(requiredConnectionState: true);
 
         // Terminate the VM.
-        await appFixture.teardown();
+        await testController.appFixture.teardown();
 
         // Ensure the client is marked as disconnected.
-        await _waitForClients(requiredConnectionState: false);
+        await testController.waitForClients(requiredConnectionState: false);
 
         // Start up a new app.
-        await _startApp();
-        await _send('vm.register', {'uri': appFixture.serviceUri.toString()});
+        await testController.startApp();
+        await testController.send(
+          'vm.register',
+          {'uri': testController.appFixture.serviceUri.toString()},
+        );
 
         // Send a new request to launch.
-        await _sendLaunchDevToolsRequest(
+        await testController.sendLaunchDevToolsRequest(
           useVmService: useVmService,
           reuseWindows: true,
           notify: true,
@@ -445,125 +356,14 @@
 
         // Ensure we now have a single connected client.
         final serverResponse =
-            await _waitForClients(requiredConnectionState: true);
+            await testController.waitForClients(requiredConnectionState: true);
         expect(serverResponse['clients'], hasLength(1));
         expect(serverResponse['clients'][0]['hasConnection'], isTrue);
         expect(
           serverResponse['clients'][0]['vmServiceUri'],
-          appFixture.serviceUri.toString(),
+          testController.appFixture.serviceUri.toString(),
         );
       }, timeout: const Timeout.factor(20));
     });
   }
 }
-
-Future<Map<String, dynamic>> _sendLaunchDevToolsRequest({
-  required bool useVmService,
-  String? page,
-  bool notify = false,
-  bool reuseWindows = false,
-}) async {
-  print('grabbing client.launch event');
-  final launchEvent = events.where((e) => e['event'] == 'client.launch').first;
-  if (useVmService) {
-    await appFixture.serviceConnection.callMethod(
-      registeredServices[DevToolsServer.launchDevToolsService]!,
-      args: {
-        'reuseWindows': reuseWindows,
-        'page': page,
-        'notify': notify,
-      },
-    );
-  } else {
-    await _send(
-      'devTools.launch',
-      {
-        'vmServiceUri': appFixture.serviceUri.toString(),
-        'reuseWindows': reuseWindows,
-        'page': page,
-      },
-    );
-  }
-  final response = await launchEvent;
-  final pid = response['params']['pid'];
-  if (pid != null) {
-    browserPids.add(pid);
-  }
-  return response['params'];
-}
-
-Future<void> _startApp() async {
-  final appUri =
-      Platform.script.resolveUri(Uri.parse('../fixtures/empty_dart_app.dart'));
-  appFixture = await CliAppFixture.create(appUri.path);
-
-  // Track services method names as they're registered.
-  appFixture.serviceConnection
-      .onEvent(EventStreams.kService)
-      .where((e) => e.kind == EventKind.kServiceRegistered)
-      .listen((e) => registeredServices[e.service!] = e.method!);
-  await appFixture.serviceConnection.streamListen(EventStreams.kService);
-}
-
-int nextId = 0;
-Future<Map<String, dynamic>> _send(
-  String method, [
-  Map<String, dynamic>? params,
-]) {
-  final id = (nextId++).toString();
-  completers[id] = Completer<Map<String, dynamic>>();
-  server.write({'id': id.toString(), 'method': method, 'params': params});
-  return completers[id]!.future;
-}
-
-// It may take time for the servers client list to be updated as the web app
-// connects, so this helper just polls waiting for the expected state and
-// then returns the client list.
-Future<Map<String, dynamic>> _waitForClients({
-  bool? requiredConnectionState,
-  String? requiredPage,
-  bool expectNone = false,
-  bool useLongTimeout = false,
-  Duration delayDuration = defaultDelay,
-}) async {
-  late Map<String, dynamic> serverResponse;
-
-  final isOnPage = (client) => client['currentPage'] == requiredPage;
-  final hasConnectionState = (client) => requiredConnectionState ?? false
-      // If we require a connected client, also require a non-null page. This
-      // avoids a race in tests where we may proceed to send messages to a client
-      // that is not fully initialised.
-      ? (client['hasConnection'] && client['currentPage'] != null)
-      : !client['hasConnection'];
-
-  await _waitFor(
-    () async {
-      // Await a short delay to give the client time to connect.
-      await delay();
-
-      serverResponse = await _send('client.list');
-      final clients = serverResponse['clients'];
-      return clients is List &&
-          (clients.isEmpty == expectNone) &&
-          (requiredPage == null || clients.any(isOnPage)) &&
-          (requiredConnectionState == null || clients.any(hasConnectionState));
-    },
-    delayDuration: delayDuration,
-  );
-
-  return serverResponse;
-}
-
-Future<void> _waitFor(
-  Future<bool> condition(), {
-  Duration delayDuration = defaultDelay,
-}) async {
-  while (true) {
-    if (await condition()) {
-      return;
-    }
-    await delay(duration: delayDuration);
-  }
-}
-
-const defaultDelay = Duration(milliseconds: 500);
diff --git a/pkg/front_end/lib/src/fasta/kernel/macro.dart b/pkg/front_end/lib/src/fasta/kernel/macro.dart
index b820d53..5a9d010 100644
--- a/pkg/front_end/lib/src/fasta/kernel/macro.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/macro.dart
@@ -36,6 +36,12 @@
 
 bool enableMacros = false;
 
+/// Enables macros whether the Macro class actually exists in the transitive
+/// deps or not. This allows for easier experimentation.
+///
+/// TODO: Remove this once it is no longer necessary.
+bool forceEnableMacros = false;
+
 const String augmentationScheme = 'org-dartlang-augmentation';
 
 final Uri macroLibraryUri =
@@ -702,8 +708,10 @@
       //  declarations?
       return new macro.FieldDeclarationImpl(
           id: macro.RemoteInstance.uniqueId,
-          identifier: new macro.IdentifierImpl(
-              id: macro.RemoteInstance.uniqueId, name: builder.name),
+          identifier: new _IdentifierImpl.forMemberBuilder(
+              memberBuilder: builder,
+              id: macro.RemoteInstance.uniqueId,
+              name: builder.name),
           definingClass: definingClass.identifier as macro.IdentifierImpl,
           isExternal: builder.isExternal,
           isFinal: builder.isFinal,
@@ -713,8 +721,10 @@
     } else {
       return new macro.VariableDeclarationImpl(
           id: macro.RemoteInstance.uniqueId,
-          identifier: new macro.IdentifierImpl(
-              id: macro.RemoteInstance.uniqueId, name: builder.name),
+          identifier: new _IdentifierImpl.forMemberBuilder(
+              memberBuilder: builder,
+              id: macro.RemoteInstance.uniqueId,
+              name: builder.name),
           isExternal: builder.isExternal,
           isFinal: builder.isFinal,
           isLate: builder.isLate,
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 2db7bc2..a281736 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -1587,7 +1587,9 @@
   }
 
   Future<MacroApplications?> computeMacroApplications() async {
-    if (!enableMacros || _macroClassBuilder == null) return null;
+    if ((!enableMacros || _macroClassBuilder == null) && !forceEnableMacros) {
+      return null;
+    }
 
     Map<SourceLibraryBuilder, LibraryMacroApplicationData> libraryData = {};
     for (SourceLibraryBuilder libraryBuilder in sourceLibraryBuilders) {
diff --git a/pkg/front_end/test/spell_checking_list_code.txt b/pkg/front_end/test/spell_checking_list_code.txt
index bd9f6ed..0093dce 100644
--- a/pkg/front_end/test/spell_checking_list_code.txt
+++ b/pkg/front_end/test/spell_checking_list_code.txt
@@ -428,6 +428,7 @@
 exp
 expando
 expense
+experimentation
 explaining
 exportable
 exportee
diff --git a/pkg/front_end/testcases/general/issue48373.dart b/pkg/front_end/testcases/general/issue48373.dart
new file mode 100644
index 0000000..4b95346
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+void fn<T, S>(T? t, S? s) {
+  var x = [t!, s!];
+  List<Object> y = x; // Ok.
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/general/issue48373.dart.textual_outline.expect b/pkg/front_end/testcases/general/issue48373.dart.textual_outline.expect
new file mode 100644
index 0000000..2854a9f
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.textual_outline.expect
@@ -0,0 +1,2 @@
+void fn<T, S>(T? t, S? s) {}
+main() {}
diff --git a/pkg/front_end/testcases/general/issue48373.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/general/issue48373.dart.textual_outline_modelled.expect
new file mode 100644
index 0000000..fada1de
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.textual_outline_modelled.expect
@@ -0,0 +1,2 @@
+main() {}
+void fn<T, S>(T? t, S? s) {}
diff --git a/pkg/front_end/testcases/general/issue48373.dart.weak.expect b/pkg/front_end/testcases/general/issue48373.dart.weak.expect
new file mode 100644
index 0000000..79628fe
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.weak.expect
@@ -0,0 +1,9 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
+  core::List<core::Object> x = <core::Object>[t!, s!];
+  core::List<core::Object> y = x;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue48373.dart.weak.modular.expect b/pkg/front_end/testcases/general/issue48373.dart.weak.modular.expect
new file mode 100644
index 0000000..79628fe
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.weak.modular.expect
@@ -0,0 +1,9 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
+  core::List<core::Object> x = <core::Object>[t!, s!];
+  core::List<core::Object> y = x;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/general/issue48373.dart.weak.outline.expect b/pkg/front_end/testcases/general/issue48373.dart.weak.outline.expect
new file mode 100644
index 0000000..9427480
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.weak.outline.expect
@@ -0,0 +1,8 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/general/issue48373.dart.weak.transformed.expect b/pkg/front_end/testcases/general/issue48373.dart.weak.transformed.expect
new file mode 100644
index 0000000..0a0e052
--- /dev/null
+++ b/pkg/front_end/testcases/general/issue48373.dart.weak.transformed.expect
@@ -0,0 +1,9 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+static method fn<T extends core::Object? = dynamic, S extends core::Object? = dynamic>(self::fn::T? t, self::fn::S? s) → void {
+  core::List<core::Object> x = core::_GrowableList::_literal2<core::Object>(t!, s!);
+  core::List<core::Object> y = x;
+}
+static method main() → dynamic {}
diff --git a/pkg/frontend_server/lib/compute_kernel.dart b/pkg/frontend_server/lib/compute_kernel.dart
index e9aac60..f16b938 100644
--- a/pkg/frontend_server/lib/compute_kernel.dart
+++ b/pkg/frontend_server/lib/compute_kernel.dart
@@ -11,12 +11,20 @@
 import 'dart:async';
 import 'dart:io';
 
+import 'package:_fe_analyzer_shared/src/macros/executor/isolated_executor.dart'
+    as isolatedExecutor;
+import 'package:_fe_analyzer_shared/src/macros/executor/process_executor.dart'
+    as processExecutor;
+import 'package:_fe_analyzer_shared/src/macros/executor/serialization.dart'
+    show SerializationMode;
 import 'package:args/args.dart';
 import 'package:build_integration/file_system/multi_root.dart';
 import 'package:compiler/src/kernel/dart2js_target.dart';
 import 'package:dev_compiler/src/kernel/target.dart';
 import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
+import 'package:front_end/src/api_prototype/experimental_flags.dart';
 import 'package:front_end/src/api_unstable/bazel_worker.dart' as fe;
+import 'package:front_end/src/fasta/kernel/macro.dart';
 import 'package:kernel/ast.dart' show Component, Library, Reference;
 import 'package:kernel/target/targets.dart';
 import 'package:vm/target/flutter.dart';
@@ -94,7 +102,22 @@
       help: 'Sets the verbosity level used for filtering messages during '
           'compilation.',
       allowed: fe.Verbosity.allowedValues,
-      allowedHelp: fe.Verbosity.allowedValuesHelp);
+      allowedHelp: fe.Verbosity.allowedValuesHelp)
+  ..addMultiOption('precompiled-macro',
+      help: 'Configuration for precompiled macro binaries or kernel files.\n'
+          'Must be used in combination with --precompiled-macro-format.\n'
+          'The expected format of this option is as follows: '
+          '<macro-library-uri>;<absolute-path-to-binary>\nFor example: '
+          '--precompiled-macro="package:some_macro/some_macro.dart;'
+          '/path/to/compiled/macro"')
+  ..addOption('precompiled-macro-format',
+      help: 'The format for precompiled macros.',
+      allowed: ['aot', 'kernel'],
+      defaultsTo: 'aot')
+  ..addOption('macro-serialization-mode',
+      help: 'The serialization mode for communicating with macros.',
+      allowed: ['bytedata', 'json'],
+      defaultsTo: 'bytedata');
 
 class ComputeKernelResult {
   final bool succeeded;
@@ -273,6 +296,51 @@
         nnbdMode: nnbdMode);
   }
 
+  // Either set up or reset the state for macros based on experiment status.
+  // TODO: Make this a part of `initializeCompiler`, if/when we want to make it
+  // more widely supported.
+  if (state.processedOpts
+      .isExperimentEnabledGlobally(ExperimentalFlag.macros)) {
+    enableMacros = true;
+    forceEnableMacros = true;
+
+    SerializationMode serializationMode;
+    switch (parsedArgs['macro-serialization-mode']) {
+      case 'json':
+        serializationMode = SerializationMode.jsonServer;
+        break;
+      case 'bytedata':
+        serializationMode = SerializationMode.byteDataServer;
+        break;
+      default:
+        throw ArgumentError('Unrecognized macro serialization mode '
+            '${parsedArgs['macro-serialization-mode']}');
+    }
+
+    var format = parsedArgs['precompiled-macro-format'];
+    switch (format) {
+      case 'kernel':
+        state.options.macroExecutorProvider =
+            () => isolatedExecutor.start(serializationMode);
+        break;
+      case 'aot':
+        state.options.macroExecutorProvider =
+            () => processExecutor.start(serializationMode);
+        break;
+      default:
+        throw ArgumentError('Unrecognized precompiled macro format $format');
+    }
+    var precompiledMacroUris = state.options.precompiledMacroUris = {};
+    for (var parts in (parsedArgs['precompiled-macro'] as List<String>)
+        .map((arg) => arg.split(';'))) {
+      precompiledMacroUris[Uri.parse(parts[0])] = toUri(parts[1]);
+    }
+  } else {
+    enableMacros = false;
+    forceEnableMacros = false;
+    state.options.precompiledMacroUris = {};
+  }
+
   void onDiagnostic(fe.DiagnosticMessage message) {
     if (fe.Verbosity.shouldPrint(verbosity, message)) {
       fe.printDiagnosticMessage(message, out.writeln);
diff --git a/pkg/frontend_server/pubspec.yaml b/pkg/frontend_server/pubspec.yaml
index a3c97a6..9985e92 100644
--- a/pkg/frontend_server/pubspec.yaml
+++ b/pkg/frontend_server/pubspec.yaml
@@ -8,6 +8,8 @@
 
 dependencies:
   args: ^2.0.0
+  _fe_analyzer_shared:
+    path: ../_fe_analyzer_shared
   build_integration:
     path: ../build_integration
   compiler:
diff --git a/pkg/kernel/lib/src/standard_bounds.dart b/pkg/kernel/lib/src/standard_bounds.dart
index 9dc32175..d929862 100644
--- a/pkg/kernel/lib/src/standard_bounds.dart
+++ b/pkg/kernel/lib/src/standard_bounds.dart
@@ -1274,8 +1274,7 @@
               type2,
               clientLibrary)
           .withDeclaredNullability(uniteNullabilities(
-              type1.promotedBound!.declaredNullability,
-              type2.declaredNullability));
+              type1.promotedBound!.declaredNullability, type2.nullability));
     }
   }
 
diff --git a/pkg/nnbd_migration/test/abstract_context.dart b/pkg/nnbd_migration/test/abstract_context.dart
index b096215..d4e0c8e 100644
--- a/pkg/nnbd_migration/test/abstract_context.dart
+++ b/pkg/nnbd_migration/test/abstract_context.dart
@@ -109,7 +109,7 @@
   File addPackageFile(String packageName, String pathInLib, String content) {
     var packagePath = '/.pub-cache/$packageName';
     knownPackages.add(packageName);
-    return newFile('$packagePath/lib/$pathInLib', content: content);
+    return newFile2('$packagePath/lib/$pathInLib', content);
   }
 
   /// Add the quiver package and a library with URI,
@@ -125,7 +125,7 @@
   }
 
   Source addSource(String path, String content, [Uri? uri]) {
-    File file = newFile(path, content: content);
+    File file = newFile2(path, content);
     return file.createSource(uri);
   }
 
@@ -171,13 +171,13 @@
     );
 
     newFolder(testsPath);
-    newFile('$testsPath/.packages', content: '''
+    newFile2('$testsPath/.packages', '''
 tests:file://$testsPath/lib
 ''');
     var pubspecPath = '$testsPath/pubspec.yaml';
     // Subclasses may write out a different file first.
     if (!getFile(pubspecPath).exists) {
-      newFile(pubspecPath, content: '''
+      newFile2(pubspecPath, '''
 name: tests
 version: 1.0.0
 environment:
@@ -215,8 +215,8 @@
       'generator': 'pub',
       'generatorVersion': '2.10.0'
     };
-    newFile('$testsPath/.dart_tool/package_config.json',
-        content: JsonEncoder.withIndent('  ').convert(packageConfigJson));
+    newFile2('$testsPath/.dart_tool/package_config.json',
+        JsonEncoder.withIndent('  ').convert(packageConfigJson));
     _analysisContextCollection = AnalysisContextCollectionImpl(
       includedPaths: [convertPath(homePath)],
       enableIndex: true,
diff --git a/pkg/nnbd_migration/test/abstract_single_unit.dart b/pkg/nnbd_migration/test/abstract_single_unit.dart
index 7934ab3..c5b466d 100644
--- a/pkg/nnbd_migration/test/abstract_single_unit.dart
+++ b/pkg/nnbd_migration/test/abstract_single_unit.dart
@@ -62,7 +62,7 @@
   void setUp() {
     var testRoot = testsPath;
     if (analyzeWithNnbd) {
-      newFile('$testRoot/analysis_options.yaml', content: '''
+      newFile2('$testRoot/analysis_options.yaml', '''
 analyzer:
   enable-experiment:
     - non-nullable
diff --git a/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart b/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
index dcc89c4..4670640 100644
--- a/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
+++ b/pkg/nnbd_migration/test/already_migrated_code_decorator_test.dart
@@ -612,7 +612,7 @@
 
 class _ContextWithFiles with ResourceProviderMixin {
   Future<_ContextWithUnitElement> buildUnitElement(String content) async {
-    var file = newFile('/home/test/lib/test.dart', content: content);
+    var file = newFile2('/home/test/lib/test.dart', content);
 
     var sdkRoot = newFolder('/sdk');
     createMockSdk(
diff --git a/pkg/nnbd_migration/test/api_test.dart b/pkg/nnbd_migration/test/api_test.dart
index c88be9a..12f9b92 100644
--- a/pkg/nnbd_migration/test/api_test.dart
+++ b/pkg/nnbd_migration/test/api_test.dart
@@ -54,10 +54,10 @@
       bool warnOnWeakCode = false,
       bool allowErrors = false}) async {
     for (var path in migratedInput.keys) {
-      newFile(path, content: migratedInput[path]!);
+      newFile2(path, migratedInput[path]!);
     }
     for (var path in input.keys) {
-      newFile(path, content: input[path]!);
+      newFile2(path, input[path]!);
     }
     var listener = TestMigrationListener();
     var migration = NullabilityMigration(listener,
diff --git a/pkg/nnbd_migration/test/front_end/analysis_abstract.dart b/pkg/nnbd_migration/test/front_end/analysis_abstract.dart
index dea20d0..41f2ec0 100644
--- a/pkg/nnbd_migration/test/front_end/analysis_abstract.dart
+++ b/pkg/nnbd_migration/test/front_end/analysis_abstract.dart
@@ -16,14 +16,14 @@
   AbstractAnalysisTest();
 
   void addAnalysisOptionsFile(String content) {
-    newFile(
+    newFile2(
         resourceProvider.pathContext
             .join(projectPath!, 'analysis_options.yaml'),
-        content: content);
+        content);
   }
 
   String? addTestFile(String content) {
-    newFile(testFile!, content: content);
+    newFile2(testFile!, content);
     testCode = content;
     return testFile;
   }
diff --git a/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart b/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
index 047149f..b061405 100644
--- a/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
+++ b/pkg/nnbd_migration/test/front_end/nnbd_migration_test_base.dart
@@ -193,7 +193,7 @@
     shouldBeMigratedFunction ??= (String? path) => true;
     var testPaths = <String>[];
     files.forEach((String path, String content) {
-      newFile(path, content: content);
+      newFile2(path, content);
       testPaths.add(path);
     });
     pathsToProcess ??= testPaths;
diff --git a/pkg/nnbd_migration/test/instrumentation_test.dart b/pkg/nnbd_migration/test/instrumentation_test.dart
index f9a4131..d0913a7 100644
--- a/pkg/nnbd_migration/test/instrumentation_test.dart
+++ b/pkg/nnbd_migration/test/instrumentation_test.dart
@@ -142,7 +142,7 @@
   Future<void> analyze(String content,
       {bool removeViaComments = false, bool warnOnWeakCode = true}) async {
     var sourcePath = convertPath('$testsPath/lib/test.dart');
-    newFile(sourcePath, content: content);
+    newFile2(sourcePath, content);
     var listener = TestMigrationListener();
     var migration = NullabilityMigration(listener,
         instrumentation: _InstrumentationClient(this),
diff --git a/pkg/pkg.status b/pkg/pkg.status
index 185ab05..7122a64 100644
--- a/pkg/pkg.status
+++ b/pkg/pkg.status
@@ -47,7 +47,6 @@
 dartdev/test/commands/analyze_test: Slow, Pass
 dartdev/test/commands/help_test: Slow, Pass
 dartdev/test/smoke/*: Slow, Pass
-dds/test/devtools_server/devtools_server_test: Slow, Pass
 dev_compiler/test/modular/*: Slow, Pass
 dev_compiler/test/options/*: Skip # test needs fixes
 dev_compiler/test/sourcemap/*: SkipByDesign # Skip sourcemap tests
@@ -146,6 +145,7 @@
 vm_snapshot_analysis/test/*: SkipByDesign # Only meant to run on vm
 
 [ $system == windows ]
+dds/test/devtools_server/devtools_server_connection_test: Skip # Issue 48528
 dds/test/devtools_server/devtools_server_test: Skip # Issue 48528
 front_end/test/fasta/bootstrap_test: Skip # Issue 31902
 front_end/test/fasta/strong_test: Pass, Slow, Timeout
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index 83c1408..7cb1c3f 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -666,6 +666,10 @@
         if (implicitly_use_dart_dev && Options::vm_service_auth_disabled()) {
           dart_options->AddArgument("--disable-service-auth-codes");
         }
+        if (implicitly_use_dart_dev &&
+            Options::enable_service_port_fallback()) {
+          dart_options->AddArgument("--enable-service-port-fallback");
+        }
       }
       first_option = false;
     }
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 4b789f8..2b6b9c2 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -5416,7 +5416,9 @@
             AbstractType::Handle(zone, type_arguments.TypeAtNullSafe(0));
         // If T0 is Future<S0>, then T0 <: Future<S1>, iff S0 <: S1.
         if (type_arg.IsSubtypeOf(other_type_arg, space, trail)) {
-          if (verified_nullability) {
+          // verified_nullability doesn't take into account the nullability of
+          // S1, just of the FutureOr type.
+          if (verified_nullability || !other_type_arg.IsNonNullable()) {
             return true;
           }
         }
@@ -19847,14 +19849,8 @@
       ASSERT(object_store->nullable_future_null_type() != Type::null());
       return object_store->nullable_future_null_type();
     }
-    // To avoid having to special case FutureOr in nullability checks, we lift
-    // the nullability of the type argument to FutureOr as appropriate.
-    if (IsNullable() || unwrapped_type.IsNullable()) {
-      // FutureOr<T?> = FutureOr<T?>* = FutureOr<T?>?, so mark as nullable.
-      return Type::Cast(*this).ToNullability(Nullability::kNullable, space);
-    } else if (unwrapped_type.IsLegacy()) {
-      // FutureOr<T*> = FutureOr<T*>*, so mark as legacy.
-      return Type::Cast(*this).ToNullability(Nullability::kLegacy, space);
+    if (IsNullable() && unwrapped_type.IsNullable()) {
+      return Type::Cast(*this).ToNullability(Nullability::kNonNullable, space);
     }
   }
   return ptr();
diff --git a/runtime/vm/os_thread_absl.cc b/runtime/vm/os_thread_absl.cc
index d922da8..65ab3a0 100644
--- a/runtime/vm/os_thread_absl.cc
+++ b/runtime/vm/os_thread_absl.cc
@@ -409,7 +409,7 @@
 void Monitor::NotifyAll() {
   // When running with assertions enabled we track the owner.
   ASSERT(IsOwnedByCurrentThread());
-  xdata_.cond()->SignalAll();
+  data_.cond()->SignalAll();
 }
 
 }  // namespace dart
diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc
index 13f4ab9..c242cda 100644
--- a/runtime/vm/timeline.cc
+++ b/runtime/vm/timeline.cc
@@ -91,6 +91,9 @@
 //       |TimelineEventRecorder::lock_|
 //
 
+std::atomic<bool> RecorderLock::shutdown_lock_ = {false};
+std::atomic<intptr_t> RecorderLock::outstanding_event_writes_ = {0};
+
 static TimelineEventRecorder* CreateTimelineRecorder() {
   // Some flags require that we use the endless recorder.
   const bool use_endless_recorder =
@@ -223,6 +226,7 @@
   TIMELINE_STREAM_LIST(TIMELINE_STREAM_DISABLE)
 #undef TIMELINE_STREAM_DISABLE
   Timeline::Clear();
+  RecorderLock::WaitForShutdown();
   delete recorder_;
   recorder_ = NULL;
   if (enabled_streams_ != NULL) {
@@ -236,8 +240,9 @@
 }
 
 void Timeline::ReclaimCachedBlocksFromThreads() {
+  RecorderLockScope rl;
   TimelineEventRecorder* recorder = Timeline::recorder();
-  if (recorder == NULL) {
+  if (recorder == NULL || rl.IsShuttingDown()) {
     return;
   }
 
@@ -269,8 +274,9 @@
 void Timeline::PrintFlagsToJSON(JSONStream* js) {
   JSONObject obj(js);
   obj.AddProperty("type", "TimelineFlags");
+  RecorderLockScope rl;
   TimelineEventRecorder* recorder = Timeline::recorder();
-  if (recorder == NULL) {
+  if (recorder == NULL || rl.IsShuttingDown()) {
     obj.AddProperty("recorderName", "null");
   } else {
     obj.AddProperty("recorderName", recorder->name());
@@ -294,8 +300,9 @@
 #endif
 
 void Timeline::Clear() {
+  RecorderLockScope rl;
   TimelineEventRecorder* recorder = Timeline::recorder();
-  if (recorder == NULL) {
+  if (recorder == NULL || rl.IsShuttingDown()) {
     return;
   }
   ReclaimCachedBlocksFromThreads();
@@ -553,9 +560,9 @@
 
 void TimelineEvent::Complete() {
   TimelineEventRecorder* recorder = Timeline::recorder();
-  if (recorder != NULL) {
-    recorder->CompleteEvent(this);
-  }
+  recorder->CompleteEvent(this);
+  // Paired with RecorderLock::EnterLock() in TimelineStream::StartEvent().
+  RecorderLock::ExitLock();
 }
 
 void TimelineEvent::Init(EventType event_type, const char* label) {
@@ -771,15 +778,24 @@
 }
 
 TimelineEvent* TimelineStream::StartEvent() {
+  // Paired with RecorderLock::ExitLock() in TimelineEvent::Complete().
+  //
+  // The lock must be held until the event is completed to avoid having the
+  // memory backing the event being freed in the middle of processing the
+  // event.
+  RecorderLock::EnterLock();
   TimelineEventRecorder* recorder = Timeline::recorder();
-  if (!enabled() || (recorder == NULL)) {
-    return NULL;
+  if (!enabled() || (recorder == nullptr) || RecorderLock::IsShuttingDown()) {
+    RecorderLock::ExitLock();
+    return nullptr;
   }
-  ASSERT(name_ != NULL);
+  ASSERT(name_ != nullptr);
   TimelineEvent* event = recorder->StartEvent();
-  if (event != NULL) {
-    event->StreamInit(this);
+  if (event == nullptr) {
+    RecorderLock::ExitLock();
+    return nullptr;
   }
+  event->StreamInit(this);
   return event;
 }
 
diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h
index f4389ce..94998ca 100644
--- a/runtime/vm/timeline.h
+++ b/runtime/vm/timeline.h
@@ -121,6 +121,48 @@
 #endif
 };
 
+class RecorderLock : public AllStatic {
+ public:
+  static void EnterLock() {
+    outstanding_event_writes_.fetch_add(1, std::memory_order_acquire);
+  }
+
+  static void ExitLock() {
+    intptr_t count =
+        outstanding_event_writes_.fetch_sub(1, std::memory_order_release);
+    ASSERT(count >= 0);
+  }
+
+  static bool IsShuttingDown() {
+    return shutdown_lock_.load(std::memory_order_relaxed);
+  }
+
+  static void WaitForShutdown() {
+    shutdown_lock_.exchange(true);
+    // Spin waiting for outstanding events to be completed.
+    while (outstanding_event_writes_.load(std::memory_order_relaxed) > 0) {
+    }
+  }
+
+ private:
+  static std::atomic<bool> shutdown_lock_;
+  static std::atomic<intptr_t> outstanding_event_writes_;
+
+  DISALLOW_COPY_AND_ASSIGN(RecorderLock);
+};
+
+class RecorderLockScope {
+ public:
+  RecorderLockScope() { RecorderLock::EnterLock(); }
+
+  ~RecorderLockScope() { RecorderLock::ExitLock(); }
+
+  bool IsShuttingDown() { return RecorderLock::IsShuttingDown(); }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(RecorderLockScope);
+};
+
 class Timeline : public AllStatic {
  public:
   // Initialize timeline system. Not thread safe.
@@ -166,6 +208,8 @@
   TIMELINE_STREAM_LIST(TIMELINE_STREAM_DECLARE)
 #undef TIMELINE_STREAM_DECLARE
 
+  static RecorderLock recorder_lock_;
+
   template <class>
   friend class TimelineRecorderOverride;
   friend class ReclaimBlocksIsolateVisitor;
diff --git a/sdk/lib/_internal/vm/bin/vmservice_io.dart b/sdk/lib/_internal/vm/bin/vmservice_io.dart
index 3df0e4c..033a9cf 100644
--- a/sdk/lib/_internal/vm/bin/vmservice_io.dart
+++ b/sdk/lib/_internal/vm/bin/vmservice_io.dart
@@ -103,6 +103,7 @@
         enableDevTools.toString(),
         devToolsBinaries,
         enableLogging.toString(),
+        _enableServicePortFallback.toString(),
       ],
       mode: ProcessStartMode.detachedWithStdio,
     );
diff --git a/sdk/lib/_internal/vm/bin/vmservice_server.dart b/sdk/lib/_internal/vm/bin/vmservice_server.dart
index c8e61b2..0cdf1f2 100644
--- a/sdk/lib/_internal/vm/bin/vmservice_server.dart
+++ b/sdk/lib/_internal/vm/bin/vmservice_server.dart
@@ -409,11 +409,8 @@
       // Already running.
       return this;
     }
-
     // Startup HTTP server.
-    var pollError;
-    var pollStack;
-    Future<bool> poll() async {
+    Future<void> startServer() async {
       try {
         var address;
         var addresses = await InternetAddress.lookup(_ip);
@@ -423,33 +420,22 @@
           if (address.type == InternetAddressType.IPv4) break;
         }
         _server = await HttpServer.bind(address, _port);
-        return true;
       } catch (e, st) {
-        pollError = e;
-        pollStack = st;
-        return false;
+        if (_port != 0 && _enableServicePortFallback) {
+          serverPrint('Failed to bind Observatory HTTP server to port $_port. '
+              'Falling back to automatic port selection');
+          _port = 0;
+          await startServer();
+        } else {
+          serverPrint('Could not start Observatory HTTP server:\n'
+              '$e\n$st');
+          _notifyServerState('');
+          onServerAddressChange(null);
+        }
       }
     }
 
-    // poll for the network for ~10 seconds.
-    int attempts = 0;
-    final maxAttempts = 10;
-    while (!await poll()) {
-      attempts++;
-      serverPrint('Observatory server failed to start after $attempts tries');
-      if (attempts > maxAttempts) {
-        serverPrint('Could not start Observatory HTTP server:\n'
-            '$pollError\n$pollStack\n');
-        _notifyServerState('');
-        onServerAddressChange(null);
-        return this;
-      }
-      if (_port != 0 && _enableServicePortFallback && attempts >= 3) {
-        _port = 0;
-        serverPrint('Falling back to automatic port selection');
-      }
-      await Future<void>.delayed(const Duration(seconds: 1));
-    }
+    await startServer();
     if (_service.isExiting) {
       serverPrint('Observatory HTTP server exiting before listening as '
           'vm service has received exit request\n');
diff --git a/tests/web/regress/issue/48422_test.dart b/tests/web/regress/issue/48422_test.dart
new file mode 100644
index 0000000..ea7886c
--- /dev/null
+++ b/tests/web/regress/issue/48422_test.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+
+void main() {
+  testTryFinally();
+  testTryCatchFinally();
+}
+
+void testTryFinally() {
+  callback(Map<String, dynamic> m) {
+    Expect.isNull(m['foo']);
+  }
+
+  var val;
+  try {
+    try {
+      val = <String, dynamic>{};
+    } catch (_) {
+      val = {}.cast<String, dynamic>();
+    }
+    // This `return` means we consider the `try` block to abort. Nevertheless,
+    // the results of its inference must flow to the `finally`.
+    return;
+  } finally {
+    callback(val);
+  }
+}
+
+void testTryCatchFinally() {
+  callback(Map<String, dynamic> m) {
+    Expect.isNull(m['foo']);
+  }
+
+  var val;
+  try {
+    try {
+      val = <String, dynamic>{};
+    } catch (_) {
+      val = {}.cast<String, dynamic>();
+    }
+    // This `return` means we consider the `try` block to abort. Nevertheless,
+    // the results of its inference must flow to the `finally`.
+    return;
+  } catch (_) {
+  } finally {
+    callback(val);
+  }
+}
diff --git a/tests/web_2/regress/issue/48422_test.dart b/tests/web_2/regress/issue/48422_test.dart
new file mode 100644
index 0000000..ea7886c
--- /dev/null
+++ b/tests/web_2/regress/issue/48422_test.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+
+void main() {
+  testTryFinally();
+  testTryCatchFinally();
+}
+
+void testTryFinally() {
+  callback(Map<String, dynamic> m) {
+    Expect.isNull(m['foo']);
+  }
+
+  var val;
+  try {
+    try {
+      val = <String, dynamic>{};
+    } catch (_) {
+      val = {}.cast<String, dynamic>();
+    }
+    // This `return` means we consider the `try` block to abort. Nevertheless,
+    // the results of its inference must flow to the `finally`.
+    return;
+  } finally {
+    callback(val);
+  }
+}
+
+void testTryCatchFinally() {
+  callback(Map<String, dynamic> m) {
+    Expect.isNull(m['foo']);
+  }
+
+  var val;
+  try {
+    try {
+      val = <String, dynamic>{};
+    } catch (_) {
+      val = {}.cast<String, dynamic>();
+    }
+    // This `return` means we consider the `try` block to abort. Nevertheless,
+    // the results of its inference must flow to the `finally`.
+    return;
+  } catch (_) {
+  } finally {
+    callback(val);
+  }
+}
diff --git a/tools/VERSION b/tools/VERSION
index 14c3783..5aeac38 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 17
 PATCH 0
-PRERELEASE 205
+PRERELEASE 206
 PRERELEASE_PATCH 0
\ No newline at end of file