Version 2.13.0-206.0.dev

Merge commit '4cba24947715248ba29f1f1a713772cb2fedf2ff' into 'dev'
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/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index 2c92945..93a7520 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -80,6 +80,9 @@
     var libraryElement = element.library;
     var libraryPath = libraryElement.source.fullName;
 
+    final oldDir = pathContext.dirname(oldFile);
+    final newDir = pathContext.dirname(newFile);
+
     // If this element is a library, update outgoing references inside the file.
     if (element == libraryElement.definingCompilationUnit) {
       // Handle part-of directives in this library
@@ -96,8 +99,6 @@
             await changeBuilder.addDartFileEdit(
                 result.unit.declaredElement.source.fullName, (builder) {
               partOfs.forEach((po) {
-                final oldDir = pathContext.dirname(oldFile);
-                final newDir = pathContext.dirname(newFile);
                 var newLocation =
                     pathContext.join(newDir, pathos.basename(newFile));
                 var newUri = _getRelativeUri(newLocation, oldDir);
@@ -112,16 +113,16 @@
         }
       }
 
-      await changeBuilder.addDartFileEdit(definingUnitResult.path, (builder) {
-        var oldDir = pathContext.dirname(oldFile);
-        var newDir = pathContext.dirname(newFile);
-        for (var directive in definingUnitResult.unit.directives) {
-          if (directive is UriBasedDirective) {
-            _updateUriReference(builder, directive, oldDir, newDir);
+      if (newDir != oldDir) {
+        await changeBuilder.addDartFileEdit(definingUnitResult.path, (builder) {
+          for (var directive in definingUnitResult.unit.directives) {
+            if (directive is UriBasedDirective) {
+              _updateUriReference(builder, directive, oldDir, newDir);
+            }
           }
-        }
-      });
-    } else {
+        });
+      }
+    } else if (newDir != oldDir) {
       // Otherwise, we need to update any relative part-of references.
       var partOfs = resolvedUnit.unit.directives
           .whereType<PartOfDirective>()
@@ -130,8 +131,6 @@
       if (partOfs.isNotEmpty) {
         await changeBuilder.addDartFileEdit(element.source.fullName, (builder) {
           partOfs.forEach((po) {
-            final oldDir = pathContext.dirname(oldFile);
-            final newDir = pathContext.dirname(newFile);
             var oldLocation = pathContext.join(oldDir, po.uri.stringValue);
             var newUri = _getRelativeUri(oldLocation, newDir);
             builder.addSimpleReplacement(
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/services/refactoring/move_file_test.dart b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
index adab84f..21879f2 100644
--- a/pkg/analysis_server/test/services/refactoring/move_file_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/move_file_test.dart
@@ -205,6 +205,21 @@
     assertNoFileChange(testFile);
   }
 
+  Future<void> test_file_imported_with_relative_uri_same_folder() async {
+    // https://github.com/dart-lang/sdk/issues/45593
+    testFile = convertPath('/home/test/bin/aaa.dart');
+    var pathB = convertPath('/home/test/bin/bbb.dart');
+    addSource(pathB, '');
+    await resolveTestCode("import 'bbb.dart';");
+    await analyzeTestPackageFiles();
+
+    _createRefactoring('/home/test/bin/new_aaa.dart');
+    await _assertSuccessfulRefactoring();
+
+    assertNoFileChange(testFile);
+    assertNoFileChange(pathB);
+  }
+
   Future<void> test_file_imported_with_relative_uri_sideways() async {
     var pathA = convertPath('/home/test/000/1111/a.dart');
     testFile = convertPath('/home/test/000/1111/sub/folder/test.dart');
@@ -422,9 +437,7 @@
     assertFileChangeResult(pathA, '''
 part of 'test2.dart';
 ''');
-    assertFileChangeResult(testFile, '''
-part 'a.dart';
-''');
+    assertNoFileChange(testFile);
   }
 
   Future<void> test_renaming_part_that_uses_uri_in_part_of_4() async {
@@ -472,9 +485,7 @@
     assertFileChangeResult(pathA, '''
 part 'test2.dart';
 ''');
-    assertFileChangeResult(testFile, '''
-part of 'a.dart';
-''');
+    assertNoFileChange(testFile);
   }
 
   Future _assertFailedRefactoring(RefactoringProblemSeverity expectedSeverity,
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(
diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc
index bdc785c..f0dee56 100644
--- a/runtime/vm/heap/scavenger.cc
+++ b/runtime/vm/heap/scavenger.cc
@@ -670,6 +670,7 @@
 }
 
 intptr_t SemiSpace::CachedSize() {
+  MutexLocker ml(page_cache_mutex);
   return page_cache_size * kNewPageSize;
 }
 
diff --git a/tools/VERSION b/tools/VERSION
index 8021494..bfa47d8 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 205
+PRERELEASE 206
 PRERELEASE_PATCH 0
\ No newline at end of file