Version 2.11.0-269.0.dev

Merge commit '47a2ab286665ec278a9465bbc09c11657a659505' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/pubspec.yaml b/pkg/_fe_analyzer_shared/pubspec.yaml
index 7d75dfd..23f68a1 100644
--- a/pkg/_fe_analyzer_shared/pubspec.yaml
+++ b/pkg/_fe_analyzer_shared/pubspec.yaml
@@ -1,5 +1,5 @@
 name: _fe_analyzer_shared
-version: 11.0.0
+version: 12.0.0
 description: Logic that is shared between the front_end and analyzer packages.
 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared
 
diff --git a/pkg/analysis_server/lib/src/services/flutter/widget_descriptions.dart b/pkg/analysis_server/lib/src/services/flutter/widget_descriptions.dart
index 6476f46..7e66c3c 100644
--- a/pkg/analysis_server/lib/src/services/flutter/widget_descriptions.dart
+++ b/pkg/analysis_server/lib/src/services/flutter/widget_descriptions.dart
@@ -273,7 +273,7 @@
     var classElement = constructorElement.enclosingElement;
     if (!classesBeingProcessed.add(classElement)) return;
 
-    var existingNamed = <ParameterElement>{};
+    var existingNamed = <String>{};
     if (instanceCreation != null) {
       for (var argumentExpression in instanceCreation.argumentList.arguments) {
         var parameter = argumentExpression.staticParameterElement;
@@ -282,7 +282,7 @@
         Expression valueExpression;
         if (argumentExpression is NamedExpression) {
           valueExpression = argumentExpression.expression;
-          existingNamed.add(parameter);
+          existingNamed.add(parameter.name);
         } else {
           valueExpression = argumentExpression;
         }
@@ -301,7 +301,7 @@
 
     for (var parameter in constructorElement.parameters) {
       if (!parameter.isNamed) continue;
-      if (existingNamed.contains(parameter)) continue;
+      if (existingNamed.contains(parameter.name)) continue;
 
       _addProperty(
         properties: properties,
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
index 7a99a5e..235e17f 100644
--- a/pkg/analysis_server/test/abstract_context.dart
+++ b/pkg/analysis_server/test/abstract_context.dart
@@ -4,18 +4,21 @@
 
 import 'package:analyzer/dart/analysis/analysis_context.dart';
 import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/analysis/results.dart';
 import 'package:analyzer/dart/analysis/session.dart';
-import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/visitor.dart';
 import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/file_system/overlay_file_system.dart';
 import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/src/dart/analysis/byte_store.dart';
 import 'package:analyzer/src/dart/analysis/driver.dart';
 import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
 import 'package:analyzer/src/generated/source_io.dart';
 import 'package:analyzer/src/test_utilities/mock_sdk.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
 import 'package:linter/src/rules.dart';
 import 'package:meta/meta.dart';
@@ -41,92 +44,64 @@
 typedef _ElementVisitorFunction = void Function(Element element);
 
 class AbstractContextTest with ResourceProviderMixin {
-  OverlayResourceProvider overlayResourceProvider;
+  static bool _lintRulesAreRegistered = false;
 
+  final ByteStore _byteStore = MemoryByteStore();
+
+  final Map<String, String> _declaredVariables = {};
   AnalysisContextCollection _analysisContextCollection;
-  AnalysisDriver _driver;
 
   /// The file system specific `/home/test/analysis_options.yaml` path.
   String get analysisOptionsPath =>
       convertPath('/home/test/analysis_options.yaml');
 
-  AnalysisDriver get driver => _driver;
+  List<String> get collectionIncludedPaths => [workspaceRootPath];
 
-  AnalysisSession get session => driver.currentSession;
+  @deprecated
+  AnalysisDriver get driver {
+    throw 0;
+  }
+
+  String get latestLanguageVersion =>
+      '${ExperimentStatus.currentVersion.major}.'
+      '${ExperimentStatus.currentVersion.minor}';
+
+  AnalysisSession get session => contextFor('/home/test').currentSession;
+
+  String get testPackageLanguageVersion => '2.9';
+
+  String get testPackageLibPath => '$testPackageRootPath/lib';
+
+  String get testPackageRootPath => '$workspaceRootPath/test';
 
   /// The file system specific `/home/test/pubspec.yaml` path.
   String get testPubspecPath => convertPath('/home/test/pubspec.yaml');
 
-  void addFlutterPackage() {
-    addMetaPackage();
-
-    addTestPackageDependency(
-      'ui',
-      MockPackages.instance.addUI(resourceProvider).parent.path,
-    );
-
-    addTestPackageDependency(
-      'flutter',
-      MockPackages.instance.addFlutter(resourceProvider).parent.path,
-    );
-  }
-
-  void addMetaPackage() {
-    var libFolder = MockPackages.instance.addMeta(resourceProvider);
-    addTestPackageDependency('meta', libFolder.parent.path);
-  }
-
-  /// Add a new file with the given [pathInLib] to the package with the
-  /// given [packageName].  Then ensure that the test package depends on the
-  /// [packageName].
-  File addPackageFile(String packageName, String pathInLib, String content) {
-    var packagePath = '/.pub-cache/$packageName';
-    addTestPackageDependency(packageName, packagePath);
-    return newFile('$packagePath/lib/$pathInLib', content: content);
-  }
+  String get workspaceRootPath => '/home';
 
   Source addSource(String path, String content, [Uri uri]) {
     var file = newFile(path, content: content);
-    var source = file.createSource(uri);
-    driver.addFile(file.path);
-    driver.changeFile(file.path);
-    return source;
+    return file.createSource(uri);
   }
 
-  void addTestPackageDependency(String name, String rootPath) {
-    var packagesFile = getFile('/home/test/.packages');
-    var packagesContent =
-        packagesFile.exists ? packagesFile.readAsStringSync() : '';
-
-    // Ignore if there is already the same package dependency.
-    if (packagesContent.contains('$name:file://')) {
-      return;
+  Future<void> analyzeTestPackageFiles() async {
+    var analysisContext = contextFor(testPackageRootPath);
+    var files = analysisContext.contextRoot.analyzedFiles().toList();
+    for (var path in files) {
+      await analysisContext.currentSession.getResolvedUnit(path);
     }
-
-    rootPath = convertPath(rootPath);
-    packagesContent += '$name:${toUri('$rootPath/lib')}\n';
-
-    packagesFile.writeAsStringSync(packagesContent);
-
-    createAnalysisContexts();
   }
 
-  void addVectorMathPackage() {
-    var libFolder = MockPackages.instance.addVectorMath(resourceProvider);
-    addTestPackageDependency('vector_math', libFolder.parent.path);
+  void changeFile(String path) {
+    path = convertPath(path);
+    driverFor(path).changeFile(path);
   }
 
-  /// Create all analysis contexts in `/home`.
-  void createAnalysisContexts() {
-    _analysisContextCollection = AnalysisContextCollectionImpl(
-      includedPaths: [convertPath('/home')],
-      enableIndex: true,
-      resourceProvider: overlayResourceProvider,
-      sdkPath: convertPath('/sdk'),
-    );
+  AnalysisContext contextFor(String path) {
+    _createAnalysisContexts();
 
-    var testPath = convertPath('/home/test');
-    _driver = getDriver(testPath);
+    path = convertPath(path);
+    return _analysisContextCollection.contextFor(path);
   }
 
   /// Create an analysis options file based on the given arguments.
@@ -162,9 +137,11 @@
     }
 
     newFile(analysisOptionsPath, content: buffer.toString());
-    if (_driver != null) {
-      createAnalysisContexts();
-    }
+  }
+
+  AnalysisDriver driverFor(String path) {
+    var context = contextFor(path) as DriverBasedAnalysisContext;
+    return context.driver;
   }
 
   /// Return the existing analysis context that should be used to analyze the
@@ -183,26 +160,33 @@
     return context.driver;
   }
 
-  Future<CompilationUnit> resolveLibraryUnit(Source source) async {
-    var resolveResult = await session.getResolvedUnit(source.fullName);
-    return resolveResult.unit;
+  @override
+  File newFile(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);
+  }
+
+  Future<ResolvedUnitResult> resolveFile(String path) async {
+    return contextFor(path).currentSession.getResolvedUnit(path);
   }
 
   @mustCallSuper
   void setUp() {
-    registerLintRules();
+    if (!_lintRulesAreRegistered) {
+      registerLintRules();
+      _lintRulesAreRegistered = true;
+    }
 
     setupResourceProvider();
-    overlayResourceProvider = OverlayResourceProvider(resourceProvider);
 
-    MockSdk(resourceProvider: resourceProvider);
+    MockSdk(
+      resourceProvider: resourceProvider,
+    );
 
-    newFolder('/home/test');
-    newFile('/home/test/.packages', content: '''
-test:${toUriStr('/home/test/lib')}
-''');
-
-    createAnalysisContexts();
+    writeTestPackageConfig();
   }
 
   void setupResourceProvider() {}
@@ -214,7 +198,95 @@
   /// Update `/home/test/pubspec.yaml` and create the driver.
   void updateTestPubspecFile(String content) {
     newFile(testPubspecPath, content: content);
-    createAnalysisContexts();
+  }
+
+  void verifyCreatedCollection() {}
+
+  void writePackageConfig(String path, PackageConfigFileBuilder config) {
+    newFile(path, content: config.toContent(toUriStr: toUriStr));
+  }
+
+  void writeTestPackageConfig({
+    PackageConfigFileBuilder config,
+    String languageVersion,
+    bool flutter = false,
+    bool meta = false,
+    bool vector_math = false,
+  }) {
+    if (config == null) {
+      config = PackageConfigFileBuilder();
+    } else {
+      config = config.copy();
+    }
+
+    config.add(
+      name: 'test',
+      rootPath: testPackageRootPath,
+      languageVersion: languageVersion ?? testPackageLanguageVersion,
+    );
+
+    if (meta || flutter) {
+      var libFolder = MockPackages.instance.addMeta(resourceProvider);
+      config.add(name: 'meta', rootPath: libFolder.parent.path);
+    }
+
+    if (flutter) {
+      {
+        var libFolder = MockPackages.instance.addUI(resourceProvider);
+        config.add(name: 'ui', rootPath: libFolder.parent.path);
+      }
+      {
+        var libFolder = MockPackages.instance.addFlutter(resourceProvider);
+        config.add(name: 'flutter', rootPath: libFolder.parent.path);
+      }
+    }
+
+    if (vector_math) {
+      var libFolder = MockPackages.instance.addVectorMath(resourceProvider);
+      config.add(name: 'vector_math', rootPath: libFolder.parent.path);
+    }
+
+    var path = '$testPackageRootPath/.dart_tool/package_config.json';
+    writePackageConfig(path, config);
+  }
+
+  /// Create all analysis contexts in [collectionIncludedPaths].
+  void _createAnalysisContexts() {
+    if (_analysisContextCollection != null) {
+      return;
+    }
+
+    _analysisContextCollection = AnalysisContextCollectionImpl(
+      byteStore: _byteStore,
+      declaredVariables: _declaredVariables,
+      enableIndex: true,
+      includedPaths: collectionIncludedPaths.map(convertPath).toList(),
+      resourceProvider: resourceProvider,
+      sdkPath: convertPath('/sdk'),
+    );
+
+    verifyCreatedCollection();
+  }
+}
+
+mixin WithNullSafetyMixin on AbstractContextTest {
+  @override
+  String get testPackageLanguageVersion =>
+      Feature.non_nullable.isEnabledByDefault ? '2.12' : '2.11';
+
+  bool get withPackageMeta => false;
+
+  /// TODO(scheglov) https://github.com/dart-lang/sdk/issues/43837
+  /// Remove when Null Safety is enabled by default.
+  @nonVirtual
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      languageVersion: testPackageLanguageVersion,
+      meta: withPackageMeta,
+    );
+    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
   }
 }
 
diff --git a/pkg/analysis_server/test/abstract_single_unit.dart b/pkg/analysis_server/test/abstract_single_unit.dart
index d40c389..7b1c442 100644
--- a/pkg/analysis_server/test/abstract_single_unit.dart
+++ b/pkg/analysis_server/test/abstract_single_unit.dart
@@ -43,6 +43,9 @@
   }
 
   void addTestSource(String code, [Uri uri]) {
+    if (useLineEndingsForPlatform) {
+      code = normalizeNewlinesForPlatform(code);
+    }
     testCode = code;
     testSource = addSource(testFile, code, uri);
   }
@@ -128,10 +131,11 @@
   }
 
   Future<void> resolveTestUnit(String code) async {
-    if (useLineEndingsForPlatform) {
-      code = normalizeNewlinesForPlatform(code);
-    }
     addTestSource(code);
+    await resolveTestUnit2();
+  }
+
+  Future<void> resolveTestUnit2() async {
     testAnalysisResult = await session.getResolvedUnit(testFile);
     testUnit = testAnalysisResult.unit;
     if (verifyNoTestUnitErrors) {
@@ -147,7 +151,7 @@
     }
     testUnitElement = testUnit.declaredElement;
     testLibraryElement = testUnitElement.library;
-    findNode = FindNode(code, testUnit);
+    findNode = FindNode(testCode, testUnit);
   }
 
   @override
diff --git a/pkg/analysis_server/test/analysis/reanalyze_test.dart b/pkg/analysis_server/test/analysis/reanalyze_test.dart
index a5c4aff..358df55 100644
--- a/pkg/analysis_server/test/analysis/reanalyze_test.dart
+++ b/pkg/analysis_server/test/analysis/reanalyze_test.dart
@@ -35,7 +35,7 @@
     newFile(testFile, content: r'''
 import '../../other/b.dart';
 
-B b;
+var b = B();
 ''');
     createProject();
 
diff --git a/pkg/analysis_server/test/client/completion_driver_test.dart b/pkg/analysis_server/test/client/completion_driver_test.dart
index 5ee0b8a..d80900b 100644
--- a/pkg/analysis_server/test/client/completion_driver_test.dart
+++ b/pkg/analysis_server/test/client/completion_driver_test.dart
@@ -351,7 +351,7 @@
 extension Ex on A {}
 mixin M { }
 typedef T = Function(Object);
-int v;
+var v = 0;
 ''');
 
     await addTestFile('''
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index 45b57b3..9b966d2 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -323,7 +323,7 @@
         content: 'pkgA:${toUriStr('/packages/pkgA')}');
     addTestFile('''
 import 'package:pkgA/libA.dart';
-main(A a) {
+void f(A a) {
 }
 ''');
     // create project and wait for analysis
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 07d6afb3..f797e2b 100644
--- a/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_refactor_test.dart
@@ -10,7 +10,6 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
-import '../src/utilities/mock_packages.dart';
 import '../tool/lsp_spec/matchers.dart';
 import 'code_actions_abstract.dart';
 
@@ -304,14 +303,10 @@
   @override
   void setUp() {
     super.setUp();
-
-    final flutterLibFolder = MockPackages.instance.addFlutter(resourceProvider);
-    final metaLibFolder = MockPackages.instance.addMeta(resourceProvider);
-    // Create .packages in the project.
-    newFile(join(projectFolderPath, '.packages'), content: '''
-flutter:${flutterLibFolder.toUri()}
-meta:${metaLibFolder.toUri()}
-''');
+    writePackageConfig(
+      projectFolderPath,
+      flutter: true,
+    );
   }
 
   Future<void> test_appliesCorrectEdits() async {
diff --git a/pkg/analysis_server/test/lsp/completion_test.dart b/pkg/analysis_server/test/lsp/completion_test.dart
index 92789b23..cdecc6f 100644
--- a/pkg/analysis_server/test/lsp/completion_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_test.dart
@@ -768,26 +768,26 @@
 
   Future<void> test_suggestionSets_enumValuesAlreadyImported() async {
     newFile(
-      join(projectFolderPath, 'source_file.dart'),
+      join(projectFolderPath, 'lib', 'source_file.dart'),
       content: '''
       enum MyExportedEnum { One, Two }
       ''',
     );
     newFile(
-      join(projectFolderPath, 'reexport1.dart'),
+      join(projectFolderPath, 'lib', 'reexport1.dart'),
       content: '''
       export 'source_file.dart';
       ''',
     );
     newFile(
-      join(projectFolderPath, 'reexport2.dart'),
+      join(projectFolderPath, 'lib', 'reexport2.dart'),
       content: '''
       export 'source_file.dart';
       ''',
     );
 
     final content = '''
-import '../reexport1.dart';
+import 'reexport1.dart';
 
 main() {
   var a = MyExported^
@@ -812,26 +812,26 @@
 
   Future<void> test_suggestionSets_filtersOutAlreadyImportedSymbols() async {
     newFile(
-      join(projectFolderPath, 'source_file.dart'),
+      join(projectFolderPath, 'lib', 'source_file.dart'),
       content: '''
       class MyExportedClass {}
       ''',
     );
     newFile(
-      join(projectFolderPath, 'reexport1.dart'),
+      join(projectFolderPath, 'lib', 'reexport1.dart'),
       content: '''
       export 'source_file.dart';
       ''',
     );
     newFile(
-      join(projectFolderPath, 'reexport2.dart'),
+      join(projectFolderPath, 'lib', 'reexport2.dart'),
       content: '''
       export 'source_file.dart';
       ''',
     );
 
     final content = '''
-import '../reexport1.dart';
+import 'reexport1.dart';
 
 main() {
   MyExported^
diff --git a/pkg/analysis_server/test/lsp/diagnostic_test.dart b/pkg/analysis_server/test/lsp/diagnostic_test.dart
index 6364bc0..d2555e9 100644
--- a/pkg/analysis_server/test/lsp/diagnostic_test.dart
+++ b/pkg/analysis_server/test/lsp/diagnostic_test.dart
@@ -9,7 +9,6 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
-import '../src/utilities/mock_packages.dart';
 import 'server_abstract.dart';
 
 void main() {
@@ -67,12 +66,6 @@
     expect(related.location.range.end.character, equals(16));
   }
 
-  @override
-  void setUp() {
-    super.setUp();
-    pedanticLibFolder = MockPackages.instance.addPedantic(resourceProvider);
-  }
-
   Future<void> test_afterDocumentEdits() async {
     const initialContents = 'int a = 1;';
     newFile(mainFilePath, content: initialContents);
@@ -105,6 +98,7 @@
     expect(initialDiagnostics.first.code, 'undefined_lint_warning');
   }
 
+  @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/43926')
   Future<void> test_analysisOptionsFile_packageInclude() async {
     newFile(analysisOptionsPath, content: '''
 include: package:pedantic/analysis_options.yaml
@@ -118,15 +112,16 @@
     expect(initialDiagnostics.first.severity, DiagnosticSeverity.Warning);
     expect(initialDiagnostics.first.code, 'include_file_not_found');
 
-    // Write a package file that allows resolving the include.
-    final secondDiagnosticsUpdate = waitForDiagnostics(analysisOptionsUri);
-    newFile('$projectFolderPath/.packages', content: '''
-pedantic:${pedanticLibFolder.toUri()}
-''');
+    // TODO(scheglov) The server does not handle the file change.
+    throw 'Times out';
 
-    // Ensure the error disappeared.
-    final updatedDiagnostics = await secondDiagnosticsUpdate;
-    expect(updatedDiagnostics, hasLength(0));
+    // // Write a package file that allows resolving the include.
+    // final secondDiagnosticsUpdate = waitForDiagnostics(analysisOptionsUri);
+    // writePackageConfig(projectFolderPath, pedantic: true);
+    //
+    // // Ensure the error disappeared.
+    // final updatedDiagnostics = await secondDiagnosticsUpdate;
+    // expect(updatedDiagnostics, hasLength(0));
   }
 
   Future<void> test_contextMessage() async {
diff --git a/pkg/analysis_server/test/lsp/flutter_outline_test.dart b/pkg/analysis_server/test/lsp/flutter_outline_test.dart
index 8a21287..5ece2b69 100644
--- a/pkg/analysis_server/test/lsp/flutter_outline_test.dart
+++ b/pkg/analysis_server/test/lsp/flutter_outline_test.dart
@@ -6,7 +6,6 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
-import '../src/utilities/mock_packages.dart';
 import 'server_abstract.dart';
 
 void main() {
@@ -20,12 +19,7 @@
   @override
   void setUp() {
     super.setUp();
-
-    final flutterLibFolder = MockPackages.instance.addFlutter(resourceProvider);
-    // Create .packages in the project.
-    newFile(join(projectFolderPath, '.packages'), content: '''
-flutter:${flutterLibFolder.toUri()}
-''');
+    writePackageConfig(projectFolderPath, flutter: true);
   }
 
   Future<void> test_afterChange() async {
diff --git a/pkg/analysis_server/test/lsp/hover_test.dart b/pkg/analysis_server/test/lsp/hover_test.dart
index d46f8bb8..de40613 100644
--- a/pkg/analysis_server/test/lsp/hover_test.dart
+++ b/pkg/analysis_server/test/lsp/hover_test.dart
@@ -67,7 +67,7 @@
 ```dart
 String abc
 ```
-*lib/main.dart*
+*package:test/main.dart*
 
 ---
 This is a string.
@@ -182,7 +182,7 @@
 ```dart
 String abc
 ```
-*lib/main.dart*
+*package:test/main.dart*
     '''
         .trim();
 
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index 4ec3477..a21044d 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -17,8 +17,10 @@
 import 'package:analysis_server/src/utilities/mocks.dart';
 import 'package:analyzer/instrumentation/instrumentation.dart';
 import 'package:analyzer/source/line_info.dart';
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/generated/sdk.dart';
 import 'package:analyzer/src/test_utilities/mock_sdk.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
@@ -28,6 +30,7 @@
 import 'package:test/test.dart';
 
 import '../mocks.dart';
+import '../src/utilities/mock_packages.dart';
 
 const dartLanguageId = 'dart';
 
@@ -43,7 +46,8 @@
     with
         ResourceProviderMixin,
         ClientCapabilitiesHelperMixin,
-        LspAnalysisServerTestMixin {
+        LspAnalysisServerTestMixin,
+        ConfigurationFilesMixin {
   MockLspServerChannel channel;
   TestPluginManager pluginManager;
   LspAnalysisServer server;
@@ -143,6 +147,7 @@
     pubspecFileUri = Uri.file(pubspecFilePath);
     analysisOptionsPath = join(projectFolderPath, 'analysis_options.yaml');
     analysisOptionsUri = Uri.file(analysisOptionsPath);
+    writePackageConfig(projectFolderPath);
   }
 
   Future tearDown() async {
@@ -389,6 +394,66 @@
   }
 }
 
+mixin ConfigurationFilesMixin on ResourceProviderMixin {
+  String get latestLanguageVersion =>
+      '${ExperimentStatus.currentVersion.major}.'
+      '${ExperimentStatus.currentVersion.minor}';
+
+  String get testPackageLanguageVersion => '2.9';
+
+  void writePackageConfig(
+    String projectFolderPath, {
+    PackageConfigFileBuilder config,
+    String languageVersion,
+    bool flutter = false,
+    bool meta = false,
+    bool pedantic = false,
+    bool vector_math = false,
+  }) {
+    if (config == null) {
+      config = PackageConfigFileBuilder();
+    } else {
+      config = config.copy();
+    }
+
+    config.add(
+      name: 'test',
+      rootPath: projectFolderPath,
+      languageVersion: languageVersion ?? testPackageLanguageVersion,
+    );
+
+    if (meta || flutter) {
+      var libFolder = MockPackages.instance.addMeta(resourceProvider);
+      config.add(name: 'meta', rootPath: libFolder.parent.path);
+    }
+
+    if (flutter) {
+      {
+        var libFolder = MockPackages.instance.addUI(resourceProvider);
+        config.add(name: 'ui', rootPath: libFolder.parent.path);
+      }
+      {
+        var libFolder = MockPackages.instance.addFlutter(resourceProvider);
+        config.add(name: 'flutter', rootPath: libFolder.parent.path);
+      }
+    }
+
+    if (pedantic) {
+      var libFolder = MockPackages.instance.addPedantic(resourceProvider);
+      config.add(name: 'pedantic', rootPath: libFolder.parent.path);
+    }
+
+    if (vector_math) {
+      var libFolder = MockPackages.instance.addVectorMath(resourceProvider);
+      config.add(name: 'vector_math', rootPath: libFolder.parent.path);
+    }
+
+    var path = '$projectFolderPath/.dart_tool/package_config.json';
+    var content = config.toContent(toUriStr: toUriStr);
+    newFile(path, content: content);
+  }
+}
+
 mixin LspAnalysisServerTestMixin implements ClientCapabilitiesHelperMixin {
   static const positionMarker = '^';
   static const rangeMarkerStart = '[[';
diff --git a/pkg/analysis_server/test/lsp/signature_help_test.dart b/pkg/analysis_server/test/lsp/signature_help_test.dart
index fbac555..64d902d 100644
--- a/pkg/analysis_server/test/lsp/signature_help_test.dart
+++ b/pkg/analysis_server/test/lsp/signature_help_test.dart
@@ -452,6 +452,9 @@
   AnalysisServerOptions get serverOptions =>
       AnalysisServerOptions()..enabledExperiments = ['non-nullable'];
 
+  @override
+  String get testPackageLanguageVersion => latestLanguageVersion;
+
   Future<void> test_params_requiredNamed() async {
     // This test requires support for the "required" keyword.
     final content = '''
diff --git a/pkg/analysis_server/test/plugin/protocol_dart_test.dart b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
index 745d3d3..f00057a 100644
--- a/pkg/analysis_server/test/plugin/protocol_dart_test.dart
+++ b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
@@ -17,7 +17,7 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
-import '../abstract_context.dart';
+import '../abstract_single_unit.dart';
 
 void main() {
   defineReflectiveSuite(() {
@@ -96,7 +96,7 @@
 }
 
 @reflectiveTest
-class ElementTest extends AbstractContextTest {
+class ElementTest extends AbstractSingleUnitTest {
   engine.Element findElementInUnit(engine.CompilationUnit unit, String name,
       [engine.ElementKind kind]) {
     return findElementsByName(unit, name)
@@ -105,13 +105,12 @@
   }
 
   Future<void> test_fromElement_CLASS() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 @deprecated
 abstract class _A {}
 class B<K, V> {}''');
-    var unit = await resolveLibraryUnit(source);
     {
-      engine.ClassElement engineElement = findElementInUnit(unit, '_A');
+      engine.ClassElement engineElement = findElementInUnit(testUnit, '_A');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.CLASS);
@@ -119,7 +118,7 @@
       expect(element.typeParameters, isNull);
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, 27);
         expect(location.length, '_A'.length);
         expect(location.startLine, 2);
@@ -133,7 +132,7 @@
               Element.FLAG_PRIVATE);
     }
     {
-      engine.ClassElement engineElement = findElementInUnit(unit, 'B');
+      engine.ClassElement engineElement = findElementInUnit(testUnit, 'B');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.CLASS);
@@ -144,13 +143,12 @@
   }
 
   Future<void> test_fromElement_CONSTRUCTOR() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 class A {
   const A.myConstructor(int a, [String b]);
 }''');
-    var unit = await resolveLibraryUnit(source);
     engine.ConstructorElement engineElement =
-        findElementInUnit(unit, 'myConstructor');
+        findElementInUnit(testUnit, 'myConstructor');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.CONSTRUCTOR);
@@ -158,7 +156,7 @@
     expect(element.typeParameters, isNull);
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 20);
       expect(location.length, 'myConstructor'.length);
       expect(location.startLine, 2);
@@ -170,16 +168,15 @@
   }
 
   Future<void> test_fromElement_CONSTRUCTOR_required_parameters_1() async {
-    addMetaPackage();
-    var source = addSource('/test.dart', '''
+    writeTestPackageConfig(meta: true);
+    await resolveTestUnit('''
 import 'package:meta/meta.dart';    
 class A {
   const A.myConstructor(int a, {int b, @required int c});
 }''');
 
-    var unit = await resolveLibraryUnit(source);
     engine.ConstructorElement engineElement =
-        findElementInUnit(unit, 'myConstructor');
+        findElementInUnit(testUnit, 'myConstructor');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.parameters, '(int a, {@required int c, int b})');
@@ -187,16 +184,15 @@
 
   /// Verify parameter re-ordering for required params
   Future<void> test_fromElement_CONSTRUCTOR_required_parameters_2() async {
-    addMetaPackage();
-    var source = addSource('/test.dart', '''
+    writeTestPackageConfig(meta: true);
+    await resolveTestUnit('''
 import 'package:meta/meta.dart';    
 class A {
   const A.myConstructor(int a, {int b, @required int d, @required int c});
 }''');
 
-    var unit = await resolveLibraryUnit(source);
     engine.ConstructorElement engineElement =
-        findElementInUnit(unit, 'myConstructor');
+        findElementInUnit(testUnit, 'myConstructor');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.parameters,
@@ -205,16 +201,16 @@
 
   /// Verify parameter re-ordering for required params
   Future<void> test_fromElement_CONSTRUCTOR_required_parameters_3() async {
-    addMetaPackage();
-    var source = addSource('/test.dart', '''
+    writeTestPackageConfig(meta: true);
+    verifyNoTestUnitErrors = false;
+    await resolveTestUnit('''
 import 'package:meta/meta.dart';    
 class A {
   const A.myConstructor(int a, {int b, @required int d, @required int c, int a});
 }''');
 
-    var unit = await resolveLibraryUnit(source);
     engine.ConstructorElement engineElement =
-        findElementInUnit(unit, 'myConstructor');
+        findElementInUnit(testUnit, 'myConstructor');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.parameters,
@@ -234,13 +230,12 @@
   }
 
   Future<void> test_fromElement_ENUM() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 @deprecated
 enum _E1 { one, two }
 enum E2 { three, four }''');
-    var unit = await resolveLibraryUnit(source);
     {
-      engine.ClassElement engineElement = findElementInUnit(unit, '_E1');
+      engine.ClassElement engineElement = findElementInUnit(testUnit, '_E1');
       expect(engineElement.hasDeprecated, isTrue);
       // create notification Element
       var element = convertElement(engineElement);
@@ -249,7 +244,7 @@
       expect(element.typeParameters, isNull);
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, 17);
         expect(location.length, '_E1'.length);
         expect(location.startLine, 2);
@@ -262,7 +257,7 @@
               Element.FLAG_PRIVATE);
     }
     {
-      engine.ClassElement engineElement = findElementInUnit(unit, 'E2');
+      engine.ClassElement engineElement = findElementInUnit(testUnit, 'E2');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.ENUM);
@@ -273,20 +268,19 @@
   }
 
   Future<void> test_fromElement_ENUM_CONSTANT() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 @deprecated
 enum _E1 { one, two }
 enum E2 { three, four }''');
-    var unit = await resolveLibraryUnit(source);
     {
-      engine.FieldElement engineElement = findElementInUnit(unit, 'one');
+      engine.FieldElement engineElement = findElementInUnit(testUnit, 'one');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.ENUM_CONSTANT);
       expect(element.name, 'one');
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, 23);
         expect(location.length, 'one'.length);
         expect(location.startLine, 2);
@@ -303,14 +297,14 @@
           Element.FLAG_CONST | Element.FLAG_STATIC);
     }
     {
-      engine.FieldElement engineElement = findElementInUnit(unit, 'three');
+      engine.FieldElement engineElement = findElementInUnit(testUnit, 'three');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.ENUM_CONSTANT);
       expect(element.name, 'three');
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, 44);
         expect(location.length, 'three'.length);
         expect(location.startLine, 3);
@@ -321,14 +315,14 @@
       expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC);
     }
     {
-      var engineElement = unit.declaredElement.enums[1].getField('index');
+      var engineElement = testUnit.declaredElement.enums[1].getField('index');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.FIELD);
       expect(element.name, 'index');
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, -1);
         expect(location.length, 'index'.length);
         expect(location.startLine, 1);
@@ -339,14 +333,14 @@
       expect(element.flags, Element.FLAG_FINAL);
     }
     {
-      var engineElement = unit.declaredElement.enums[1].getField('values');
+      var engineElement = testUnit.declaredElement.enums[1].getField('values');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.FIELD);
       expect(element.name, 'values');
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, -1);
         expect(location.length, 'values'.length);
         expect(location.startLine, 1);
@@ -359,19 +353,18 @@
   }
 
   Future<void> test_fromElement_FIELD() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 class A {
   static const myField = 42;
 }''');
-    var unit = await resolveLibraryUnit(source);
-    engine.FieldElement engineElement = findElementInUnit(unit, 'myField');
+    engine.FieldElement engineElement = findElementInUnit(testUnit, 'myField');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.FIELD);
     expect(element.name, 'myField');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 25);
       expect(location.length, 'myField'.length);
       expect(location.startLine, 2);
@@ -383,12 +376,11 @@
   }
 
   Future<void> test_fromElement_FUNCTION_TYPE_ALIAS() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 typedef int F<T>(String x);
 ''');
-    var unit = await resolveLibraryUnit(source);
     engine.FunctionTypeAliasElement engineElement =
-        findElementInUnit(unit, 'F');
+        findElementInUnit(testUnit, 'F');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS);
@@ -396,7 +388,7 @@
     expect(element.typeParameters, '<T>');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 12);
       expect(location.length, 'F'.length);
       expect(location.startLine, 1);
@@ -408,12 +400,11 @@
   }
 
   Future<void> test_fromElement_FUNCTION_TYPE_ALIAS_genericTypeAlias() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 typedef F<T> = int Function(String x);
 ''');
-    var unit = await resolveLibraryUnit(source);
     engine.FunctionTypeAliasElement engineElement =
-        findElementInUnit(unit, 'F');
+        findElementInUnit(testUnit, 'F');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS);
@@ -421,7 +412,7 @@
     expect(element.typeParameters, '<T>');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 8);
       expect(location.length, 'F'.length);
       expect(location.startLine, 1);
@@ -433,20 +424,20 @@
   }
 
   Future<void> test_fromElement_GETTER() async {
-    var source = addSource('/test.dart', '''
+    verifyNoTestUnitErrors = false;
+    await resolveTestUnit('''
 class A {
   String get myGetter => 42;
 }''');
-    var unit = await resolveLibraryUnit(source);
     engine.PropertyAccessorElement engineElement =
-        findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER);
+        findElementInUnit(testUnit, 'myGetter', engine.ElementKind.GETTER);
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.GETTER);
     expect(element.name, 'myGetter');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 23);
       expect(location.length, 'myGetter'.length);
       expect(location.startLine, 2);
@@ -458,22 +449,21 @@
   }
 
   Future<void> test_fromElement_LABEL() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 main() {
 myLabel:
   while (true) {
     break myLabel;
   }
 }''');
-    var unit = await resolveLibraryUnit(source);
-    engine.LabelElement engineElement = findElementInUnit(unit, 'myLabel');
+    engine.LabelElement engineElement = findElementInUnit(testUnit, 'myLabel');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.LABEL);
     expect(element.name, 'myLabel');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 9);
       expect(location.length, 'myLabel'.length);
       expect(location.startLine, 2);
@@ -485,21 +475,21 @@
   }
 
   Future<void> test_fromElement_METHOD() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 class A {
   static List<String> myMethod(int a, {String b, int c}) {
     return null;
   }
 }''');
-    var unit = await resolveLibraryUnit(source);
-    engine.MethodElement engineElement = findElementInUnit(unit, 'myMethod');
+    engine.MethodElement engineElement =
+        findElementInUnit(testUnit, 'myMethod');
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.METHOD);
     expect(element.name, 'myMethod');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 32);
       expect(location.length, 'myGetter'.length);
       expect(location.startLine, 2);
@@ -511,12 +501,11 @@
   }
 
   Future<void> test_fromElement_MIXIN() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 mixin A {}
 ''');
-    var unit = await resolveLibraryUnit(source);
     {
-      engine.ClassElement engineElement = findElementInUnit(unit, 'A');
+      engine.ClassElement engineElement = findElementInUnit(testUnit, 'A');
       // create notification Element
       var element = convertElement(engineElement);
       expect(element.kind, ElementKind.MIXIN);
@@ -524,7 +513,7 @@
       expect(element.typeParameters, isNull);
       {
         var location = element.location;
-        expect(location.file, convertPath('/test.dart'));
+        expect(location.file, testFile);
         expect(location.offset, 6);
         expect(location.length, 'A'.length);
         expect(location.startLine, 1);
@@ -536,20 +525,19 @@
   }
 
   Future<void> test_fromElement_SETTER() async {
-    var source = addSource('/test.dart', '''
+    await resolveTestUnit('''
 class A {
   set mySetter(String x) {}
 }''');
-    var unit = await resolveLibraryUnit(source);
     engine.PropertyAccessorElement engineElement =
-        findElementInUnit(unit, 'mySetter', engine.ElementKind.SETTER);
+        findElementInUnit(testUnit, 'mySetter', engine.ElementKind.SETTER);
     // create notification Element
     var element = convertElement(engineElement);
     expect(element.kind, ElementKind.SETTER);
     expect(element.name, 'mySetter');
     {
       var location = element.location;
-      expect(location.file, convertPath('/test.dart'));
+      expect(location.file, testFile);
       expect(location.offset, 16);
       expect(location.length, 'mySetter'.length);
       expect(location.startLine, 2);
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 197842e..f91b4f7 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
@@ -9,16 +9,17 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../abstract_context.dart';
 import 'completion_contributor_util.dart';
 
 void main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ArgListContributorTest);
+    defineReflectiveTests(ArgListContributorWithNullSafetyTest);
   });
 }
 
-@reflectiveTest
-class ArgListContributorTest extends DartCompletionContributorTest {
+mixin ArgListContributorMixin on DartCompletionContributorTest {
   void assertNoOtherSuggestions(Iterable<CompletionSuggestion> expected) {
     for (var suggestion in suggestions) {
       if (!expected.contains(suggestion)) {
@@ -111,7 +112,11 @@
   DartCompletionContributor createContributor() {
     return ArgListContributor();
   }
+}
 
+@reflectiveTest
+class ArgListContributorTest extends DartCompletionContributorTest
+    with ArgListContributorMixin {
   Future<void> test_Annotation_imported_constructor_named_param() async {
     addSource('/home/test/lib/a.dart', '''
 library libA; class A { const A({int one, String two: 'defaultValue'}); }''');
@@ -380,7 +385,7 @@
   }
 
   Future<void> test_ArgumentList_Flutter_InstanceCreationExpression_0() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/widgets.dart';
@@ -400,7 +405,7 @@
   }
 
   Future<void> test_ArgumentList_Flutter_InstanceCreationExpression_01() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -421,7 +426,7 @@
   }
 
   Future<void> test_ArgumentList_Flutter_InstanceCreationExpression_1() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -442,7 +447,7 @@
   }
 
   Future<void> test_ArgumentList_Flutter_InstanceCreationExpression_2() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -466,7 +471,7 @@
       test_ArgumentList_Flutter_InstanceCreationExpression_children_dynamic() async {
     // Ensure we don't generate unneeded <dynamic> param if a future API doesn't
     // type it's children.
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -492,7 +497,7 @@
   Future<void>
       test_ArgumentList_Flutter_InstanceCreationExpression_children_Map() async {
     // Ensure we don't generate Map params for a future API
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -516,7 +521,7 @@
 
   Future<void>
       test_ArgumentList_Flutter_InstanceCreationExpression_slivers() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -544,7 +549,7 @@
     // TODO(brianwilkerson) This test has been changed so that it no longer has
     // anything to do with Flutter (by moving the declaration of `foo` out of
     // the 'material' library). Determine whether the test is still valid.
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
 
     addTestSource('''
 import 'package:flutter/material.dart';
@@ -964,7 +969,7 @@
   }
 
   Future<void> test_ArgumentList_local_constructor_required_param_0() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 class A { A({int one, @required String two: 'defaultValue'}) { } }
@@ -1078,8 +1083,27 @@
     assertNoSuggestions();
   }
 
+  Future<void> test_superConstructorInvocation() async {
+    addTestSource('''
+class A {
+  final bool field1;
+  final int field2;
+  A({this.field1, this.field2});
+}
+class B extends A {
+  B() : super(^);
+}
+''');
+    await computeSuggestions();
+    assertSuggestArgumentsAndTypes(
+        namedArgumentsWithTypes: {'field1': 'bool', 'field2': 'int'});
+  }
+}
+
+@reflectiveTest
+class ArgListContributorWithNullSafetyTest extends DartCompletionContributorTest
+    with WithNullSafetyMixin, ArgListContributorMixin {
   Future<void> test_ArgumentList_nnbd_function_named_param() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     addTestSource(r'''
 f({int? nullable, int nonnullable}) {}
 main() { f(^);}');
@@ -1092,7 +1116,6 @@
   }
 
   Future<void> test_ArgumentList_nnbd_function_named_param_imported() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     addSource('/home/test/lib/a.dart', '''
 f({int? nullable, int nonnullable}) {}''');
     createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
@@ -1108,7 +1131,6 @@
   }
 
   Future<void> test_ArgumentList_nnbd_function_named_param_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     addSource('/home/test/lib/a.dart', '''
 // @dart = 2.8
 f({int named}) {}''');
@@ -1121,20 +1143,4 @@
       'named': 'int*',
     });
   }
-
-  Future<void> test_superConstructorInvocation() async {
-    addTestSource('''
-class A {
-  final bool field1;
-  final int field2;
-  A({this.field1, this.field2});
-}
-class B extends A {
-  B() : super(^);
-}
-''');
-    await computeSuggestions();
-    assertSuggestArgumentsAndTypes(
-        namedArgumentsWithTypes: {'field1': 'bool', 'field2': 'int'});
-  }
 }
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
index d326ca1..8e22c6a 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_contributor_util.dart
@@ -11,6 +11,7 @@
     show DartCompletionRequestImpl;
 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
 import 'package:analysis_server/src/services/completion/dart/utilities.dart';
+import 'package:analyzer/dart/analysis/results.dart';
 import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
 import 'package:analyzer/src/generated/parser.dart' as analyzer;
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -75,6 +76,8 @@
   int replacementOffset;
   int replacementLength;
 
+  ResolvedUnitResult result;
+
   /// The Dartdoc information passed to requests.
   final DartdocDirectiveInfo dartdocInfo = DartdocDirectiveInfo();
 
@@ -547,9 +550,9 @@
       DartCompletionRequest request);
 
   Future computeSuggestions({int times = 200}) async {
-    var resolveResult = await session.getResolvedUnit(testFile);
-    var baseRequest = CompletionRequestImpl(resolveResult, completionOffset,
-        useNewRelevance, CompletionPerformance());
+    result = await session.getResolvedUnit(testFile);
+    var baseRequest = CompletionRequestImpl(
+        result, completionOffset, useNewRelevance, CompletionPerformance());
 
     return await baseRequest.performance.runRequestOperation(
       (performance) async {
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 c77e7ce..5a3825d 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
@@ -30,7 +30,7 @@
   }
 
   Future<void> test_resolveDirectives() async {
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
 library libA;
 /// My class.
 /// Short description.
@@ -38,13 +38,15 @@
 /// Longer description.
 class A {}
 ''');
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
 library libB;
 import "a.dart" as foo;
 part 'test.dart';
 ''');
     addTestSource('part of libB; main() {^}');
 
+    await resolveFile('$testPackageLibPath/b.dart');
+
     // Build the request
     var baseRequest = CompletionRequestImpl(
         await session.getResolvedUnit(testFile),
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 1ae4849..610dded 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
@@ -9,16 +9,17 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../abstract_context.dart';
 import 'completion_contributor_util.dart';
 
 void main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(ImportedReferenceContributorTest);
+    defineReflectiveTests(ImportedReferenceContributorWithNullSafetyTest);
   });
 }
 
-@reflectiveTest
-class ImportedReferenceContributorTest extends DartCompletionContributorTest {
+mixin ImportedReferenceContributorMixin on DartCompletionContributorTest {
   @override
   bool get isNullExpectedReturnTypeConsideredDynamic => false;
 
@@ -26,10 +27,14 @@
   DartCompletionContributor createContributor() {
     return ImportedReferenceContributor();
   }
+}
 
+@reflectiveTest
+class ImportedReferenceContributorTest extends DartCompletionContributorTest
+    with ImportedReferenceContributorMixin {
   /// Sanity check.  Permutations tested in local_ref_contributor.
   Future<void> test_ArgDefaults_function_with_required_named() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
 
     resolveSource('/home/test/lib/b.dart', '''
 lib B;
@@ -1192,7 +1197,8 @@
   }
 
   Future<void> test_Block_unimported() async {
-    addPackageFile('aaa', 'a.dart', 'class A {}');
+    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
+
     addTestSource('main() { ^ }');
 
     await computeSuggestions();
@@ -2303,69 +2309,6 @@
     expect(suggestion.hasNamedParameters, true);
   }
 
-  Future<void> test_function_parameters_nnbd_required() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    resolveSource('/home/test/lib/a.dart', '''
-void m(int? nullable, int nonNullable) {}
-''');
-    addTestSource('''
-import 'a.dart';
-
-main() {^}
-''');
-    await computeSuggestions();
-    var suggestion = assertSuggestFunction('m', 'void');
-    expect(suggestion.parameterNames, hasLength(2));
-    expect(suggestion.parameterNames[0], 'nullable');
-    expect(suggestion.parameterTypes[0], 'int?');
-    expect(suggestion.parameterNames[1], 'nonNullable');
-    expect(suggestion.parameterTypes[1], 'int');
-    expect(suggestion.requiredParameterCount, 2);
-    expect(suggestion.hasNamedParameters, false);
-  }
-
-  Future<void> test_function_parameters_nnbd_required_into_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    resolveSource('/home/test/lib/a.dart', '''
-void m(int? nullable, int nonNullable) {}
-''');
-    addTestSource('''
-// @dart = 2.8
-import 'a.dart';
-
-main() {^}
-''');
-    await computeSuggestions();
-    var suggestion = assertSuggestFunction('m', 'void');
-    expect(suggestion.parameterNames, hasLength(2));
-    expect(suggestion.parameterNames[0], 'nullable');
-    expect(suggestion.parameterTypes[0], 'int');
-    expect(suggestion.parameterNames[1], 'nonNullable');
-    expect(suggestion.parameterTypes[1], 'int');
-    expect(suggestion.requiredParameterCount, 2);
-    expect(suggestion.hasNamedParameters, false);
-  }
-
-  Future<void> test_function_parameters_nnbd_required_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    resolveSource('/home/test/lib/a.dart', '''
-// @dart = 2.8
-void m(int param) {}
-''');
-    addTestSource('''
-import 'a.dart';
-
-main() {^}
-''');
-    await computeSuggestions();
-    var suggestion = assertSuggestFunction('m', 'void');
-    expect(suggestion.parameterNames, hasLength(1));
-    expect(suggestion.parameterNames[0], 'param');
-    expect(suggestion.parameterTypes[0], 'int*');
-    expect(suggestion.requiredParameterCount, 1);
-    expect(suggestion.hasNamedParameters, false);
-  }
-
   Future<void> test_function_parameters_none() async {
     resolveSource('/home/test/lib/a.dart', '''
 void m() {}
@@ -3776,12 +3719,12 @@
 
   Future<void> test_partFile_TypeName() async {
     // SimpleIdentifier  TypeName  ConstructorName
-    addSource('/home/test/lib/b.dart', '''
+    addSource('$testPackageLibPath/b.dart', '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    addSource('$testPackageLibPath/a.dart', '''
         library libA;
         import 'b.dart';
         part "test.dart";
@@ -3792,6 +3735,8 @@
         class B { B.bar(int x); }
         main() {new ^}''');
 
+    await resolveFile('$testPackageLibPath/a.dart');
+
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
     expect(replacementLength, 0);
@@ -4755,3 +4700,71 @@
     assertSuggestClass('Object');
   }
 }
+
+@reflectiveTest
+class ImportedReferenceContributorWithNullSafetyTest
+    extends DartCompletionContributorTest
+    with WithNullSafetyMixin, ImportedReferenceContributorMixin {
+  Future<void> test_function_parameters_nnbd_required() async {
+    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+    resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+    addTestSource('''
+import 'a.dart';
+
+main() {^}
+''');
+    await computeSuggestions();
+    var suggestion = assertSuggestFunction('m', 'void');
+    expect(suggestion.parameterNames, hasLength(2));
+    expect(suggestion.parameterNames[0], 'nullable');
+    expect(suggestion.parameterTypes[0], 'int?');
+    expect(suggestion.parameterNames[1], 'nonNullable');
+    expect(suggestion.parameterTypes[1], 'int');
+    expect(suggestion.requiredParameterCount, 2);
+    expect(suggestion.hasNamedParameters, false);
+  }
+
+  Future<void> test_function_parameters_nnbd_required_into_legacy() async {
+    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+    resolveSource('/home/test/lib/a.dart', '''
+void m(int? nullable, int nonNullable) {}
+''');
+    addTestSource('''
+// @dart = 2.8
+import 'a.dart';
+
+main() {^}
+''');
+    await computeSuggestions();
+    var suggestion = assertSuggestFunction('m', 'void');
+    expect(suggestion.parameterNames, hasLength(2));
+    expect(suggestion.parameterNames[0], 'nullable');
+    expect(suggestion.parameterTypes[0], 'int');
+    expect(suggestion.parameterNames[1], 'nonNullable');
+    expect(suggestion.parameterTypes[1], 'int');
+    expect(suggestion.requiredParameterCount, 2);
+    expect(suggestion.hasNamedParameters, false);
+  }
+
+  Future<void> test_function_parameters_nnbd_required_legacy() async {
+    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
+    resolveSource('/home/test/lib/a.dart', '''
+// @dart = 2.8
+void m(int param) {}
+''');
+    addTestSource('''
+import 'a.dart';
+
+main() {^}
+''');
+    await computeSuggestions();
+    var suggestion = assertSuggestFunction('m', 'void');
+    expect(suggestion.parameterNames, hasLength(1));
+    expect(suggestion.parameterNames[0], 'param');
+    expect(suggestion.parameterTypes[0], 'int*');
+    expect(suggestion.requiredParameterCount, 1);
+    expect(suggestion.hasNamedParameters, false);
+  }
+}
diff --git a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
index 9f3adc4..f5f9774 100644
--- a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
@@ -11,6 +11,7 @@
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../abstract_context.dart';
 import 'completion_contributor_util.dart';
 
 void main() {
@@ -457,7 +458,7 @@
 
   /// Return `true` if the given [feature] is enabled.
   bool isEnabled(Feature feature) =>
-      driver.analysisOptions.contextFeatures.isEnabled(feature);
+      result.libraryElement.featureSet.isEnabled(feature);
 
   Future<void> test_after_class_noPrefix() async {
     addTestSource('class A {} ^');
@@ -2267,10 +2268,5 @@
 }
 
 @reflectiveTest
-class KeywordContributorWithNullSafetyTest extends KeywordContributorTest {
-  @override
-  void setupResourceProvider() {
-    super.setupResourceProvider();
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-  }
-}
+class KeywordContributorWithNullSafetyTest extends KeywordContributorTest
+    with WithNullSafetyMixin {}
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 1f1a333..95a7d99 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
@@ -99,11 +99,12 @@
 
   Future<void> test_libraryPrefix_deferred_inPart() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         library testA;
         import "dart:async" deferred as bar;
         part "test.dart";''');
     addTestSource('part of testA; foo() {bar.^}');
+    await resolveFile('$testPackageLibPath/a.dart');
     // Assume that libraries containing has been computed for part files
     await computeSuggestions();
     assertSuggestClass('Future');
@@ -112,8 +113,8 @@
   }
 
   Future<void> test_libraryPrefix_with_exports() async {
-    addSource('/home/test/lib/a.dart', 'library libA; class A { }');
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: 'library libA; class A { }');
+    newFile('$testPackageLibPath/b.dart', content: '''
         library libB;
         export "a.dart";
         class B { }
@@ -188,12 +189,12 @@
 
   Future<void> test_PrefixedIdentifier_library_inPart() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         var T1;
         class X { }
         class Y { }''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         library testA;
         import "b.dart" as b;
         part "test.dart";
@@ -202,6 +203,7 @@
     addTestSource('''
         part of testA;
         main() {b.^}''');
+    await resolveFile('$testPackageLibPath/a.dart');
     // Assume that libraries containing has been computed for part files
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
@@ -218,7 +220,7 @@
 
   Future<void> test_PrefixedIdentifier_library_typesOnly() async {
     // SimpleIdentifier  PrefixedIdentifier  TypeName
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         var T1;
         class X { }
@@ -243,7 +245,7 @@
 
   Future<void> test_PrefixedIdentifier_library_typesOnly2() async {
     // SimpleIdentifier  PrefixedIdentifier  TypeName
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         var T1;
         class X { }
@@ -268,7 +270,7 @@
 
   Future<void> test_PrefixedIdentifier_parameter() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         class _W {M y; var _z;}
         class X extends _W {}
@@ -282,7 +284,7 @@
 
   Future<void> test_PrefixedIdentifier_prefix() async {
     // SimpleIdentifier  PrefixedIdentifier  ExpressionStatement
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         class A {static int bar = 10;}
         _B() {}''');
     addTestSource('''
diff --git a/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
index 0cdcb90..e6e9ec2 100644
--- a/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/library_prefix_contributor_test.dart
@@ -303,6 +303,7 @@
     addTestSource('''
 part of testB;
 main() {new ^ String x = "hello";}''');
+    await analyzeTestPackageFiles();
     await computeSuggestions();
     assertSuggestLibraryPrefixes(['math', 't']);
   }
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 e6724b6..08f9a72 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
@@ -24,12 +24,12 @@
 
   Future<void> test_partFile_Constructor() async {
     // SimpleIdentifier  TypeName  ConstructorName
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         library libA;
         import "b.dart";
         part "test.dart";
@@ -39,6 +39,7 @@
         part of libA;
         class B { B.bar(int x); }
         main() {new ^}''');
+    await resolveFile('$testPackageLibPath/a.dart');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
     expect(replacementLength, 0);
@@ -58,12 +59,12 @@
 
   Future<void> test_partFile_Constructor2() async {
     // SimpleIdentifier  TypeName  ConstructorName
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         part of libA;
         class B { }''');
     addTestSource('''
@@ -91,7 +92,7 @@
   }
 
   Future<void> test_partFile_extension() async {
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
 part of libA;
 extension E on int {}
 ''');
@@ -109,12 +110,12 @@
   Future<void>
       test_partFile_InstanceCreationExpression_assignment_filter() async {
     // ConstructorName  InstanceCreationExpression  VariableDeclarationList
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         part of libA;
         class A {} class B extends A {} class C implements A {} class D {}
         ''');
@@ -156,12 +157,12 @@
   Future<void>
       test_partFile_InstanceCreationExpression_variable_declaration_filter() async {
     // ConstructorName  InstanceCreationExpression  VariableDeclarationList
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         part of libA;
         class A {} class B extends A {} class C implements A {} class D {}
         ''');
@@ -199,12 +200,12 @@
   }
 
   Future<void> test_partFile_TypeName() async {
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         library libA;
         import "b.dart";
         part "test.dart";
@@ -216,6 +217,7 @@
         part of libA;
         class B { B.bar(int x); }
         main() {^}''');
+    await resolveFile('$testPackageLibPath/a.dart');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
     expect(replacementLength, 0);
@@ -241,12 +243,12 @@
   }
 
   Future<void> test_partFile_TypeName2() async {
-    addSource('/home/test/lib/b.dart', '''
+    newFile('$testPackageLibPath/b.dart', content: '''
         lib B;
         int T1;
         F1() { }
         class X {X.c(); X._d(); z() {}}''');
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
         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 bb0f9a8..e0268de 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
@@ -48,7 +48,7 @@
   }
 
   Future<void> test_ArgDefaults_function_with_optional_positional() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -61,7 +61,7 @@
   }
 
   Future<void> test_ArgDefaults_function_with_required_named() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -75,7 +75,7 @@
   }
 
   Future<void> test_ArgDefaults_inherited_method_with_required_named() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     resolveSource('/home/test/lib/b.dart', '''
 import 'package:meta/meta.dart';
 
@@ -96,7 +96,7 @@
   }
 
   Future<void> test_ArgDefaults_method_with_required_named() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -1498,7 +1498,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    addPackageFile('aaa', 'a.dart', 'class A {}');
+    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
     addTestSource('main() { ^ }');
 
     await computeSuggestions();
@@ -3995,7 +3995,7 @@
   }
 
   Future<void> test_localConstructor() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -4010,14 +4010,14 @@
   }
 
   Future<void> test_localConstructor2() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''class A {A.named();} main() {^}}''');
     await computeSuggestions();
     assertSuggestConstructor('A.named');
   }
 
   Future<void> test_localConstructor_abstract() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 abstract class A {
   A();
@@ -4030,14 +4030,14 @@
   }
 
   Future<void> test_localConstructor_defaultConstructor() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''class A {} main() {^}}''');
     await computeSuggestions();
     assertSuggestConstructor('A');
   }
 
   Future<void> test_localConstructor_factory() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 abstract class A {
   factory A();
@@ -4050,7 +4050,7 @@
   }
 
   Future<void> test_localConstructor_optionalNew() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -6047,7 +6047,7 @@
 
   Future<void> _check_flutter_setState(
       String line, String completion, int selectionOffset) async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     addTestSource('''
 import 'package:flutter/widgets.dart';
 
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 7edebfc..34832e9 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
@@ -171,6 +171,7 @@
 }
 ''');
     // assume information for context.getLibrariesContaining has been cached
+    await resolveFile('$testPackageLibPath/myLib.dart');
     await computeSuggestions();
     _assertOverride('''
 @override
@@ -405,7 +406,7 @@
   }
 
   Future<void> test_private_otherLibrary() async {
-    addSource('/home/test/lib/a.dart', '''
+    newFile('$testPackageLibPath/a.dart', content: '''
 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 ba212b20..f1fd8f5 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
@@ -78,7 +78,7 @@
   }
 
   Future<void> test_ArgDefaults_method_with_optional_positional() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -93,7 +93,7 @@
   }
 
   Future<void> test_ArgDefaults_method_with_required_named() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     addTestSource('''
 import 'package:meta/meta.dart';
 
@@ -1075,7 +1075,7 @@
   }
 
   Future<void> test_Block_unimported() async {
-    addPackageFile('aaa', 'a.dart', 'class A {}');
+    newFile('$testPackageLibPath/a.dart', content: 'class A {}');
     addTestSource('main() { ^ }');
 
     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 cf86d79..3d4a399 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
@@ -5,6 +5,7 @@
 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
 import 'package:analysis_server/src/services/completion/dart/uri_contributor.dart';
 import 'package:analyzer/file_system/memory_file_system.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:path/path.dart';
 import 'package:test/test.dart';
@@ -21,6 +22,8 @@
 
 @reflectiveTest
 class UriContributorTest extends DartCompletionContributorTest {
+  String get testPackageTestPath => '$testPackageRootPath/test';
+
   @override
   DartCompletionContributor createContributor() {
     return UriContributor();
@@ -67,9 +70,18 @@
   }
 
   Future<void> test_export_package2() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    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;');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('export "package:foo/baz/^" import');
     await computeSuggestions();
     assertSuggest('package:foo/baz/too.dart',
@@ -79,9 +91,19 @@
   Future<void> test_export_package2_off() async {
     try {
       UriContributor.suggestFilePaths = false;
-      addPackageFile('foo', 'foo.dart', 'library foo;');
-      addPackageFile('foo', 'baz/too.dart', 'library too;');
-      addPackageFile('bar', 'bar.dart', 'library bar;');
+
+      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;');
+
+      writeTestPackageConfig(
+        config: PackageConfigFileBuilder()
+          ..add(name: 'foo', rootPath: fooRootPath)
+          ..add(name: 'bar', rootPath: barRootPath),
+      );
+
       addTestSource('export "package:foo/baz/^" import');
       await computeSuggestions();
       assertNotSuggested('package:foo/baz/too.dart');
@@ -142,10 +164,11 @@
   }
 
   Future<void> test_import_file() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
@@ -159,10 +182,11 @@
   }
 
   Future<void> test_import_file2() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "..^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 2);
@@ -178,10 +202,12 @@
   Future<void> test_import_file2_off() async {
     try {
       UriContributor.suggestFilePaths = false;
-      testFile = convertPath('/proj/completion.dart');
-      addSource('/proj/other.dart', 'library other;');
-      addSource('/proj/foo/bar.dart', 'library bar;');
-      addSource('/blat.dart', 'library blat;');
+
+      testFile = convertPath('$testPackageRootPath/test.dart');
+      newFile('$testPackageRootPath/other.dart');
+      newFile('$testPackageRootPath/foo/bar.dart');
+      newFile('$workspaceRootPath/blat.dart');
+
       addTestSource('import "..^" import');
       await computeSuggestions();
       expect(replacementOffset, completionOffset - 2);
@@ -198,10 +224,11 @@
   }
 
   Future<void> test_import_file_child() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "foo/^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -215,11 +242,11 @@
   }
 
   Future<void> test_import_file_outside_lib() async {
-    testFile = convertPath('/proj/lib/completion.dart');
-    addSource('/proj/lib/other.dart', 'library other;');
-    addSource('/proj/lib/foo/bar.dart', 'library bar;');
-    addSource('/proj/blat.dart', 'library blat;');
-    addSource('/proj/bin/boo.dart', 'library boo;');
+    newFile('$testPackageLibPath/other.dart');
+    newFile('$testPackageLibPath/foo/bar.dart');
+    newFile('$testPackageRootPath/blat.dart');
+    newFile('$testPackageRootPath/bin/boo.dart');
+
     addTestSource('import "../^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 3);
@@ -235,11 +262,12 @@
   }
 
   Future<void> test_import_file_parent() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
-    addSource('/proj2/boo.dart', 'library boo;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+    newFile('$workspaceRootPath/aaa/boo.dart');
+
     addTestSource('import "../^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 3);
@@ -250,14 +278,15 @@
     assertNotSuggested('foo/');
     assertNotSuggested('foo/bar.dart');
     assertSuggest('../blat.dart', csKind: CompletionSuggestionKind.IMPORT);
-    assertSuggest('../proj2/', csKind: CompletionSuggestionKind.IMPORT);
+    assertSuggest('../aaa/', csKind: CompletionSuggestionKind.IMPORT);
   }
 
   Future<void> test_import_file_parent2() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "../b^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -271,27 +300,37 @@
   }
 
   Future<void> test_import_no_dot_folders() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    newFolder('/proj/.fooFolder');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFolder('$testPackageRootPath/.foo');
+
     addTestSource('import "package:^";');
     await computeSuggestions();
-    assertNotSuggested('.fooFolder/');
+    assertNotSuggested('.foo/');
   }
 
   Future<void> test_import_only_dart_files() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    newFile('/proj/analysis_options.yaml', content: '# analysis options');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/analysis_options.yaml');
+
     addTestSource('import "package:^";');
     await computeSuggestions();
     assertNotSuggested('analysis_options.yaml');
   }
 
   Future<void> test_import_package() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    var fooRootPath = '$workspaceRootPath/foo';
+    var barRootPath = '$workspaceRootPath/bar';
+    newFile('$fooRootPath/lib/foo.dart');
+    newFile('$fooRootPath/lib/baz/too.dart');
+    newFile('$barRootPath/lib/bar.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import "p^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 1);
@@ -308,9 +347,18 @@
   }
 
   Future<void> test_import_package2() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    var fooRootPath = '$workspaceRootPath/foo';
+    var barRootPath = '$workspaceRootPath/bar';
+    newFile('$fooRootPath/lib/foo.dart');
+    newFile('$fooRootPath/lib/baz/too.dart');
+    newFile('$barRootPath/lib/bar.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import "package:foo/baz/^" import');
     await computeSuggestions();
     assertSuggest('package:foo/baz/too.dart',
@@ -320,9 +368,19 @@
   Future<void> test_import_package2_off() async {
     try {
       UriContributor.suggestFilePaths = false;
-      addPackageFile('foo', 'foo.dart', 'library foo;');
-      addPackageFile('foo', 'baz/too.dart', 'library too;');
-      addPackageFile('bar', 'bar.dart', 'library bar;');
+
+      var fooRootPath = '$workspaceRootPath/foo';
+      var barRootPath = '$workspaceRootPath/bar';
+      newFile('$fooRootPath/lib/foo.dart');
+      newFile('$fooRootPath/lib/baz/too.dart');
+      newFile('$barRootPath/lib/bar.dart');
+
+      writeTestPackageConfig(
+        config: PackageConfigFileBuilder()
+          ..add(name: 'foo', rootPath: fooRootPath)
+          ..add(name: 'bar', rootPath: barRootPath),
+      );
+
       addTestSource('import "package:foo/baz/^" import');
       await computeSuggestions();
       assertNotSuggested('package:foo/baz/too.dart');
@@ -332,9 +390,18 @@
   }
 
   Future<void> test_import_package2_raw() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    var fooRootPath = '$workspaceRootPath/foo';
+    var barRootPath = '$workspaceRootPath/bar';
+    newFile('$fooRootPath/lib/foo.dart');
+    newFile('$fooRootPath/lib/baz/too.dart');
+    newFile('$barRootPath/lib/bar.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import r"package:foo/baz/^" import');
     await computeSuggestions();
     assertSuggest('package:foo/baz/too.dart',
@@ -342,9 +409,18 @@
   }
 
   Future<void> test_import_package2_with_trailing() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    var fooRootPath = '$workspaceRootPath/foo';
+    var barRootPath = '$workspaceRootPath/bar';
+    newFile('$fooRootPath/lib/foo.dart');
+    newFile('$fooRootPath/lib/baz/too.dart');
+    newFile('$barRootPath/lib/bar.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import "package:foo/baz/^.dart" import');
     await computeSuggestions();
     assertSuggest('package:foo/baz/too.dart',
@@ -354,8 +430,12 @@
   }
 
   Future<void> test_import_package_missing_lib() async {
-    var pkgFile = addPackageFile('bar', 'bar.dart', 'library bar;');
-    deleteFolder(pkgFile.parent.path);
+    var barRootPath = '$workspaceRootPath/bar';
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import "p^" class');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 1);
@@ -366,9 +446,18 @@
   }
 
   Future<void> test_import_package_raw() async {
-    addPackageFile('foo', 'foo.dart', 'library foo;');
-    addPackageFile('foo', 'baz/too.dart', 'library too;');
-    addPackageFile('bar', 'bar.dart', 'library bar;');
+    var fooRootPath = '$workspaceRootPath/foo';
+    var barRootPath = '$workspaceRootPath/bar';
+    newFile('$fooRootPath/lib/foo.dart');
+    newFile('$fooRootPath/lib/baz/too.dart');
+    newFile('$barRootPath/lib/bar.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: fooRootPath)
+        ..add(name: 'bar', rootPath: barRootPath),
+    );
+
     addTestSource('import r"p^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 1);
@@ -458,10 +547,11 @@
   }
 
   Future<void> test_part_file() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
@@ -475,10 +565,11 @@
   }
 
   Future<void> test_part_file2() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "..^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 2);
@@ -492,10 +583,11 @@
   }
 
   Future<void> test_part_file_child() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "foo/^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -509,10 +601,11 @@
   }
 
   Future<void> test_part_file_parent() async {
-    testFile = convertPath('/proj/completion.dart');
-    addSource('/proj/other.dart', 'library other;');
-    addSource('/proj/foo/bar.dart', 'library bar;');
-    addSource('/blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "../^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 3);
@@ -539,10 +632,11 @@
   }
 
   Future<void> test_import_file() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
@@ -556,10 +650,11 @@
   }
 
   Future<void> test_import_file2() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "..^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 2);
@@ -573,10 +668,11 @@
   }
 
   Future<void> test_import_file_child() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "foo/^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -590,10 +686,11 @@
   }
 
   Future<void> test_import_file_parent() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "../^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 3);
@@ -607,10 +704,11 @@
   }
 
   Future<void> test_import_file_parent2() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('import "../b^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -624,10 +722,11 @@
   }
 
   Future<void> test_part_file() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset);
@@ -641,10 +740,11 @@
   }
 
   Future<void> test_part_file2() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "..^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 2);
@@ -658,10 +758,11 @@
   }
 
   Future<void> test_part_file_child() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "foo/^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 4);
@@ -675,10 +776,11 @@
   }
 
   Future<void> test_part_file_parent() async {
-    testFile = convertPath('\\proj\\completion.dart');
-    addSource('\\proj\\other.dart', 'library other;');
-    addSource('\\proj\\foo\\bar.dart', 'library bar;');
-    addSource('\\blat.dart', 'library blat;');
+    testFile = convertPath('$testPackageRootPath/test.dart');
+    newFile('$testPackageRootPath/other.dart');
+    newFile('$testPackageRootPath/foo/bar.dart');
+    newFile('$workspaceRootPath/blat.dart');
+
     addTestSource('library x; part "../^" import');
     await computeSuggestions();
     expect(replacementOffset, completionOffset - 3);
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 07d36a2..da88074 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
@@ -4,10 +4,10 @@
 
 import 'package:analysis_server/src/protocol_server.dart';
 import 'package:analysis_server/src/services/completion/postfix/postfix_completion.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../abstract_context.dart';
 import '../../../abstract_single_unit.dart';
 
 void main() {
@@ -623,7 +623,7 @@
 }
 
 @reflectiveTest
-class _TryTest extends PostfixCompletionTest {
+class _TryTest extends PostfixCompletionTest with WithNullSafetyMixin {
   Future<void> test_try() async {
     await _prepareCompletion('.try', '''
 f() {
@@ -710,7 +710,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     await _prepareCompletion('.tryon', '''
 f() {
   throw 'error';.tryon
@@ -728,7 +727,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_into_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     newFile('/home/test/lib/a.dart', content: r'''
 String? x;
 ''');
@@ -753,7 +751,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_into_legacy_nested() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     newFile('/home/test/lib/a.dart', content: r'''
 List<String?> x;
 ''');
@@ -778,7 +775,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     newFile('/home/test/lib/a.dart', content: r'''
 // @dart = 2.8
 String x;
@@ -802,7 +798,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_legacy_nested() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     newFile('/home/test/lib/a.dart', content: r'''
 // @dart = 2.8
 List<String> x;
@@ -826,7 +821,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_nullable() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     await _prepareCompletion('.tryon', '''
 f() {
   String? x;
@@ -846,7 +840,6 @@
   }
 
   Future<void> test_tryonThrowStatement_nnbd_nullable_nested() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
     await _prepareCompletion('.tryon', '''
 f() {
   List<String?>? x;
diff --git a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
index 11cbc6b..cb6d7b5 100644
--- a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
+++ b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
@@ -61,7 +61,6 @@
   }
 
   Future<void> _computeCompletion(int offset) async {
-    driver.changeFile(testFile);
     var result = await session.getResolvedUnit(testFile);
     var context = StatementCompletionContext(result, offset);
     var processor = StatementCompletionProcessor(context);
diff --git a/pkg/analysis_server/test/services/correction/util_test.dart b/pkg/analysis_server/test/services/correction/util_test.dart
index 530c5ea..7d4eacc 100644
--- a/pkg/analysis_server/test/services/correction/util_test.dart
+++ b/pkg/analysis_server/test/services/correction/util_test.dart
@@ -11,6 +11,7 @@
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../../abstract_single_unit.dart';
+import '../../src/services/correction/assist/assist_processor.dart';
 
 void main() {
   defineReflectiveSuite(() {
@@ -36,6 +37,9 @@
     var condition = ifStatement.condition;
     var result = CorrectionUtils(testAnalysisResult).invertCondition(condition);
     expect(result, expected);
+    // For compactness we put multiple cases into one test method.
+    // Prepare for resolving the test file one again.
+    changeFile(testFile);
   }
 
   Future<void> test_addLibraryImports_dart_hasImports_between() async {
@@ -192,7 +196,15 @@
 
   Future<void>
       test_addLibraryImports_package_hasDart_hasPackages_insertAfter() async {
-    addPackageFile('aaa', 'aaa.dart', '');
+    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
+    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
+        ..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
+    );
+
     await resolveTestUnit('''
 import 'dart:async';
 
@@ -209,7 +221,15 @@
 
   Future<void>
       test_addLibraryImports_package_hasDart_hasPackages_insertBefore() async {
-    addPackageFile('bbb', 'bbb.dart', '');
+    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
+    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
+        ..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
+    );
+
     await resolveTestUnit('''
 import 'dart:async';
 
@@ -225,8 +245,19 @@
   }
 
   Future<void> test_addLibraryImports_package_hasImports_between() async {
-    addPackageFile('aaa', 'aaa.dart', '');
-    addPackageFile('ddd', 'ddd.dart', '');
+    newFile('$workspaceRootPath/aaa/lib/aaa.dart');
+    newFile('$workspaceRootPath/bbb/lib/bbb.dart');
+    newFile('$workspaceRootPath/ccc/lib/ccc.dart');
+    newFile('$workspaceRootPath/ddd/lib/ddd.dart');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
+        ..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb')
+        ..add(name: 'ccc', rootPath: '$workspaceRootPath/ccc')
+        ..add(name: 'ddd', rootPath: '$workspaceRootPath/ddd'),
+    );
+
     await resolveTestUnit('''
 import 'package:aaa/aaa.dart';
 import 'package:ddd/ddd.dart';
diff --git a/pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart b/pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart
index 9f40c52..36d28f4 100644
--- a/pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart
+++ b/pkg/analysis_server/test/services/refactoring/abstract_refactoring.dart
@@ -136,10 +136,12 @@
   }
 
   @override
-  void setUp() {
-    super.setUp();
+  void verifyCreatedCollection() {
+    super.verifyCreatedCollection();
     // TODO(dantup): Get these tests passing with either line ending and change this to true.
     useLineEndingsForPlatform = false;
-    searchEngine = SearchEngineImpl([driver]);
+    searchEngine = SearchEngineImpl([
+      driverFor(testPackageRootPath),
+    ]);
   }
 }
diff --git a/pkg/analysis_server/test/services/refactoring/abstract_rename.dart b/pkg/analysis_server/test/services/refactoring/abstract_rename.dart
index 4b0783f..7de0635 100644
--- a/pkg/analysis_server/test/services/refactoring/abstract_rename.dart
+++ b/pkg/analysis_server/test/services/refactoring/abstract_rename.dart
@@ -12,6 +12,8 @@
 
 import 'abstract_refactoring.dart';
 
+export 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
+
 /// The base class for all [RenameRefactoring] tests.
 class RenameRefactoringTest extends RefactoringTest {
   @override
@@ -49,7 +51,10 @@
   /// Creates a new [RenameRefactoring] in [refactoring] for [element].
   /// Fails if no [RenameRefactoring] can be created.
   void createRenameRefactoringForElement(Element element) {
-    var workspace = RefactoringWorkspace([driver], searchEngine);
+    var workspace = RefactoringWorkspace(
+      [driverFor(testFile)],
+      searchEngine,
+    );
     refactoring = RenameRefactoring(workspace, testAnalysisResult, element);
     expect(refactoring, isNotNull, reason: "No refactoring for '$element'.");
   }
diff --git a/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart b/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
index 8c1da18..be25023 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_widget_test.dart
@@ -21,8 +21,15 @@
   @override
   ExtractWidgetRefactoringImpl refactoring;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_checkAllConditions_selection() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 class C {}
@@ -34,7 +41,6 @@
   }
 
   Future<void> test_checkName() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -65,7 +71,6 @@
   }
 
   Future<void> test_checkName_alreadyDeclared() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -87,7 +92,6 @@
   }
 
   Future<void> test_expression() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -146,7 +150,6 @@
   }
 
   Future<void> test_expression_localFunction() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -193,7 +196,6 @@
   }
 
   Future<void> test_expression_onTypeName() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -230,7 +232,6 @@
   }
 
   Future<void> test_expression_selection() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -278,7 +279,6 @@
   }
 
   Future<void> test_expression_topFunction() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -319,7 +319,6 @@
   }
 
   Future<void> test_invocation_enclosingClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -344,7 +343,6 @@
   }
 
   Future<void> test_invocation_enclosingSuperClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -371,7 +369,6 @@
   }
 
   Future<void> test_invocation_otherClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -433,7 +430,6 @@
   }
 
   Future<void> test_method() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -482,7 +478,6 @@
   }
 
   Future<void> test_method_parameters() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -554,7 +549,6 @@
   }
 
   Future<void> test_method_parameters_named() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -626,7 +620,6 @@
   }
 
   Future<void> test_parameters_field_read_enclosingClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -670,7 +663,6 @@
   }
 
   Future<void> test_parameters_field_read_otherClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -722,7 +714,6 @@
   }
 
   Future<void> test_parameters_field_read_topLevelVariable() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -763,7 +754,6 @@
   }
 
   Future<void> test_parameters_field_write_enclosingClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -788,7 +778,6 @@
   }
 
   Future<void> test_parameters_field_write_enclosingSuperClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -815,7 +804,6 @@
   }
 
   Future<void> test_parameters_field_write_otherClass() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -877,7 +865,6 @@
   }
 
   Future<void> test_parameters_key() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -896,7 +883,6 @@
   }
 
   Future<void> test_parameters_local_read_enclosingScope() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -938,7 +924,6 @@
   }
 
   Future<void> test_parameters_local_write_enclosingScope() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -962,7 +947,6 @@
   }
 
   Future<void> test_parameters_private() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -1006,7 +990,6 @@
   }
 
   Future<void> test_parameters_private_conflictWithPublic() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -1054,7 +1037,6 @@
   }
 
   Future<void> test_parameters_readField_readLocal() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -1112,7 +1094,6 @@
   }
 
   Future<void> test_refactoringName() async {
-    addFlutterPackage();
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -1128,7 +1109,6 @@
   }
 
   Future<void> test_statements() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -1184,7 +1164,6 @@
   }
 
   Future<void> test_statements_BAD_emptySelection() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -1200,7 +1179,6 @@
   }
 
   Future<void> test_statements_BAD_notReturnStatement() async {
-    addFlutterPackage();
     await indexTestUnit(r'''
 import 'package:flutter/material.dart';
 
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 6fdbfda..26f8105 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -38,6 +38,7 @@
 part 'a.dart';
 part '${toUriStr('/absolute/uri.dart')}';
 ''');
+    await analyzeTestPackageFiles();
     // perform refactoring
     _createRefactoring('/home/test/000/1111/22/new_name.dart');
     await _assertSuccessfulRefactoring();
@@ -59,6 +60,7 @@
     addTestSource(r'''
 import 'package:test/old_name.dart';
 ''');
+    await analyzeTestPackageFiles();
 
     // Since the file being refactored isn't the test source, we set the
     // testAnalysisResult manually here, the path is referenced through the
@@ -147,6 +149,7 @@
     addTestSource(r'''
 import 'package:test/111/old_name.dart';
 ''');
+    await analyzeTestPackageFiles();
 
     // Since the file being refactored isn't the test source, we set the
     // testAnalysisResult manually here, the path is referenced through the
@@ -166,6 +169,7 @@
     addTestSource(r'''
 import 'package:test/222/old_name.dart';
 ''');
+    await analyzeTestPackageFiles();
 
     // Since the file being refactored isn't the test source, we set the
     // testAnalysisResult manually here, the path is referenced through the
@@ -186,6 +190,7 @@
     addSource(pathA, '''
 import 'test.dart';
 ''');
+    await analyzeTestPackageFiles();
     await resolveTestUnit('');
 
     // perform refactoring
@@ -204,6 +209,7 @@
     addSource(pathA, '''
 import 'sub/folder/test.dart';
 ''');
+    await analyzeTestPackageFiles();
     await resolveTestUnit('');
     // perform refactoring
     _createRefactoring('/home/test/000/new/folder/name/new_name.dart');
@@ -220,6 +226,7 @@
     addSource(pathA, '''
 import '22/test.dart';
 ''');
+    await analyzeTestPackageFiles();
     await resolveTestUnit('');
     // perform refactoring
     _createRefactoring('/home/test/000/1111/new_name.dart');
@@ -269,9 +276,11 @@
 library lib;
 part '22/test.dart';
 ''');
-    await resolveTestUnit('''
+    addTestSource('''
 part of lib;
 ''');
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     // perform refactoring
     _createRefactoring('/home/test/000/1111/22/new_name.dart');
     await _assertSuccessfulRefactoring();
@@ -328,9 +337,11 @@
 library lib;
 part '22/test.dart';
 ''');
-    await resolveTestUnit('''
+    addTestSource('''
 part of '../a.dart';
 ''');
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     // perform refactoring
     _createRefactoring('/home/test/000/1111/22/33/test.dart');
     await _assertSuccessfulRefactoring();
@@ -398,9 +409,11 @@
     addSource(pathA, '''
 part 'test.dart';
 ''');
-    await resolveTestUnit('''
+    addTestSource('''
 part of 'a.dart';
 ''');
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     // perform refactoring
     _createRefactoring('/home/test/000/1111/22/test.dart');
     await _assertSuccessfulRefactoring();
@@ -421,9 +434,11 @@
     addSource(pathA, '''
 part 'test.dart';
 ''');
-    await resolveTestUnit('''
+    addTestSource('''
 part of 'a.dart';
 ''');
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     // perform refactoring
     _createRefactoring('/home/test/000/1111/test2.dart');
     await _assertSuccessfulRefactoring();
@@ -449,7 +464,8 @@
   }
 
   void _createRefactoring(String newFile, {String oldFile}) {
-    var refactoringWorkspace = RefactoringWorkspace([driver], searchEngine);
+    var refactoringWorkspace =
+        RefactoringWorkspace([driverFor(testFile)], searchEngine);
     // Allow passing an oldName for when we don't want to rename testSource,
     // but otherwise fall back to testSource.fullname
     oldFile = convertPath(oldFile ?? testSource.fullName);
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 dec50cc..97731a6 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
@@ -748,11 +748,18 @@
   }
 
   Future<void> test_createChange_MethodElement_potential_inPubCache() async {
-    var externalPath = addPackageFile('aaa', 'lib.dart', r'''
+    var externalPath = '/.pub-cache/aaa/lib/lib.dart';
+    newFile(externalPath, content: r'''
 processObj(p) {
   p.test();
 }
-''').path;
+''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '/.pub-cache/aaa/'),
+    );
+
     await indexTestUnit('''
 import 'package:aaa/lib.dart';
 
@@ -821,7 +828,7 @@
   }
 
   Future<void> test_createChange_outsideOfProject_declarationInPackage() async {
-    addPackageFile('aaa', 'aaa.dart', r'''
+    newFile('$workspaceRootPath/aaa/lib/aaa.dart', content: r'''
 class A {
   void test() {}
 }
@@ -830,6 +837,12 @@
   a.test();
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
+    );
+
     await indexTestUnit('''
 import 'package:aaa/aaa.dart';
 
diff --git a/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart b/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
index bd45b2f..045a97a 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart
@@ -230,7 +230,7 @@
 
   Future<void> test_newInstance_nullElement() async {
     await indexTestUnit('');
-    var workspace = RefactoringWorkspace([driver], searchEngine);
+    var workspace = RefactoringWorkspace([driverFor(testFile)], searchEngine);
     var refactoring = RenameRefactoring(workspace, testAnalysisResult, null);
     expect(refactoring, isNull);
   }
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 b0d2aff..31993ea 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
@@ -463,11 +463,9 @@
   new A(test: 2);
 }
 ''');
-    driver.addFile(a);
-    driver.addFile(b);
+    await analyzeTestPackageFiles();
 
-    var session = driver.currentSession;
-    testAnalysisResult = await session.getResolvedUnit(a);
+    testAnalysisResult = await resolveFile(a);
     testFile = testAnalysisResult.path;
     testCode = testAnalysisResult.content;
     testUnit = testAnalysisResult.unit;
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 0e64120..ab7d05d 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,11 +236,17 @@
   }
 
   Future<void> test_checkInitialConditions_outsideOfProject() async {
-    addPackageFile('aaa', 'lib.dart', r'''
+    newFile('$workspaceRootPath/aaa/lib/a.dart', content: r'''
 class A {}
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
+    );
+
     await indexTestUnit('''
-import "package:aaa/lib.dart";
+import "package:aaa/a.dart";
 main() {
   A a;
 }
@@ -374,7 +380,7 @@
   }
 
   Future<void> test_createChange_ClassElement_flutterWidget() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -416,7 +422,7 @@
 
   Future<void>
       test_createChange_ClassElement_flutterWidget_privateBoth() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -458,7 +464,7 @@
 
   Future<void>
       test_createChange_ClassElement_flutterWidget_privateState() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await indexTestUnit('''
 import 'package:flutter/material.dart';
 
diff --git a/pkg/analysis_server/test/services/search/hierarchy_test.dart b/pkg/analysis_server/test/services/search/hierarchy_test.dart
index b74fc20..f445dcc 100644
--- a/pkg/analysis_server/test/services/search/hierarchy_test.dart
+++ b/pkg/analysis_server/test/services/search/hierarchy_test.dart
@@ -23,7 +23,7 @@
   @override
   void setUp() {
     super.setUp();
-    searchEngine = SearchEngineImpl([driver]);
+    searchEngine = SearchEngineImpl([driverFor(testFile)]);
   }
 
   Future<void> test_getClassMembers() async {
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 af893d6..4cbaa050 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
@@ -4,6 +4,7 @@
 
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/computer/import_elements_computer.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -78,12 +79,19 @@
   }
 
   Future<void> test_createEdits_addImport_noPrefix() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' as foo;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' as foo;
@@ -92,12 +100,19 @@
   }
 
   Future<void> test_createEdits_addImport_prefix() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart';
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, 'foo', <String>['A'])
+      ImportedElements(fooPath, 'foo', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart';
@@ -106,13 +121,20 @@
   }
 
   Future<void> test_createEdits_addShow_multipleNames() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' show B;
 import 'package:pkg/foo.dart' as foo;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A', 'C'])
+      ImportedElements(fooPath, '', <String>['A', 'C'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' show B, A, C;
@@ -121,12 +143,19 @@
   }
 
   Future<void> test_createEdits_addShow_removeHide() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' show A, B hide C, D;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['C'])
+      ImportedElements(fooPath, '', <String>['C'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' show A, B, C hide D;
@@ -134,12 +163,19 @@
   }
 
   Future<void> test_createEdits_addShow_singleName_noPrefix() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' show B;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' show B, A;
@@ -147,13 +183,20 @@
   }
 
   Future<void> test_createEdits_addShow_singleName_prefix() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' show C;
 import 'package:pkg/foo.dart' as foo show B;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, 'foo', <String>['A'])
+      ImportedElements(fooPath, 'foo', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' show C;
@@ -162,34 +205,55 @@
   }
 
   Future<void> test_createEdits_alreadyImported_noCombinators() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart';
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A', 'B'])
+      ImportedElements(fooPath, '', <String>['A', 'B'])
     ]);
     assertNoChanges();
   }
 
   Future<void> test_createEdits_alreadyImported_withPrefix() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' as foo;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, 'foo', <String>['A', 'B'])
+      ImportedElements(fooPath, 'foo', <String>['A', 'B'])
     ]);
     assertNoChanges();
   }
 
   Future<void> test_createEdits_alreadyImported_withShow() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' show A;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertNoChanges();
   }
@@ -207,12 +271,19 @@
   }
 
   Future<void> test_createEdits_invalidUri() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'pakage:pkg/foo.dart';
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'pakage:pkg/foo.dart';
@@ -227,12 +298,19 @@
   }
 
   Future<void> test_createEdits_removeHide_firstInCombinator() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B, C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide B, C;
@@ -240,12 +318,19 @@
   }
 
   Future<void> test_createEdits_removeHide_lastInCombinator() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B, C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['C'])
+      ImportedElements(fooPath, '', <String>['C'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide A, B;
@@ -253,12 +338,19 @@
   }
 
   Future<void> test_createEdits_removeHide_middleInCombinator() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B, C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['B'])
+      ImportedElements(fooPath, '', <String>['B'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide A, C;
@@ -266,12 +358,19 @@
   }
 
   Future<void> test_createEdits_removeHide_multipleCombinators() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B, C hide A, B, C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['B'])
+      ImportedElements(fooPath, '', <String>['B'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide A, C hide A, C;
@@ -279,12 +378,19 @@
   }
 
   Future<void> test_createEdits_removeHide_multipleNames() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B, C hide D, E, F hide G, H, I;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A', 'E', 'I'])
+      ImportedElements(fooPath, '', <String>['A', 'E', 'I'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide B, C hide D, F hide G, H;
@@ -292,12 +398,19 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_first() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A hide B hide C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide B hide C;
@@ -305,12 +418,19 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_last() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A hide B hide C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['C'])
+      ImportedElements(fooPath, '', <String>['C'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide A hide B;
@@ -318,12 +438,19 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_middle() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A hide B hide C;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['B'])
+      ImportedElements(fooPath, '', <String>['B'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart' hide A hide C;
@@ -331,12 +458,19 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_only() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A'])
+      ImportedElements(fooPath, '', <String>['A'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart';
@@ -344,12 +478,19 @@
   }
 
   Future<void> test_createEdits_removeHideCombinator_only_multiple() async {
-    var fooFile = addPackageFile('pkg', 'foo.dart', '');
+    var fooPath = '$workspaceRootPath/pkg/lib/foo.dart';
+    newFile(fooPath, content: '');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await createBuilder('''
 import 'package:pkg/foo.dart' hide A, B;
 ''');
     await computeChanges(<ImportedElements>[
-      ImportedElements(fooFile.path, '', <String>['A', 'B'])
+      ImportedElements(fooPath, '', <String>['A', 'B'])
     ]);
     assertChanges('''
 import 'package:pkg/foo.dart';
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 a00364a..171d627 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
@@ -8,6 +8,7 @@
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../../abstract_context.dart';
+import '../../services/refactoring/abstract_rename.dart';
 
 void main() {
   defineReflectiveSuite(() {
@@ -220,7 +221,8 @@
   }
 
   Future<void> test_package_multipleInSame() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 class A {
   static String a = '';
 }
@@ -228,6 +230,12 @@
   static String b = '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'A.a + B.b';
     var content = '''
 import 'package:foo/foo.dart';
@@ -237,16 +245,23 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', '', ['A', 'B']),
+      ImportedElements(fooPath, '', ['A', 'B']),
     ]);
   }
 
   Future<void> test_package_noPrefix() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 class Foo {
   static String first = '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'Foo.first';
     var content = '''
 import 'package:foo/foo.dart';
@@ -256,16 +271,23 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', '', ['Foo']),
+      ImportedElements(fooPath, '', ['Foo']),
     ]);
   }
 
   Future<void> test_package_prefix_selected_class() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 class Foo {
   static String first = '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'f.Foo.first';
     var content = '''
 import 'package:foo/foo.dart' as f;
@@ -275,14 +297,21 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', 'f', ['Foo']),
+      ImportedElements(fooPath, 'f', ['Foo']),
     ]);
   }
 
   Future<void> test_package_prefix_selected_function() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 String foo() => '';
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'f.foo()';
     var content = '''
 import 'package:foo/foo.dart' as f;
@@ -292,14 +321,21 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', 'f', ['foo']),
+      ImportedElements(fooPath, 'f', ['foo']),
     ]);
   }
 
   Future<void> test_package_prefix_selected_getter() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 String foo = '';
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'f.foo';
     var content = '''
 import 'package:foo/foo.dart' as f;
@@ -309,14 +345,21 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', 'f', ['foo']),
+      ImportedElements(fooPath, 'f', ['foo']),
     ]);
   }
 
   Future<void> test_package_prefix_selected_setter() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 String foo = '';
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'f.foo';
     var content = '''
 import 'package:foo/foo.dart' as f;
@@ -326,16 +369,23 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', 'f', ['foo=']),
+      ImportedElements(fooPath, 'f', ['foo=']),
     ]);
   }
 
   Future<void> test_package_prefix_unselected() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 class Foo {
   static String first = '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'Foo.first';
     var content = '''
 import 'package:foo/foo.dart' as f;
@@ -345,17 +395,24 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', '', ['Foo']),
+      ImportedElements(fooPath, '', ['Foo']),
     ]);
   }
 
   Future<void> test_package_prefixedAndNot() async {
-    addPackageFile('foo', 'foo.dart', '''
+    var fooPath = '$workspaceRootPath/foo/lib/foo.dart';
+    newFile(fooPath, content: '''
 class Foo {
   static String first = '';
   static String second = '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
+    );
+
     var selection = 'f.Foo.first + Foo.second';
     var content = '''
 import 'package:foo/foo.dart';
@@ -366,8 +423,8 @@
 ''';
     await _computeElements(content, selection);
     assertElements([
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', '', ['Foo']),
-      ImportedElements('/.pub-cache/foo/lib/foo.dart', 'f', ['Foo']),
+      ImportedElements(fooPath, '', ['Foo']),
+      ImportedElements(fooPath, 'f', ['Foo']),
     ]);
   }
 
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 9f38295..6bdeff5 100644
--- a/pkg/analysis_server/test/src/computer/outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
@@ -43,7 +43,7 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
   }
 
   Future<void> test_columnWithChildren() async {
@@ -671,7 +671,7 @@
   }
 
   Future<void> test_isTest_isTestGroup() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     var outline = await _computeOutline('''
 import 'package:meta/meta.dart';
 
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 5e7d02c..b70a9bb 100644
--- a/pkg/analysis_server/test/src/domains/execution/completion_test.dart
+++ b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
@@ -4,6 +4,7 @@
 
 import 'package:analysis_server/src/domains/execution/completion.dart';
 import 'package:analysis_server/src/protocol_server.dart';
+import 'package:analyzer/file_system/overlay_file_system.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -17,6 +18,7 @@
 
 @reflectiveTest
 class RuntimeCompletionComputerTest extends AbstractContextTest {
+  OverlayResourceProvider overlayResourceProvider;
   String contextFile;
   int contextOffset;
 
@@ -57,8 +59,15 @@
     expect(codeOffset, isNonNegative);
     code = code.replaceAll('^', '');
 
-    var computer = RuntimeCompletionComputer(overlayResourceProvider, driver,
-        code, codeOffset, contextFile, contextOffset, variables, expressions);
+    var computer = RuntimeCompletionComputer(
+        overlayResourceProvider,
+        driverFor(contextFile),
+        code,
+        codeOffset,
+        contextFile,
+        contextOffset,
+        variables,
+        expressions);
     result = await computer.compute();
   }
 
@@ -85,6 +94,7 @@
     return null;
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_class_fields() async {
     addContextFile(r'''
 class A {
@@ -103,6 +113,7 @@
     assertSuggested('c', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_class_methods() async {
     addContextFile(r'''
 class A {
@@ -120,6 +131,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_inPart() async {
     addSource('/home/test/lib/a.dart', r'''
 part 'b.dart';
@@ -147,6 +159,7 @@
     assertSuggested('c', returnType: 'String');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_locals_block() async {
     addContextFile(r'''
 class A {
@@ -167,6 +180,7 @@
     assertSuggested('foo');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_locals_block_codeWithClosure() async {
     addContextFile(r'''
 main() {
@@ -178,6 +192,7 @@
     assertSuggested('toUpperCase');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_locals_block_nested() async {
     addContextFile(r'''
 void main() {
@@ -198,6 +213,7 @@
     assertNotSuggested('c');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_locals_for() async {
     addContextFile(r'''
 void main(List<int> intItems, List<double> doubleItems) {
@@ -211,6 +227,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_locals_forEach() async {
     addContextFile(r'''
 void main(List<int> intItems, List<double> doubleItems) {
@@ -226,6 +243,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_constructor() async {
     addContextFile(r'''
 class C {
@@ -239,6 +257,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_function() async {
     addContextFile(r'''
 void main(int a, double b) {
@@ -250,6 +269,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_function_locals() async {
     addContextFile(r'''
 void main(int a, int b) {
@@ -264,6 +284,7 @@
     assertSuggested('c', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_function_nested() async {
     addContextFile(r'''
 void foo(int a, double b) {
@@ -278,6 +299,7 @@
     assertSuggested('c', returnType: 'bool');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_functionExpression() async {
     addContextFile(r'''
 void main(List<int> intItems, List<double> doubleItems) {
@@ -293,6 +315,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_method() async {
     addContextFile(r'''
 class C {
@@ -306,6 +329,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_parameters_method_locals() async {
     addContextFile(r'''
 class C {
@@ -322,6 +346,7 @@
     assertSuggested('c', returnType: 'double');
   }
 
+  @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 {}');
@@ -340,6 +365,7 @@
     }
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_topLevelFunctions() async {
     addContextFile(r'''
 int a() => null;
@@ -353,6 +379,7 @@
     assertSuggested('b', returnType: 'double');
   }
 
+  @FailingTest(reason: 'No support for OverlayResourceProvider')
   Future<void> test_topLevelVariables() async {
     addContextFile(r'''
 int a;
diff --git a/pkg/analysis_server/test/src/flutter/flutter_correction_test.dart b/pkg/analysis_server/test/src/flutter/flutter_correction_test.dart
index 701dc96..3ab09de 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_correction_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_correction_test.dart
@@ -30,7 +30,7 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
   }
 
 //  void _assertChange(SourceChange change, String expectedCode) {
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 02fff3b..81e43c3 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
@@ -26,8 +26,8 @@
   @override
   void setUp() {
     super.setUp();
+    writeTestPackageConfig(flutter: true);
     testPath = convertPath('/home/test/lib/test.dart');
-    addFlutterPackage();
   }
 
   Future<void> test_attribute_namedExpression() async {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/assist/add_diagnostic_property_reference_test.dart
index ded7a23..9525059 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/add_diagnostic_property_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/add_diagnostic_property_reference_test.dart
@@ -19,9 +19,16 @@
   @override
   AssistKind get kind => DartAssistKind.ADD_DIAGNOSTIC_PROPERTY_REFERENCE;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   /// Full coverage in fix/add_diagnostic_property_reference_test.dart
   Future<void> test_boolField_debugFillProperties() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/foundation.dart';
 import 'package:flutter/widgets.dart';
@@ -60,7 +67,6 @@
   }
 
   Future<void> test_notAvailable_outsideDiagnosticable() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 class C {
   String get f/*caret*/ => null;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
index d0d30dd..58b7e66 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
@@ -201,17 +201,17 @@
 import 'my_lib.dart';
 part 'test.dart';
 ''';
-    var partCode = r'''
+    addTestSource(r'''
 part of my_app;
 main() {
   var /*caret*/v = getMap();
 }
-''';
+''');
 
     var appPath = convertPath('/home/test/lib/app.dart');
     addSource(appPath, appCode);
-    addSource(testFile, partCode);
-    await resolveTestUnit(partCode);
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
 
     await assertHasAssist('''
 part of my_app;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart b/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
index 478f098..cac4641 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
@@ -16,6 +16,8 @@
 
 import '../../../../abstract_single_unit.dart';
 
+export 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
+
 /// A base class defining support for writing assist processor tests.
 abstract class AssistProcessorTest extends AbstractSingleUnitTest {
   int _offset;
@@ -32,6 +34,36 @@
     return DartChangeWorkspace([session]);
   }
 
+  @override
+  void addTestSource(String code, [Uri uri]) {
+    if (useLineEndingsForPlatform) {
+      code = normalizeNewlinesForPlatform(code);
+    }
+    final eol = code.contains('\r\n') ? '\r\n' : '\n';
+    var offset = code.indexOf('/*caret*/');
+    if (offset >= 0) {
+      var endOffset = offset + '/*caret*/'.length;
+      code = code.substring(0, offset) + code.substring(endOffset);
+      _offset = offset;
+      _length = 0;
+    } else {
+      var startOffset = code.indexOf('// start$eol');
+      var endOffset = code.indexOf('// end$eol');
+      if (startOffset >= 0 && endOffset >= 0) {
+        var startLength = '// start$eol'.length;
+        code = code.substring(0, startOffset) +
+            code.substring(startOffset + startLength, endOffset) +
+            code.substring(endOffset + '// end$eol'.length);
+        _offset = startOffset;
+        _length = endOffset - startLength - _offset;
+      } else {
+        _offset = 0;
+        _length = 0;
+      }
+    }
+    super.addTestSource(code, uri);
+  }
+
   void assertExitPosition({String before, String after}) {
     var exitPosition = _change.selection;
     expect(exitPosition, isNotNull);
@@ -142,36 +174,6 @@
   }
 
   @override
-  Future<void> resolveTestUnit(String code) async {
-    if (useLineEndingsForPlatform) {
-      code = normalizeNewlinesForPlatform(code);
-    }
-    final eol = code.contains('\r\n') ? '\r\n' : '\n';
-    var offset = code.indexOf('/*caret*/');
-    if (offset >= 0) {
-      var endOffset = offset + '/*caret*/'.length;
-      code = code.substring(0, offset) + code.substring(endOffset);
-      _offset = offset;
-      _length = 0;
-    } else {
-      var startOffset = code.indexOf('// start$eol');
-      var endOffset = code.indexOf('// end$eol');
-      if (startOffset >= 0 && endOffset >= 0) {
-        var startLength = '// start$eol'.length;
-        code = code.substring(0, startOffset) +
-            code.substring(startOffset + startLength, endOffset) +
-            code.substring(endOffset + '// end$eol'.length);
-        _offset = startOffset;
-        _length = endOffset - startLength - _offset;
-      } else {
-        _offset = 0;
-        _length = 0;
-      }
-    }
-    return super.resolveTestUnit(code);
-  }
-
-  @override
   void setUp() {
     super.setUp();
     useLineEndingsForPlatform = true;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
index b09a195..f9aecc2 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
@@ -24,10 +24,14 @@
 library foo;
 part 'src/bar.dart';
 ''');
+
     testFile = convertPath('/home/test/lib/src/bar.dart');
-    await resolveTestUnit('''
+    addTestSource('''
 part of foo;
 ''');
+
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     await assertHasAssistAt('foo', '''
 part of '../foo.dart';
 ''');
@@ -38,10 +42,14 @@
 library foo;
 part 'bar.dart';
 ''');
+
     testFile = convertPath('/home/test/lib/bar.dart');
-    await resolveTestUnit('''
+    addTestSource('''
 part of foo;
 ''');
+
+    await analyzeTestPackageFiles();
+    await resolveTestUnit2();
     await assertHasAssistAt('foo', '''
 part of 'foo.dart';
 ''');
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_children_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_children_test.dart
index b34b23d..3884824 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_children_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_children_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_CONVERT_TO_CHILDREN;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_childUnresolved() async {
-    addFlutterPackage();
     verifyNoTestUnitErrors = false;
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
@@ -34,7 +41,6 @@
   }
 
   Future<void> test_multiLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -69,7 +75,7 @@
 
   Future<void> test_newlineChild() async {
     // This case could occur with deeply nested constructors, common in Flutter.
-    addFlutterPackage();
+
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -104,7 +110,6 @@
   }
 
   Future<void> test_notOnChild() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -119,7 +124,6 @@
   }
 
   Future<void> test_singleLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_stateful_widget_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_stateful_widget_test.dart
index d239e4b..879fef5 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_stateful_widget_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_convert_to_stateful_widget_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_CONVERT_TO_STATEFUL_WIDGET;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_empty() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -49,7 +56,6 @@
   }
 
   Future<void> test_empty_typeParam() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -78,7 +84,6 @@
   }
 
   Future<void> test_fields() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -159,7 +164,6 @@
   }
 
   Future<void> test_getters() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -218,7 +222,6 @@
   }
 
   Future<void> test_methods() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -308,7 +311,6 @@
   }
 
   Future<void> test_notClass() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 /*caret*/main() {}
@@ -317,7 +319,6 @@
   }
 
   Future<void> test_notStatelessWidget() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 class /*caret*/MyWidget extends Text {
@@ -328,7 +329,6 @@
   }
 
   Future<void> test_notWidget() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 class /*caret*/MyWidget {}
@@ -337,7 +337,6 @@
   }
 
   Future<void> test_simple() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
@@ -390,7 +389,6 @@
   }
 
   Future<void> test_tail() async {
-    addFlutterPackage();
     await resolveTestUnit(r'''
 import 'package:flutter/material.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_move_down_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_move_down_test.dart
index ee427b0..12d8ac8 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_move_down_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_move_down_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_MOVE_DOWN;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_first() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -49,7 +56,6 @@
   }
 
   Future<void> test_last() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -66,7 +72,6 @@
   }
 
   Future<void> test_notInList() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_move_up_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_move_up_test.dart
index a88b498..b2e3386 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_move_up_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_move_up_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_MOVE_UP;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_first() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -37,7 +44,6 @@
   }
 
   Future<void> test_last() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -66,7 +72,6 @@
   }
 
   Future<void> test_notInList() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_remove_widget_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_remove_widget_test.dart
index fce863a..c470789 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_remove_widget_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_remove_widget_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_REMOVE_WIDGET;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_childIntoChild_multiLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -57,7 +64,6 @@
   }
 
   Future<void> test_childIntoChild_singleLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -82,7 +88,6 @@
   }
 
   Future<void> test_childIntoChildren() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -119,7 +124,6 @@
   }
 
   Future<void> test_childrenMultipleIntoChild() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -137,7 +141,6 @@
   }
 
   Future<void> test_childrenOneIntoChild() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -161,7 +164,6 @@
   }
 
   Future<void> test_childrenOneIntoReturn() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -181,7 +183,6 @@
   }
 
   Future<void> test_intoChildren() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_surround_with_set_state_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_surround_with_set_state_test.dart
index 35dac67..3938f65 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_surround_with_set_state_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_surround_with_set_state_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.SURROUND_WITH_SET_STATE;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_outsideState() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -40,7 +47,6 @@
   }
 
   Future<void> test_stateSubclass() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_child_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_child_test.dart
index 0228ef0..6ebbd20 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_child_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_child_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_SWAP_WITH_CHILD;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundCenter() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -60,7 +67,6 @@
   }
 
   Future<void> test_notFormatted() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_parent_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_parent_test.dart
index dd3ce14..dbd59ca 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_parent_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_swap_with_parent_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_SWAP_WITH_PARENT;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_inCenter() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -60,7 +67,6 @@
   }
 
   Future<void> test_notFormatted() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 
@@ -111,7 +117,6 @@
   }
 
   Future<void> test_outerIsInChildren() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_center_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_center_test.dart
index 752cc43..b2037c6 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_center_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_center_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_CENTER;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundCenter() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -33,7 +40,6 @@
   }
 
   Future<void> test_aroundContainer() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -53,7 +59,6 @@
   }
 
   Future<void> test_aroundNamedConstructor() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -83,7 +88,6 @@
   }
 
   Future<void> test_assignment() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -103,7 +107,6 @@
   }
 
   Future<void> test_expressionFunctionBody() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
index c16385a..d707097 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_COLUMN;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_controlFlowCollections_if() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -54,7 +61,6 @@
   }
 
   Future<void> test_coveredByWidget() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -84,7 +90,6 @@
   }
 
   Future<void> test_coversWidgets() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -122,7 +127,6 @@
   }
 
   Future<void> test_endOfWidgetName() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_container_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_container_test.dart
index 26e88f7..39be197 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_container_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_container_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_CONTAINER;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundContainer() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 main() {
@@ -31,7 +38,6 @@
   }
 
   Future<void> test_aroundText() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
index 794cc11..347d013 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_GENERIC;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_minimal() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 /*caret*/x(){}
 ''');
@@ -28,7 +35,6 @@
   }
 
   Future<void> test_multiLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -65,7 +71,7 @@
 
   Future<void> test_multiLine_inListLiteral() async {
     verifyNoTestUnitErrors = false;
-    addFlutterPackage();
+
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -86,7 +92,6 @@
   }
 
   Future<void> test_multiLines() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -126,7 +131,6 @@
   }
 
   Future<void> test_multiLines_eol2() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {\r
@@ -166,7 +170,6 @@
   }
 
   Future<void> test_prefixedIdentifier_identifier() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -192,7 +195,6 @@
   }
 
   Future<void> test_prefixedIdentifier_prefix() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -218,7 +220,6 @@
   }
 
   Future<void> test_singleLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -232,7 +233,6 @@
   }
 
   Future<void> test_singleLine1() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -252,7 +252,6 @@
   }
 
   Future<void> test_singleLine2() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -272,7 +271,6 @@
   }
 
   Future<void> test_variable() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
index c457ccf..1470d12 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_PADDING;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundContainer() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -43,7 +50,6 @@
   }
 
   Future<void> test_aroundPadding() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -59,7 +65,6 @@
   }
 
   Future<void> test_inConstantContext() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_row_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_row_test.dart
index 2325c8c..c28ab00 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_row_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_row_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_ROW;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_twoWidgets() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_sized_box_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_sized_box_test.dart
index b9b6947..cff7743 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_sized_box_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_sized_box_test.dart
@@ -21,8 +21,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_SIZED_BOX;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundContainer() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -42,7 +49,6 @@
   }
 
   Future<void> test_aroundNamedConstructor() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -72,7 +78,6 @@
   }
 
   Future<void> test_aroundSizedBox() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
@@ -85,7 +90,6 @@
   }
 
   Future<void> test_assignment() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -105,7 +109,6 @@
   }
 
   Future<void> test_expressionFunctionBody() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 class FakeFlutter {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_stream_builder_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_stream_builder_test.dart
index c44049f..61b04bf 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_stream_builder_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_stream_builder_test.dart
@@ -19,8 +19,15 @@
   @override
   AssistKind get kind => DartAssistKind.FLUTTER_WRAP_STREAM_BUILDER;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_aroundStreamBuilder() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -35,7 +42,6 @@
   }
 
   Future<void> test_aroundText() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
index 09acc3d74..aa74274 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/assist.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/assist/assist.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'assist_processor.dart';
 
 void main() {
@@ -108,13 +108,8 @@
 }
 
 @reflectiveTest
-class ShadowFieldWithNullSafetyTest extends ShadowFieldTest {
-  @override
-  void setUp() {
-    super.setUp();
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-  }
-
+class ShadowFieldWithNullSafetyTest extends ShadowFieldTest
+    with WithNullSafetyMixin {
   Future<void> test_notNull() async {
     await resolveTestUnit('''
 class C {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart b/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
index 9335cd1..86b6655 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
@@ -20,8 +20,15 @@
   @override
   AssistKind get kind => DartAssistKind.SORT_CHILD_PROPERTY_LAST;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_already_sorted() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -39,7 +46,6 @@
   }
 
   Future<void> test_already_sorted_one_prop() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -56,7 +62,6 @@
   }
 
   Future<void> test_no_children() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -69,7 +74,6 @@
   }
 
   Future<void> test_sort() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
@@ -100,7 +104,6 @@
   }
 
   Future<void> test_sort_noAssistWithLint() async {
-    addFlutterPackage();
     createAnalysisOptionsFile(lints: [LintNames.sort_child_properties_last]);
     verifyNoTestUnitErrors = false;
     await resolveTestUnit('''
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
index 99c530f..f04807c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
@@ -68,8 +68,15 @@
   @override
   String get lintCode => LintNames.prefer_const_constructors_in_immutables;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      meta: true,
+    );
+  }
+
   Future<void> test_constConstructor() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -89,7 +96,6 @@
   }
 
   Future<void> test_constConstructorWithComment() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
index b4fdc40..864433b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
@@ -27,7 +27,9 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(
+      flutter: true,
+    );
   }
 
   Future<void> test_boolField() async {
@@ -380,7 +382,10 @@
   }
 
   Future<void> test_matrix4Field() async {
-    addVectorMathPackage();
+    writeTestPackageConfig(
+      flutter: true,
+      vector_math: true,
+    );
     await resolveTestUnit('''
 import 'package:flutter/foundation.dart';
 import 'package:flutter/widgets.dart';
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
index 115d78c..25a4a6c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
@@ -3,11 +3,11 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -478,10 +478,8 @@
 }
 
 @reflectiveTest
-class AddExplicitCastWithNullSafetyTest extends AddExplicitCastTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class AddExplicitCastWithNullSafetyTest extends AddExplicitCastTest
+    with WithNullSafetyMixin {
   Future<void> test_assignment_null() async {
     await resolveTestUnit('''
 void f(int x) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_field_formal_parameters_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_field_formal_parameters_test.dart
index 61a6718..0e59102 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_field_formal_parameters_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_field_formal_parameters_test.dart
@@ -20,7 +20,10 @@
   FixKind get kind => DartFixKind.ADD_FIELD_FORMAL_PARAMETERS;
 
   Future<void> test_flutter() async {
-    addFlutterPackage();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_late_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_late_test.dart
index 9a67e6e..2169e59 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_late_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_late_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -32,10 +32,7 @@
 }
 
 @reflectiveTest
-class AddLateTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class AddLateTest extends FixProcessorTest with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.ADD_LATE;
 
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 293c98a..9957bbe 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
@@ -156,7 +156,11 @@
 
   Future<void> test_function_inPackage_inWorkspace() async {
     newFile('/home/aaa/lib/a.dart', content: 'void test() {}');
-    addTestPackageDependency('aaa', '/home/aaa');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
+    );
 
     _workspace = DartChangeWorkspace([
       session,
@@ -178,7 +182,12 @@
   }
 
   Future<void> test_function_inPackage_outsideWorkspace() async {
-    addPackageFile('bbb', 'b.dart', 'void test() {}');
+    newFile('/home/bbb/lib/b.dart', content: 'void test() {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
+    );
 
     await resolveTestUnit('''
 import 'package:bbb/b.dart';
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
index 2eb4fa8..ed684f8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -21,9 +21,15 @@
   @override
   FixKind get kind => DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_constructor_flutter_children() async {
-    addFlutterPackage();
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 import 'package:meta/meta.dart';
@@ -51,8 +57,6 @@
   }
 
   Future<void> test_constructor_flutter_hasTrailingComma() async {
-    addFlutterPackage();
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 import 'package:meta/meta.dart';
@@ -80,7 +84,6 @@
   }
 
   Future<void> test_constructor_named() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -108,7 +111,6 @@
   }
 
   Future<void> test_constructor_single() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -135,7 +137,6 @@
   }
 
   Future<void> test_constructor_single_closure() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -164,7 +165,6 @@
   }
 
   Future<void> test_constructor_single_closure2() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -193,7 +193,6 @@
   }
 
   Future<void> test_constructor_single_closure3() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -222,7 +221,6 @@
   }
 
   Future<void> test_constructor_single_closure4() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -250,101 +248,7 @@
 ''');
   }
 
-  Future<void> test_constructor_single_closure_nnbd() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    addMetaPackage();
-    addSource('/home/test/lib/a.dart', r'''
-import 'package:meta/meta.dart';
-
-typedef int Callback(int? a);
-
-class A {
-  A({@required Callback callback}) {}
-}
-''');
-    await resolveTestUnit('''
-import 'package:test/a.dart';
-
-main() {
-  A a = new A();
-  print(a);
-}
-''');
-    await assertHasFix('''
-import 'package:test/a.dart';
-
-main() {
-  A a = new A(callback: (int? a) {  });
-  print(a);
-}
-''');
-  }
-
-  Future<void> test_constructor_single_closure_nnbd_from_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    addMetaPackage();
-    addSource('/home/test/lib/a.dart', r'''
-// @dart = 2.8
-import 'package:meta/meta.dart';
-
-typedef int Callback(int a);
-
-class A {
-  A({@required Callback callback}) {}
-}
-''');
-    await resolveTestUnit('''
-import 'package:test/a.dart';
-
-main() {
-  A a = new A();
-  print(a);
-}
-''');
-    await assertHasFix('''
-import 'package:test/a.dart';
-
-main() {
-  A a = new A(callback: (int a) {  });
-  print(a);
-}
-''');
-  }
-
-  Future<void> test_constructor_single_closure_nnbd_into_legacy() async {
-    createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
-    addMetaPackage();
-    addSource('/home/test/lib/a.dart', r'''
-import 'package:meta/meta.dart';
-
-typedef int Callback(int? a);
-
-class A {
-  A({@required Callback callback}) {}
-}
-''');
-    await resolveTestUnit('''
-// @dart = 2.8
-import 'package:test/a.dart';
-
-main() {
-  A a = new A();
-  print(a);
-}
-''');
-    await assertHasFix('''
-// @dart = 2.8
-import 'package:test/a.dart';
-
-main() {
-  A a = new A(callback: (int a) {  });
-  print(a);
-}
-''');
-  }
-
   Future<void> test_constructor_single_list() async {
-    addMetaPackage();
     addSource('/home/test/lib/a.dart', r'''
 import 'package:meta/meta.dart';
 
@@ -371,7 +275,6 @@
   }
 
   Future<void> test_multiple() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -391,7 +294,6 @@
   }
 
   Future<void> test_multiple_1of2() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -411,7 +313,6 @@
   }
 
   Future<void> test_multiple_2of2() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -431,8 +332,6 @@
   }
 
   Future<void> test_param_child() async {
-    addFlutterPackage();
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 import 'package:meta/meta.dart';
@@ -465,8 +364,6 @@
   }
 
   Future<void> test_param_children() async {
-    addFlutterPackage();
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 import 'package:meta/meta.dart';
@@ -499,7 +396,6 @@
   }
 
   Future<void> test_single() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -520,7 +416,6 @@
   }
 
   Future<void> test_single_normal() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -540,7 +435,6 @@
   }
 
   Future<void> test_single_with_details() async {
-    addMetaPackage();
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
@@ -561,13 +455,101 @@
 }
 
 @reflectiveTest
-class AddMissingRequiredArgumentWithNullSafetyTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class AddMissingRequiredArgumentWithNullSafetyTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT;
 
+  @override
+  bool get withPackageMeta => true;
+
+  Future<void> test_constructor_single_closure_nnbd() async {
+    addSource('/home/test/lib/a.dart', r'''
+import 'package:meta/meta.dart';
+
+typedef int Callback(int? a);
+
+class A {
+  A({@required Callback callback}) {}
+}
+''');
+    await resolveTestUnit('''
+import 'package:test/a.dart';
+
+main() {
+  A a = new A();
+  print(a);
+}
+''');
+    await assertHasFix('''
+import 'package:test/a.dart';
+
+main() {
+  A a = new A(callback: (int? a) {  });
+  print(a);
+}
+''');
+  }
+
+  Future<void> test_constructor_single_closure_nnbd_from_legacy() async {
+    addSource('/home/test/lib/a.dart', r'''
+// @dart = 2.8
+import 'package:meta/meta.dart';
+
+typedef int Callback(int a);
+
+class A {
+  A({@required Callback callback}) {}
+}
+''');
+    await resolveTestUnit('''
+import 'package:test/a.dart';
+
+main() {
+  A a = new A();
+  print(a);
+}
+''');
+    await assertHasFix('''
+import 'package:test/a.dart';
+
+main() {
+  A a = new A(callback: (int a) {  });
+  print(a);
+}
+''');
+  }
+
+  Future<void> test_constructor_single_closure_nnbd_into_legacy() async {
+    addSource('/home/test/lib/a.dart', r'''
+import 'package:meta/meta.dart';
+
+typedef int Callback(int? a);
+
+class A {
+  A({@required Callback callback}) {}
+}
+''');
+    await resolveTestUnit('''
+// @dart = 2.8
+import 'package:test/a.dart';
+
+main() {
+  A a = new A();
+  print(a);
+}
+''');
+    await assertHasFix('''
+// @dart = 2.8
+import 'package:test/a.dart';
+
+main() {
+  A a = new A(callback: (int a) {  });
+  print(a);
+}
+''');
+  }
+
   Future<void> test_nonNullable() async {
     await resolveTestUnit('''
 void f({required int x}) {}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
index 67c35f1..96010dd 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_null_check_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,7 @@
 }
 
 @reflectiveTest
-class AddNullCheckTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class AddNullCheckTest extends FixProcessorTest with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.ADD_NULL_CHECK;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
index 9b90123..fcf9c8b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
@@ -4,10 +4,10 @@
 
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -40,10 +40,8 @@
 }
 
 @reflectiveTest
-class AddRequiredWithNullSafetyTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class AddRequiredWithNullSafetyTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.ADD_REQUIRED2;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart
index 735e1c5..fd2fc44 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart
@@ -22,7 +22,7 @@
   /// Disabled in BulkFixProcessor.
   @failingTest
   Future<void> test_singleFile() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     await resolveTestUnit(r'''
 class C {
   const C([C c]);
@@ -45,7 +45,7 @@
   String get lintCode => LintNames.prefer_const_constructors_in_immutables;
 
   Future<void> test_singleFile() async {
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
     await resolveTestUnit('''
 import 'package:meta/meta.dart';
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart
index cda5640..8ea5e2f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart
@@ -19,7 +19,7 @@
   String get lintCode => LintNames.diagnostic_describe_all_properties;
 
   Future<void> test_singleFile() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await resolveTestUnit('''
 import 'package:flutter/foundation.dart';
 import 'package:flutter/widgets.dart';
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart
index 96292b2..de7282e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart
@@ -62,9 +62,10 @@
   /// Computes fixes for the given [error] in [testUnit].
   Future<SourceChange> _computeFixes() async {
     var tracker = DeclarationsTracker(MemoryByteStore(), resourceProvider);
-    tracker.addContext(driver.analysisContext);
+    var analysisContext = contextFor(testFile);
+    tracker.addContext(analysisContext);
     var changeBuilder =
-        await BulkFixProcessor(workspace).fixErrors([driver.analysisContext]);
+        await BulkFixProcessor(workspace).fixErrors([analysisContext]);
     return changeBuilder.sourceChange;
   }
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart
index 5b43664..4a91e90 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_manager.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'bulk_fix_processor.dart';
@@ -1155,12 +1156,17 @@
   /// Add the file containing the data used by the data-driven fix with the
   /// given [content].
   void addPackageDataFile(String content) {
-    addPackageFile('p', TransformSetManager.dataFileName, content);
+    newFile('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
+        content: 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) {
-    addPackageFile('p', 'lib.dart', content);
+    newFile('$workspaceRootPath/p/lib/lib.dart', content: content);
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'p', rootPath: '$workspaceRootPath/p'),
+    );
   }
 }
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart
index 80c02dd..dafc81d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart
@@ -19,7 +19,7 @@
   String get lintCode => LintNames.sort_child_properties_last;
 
   Future<void> test_singleFile() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_child_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_child_test.dart
index 3e17f59..d083826 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_child_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_child_test.dart
@@ -19,8 +19,15 @@
   @override
   FixKind get kind => DartFixKind.CONVERT_FLUTTER_CHILD;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_hasList() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -50,7 +57,6 @@
   }
 
   Future<void> test_hasTypedList() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -80,7 +86,6 @@
   }
 
   Future<void> test_listNotWidget() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -98,7 +103,6 @@
   }
 
   Future<void> test_multiLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
@@ -130,7 +134,6 @@
   }
 
   Future<void> test_widgetVariable() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 build() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_children_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_children_test.dart
index 8f71ef6..36d89c5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_children_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_flutter_children_test.dart
@@ -19,8 +19,15 @@
   @override
   FixKind get kind => DartFixKind.CONVERT_FLUTTER_CHILDREN;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   Future<void> test_undefinedParameter_multiLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -48,7 +55,6 @@
   }
 
   Future<void> test_undefinedParameter_notWidget() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -63,7 +69,6 @@
   }
 
   Future<void> test_undefinedParameter_singleLine() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
@@ -85,7 +90,6 @@
   }
 
   Future<void> test_undefinedParameter_singleLine2() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 build() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
index 4c0a8d0..1b587fa 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_constructor_for_final_fields_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -22,7 +22,7 @@
   FixKind get kind => DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS;
 
   Future<void> test_flutter() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -48,7 +48,7 @@
   }
 
   Future<void> test_flutter_childLast() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -74,7 +74,7 @@
   }
 
   Future<void> test_flutter_childrenLast() async {
-    addFlutterPackage();
+    writeTestPackageConfig(flutter: true);
     await resolveTestUnit('''
 import 'package:flutter/widgets.dart';
 
@@ -139,11 +139,8 @@
 }
 
 @reflectiveTest
-class CreateConstructorForFinalFieldsWithNullSafetyTest
-    extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class CreateConstructorForFinalFieldsWithNullSafetyTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.CREATE_CONSTRUCTOR_FOR_FINAL_FIELDS;
 
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 a57a686..06132ad 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
@@ -147,13 +147,13 @@
   }
 
   Future<void> test_withImport() async {
-    addPackageFile('pkg', 'a/a.dart', '''
+    newFile('$workspaceRootPath/pkg/lib/a/a.dart', content: '''
 class A {}
 ''');
-    addPackageFile('pkg', 'b/b.dart', '''
+    newFile('$workspaceRootPath/pkg/lib/b/b.dart', content: '''
 class B {}
 ''');
-    addPackageFile('pkg', 'c/c.dart', '''
+    newFile('$workspaceRootPath/pkg/lib/c/c.dart', content: '''
 import 'package:pkg/a/a.dart';
 import 'package:pkg/b/b.dart';
 
@@ -162,6 +162,11 @@
 }
 ''');
 
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
+    );
+
     await resolveTestUnit('''
 import 'package:pkg/a/a.dart';
 import 'package:pkg/c/c.dart';
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
index 7335380..8cafbac 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_missing_overrides_test.dart
@@ -3,11 +3,11 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -611,10 +611,8 @@
 }
 
 @reflectiveTest
-class CreateMissingOverridesWithNullSafetyTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class CreateMissingOverridesWithNullSafetyTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.CREATE_MISSING_OVERRIDES;
 
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 fe452ec..55525ff 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
@@ -10,6 +10,7 @@
 import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_manager.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/src/dart/error/hint_codes.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 
 import '../fix_processor.dart';
@@ -26,7 +27,8 @@
   /// Add the file containing the data used by the data-driven fix with the
   /// given [content].
   void addPackageDataFile(String content) {
-    addPackageFile('p', TransformSetManager.dataFileName, content);
+    newFile('$workspaceRootPath/p/lib/${TransformSetManager.dataFileName}',
+        content: content);
   }
 
   /// Return a code template that will produce the given [text].
@@ -42,7 +44,15 @@
   /// Set the content of the library that defines the element referenced by the
   /// data on which this test is based.
   void setPackageContent(String content) {
-    addPackageFile('p', 'lib.dart', content);
+    newFile('$workspaceRootPath/p/lib/lib.dart', content: content);
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(
+          name: 'p',
+          rootPath: '$workspaceRootPath/p',
+          languageVersion: '2.9',
+        ),
+    );
   }
 
   /// Set the data on which this test is based.
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 1e29672..98bd8db 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
@@ -8,6 +8,7 @@
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../../../../../abstract_context.dart';
+import '../../../../../services/refactoring/abstract_rename.dart';
 
 void main() {
   defineReflectiveSuite(() {
@@ -22,6 +23,13 @@
   void test_twoFiles() async {
     _addDataFile('p1');
     _addDataFile('p2');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'p1', rootPath: '$workspaceRootPath/p1')
+        ..add(name: 'p2', rootPath: '$workspaceRootPath/p2'),
+    );
+
     addSource('/home/test/pubspec.yaml', '');
     var testSource = addSource('/home/test/lib/test.dart', '');
     var result = await session.getResolvedLibrary(testSource.fullName);
@@ -30,8 +38,8 @@
   }
 
   void test_zeroFiles() async {
-    addTestPackageDependency('p1', '/.pub-cache/p1');
-    addTestPackageDependency('p2', '/.pub-cache/p2');
+    // addTestPackageDependency('p1', '/.pub-cache/p1');
+    // addTestPackageDependency('p2', '/.pub-cache/p2');
     addSource('/home/test/pubspec.yaml', '');
     var testSource = addSource('/home/test/lib/test.dart', '');
     var result = await session.getResolvedLibrary(testSource.fullName);
@@ -40,7 +48,7 @@
   }
 
   void _addDataFile(String packageName) {
-    addPackageFile(packageName, 'fix_data.yaml', '''
+    newFile('$workspaceRootPath/$packageName/lib/fix_data.yaml', content: '''
 version: 1
 transforms:
 - title: 'Rename A'
diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
index ca983e6..27092f2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
@@ -7,8 +7,10 @@
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
 import 'package:analysis_server/src/services/correction/fix_internal.dart';
+import 'package:analyzer/dart/analysis/features.dart';
 import 'package:analyzer/error/error.dart';
 import 'package:analyzer/src/dart/analysis/byte_store.dart';
+import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer/src/dart/error/lint_codes.dart';
 import 'package:analyzer/src/services/available_declarations.dart';
 import 'package:analyzer/src/test_utilities/platform.dart';
@@ -16,10 +18,14 @@
     hide AnalysisError;
 import 'package:analyzer_plugin/utilities/change_builder/change_workspace.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:meta/meta.dart';
 import 'package:test/test.dart';
 
+import '../../../../abstract_context.dart';
 import '../../../../abstract_single_unit.dart';
 
+export 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
+
 /// A base class defining support for writing fix processor tests that are
 /// specific to fixes associated with lints that use the FixKind.
 abstract class FixProcessorLintTest extends FixProcessorTest {
@@ -283,8 +289,10 @@
 
   /// Computes fixes for the given [error] in [testUnit].
   Future<List<Fix>> _computeFixes(AnalysisError error) async {
+    var analysisContext = contextFor(testFile);
+
     var tracker = DeclarationsTracker(MemoryByteStore(), resourceProvider);
-    tracker.addContext(driver.analysisContext);
+    tracker.addContext(analysisContext);
 
     var context = DartFixContextImpl(
       workspace,
@@ -293,7 +301,7 @@
       (name) {
         var provider = TopLevelDeclarationsProvider(tracker);
         provider.doTrackerWork();
-        return provider.get(driver.analysisContext, testFile, name);
+        return provider.get(analysisContext, testFile, name);
       },
     );
     return await DartFixContributor().computeFixes(context);
@@ -351,3 +359,22 @@
     return positions;
   }
 }
+
+mixin WithNullSafetyLintMixin on AbstractContextTest {
+  /// Return the lint code being tested.
+  String get lintCode;
+
+  @override
+  String get testPackageLanguageVersion =>
+      Feature.non_nullable.isEnabledByDefault ? '2.12' : '2.11';
+
+  /// TODO(scheglov) https://github.com/dart-lang/sdk/issues/43837
+  /// Remove when Null Safety is enabled by default.
+  @nonVirtual
+  @override
+  void setUp() {
+    super.setUp();
+    createAnalysisOptionsFile(
+        experiments: [EnableString.non_nullable], lints: [lintCode]);
+  }
+}
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 86dce04..856bb00e 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
@@ -7,6 +7,7 @@
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../services/refactoring/abstract_rename.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -65,7 +66,13 @@
   }
 
   Future<void> test_lib() async {
-    addPackageFile('my_pkg', 'a.dart', 'class Test {}');
+    newFile('/.pub-cache/my_pkg/lib/a.dart', content: 'class Test {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -89,11 +96,17 @@
   }
 
   Future<void> test_lib_extension() async {
-    addPackageFile('my_pkg', 'a.dart', '''
+    newFile('/.pub-cache/my_pkg/lib/a.dart', content: '''
 extension E on int {
   static String m() => '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -115,7 +128,13 @@
   }
 
   Future<void> test_lib_src() async {
-    addPackageFile('my_pkg', 'src/a.dart', 'class Test {}');
+    newFile('/.pub-cache/my_pkg/lib/src/a.dart', content: 'class Test {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -594,8 +613,14 @@
   FixKind get kind => DartFixKind.IMPORT_LIBRARY_PROJECT2;
 
   Future<void> test_lib() async {
-    addPackageFile('my_pkg', 'a.dart', "export 'b.dart';");
-    addPackageFile('my_pkg', 'b.dart', 'class Test {}');
+    newFile('/.pub-cache/my_pkg/lib/a.dart', content: "export 'b.dart';");
+    newFile('/.pub-cache/my_pkg/lib/b.dart', content: 'class Test {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -617,8 +642,14 @@
   }
 
   Future<void> test_lib_src() async {
-    addPackageFile('my_pkg', 'a.dart', "export 'src/b.dart';");
-    addPackageFile('my_pkg', 'src/b.dart', 'class Test {}');
+    newFile('/.pub-cache/my_pkg/lib/a.dart', content: "export 'src/b.dart';");
+    newFile('/.pub-cache/my_pkg/lib/src/b.dart', content: 'class Test {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -640,12 +671,18 @@
   }
 
   Future<void> test_lib_src_extension() async {
-    addPackageFile('my_pkg', 'a.dart', "export 'src/b.dart';");
-    addPackageFile('my_pkg', 'src/b.dart', '''
+    newFile('/.pub-cache/my_pkg/lib/a.dart', content: "export 'src/b.dart';");
+    newFile('/.pub-cache/my_pkg/lib/src/b.dart', content: '''
 extension E on int {
   static String m() => '';
 }
 ''');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'my_pkg', rootPath: '/.pub-cache/my_pkg'),
+    );
+
     newFile('/home/test/pubspec.yaml', content: r'''
 dependencies:
   my_pkg: any
@@ -671,11 +708,17 @@
   FixKind get kind => DartFixKind.IMPORT_LIBRARY_PROJECT3;
 
   Future<void> test_inLibSrc_differentContextRoot() async {
-    addPackageFile('bbb', 'b1.dart', r'''
+    newFile('/.pub-cache/bbb/lib/b1.dart', content: r'''
 import 'src/b2.dart';
 class A {}
 ''');
-    addPackageFile('bbb', 'src/b2.dart', 'class Test {}');
+
+    writeTestPackageConfig(
+      config: PackageConfigFileBuilder()
+        ..add(name: 'bbb', rootPath: '/.pub-cache/bbb'),
+    );
+
+    newFile('/.pub-cache/bbb/lib/src/b2.dart', content: 'class Test {}');
     await resolveTestUnit('''
 import 'package:bbb/b1.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
index 3eeb26c..e94ab21 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
@@ -4,7 +4,6 @@
 
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -137,10 +136,8 @@
 }
 
 @reflectiveTest
-class InlineTypedefWithNullSafetyTest extends InlineTypedefTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class InlineTypedefWithNullSafetyTest extends InlineTypedefTest
+    with WithNullSafetyLintMixin {
   Future<void> test_generic_parameter_requiredNamed() async {
     await resolveTestUnit('''
 typedef _F = Function({required int i});
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
index 7486e14..01e9935 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
@@ -4,7 +4,6 @@
 
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -58,10 +57,8 @@
 }
 
 @reflectiveTest
-class PreferFinalFieldsWithNullSafetyTest extends FixProcessorLintTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class PreferFinalFieldsWithNullSafetyTest extends FixProcessorLintTest
+    with WithNullSafetyLintMixin {
   @override
   FixKind get kind => DartFixKind.MAKE_FINAL;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
index 6181ed4..ff7d59e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_return_type_nullable_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,8 @@
 }
 
 @reflectiveTest
-class MakeReturnTypeNullableTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class MakeReturnTypeNullableTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.MAKE_RETURN_TYPE_NULLABLE;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
index b38dd55..9d475df 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_variable_nullable_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,8 @@
 }
 
 @reflectiveTest
-class MakeVariableNullableTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class MakeVariableNullableTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.MAKE_VARIABLE_NULLABLE;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_annotation_test.dart
index f69c58b..126dd33 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_annotation_test.dart
@@ -22,7 +22,7 @@
   @override
   void setUp() {
     super.setUp();
-    addMetaPackage();
+    writeTestPackageConfig(meta: true);
   }
 
   Future<void> test_factory() async {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
index 67590ce..89a631b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_comparison_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,7 @@
 }
 
 @reflectiveTest
-class RemoveComparisonTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class RemoveComparisonTest extends FixProcessorTest with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.REMOVE_COMPARISON;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
index 32b927a..b9b4921 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
@@ -4,10 +4,10 @@
 
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -18,10 +18,8 @@
 }
 
 @reflectiveTest
-class DeadNullAwareExpressionTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class DeadNullAwareExpressionTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.REMOVE_IF_NULL_OPERATOR;
 
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 77b371d..6b673ad 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
@@ -92,7 +92,6 @@
 ''');
   }
 
-  @FailingTest(issue: 'https://github.com/dart-lang/linter/issues/1997')
   Future<void> test_method_nullSafety_optIn_fromOptOut() async {
     createAnalysisOptionsFile(
       experiments: [EnableString.non_nullable],
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
index 69573a2..71ed805 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,7 @@
 }
 
 @reflectiveTest
-class RemoveQuestionMarkTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class RemoveQuestionMarkTest extends FixProcessorTest with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.REMOVE_QUESTION_MARK;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_cascade_with_dot_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_cascade_with_dot_test.dart
index 907e168..0429ffa 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_cascade_with_dot_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_cascade_with_dot_test.dart
@@ -4,7 +4,6 @@
 
 import 'package:analysis_server/src/services/correction/fix.dart';
 import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -119,11 +118,8 @@
 }
 
 @reflectiveTest
-class ReplaceCascadeWithDotWithNullSafetyTest
-    extends ReplaceCascadeWithDotTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class ReplaceCascadeWithDotWithNullSafetyTest extends ReplaceCascadeWithDotTest
+    with WithNullSafetyLintMixin {
   Future<void> test_assignment_index_nullAwareCascade() async {
     await resolveTestUnit('''
 void f(List<int>? l) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
index 5003102..cc0af18 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_filled_test.dart
@@ -3,10 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
-import 'package:analyzer/src/dart/analysis/experiments.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -16,10 +16,7 @@
 }
 
 @reflectiveTest
-class ReplaceWithFilledTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => [EnableString.non_nullable];
-
+class ReplaceWithFilledTest extends FixProcessorTest with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.REPLACE_WITH_FILLED;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
index 64b71ef..2ddd88c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
@@ -6,6 +6,7 @@
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
+import '../../../../abstract_context.dart';
 import 'fix_processor.dart';
 
 void main() {
@@ -15,10 +16,8 @@
 }
 
 @reflectiveTest
-class ReplaceWithNotNullAwareTest extends FixProcessorTest {
-  @override
-  List<String> get experiments => ['non-nullable'];
-
+class ReplaceWithNotNullAwareTest extends FixProcessorTest
+    with WithNullSafetyMixin {
   @override
   FixKind get kind => DartFixKind.REPLACE_WITH_NOT_NULL_AWARE;
 
diff --git a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
index 48d2b28..ad2dd11 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
@@ -23,9 +23,16 @@
   @override
   String get lintCode => LintNames.sort_child_properties_last;
 
+  @override
+  void setUp() {
+    super.setUp();
+    writeTestPackageConfig(
+      flutter: true,
+    );
+  }
+
   /// More coverage in the `sort_child_properties_last_test.dart` assist test.
   Future<void> test_sort() async {
-    addFlutterPackage();
     await resolveTestUnit('''
 import 'package:flutter/material.dart';
 main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/update_sdk_constraints_test.dart b/pkg/analysis_server/test/src/services/correction/fix/update_sdk_constraints_test.dart
index 9576a29..5fc9bb4 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/update_sdk_constraints_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/update_sdk_constraints_test.dart
@@ -64,6 +64,7 @@
   }
 
   Future<void> test_gtGtGtOperator() async {
+    writeTestPackageConfig(languageVersion: latestLanguageVersion);
     createAnalysisOptionsFile(experiments: [EnableString.triple_shift]);
     await testUpdate(content: '''
 class C {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/wrap_in_text_test.dart b/pkg/analysis_server/test/src/services/correction/fix/wrap_in_text_test.dart
index d3b0b24..7c67cbd 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/wrap_in_text_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/wrap_in_text_test.dart
@@ -22,7 +22,9 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(
+      flutter: true,
+    );
   }
 
   Future<void> test_literal() async {
diff --git a/pkg/analysis_server/test/src/services/flutter/widget_description.dart b/pkg/analysis_server/test/src/services/flutter/widget_description.dart
index da82d9c..012b925 100644
--- a/pkg/analysis_server/test/src/services/flutter/widget_description.dart
+++ b/pkg/analysis_server/test/src/services/flutter/widget_description.dart
@@ -88,7 +88,9 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(
+      flutter: true,
+    );
   }
 
   void _removeNotInterestingElements(Map<String, dynamic> json) {
diff --git a/pkg/analysis_server/test/src/utilities/flutter_test.dart b/pkg/analysis_server/test/src/utilities/flutter_test.dart
index b7d9636..446b4dd 100644
--- a/pkg/analysis_server/test/src/utilities/flutter_test.dart
+++ b/pkg/analysis_server/test/src/utilities/flutter_test.dart
@@ -22,7 +22,9 @@
   @override
   void setUp() {
     super.setUp();
-    addFlutterPackage();
+    writeTestPackageConfig(
+      flutter: true,
+    );
   }
 
   Future<void> test_getWidgetPresentationText_icon() async {
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index e67947e..4fb7696 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 0.40.5-dev
+## 0.40.5
 * Deprecated `GenericTypeAliasElement`. Use `FunctionTypeAliasElement`.
 * Read imports, exports, and parts on demand in `AnalysisDriver`.
   Specifically, `parseFileSync` will not read any referenced files.
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 462daf1..6177894 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -2347,7 +2347,7 @@
     while (timer.elapsedMilliseconds < _MS_WORK_INTERVAL) {
       // Prepare files to check.
       if (filesToCheck.isEmpty) {
-        Set<String> newFiles = driver.addedFiles.difference(checkedFiles);
+        Set<String> newFiles = driver.knownFiles.difference(checkedFiles);
         filesToCheck.addAll(newFiles);
       }
 
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 2122a7e..bd53e0e 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,5 +1,5 @@
 name: analyzer
-version: 0.40.5-dev
+version: 0.40.5
 description: This package provides a library that performs static analysis of Dart code.
 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
 
@@ -7,7 +7,7 @@
   sdk: '>=2.7.0 <3.0.0'
 
 dependencies:
-  _fe_analyzer_shared: ^11.0.0
+  _fe_analyzer_shared: ^12.0.0
   args: ^1.0.0
   cli_util: '>=0.1.4 <0.3.0'
   collection: ^1.10.1
diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc
index 7af21bf..3458a33 100644
--- a/runtime/vm/class_finalizer.cc
+++ b/runtime/vm/class_finalizer.cc
@@ -1003,6 +1003,12 @@
   if (cls.is_type_finalized()) {
     return;
   }
+
+  SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
+  if (cls.is_type_finalized()) {
+    return;
+  }
+
   if (FLAG_trace_class_finalization) {
     THR_Print("Finalize types in %s\n", cls.ToCString());
   }
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index b047850..d1b5da2 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -2052,6 +2052,7 @@
   auto& retained_constants = GrowableObjectArray::Handle(Z);
   auto& constant = Instance::Handle(Z);
 
+  SafepointWriteRwLocker ml(T, T->isolate_group()->program_lock());
   for (intptr_t i = 0; i < libraries_.Length(); i++) {
     lib ^= libraries_.At(i);
     ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
diff --git a/runtime/vm/isolate_reload.cc b/runtime/vm/isolate_reload.cc
index 10b3e76..005a2e9 100644
--- a/runtime/vm/isolate_reload.cc
+++ b/runtime/vm/isolate_reload.cc
@@ -857,9 +857,13 @@
     // ValidateReload mutates the direct subclass information and does
     // not remove dead subclasses.  Rebuild the direct subclass
     // information from scratch.
-    ForEachIsolate([&](Isolate* isolate) {
-      isolate->reload_context()->RebuildDirectSubclasses();
-    });
+    {
+      SafepointWriteRwLocker ml(thread,
+                                thread->isolate_group()->program_lock());
+      ForEachIsolate([&](Isolate* isolate) {
+        isolate->reload_context()->RebuildDirectSubclasses();
+      });
+    }
     const intptr_t final_library_count =
         GrowableObjectArray::Handle(Z,
                                     first_isolate_->object_store()->libraries())
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 175b1f0..eaf97ca 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2926,8 +2926,7 @@
   StorePointer(&raw_ptr()->constants_, Object::null_array().raw());
   set_functions(Object::empty_array());
   set_fields(Object::empty_array());
-  StorePointer(&raw_ptr()->invocation_dispatcher_cache_,
-               Object::empty_array().raw());
+  set_invocation_dispatcher_cache(Object::empty_array());
 }
 
 ArrayPtr Class::OffsetToFieldMap(bool original_classes) const {
@@ -3184,6 +3183,13 @@
                                                     value.raw());
 }
 
+void Class::set_invocation_dispatcher_cache(const Array& cache) const {
+  // Ensure all writes to the cache are visible by the time the array
+  // is visible.
+  StorePointer<ArrayPtr, std::memory_order_release>(
+      &raw_ptr()->invocation_dispatcher_cache_, cache.raw());
+}
+
 intptr_t Class::NumTypeParameters(Thread* thread) const {
   if (!is_declaration_loaded()) {
     ASSERT(is_prefinalized());
@@ -3493,7 +3499,11 @@
 void Class::AddInvocationDispatcher(const String& target_name,
                                     const Array& args_desc,
                                     const Function& dispatcher) const {
-  auto& cache = Array::Handle(invocation_dispatcher_cache());
+  auto thread = Thread::Current();
+  ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
+
+  auto zone = thread->zone();
+  auto& cache = Array::Handle(zone, invocation_dispatcher_cache());
   InvocationDispatcherTable dispatchers(cache);
   intptr_t i = 0;
   for (auto dispatcher : dispatchers) {
@@ -3510,10 +3520,12 @@
     cache = Array::Grow(cache, new_len);
     set_invocation_dispatcher_cache(cache);
   }
+  // Ensure all stores are visible at the point the name is visible.
   auto entry = dispatchers[i];
-  entry.Set<Class::kInvocationDispatcherName>(target_name);
   entry.Set<Class::kInvocationDispatcherArgsDesc>(args_desc);
   entry.Set<Class::kInvocationDispatcherFunction>(dispatcher);
+  entry.Set<Class::kInvocationDispatcherName, std::memory_order_release>(
+      target_name);
 }
 
 FunctionPtr Class::GetInvocationDispatcher(const String& target_name,
@@ -3523,30 +3535,49 @@
   ASSERT(kind == FunctionLayout::kNoSuchMethodDispatcher ||
          kind == FunctionLayout::kInvokeFieldDispatcher ||
          kind == FunctionLayout::kDynamicInvocationForwarder);
-  auto Z = Thread::Current()->zone();
+  auto thread = Thread::Current();
+  auto Z = thread->zone();
   auto& function = Function::Handle(Z);
   auto& name = String::Handle(Z);
   auto& desc = Array::Handle(Z);
-  auto& cache = Array::Handle(Z, invocation_dispatcher_cache());
-  ASSERT(!cache.IsNull());
+  auto& cache = Array::Handle(Z);
 
-  InvocationDispatcherTable dispatchers(cache);
-  for (auto dispatcher : dispatchers) {
-    name = dispatcher.Get<Class::kInvocationDispatcherName>();
-    if (name.IsNull()) break;  // Reached last entry.
-    if (!name.Equals(target_name)) continue;
-    desc = dispatcher.Get<Class::kInvocationDispatcherArgsDesc>();
-    if (desc.raw() != args_desc.raw()) continue;
-    function = dispatcher.Get<Class::kInvocationDispatcherFunction>();
-    if (function.kind() == kind) {
-      break;  // Found match.
+  auto find_entry = [&]() {
+    cache = invocation_dispatcher_cache();
+    ASSERT(!cache.IsNull());
+    InvocationDispatcherTable dispatchers(cache);
+    for (auto dispatcher : dispatchers) {
+      // Ensure all loads are done after loading the name.
+      name = dispatcher.Get<Class::kInvocationDispatcherName,
+                            std::memory_order_acquire>();
+      if (name.IsNull()) break;  // Reached last entry.
+      if (!name.Equals(target_name)) continue;
+      desc = dispatcher.Get<Class::kInvocationDispatcherArgsDesc>();
+      if (desc.raw() != args_desc.raw()) continue;
+      function = dispatcher.Get<Class::kInvocationDispatcherFunction>();
+      if (function.kind() == kind) {
+        return function.raw();
+      }
     }
+    return Function::null();
+  };
+
+  // First we'll try to find it without using locks.
+  function = find_entry();
+  if (!function.IsNull() || !create_if_absent) {
+    return function.raw();
   }
 
-  if (function.IsNull() && create_if_absent) {
-    function = CreateInvocationDispatcher(target_name, args_desc, kind);
-    AddInvocationDispatcher(target_name, args_desc, function);
-  }
+  // If we failed to find it and possibly need to create it, use a write lock.
+  SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
+
+  // Try to find it again & return if it was added in the meantime.
+  function = find_entry();
+  if (!function.IsNull()) return function.raw();
+
+  // Otherwise create it & add it.
+  function = CreateInvocationDispatcher(target_name, args_desc, kind);
+  AddInvocationDispatcher(target_name, args_desc, function);
   return function.raw();
 }
 
@@ -3802,30 +3833,40 @@
 
 FunctionPtr Function::GetDynamicInvocationForwarder(
     const String& mangled_name,
-    bool allow_add /* = true */) const {
+    bool allow_add /*=true*/) const {
   ASSERT(IsDynamicInvocationForwarderName(mangled_name));
-  auto zone = Thread::Current()->zone();
+  auto thread = Thread::Current();
+  auto zone = thread->zone();
   const Class& owner = Class::Handle(zone, Owner());
-  Function& result = Function::Handle(
-      zone,
+  Function& result = Function::Handle(zone);
+
+  // First we'll try to find it without using locks.
+  result =
       owner.GetInvocationDispatcher(mangled_name, Array::null_array(),
                                     FunctionLayout::kDynamicInvocationForwarder,
-                                    /*create_if_absent=*/false));
+                                    /*create_if_absent=*/false);
+  if (!result.IsNull()) return result.raw();
 
-  if (!result.IsNull()) {
-    return result.raw();
+  const bool needs_dyn_forwarder =
+      kernel::NeedsDynamicInvocationForwarder(*this);
+  if (!allow_add) {
+    return needs_dyn_forwarder ? Function::null() : raw();
   }
 
-  // Check if function actually needs a dynamic invocation forwarder.
-  if (!kernel::NeedsDynamicInvocationForwarder(*this)) {
-    result = raw();
-  } else if (allow_add) {
-    result = CreateDynamicInvocationForwarder(mangled_name);
-  }
+  // If we failed to find it and possibly need to create it, use a write lock.
+  SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
 
-  if (allow_add) {
-    owner.AddInvocationDispatcher(mangled_name, Array::null_array(), result);
-  }
+  // Try to find it again & return if it was added in the mean time.
+  result =
+      owner.GetInvocationDispatcher(mangled_name, Array::null_array(),
+                                    FunctionLayout::kDynamicInvocationForwarder,
+                                    /*create_if_absent=*/false);
+  if (!result.IsNull()) return result.raw();
+
+  // Otherwise create it & add it.
+  result = needs_dyn_forwarder ? CreateDynamicInvocationForwarder(mangled_name)
+                               : raw();
+  owner.AddInvocationDispatcher(mangled_name, Array::null_array(), result);
 
   return result.raw();
 }
@@ -3852,10 +3893,6 @@
   return raw_ptr()->invocation_dispatcher_cache_;
 }
 
-void Class::set_invocation_dispatcher_cache(const Array& cache) const {
-  StorePointer(&raw_ptr()->invocation_dispatcher_cache_, cache.raw());
-}
-
 void Class::Finalize() const {
   auto thread = Thread::Current();
   Isolate* isolate = thread->isolate();
@@ -4993,6 +5030,7 @@
 
 void Class::AddDirectImplementor(const Class& implementor,
                                  bool is_mixin) const {
+  ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
   ASSERT(is_implemented());
   ASSERT(!implementor.IsNull());
   GrowableObjectArray& direct_implementors =
@@ -5017,10 +5055,12 @@
 }
 
 void Class::ClearDirectImplementors() const {
+  ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
   StorePointer(&raw_ptr()->direct_implementors_, GrowableObjectArray::null());
 }
 
 void Class::AddDirectSubclass(const Class& subclass) const {
+  ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
   ASSERT(!subclass.IsNull());
   ASSERT(subclass.SuperClass() == raw());
   // Do not keep track of the direct subclasses of class Object.
@@ -5041,6 +5081,7 @@
 }
 
 void Class::ClearDirectSubclasses() const {
+  ASSERT(IsolateGroup::Current()->program_lock()->IsCurrentThreadWriter());
   StorePointer(&raw_ptr()->direct_subclasses_, GrowableObjectArray::null());
 }
 
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index ceffe2f..01d448d 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1717,8 +1717,6 @@
   const char* GenerateUserVisibleName() const;
   void set_state_bits(intptr_t bits) const;
 
-  ArrayPtr invocation_dispatcher_cache() const;
-  void set_invocation_dispatcher_cache(const Array& cache) const;
   FunctionPtr CreateInvocationDispatcher(const String& target_name,
                                          const Array& args_desc,
                                          FunctionLayout::Kind kind) const;
@@ -1750,6 +1748,9 @@
  private:
   void set_functions(const Array& value) const;
   void set_fields(const Array& value) const;
+  void set_invocation_dispatcher_cache(const Array& cache) const;
+
+  ArrayPtr invocation_dispatcher_cache() const;
 
   // Calculates number of type arguments of this class.
   // This includes type arguments of a superclass and takes overlapping
diff --git a/sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart b/sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart
index 6e2b934..a36132b 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart
@@ -392,9 +392,9 @@
   /// If the length is not specified, it defaults to null, which indicates
   /// that the view extends to the end of the byte buffer.
   ///
-  /// Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-  /// if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-  /// the length of [buffer].
+  /// The [offsetInBytes] and [length] must be non-negative, and
+  /// [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+  /// equal to the length of [buffer].
   factory NativeByteData.view(
       ByteBuffer buffer, int offsetInBytes, int? length) {
     _checkViewArguments(buffer, offsetInBytes, length);
@@ -411,8 +411,8 @@
   /// the specified [byteOffset] in this object, in IEEE 754
   /// single-precision binary floating-point format (binary32).
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   double getFloat32(int byteOffset, [Endian endian = Endian.big]) =>
       _getFloat32(byteOffset, Endian.little == endian);
 
@@ -424,8 +424,8 @@
   /// the specified [byteOffset] in this object, in IEEE 754
   /// double-precision binary floating-point format (binary64).
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   double getFloat64(int byteOffset, [Endian endian = Endian.big]) =>
       _getFloat64(byteOffset, Endian.little == endian);
 
@@ -439,8 +439,8 @@
   /// The return value will be between 2<sup>15</sup> and 2<sup>15</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   int getInt16(int byteOffset, [Endian endian = Endian.big]) =>
       _getInt16(byteOffset, Endian.little == endian);
 
@@ -454,8 +454,8 @@
   /// The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   int getInt32(int byteOffset, [Endian endian = Endian.big]) =>
       _getInt32(byteOffset, Endian.little == endian);
 
@@ -469,8 +469,8 @@
   /// The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   int getInt64(int byteOffset, [Endian endian = Endian.big]) {
     throw UnsupportedError('Int64 accessor not supported by dart2js.');
   }
@@ -479,8 +479,8 @@
   /// specified [byteOffset] in this object, in two's complement binary
   /// representation. The return value will be between -128 and 127, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   int getInt8(int byteOffset) native;
 
   /// Returns the positive integer represented by the two bytes starting
@@ -488,8 +488,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>16</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   int getUint16(int byteOffset, [Endian endian = Endian.big]) =>
       _getUint16(byteOffset, Endian.little == endian);
 
@@ -502,8 +502,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>32</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   int getUint32(int byteOffset, [Endian endian = Endian.big]) =>
       _getUint32(byteOffset, Endian.little == endian);
 
@@ -516,8 +516,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>64</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   int getUint64(int byteOffset, [Endian endian = Endian.big]) {
     throw UnsupportedError('Uint64 accessor not supported by dart2js.');
   }
@@ -526,8 +526,8 @@
   /// [byteOffset] in this object, in unsigned binary form. The
   /// return value will be between 0 and 255, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   int getUint8(int byteOffset) native;
 
   /// Sets the four bytes starting at the specified [byteOffset] in this
@@ -543,8 +543,8 @@
   /// Note that finite (but large) values can be converted to infinity, and
   /// small non-zero values can be converted to zero.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setFloat32(int byteOffset, num value, [Endian endian = Endian.big]) =>
       _setFloat32(byteOffset, value, Endian.little == endian);
 
@@ -555,8 +555,8 @@
   /// object to the IEEE 754 double-precision binary floating-point
   /// (binary64) representation of the specified [value].
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setFloat64(int byteOffset, num value, [Endian endian = Endian.big]) =>
       _setFloat64(byteOffset, value, Endian.little == endian);
 
@@ -568,8 +568,8 @@
   /// [value], which must fit in two bytes. In other words, [value] must lie
   /// between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   void setInt16(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setInt16(byteOffset, value, Endian.little == endian);
 
@@ -581,8 +581,8 @@
   /// [value], which must fit in four bytes. In other words, [value] must lie
   /// between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setInt32(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setInt32(byteOffset, value, Endian.little == endian);
 
@@ -594,8 +594,8 @@
   /// [value], which must fit in eight bytes. In other words, [value] must lie
   /// between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setInt64(int byteOffset, int value, [Endian endian = Endian.big]) {
     throw UnsupportedError('Int64 accessor not supported by dart2js.');
   }
@@ -605,8 +605,8 @@
   /// must fit in a single byte. In other words, [value] must be between
   /// -128 and 127, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   void setInt8(int byteOffset, int value) native;
 
   /// Sets the two bytes starting at the specified [byteOffset] in this object
@@ -614,8 +614,8 @@
   /// which must fit in two bytes. in other words, [value] must be between
   /// 0 and 2<sup>16</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   void setUint16(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setUint16(byteOffset, value, Endian.little == endian);
 
@@ -627,8 +627,8 @@
   /// which must fit in four bytes. in other words, [value] must be between
   /// 0 and 2<sup>32</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setUint32(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setUint32(byteOffset, value, Endian.little == endian);
 
@@ -640,8 +640,8 @@
   /// which must fit in eight bytes. in other words, [value] must be between
   /// 0 and 2<sup>64</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setUint64(int byteOffset, int value, [Endian endian = Endian.big]) {
     throw UnsupportedError('Uint64 accessor not supported by dart2js.');
   }
@@ -651,8 +651,8 @@
   /// in a single byte. in other words, [value] must be between 0 and 255,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative,
-  /// or greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   void setUint8(int byteOffset, int value) native;
 
   static NativeByteData _create1(arg) =>
diff --git a/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart b/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
index 6a7b7b3..2b66dfc 100644
--- a/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
+++ b/sdk/lib/_internal/js_runtime/lib/native_typed_data.dart
@@ -393,9 +393,9 @@
   /// If the length is not specified, it defaults to null, which indicates
   /// that the view extends to the end of the byte buffer.
   ///
-  /// Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-  /// if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-  /// the length of [buffer].
+  /// The [offsetInBytes] and [length] must be non-negative, and
+  /// [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+  /// equal to the length of [buffer].
   factory NativeByteData.view(
       ByteBuffer buffer, int offsetInBytes, int? length) {
     _checkViewArguments(buffer, offsetInBytes, length);
@@ -412,8 +412,8 @@
   /// the specified [byteOffset] in this object, in IEEE 754
   /// single-precision binary floating-point format (binary32).
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   double getFloat32(int byteOffset, [Endian endian = Endian.big]) =>
       _getFloat32(byteOffset, Endian.little == endian);
 
@@ -425,8 +425,8 @@
   /// the specified [byteOffset] in this object, in IEEE 754
   /// double-precision binary floating-point format (binary64).
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   double getFloat64(int byteOffset, [Endian endian = Endian.big]) =>
       _getFloat64(byteOffset, Endian.little == endian);
 
@@ -440,8 +440,8 @@
   /// The return value will be between 2<sup>15</sup> and 2<sup>15</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   int getInt16(int byteOffset, [Endian endian = Endian.big]) =>
       _getInt16(byteOffset, Endian.little == endian);
 
@@ -455,8 +455,8 @@
   /// The return value will be between 2<sup>31</sup> and 2<sup>31</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   int getInt32(int byteOffset, [Endian endian = Endian.big]) =>
       _getInt32(byteOffset, Endian.little == endian);
 
@@ -470,8 +470,8 @@
   /// The return value will be between 2<sup>63</sup> and 2<sup>63</sup> - 1,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   int getInt64(int byteOffset, [Endian endian = Endian.big]) {
     throw UnsupportedError('Int64 accessor not supported by dart2js.');
   }
@@ -480,8 +480,8 @@
   /// specified [byteOffset] in this object, in two's complement binary
   /// representation. The return value will be between -128 and 127, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   int getInt8(int byteOffset) native;
 
   /// Returns the positive integer represented by the two bytes starting
@@ -489,8 +489,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>16</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   int getUint16(int byteOffset, [Endian endian = Endian.big]) =>
       _getUint16(byteOffset, Endian.little == endian);
 
@@ -503,8 +503,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>32</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   int getUint32(int byteOffset, [Endian endian = Endian.big]) =>
       _getUint32(byteOffset, Endian.little == endian);
 
@@ -517,8 +517,8 @@
   /// form.
   /// The return value will be between 0 and  2<sup>64</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   int getUint64(int byteOffset, [Endian endian = Endian.big]) {
     throw UnsupportedError('Uint64 accessor not supported by dart2js.');
   }
@@ -527,8 +527,8 @@
   /// [byteOffset] in this object, in unsigned binary form. The
   /// return value will be between 0 and 255, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   int getUint8(int byteOffset) native;
 
   /// Sets the four bytes starting at the specified [byteOffset] in this
@@ -544,8 +544,8 @@
   /// Note that finite (but large) values can be converted to infinity, and
   /// small non-zero values can be converted to zero.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setFloat32(int byteOffset, num value, [Endian endian = Endian.big]) =>
       _setFloat32(byteOffset, value, Endian.little == endian);
 
@@ -556,8 +556,8 @@
   /// object to the IEEE 754 double-precision binary floating-point
   /// (binary64) representation of the specified [value].
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setFloat64(int byteOffset, num value, [Endian endian = Endian.big]) =>
       _setFloat64(byteOffset, value, Endian.little == endian);
 
@@ -569,8 +569,8 @@
   /// [value], which must fit in two bytes. In other words, [value] must lie
   /// between 2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   void setInt16(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setInt16(byteOffset, value, Endian.little == endian);
 
@@ -582,8 +582,8 @@
   /// [value], which must fit in four bytes. In other words, [value] must lie
   /// between 2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setInt32(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setInt32(byteOffset, value, Endian.little == endian);
 
@@ -595,8 +595,8 @@
   /// [value], which must fit in eight bytes. In other words, [value] must lie
   /// between 2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setInt64(int byteOffset, int value, [Endian endian = Endian.big]) {
     throw UnsupportedError('Int64 accessor not supported by dart2js.');
   }
@@ -606,8 +606,8 @@
   /// must fit in a single byte. In other words, [value] must be between
   /// -128 and 127, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   void setInt8(int byteOffset, int value) native;
 
   /// Sets the two bytes starting at the specified [byteOffset] in this object
@@ -615,8 +615,8 @@
   /// which must fit in two bytes. in other words, [value] must be between
   /// 0 and 2<sup>16</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 2` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 2` must be less than or equal to the length of this object.
   void setUint16(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setUint16(byteOffset, value, Endian.little == endian);
 
@@ -628,8 +628,8 @@
   /// which must fit in four bytes. in other words, [value] must be between
   /// 0 and 2<sup>32</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 4` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 4` must be less than or equal to the length of this object.
   void setUint32(int byteOffset, int value, [Endian endian = Endian.big]) =>
       _setUint32(byteOffset, value, Endian.little == endian);
 
@@ -641,8 +641,8 @@
   /// which must fit in eight bytes. in other words, [value] must be between
   /// 0 and 2<sup>64</sup> - 1, inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative, or
-  /// `byteOffset + 8` is greater than the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// `byteOffset + 8` must be less than or equal to the length of this object.
   void setUint64(int byteOffset, int value, [Endian endian = Endian.big]) {
     throw UnsupportedError('Uint64 accessor not supported by dart2js.');
   }
@@ -652,8 +652,8 @@
   /// in a single byte. in other words, [value] must be between 0 and 255,
   /// inclusive.
   ///
-  /// Throws [RangeError] if [byteOffset] is negative,
-  /// or greater than or equal to the length of this object.
+  /// The [byteOffset] must be non-negative, and
+  /// less than the length of this object.
   void setUint8(int byteOffset, int value) native;
 
   static NativeByteData _create1(arg) =>
diff --git a/sdk/lib/typed_data/typed_data.dart b/sdk/lib/typed_data/typed_data.dart
index eeafdc6..c796465 100644
--- a/sdk/lib/typed_data/typed_data.dart
+++ b/sdk/lib/typed_data/typed_data.dart
@@ -483,9 +483,9 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -545,8 +545,8 @@
    *
    * The return value will be between -128 and 127, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * greater than or equal to the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * less than the length of this object.
    */
   int getInt8(int byteOffset);
 
@@ -557,8 +557,8 @@
    *
    * In other words, [value] must be between -128 and 127, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * greater than or equal to the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * less than the length of this object.
    */
   void setInt8(int byteOffset, int value);
 
@@ -568,8 +568,8 @@
    *
    * The return value will be between 0 and 255, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * greater than or equal to the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * less than the length of this object.
    */
   int getUint8(int byteOffset);
 
@@ -580,8 +580,8 @@
    *
    * In other words, [value] must be between 0 and 255, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative,
-   * or greater than or equal to the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * less than the length of this object.
    */
   void setUint8(int byteOffset, int value);
 
@@ -593,8 +593,8 @@
    * The return value will be between -2<sup>15</sup> and 2<sup>15</sup> - 1,
    * inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 2` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 2` must be less than or equal to the length of this object.
    */
   int getInt16(int byteOffset, [Endian endian = Endian.big]);
 
@@ -606,8 +606,8 @@
    * In other words, [value] must lie
    * between -2<sup>15</sup> and 2<sup>15</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 2` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 2` must be less than or equal to the length of this object.
    */
   void setInt16(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -618,8 +618,8 @@
    *
    * The return value will be between 0 and  2<sup>16</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 2` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 2` must be less than or equal to the length of this object.
    */
   int getUint16(int byteOffset, [Endian endian = Endian.big]);
 
@@ -631,8 +631,8 @@
    * In other words, [value] must be between
    * 0 and 2<sup>16</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 2` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 2` must be less than or equal to the length of this object.
    */
   void setUint16(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -644,8 +644,8 @@
    * The return value will be between -2<sup>31</sup> and 2<sup>31</sup> - 1,
    * inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   int getInt32(int byteOffset, [Endian endian = Endian.big]);
 
@@ -657,8 +657,8 @@
    * In other words, [value] must lie
    * between -2<sup>31</sup> and 2<sup>31</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   void setInt32(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -669,8 +669,8 @@
    *
    * The return value will be between 0 and  2<sup>32</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   int getUint32(int byteOffset, [Endian endian = Endian.big]);
 
@@ -682,8 +682,8 @@
    * In other words, [value] must be between
    * 0 and 2<sup>32</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   void setUint32(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -695,8 +695,8 @@
    * The return value will be between -2<sup>63</sup> and 2<sup>63</sup> - 1,
    * inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   int getInt64(int byteOffset, [Endian endian = Endian.big]);
 
@@ -708,8 +708,8 @@
    * In other words, [value] must lie
    * between -2<sup>63</sup> and 2<sup>63</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   void setInt64(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -720,8 +720,8 @@
    *
    * The return value will be between 0 and  2<sup>64</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   int getUint64(int byteOffset, [Endian endian = Endian.big]);
 
@@ -733,8 +733,8 @@
    * In other words, [value] must be between
    * 0 and 2<sup>64</sup> - 1, inclusive.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   void setUint64(int byteOffset, int value, [Endian endian = Endian.big]);
 
@@ -743,8 +743,8 @@
    * the specified [byteOffset] in this object, in IEEE 754
    * single-precision binary floating-point format (binary32).
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   double getFloat32(int byteOffset, [Endian endian = Endian.big]);
 
@@ -762,8 +762,8 @@
    * Note that finite (but large) values can be converted to infinity, and
    * small non-zero values can be converted to zero.
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 4` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 4` must be less than or equal to the length of this object.
    */
   void setFloat32(int byteOffset, double value, [Endian endian = Endian.big]);
 
@@ -772,8 +772,8 @@
    * the specified [byteOffset] in this object, in IEEE 754
    * double-precision binary floating-point format (binary64).
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   double getFloat64(int byteOffset, [Endian endian = Endian.big]);
 
@@ -782,8 +782,8 @@
    * object to the IEEE 754 double-precision binary floating-point
    * (binary64) representation of the specified [value].
    *
-   * Throws [RangeError] if [byteOffset] is negative, or
-   * `byteOffset + 8` is greater than the length of this object.
+   * The [byteOffset] must be non-negative, and
+   * `byteOffset + 8` must be less than or equal to the length of this object.
    */
   void setFloat64(int byteOffset, double value, [Endian endian = Endian.big]);
 }
@@ -829,9 +829,9 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -952,9 +952,9 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1085,9 +1085,9 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1211,12 +1211,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1348,12 +1347,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1484,12 +1482,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1621,12 +1618,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1757,12 +1753,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -1894,12 +1889,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -2031,12 +2025,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -2161,12 +2154,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -2290,12 +2282,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -2427,12 +2418,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
@@ -2572,12 +2562,11 @@
    * If the length is not specified, it defaults to `null`,
    * which indicates that the view extends to the end of the byte buffer.
    *
-   * Throws [RangeError] if [offsetInBytes] or [length] are negative, or
-   * if [offsetInBytes] + ([length] * elementSizeInBytes) is greater than
-   * the length of [buffer].
+   * The [offsetInBytes] and [length] must be non-negative, and
+   * [offsetInBytes] + ([length] * elementSizeInBytes) must be less than or
+   * equal to the length of [buffer].
    *
-   * Throws [ArgumentError] if [offsetInBytes] is not a multiple of
-   * [bytesPerElement].
+   * The [offsetInBytes] must be a multiple of [bytesPerElement].
    *
    * Note that when creating a view from a [TypedData] list or byte data,
    * that list or byte data may itself be a view on a larger buffer
diff --git a/tools/VERSION b/tools/VERSION
index 958db32..3ad189b 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 11
 PATCH 0
-PRERELEASE 268
+PRERELEASE 269
 PRERELEASE_PATCH 0
\ No newline at end of file