Migrate a couple of additional libraries and some missed tests

Change-Id: I7c107b71a7b6226c8e294428a70656182353a048
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194018
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/server/sdk_configuration.dart b/pkg/analysis_server/lib/src/server/sdk_configuration.dart
index c296772..39eb0d1 100644
--- a/pkg/analysis_server/lib/src/server/sdk_configuration.dart
+++ b/pkg/analysis_server/lib/src/server/sdk_configuration.dart
@@ -40,18 +40,19 @@
   }
 
   /// Whether analytics is forced on.
-  bool get analyticsForceEnabled => _values['server.analytics.forceEnabled'];
+  bool? get analyticsForceEnabled => _values['server.analytics.forceEnabled'];
 
-  /// Return a override value for the analysis server's google analytics ID.
-  String get analyticsId => _values['server.analytics.id'];
+  /// Return an override value for the analysis server's google analytics ID, or
+  /// `null` if the default value should be used.
+  String? get analyticsId => _values['server.analytics.id'];
 
   /// Whether crash reporting is forced on.
-  bool get crashReportingForceEnabled =>
+  bool? get crashReportingForceEnabled =>
       _values['server.crash.reporting.forceEnabled'];
 
-  /// Return a override value for the analysis server's crash reporting product
-  /// ID.
-  String get crashReportingId => _values['server.crash.reporting.id'];
+  /// Return an override value for the analysis server's crash reporting product
+  /// ID, or `null` if the default value should be used.
+  String? get crashReportingId => _values['server.crash.reporting.id'];
 
   /// Return a string describing the contents of this SDK configuration.
   String get displayString {
diff --git a/pkg/analysis_server/lib/src/services/flutter/class_description.dart b/pkg/analysis_server/lib/src/services/flutter/class_description.dart
index b8caaf2..b37c741 100644
--- a/pkg/analysis_server/lib/src/services/flutter/class_description.dart
+++ b/pkg/analysis_server/lib/src/services/flutter/class_description.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
@@ -40,7 +38,7 @@
 
   /// If we know how to materialize the [element], return [ClassDescription].
   /// Otherwise return `null`.
-  ClassDescription get(ClassElement element) {
+  ClassDescription? get(ClassElement element) {
     var description = _map[element];
     if (description == null) {
       description = _classDescription(element);
@@ -59,7 +57,7 @@
     return false;
   }
 
-  ClassDescription _classDescription(ClassElement element) {
+  ClassDescription? _classDescription(ClassElement element) {
     if (!_isOptedInClass(element)) return null;
 
     var constructor = element.unnamedConstructor;
diff --git a/pkg/analysis_server/lib/src/services/refactoring/visible_ranges_computer.dart b/pkg/analysis_server/lib/src/services/refactoring/visible_ranges_computer.dart
index 4eaa39c..72101d6 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/visible_ranges_computer.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/visible_ranges_computer.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/dart/element/element.dart';
@@ -26,7 +24,9 @@
     var element = node.declaredElement;
     if (element is ParameterElement) {
       var body = _getFunctionBody(node);
-      if (body is BlockFunctionBody || body is ExpressionFunctionBody) {
+      if (body is BlockFunctionBody) {
+        _map[element] = range.node(body);
+      } else if (body is ExpressionFunctionBody) {
         _map[element] = range.node(body);
       }
     }
@@ -35,9 +35,11 @@
   @override
   void visitForPartsWithDeclarations(ForPartsWithDeclarations node) {
     var loop = node.parent;
-    for (var variable in node.variables.variables) {
-      _addLocalVariable(loop, variable.declaredElement);
-      variable.initializer?.accept(this);
+    if (loop != null) {
+      for (var variable in node.variables.variables) {
+        _addLocalVariable(loop, variable.declaredElement);
+        variable.initializer?.accept(this);
+      }
     }
   }
 
@@ -55,13 +57,15 @@
   @override
   void visitVariableDeclarationStatement(VariableDeclarationStatement node) {
     var block = node.parent;
-    for (var variable in node.variables.variables) {
-      _addLocalVariable(block, variable.declaredElement);
-      variable.initializer?.accept(this);
+    if (block != null) {
+      for (var variable in node.variables.variables) {
+        _addLocalVariable(block, variable.declaredElement);
+        variable.initializer?.accept(this);
+      }
     }
   }
 
-  void _addLocalVariable(AstNode scopeNode, Element element) {
+  void _addLocalVariable(AstNode scopeNode, Element? element) {
     if (element is LocalVariableElement) {
       _map[element] = range.node(scopeNode);
     }
@@ -75,8 +79,8 @@
 
   /// Return the body of the function that contains the given [parameter], or
   /// `null` if no function body could be found.
-  static FunctionBody _getFunctionBody(FormalParameter parameter) {
-    var parent = parameter?.parent?.parent;
+  static FunctionBody? _getFunctionBody(FormalParameter parameter) {
+    var parent = parameter.parent?.parent;
     if (parent is ConstructorDeclaration) {
       return parent.body;
     } else if (parent is FunctionExpression) {
diff --git a/pkg/analysis_server/test/src/server/sdk_configuration_test.dart b/pkg/analysis_server/test/src/server/sdk_configuration_test.dart
index e0a6525..450ace8 100644
--- a/pkg/analysis_server/test/src/server/sdk_configuration_test.dart
+++ b/pkg/analysis_server/test/src/server/sdk_configuration_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:analysis_server/src/server/sdk_configuration.dart';
@@ -12,7 +10,11 @@
 
 void main() {
   group('SdkConfiguration', () {
-    Directory tempDir;
+    Directory? tempDir;
+
+    Directory createTempDir() {
+      return tempDir = Directory.systemTemp.createTempSync('SdkConfiguration');
+    }
 
     tearDown(() {
       tempDir?.deleteSync(recursive: true);
@@ -23,8 +25,8 @@
     });
 
     test("custom settings file doesn't exist", () {
-      tempDir = Directory.systemTemp.createTempSync('SdkConfiguration');
-      var file = File(path.join(tempDir.path, 'config.json'));
+      var dir = createTempDir();
+      var file = File(path.join(dir.path, 'config.json'));
 
       expect(() {
         SdkConfiguration.readFromFile(file);
@@ -32,8 +34,8 @@
     });
 
     test('is not configured', () {
-      tempDir = Directory.systemTemp.createTempSync('SdkConfiguration');
-      var file = File(path.join(tempDir.path, 'config.json'));
+      var dir = createTempDir();
+      var file = File(path.join(dir.path, 'config.json'));
       file.writeAsStringSync('''
 {}
 ''');
@@ -48,8 +50,8 @@
     });
 
     test('is configured', () {
-      tempDir = Directory.systemTemp.createTempSync('SdkConfiguration');
-      var file = File(path.join(tempDir.path, 'config.json'));
+      var dir = createTempDir();
+      var file = File(path.join(dir.path, 'config.json'));
       file.writeAsStringSync('''
 {
   "server.analytics.id": "aaaa-1234",
diff --git a/pkg/analysis_server/test/src/services/completion/filtering/fuzzy_matcher_test.dart b/pkg/analysis_server/test/src/services/completion/filtering/fuzzy_matcher_test.dart
index b607031..e1cda4a 100644
--- a/pkg/analysis_server/test/src/services/completion/filtering/fuzzy_matcher_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/filtering/fuzzy_matcher_test.dart
@@ -2,10 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/src/services/completion/filtering/fuzzy_matcher.dart';
-import 'package:meta/meta.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -44,8 +41,8 @@
   static MatchStyle SYM = MatchStyle.SYMBOL;
 
   void map(
-      {@required String str,
-      @required String want,
+      {required String str,
+      required String want,
       MatchStyle matchStyle = MatchStyle.TEXT}) {
 //    test('maps characters of $str', () {
     var out = List<CharRole>.filled(str.length, CharRole.NONE);
@@ -201,9 +198,9 @@
   static MatchStyle SYM = MatchStyle.SYMBOL;
 
   void score(
-      {@required String p,
-      @required String str,
-      String want,
+      {required String p,
+      required String str,
+      String? want,
       MatchStyle input = MatchStyle.TEXT}) {
 //    test('scores $str against $p', () {
     var matcher = FuzzyMatcher(p, matchStyle: input);
@@ -308,7 +305,7 @@
 @reflectiveTest
 class ScoringFunctionTest {
   ///
-  void score({@required String p, @required String str, double want}) {
+  void score({required String p, required String str, required double want}) {
 //    test('scores $str against $p', () {
     var matcher = FuzzyMatcher(p, matchStyle: MatchStyle.SYMBOL);
     expect(