Revert "Compute unlinked API signatures without unlinked summaries."

This reverts commit eb9687189de61c7a50bb1ad76dd10389ed428663.

Exceptions like "Element not found in summary" still happen with
2.1.0-dev.7.1 internally, and I suspect that it is caused by
discrepancies in API signatures and unlinked units. So, I think we
should revert this change.  We are not going to do one-phase link
anymore, so this CL is not strongly required anymore.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I213156942fa3257b1884b209dda0b1d0c731d9a8
Reviewed-on: https://dart-review.googlesource.com/c/81181
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 496216c..c1aad81 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -15,7 +15,6 @@
 import 'package:analyzer/src/dart/analysis/performance_logger.dart';
 import 'package:analyzer/src/dart/analysis/referenced_names.dart';
 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
-import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
 import 'package:analyzer/src/dart/scanner/reader.dart';
 import 'package:analyzer/src/dart/scanner/scanner.dart';
 import 'package:analyzer/src/generated/engine.dart';
@@ -114,6 +113,7 @@
   Set<String> _definedClassMemberNames;
   Set<String> _definedTopLevelNames;
   Set<String> _referencedNames;
+  String _unlinkedKey;
   AnalysisDriverUnlinkedUnit _driverUnlinkedUnit;
   UnlinkedUnit _unlinked;
   List<int> _apiSignature;
@@ -396,37 +396,26 @@
       _contentHash = rawFileState.contentHash;
     }
 
-    // Prepare keys of unlinked data.
-    String apiSignatureKey;
-    String unlinkedKey;
+    // Prepare the unlinked bundle key.
     {
       var signature = new ApiSignature();
       signature.addUint32List(_fsState._unlinkedSalt);
       signature.addString(_contentHash);
-
-      var signatureHex = signature.toHex();
-      apiSignatureKey = '$signatureHex.api_signature';
-      unlinkedKey = '$signatureHex.unlinked';
+      _unlinkedKey = '${signature.toHex()}.unlinked';
     }
 
-    // Try to get bytes of unlinked data.
-    var apiSignatureBytes = _fsState._byteStore.get(apiSignatureKey);
-    var unlinkedUnitBytes = _fsState._byteStore.get(unlinkedKey);
-
-    // Compute unlinked data that we are missing.
-    if (apiSignatureBytes == null || unlinkedUnitBytes == null) {
-      CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER);
-      _fsState._logger.run('Create unlinked for $path', () {
-        if (apiSignatureBytes == null) {
-          apiSignatureBytes = computeUnlinkedApiSignature(unit);
-          _fsState._byteStore.put(apiSignatureKey, apiSignatureBytes);
-        }
-        if (unlinkedUnitBytes == null) {
-          var unlinkedUnit = serializeAstUnlinked(unit);
-          var definedNames = computeDefinedNames(unit);
-          var referencedNames = computeReferencedNames(unit).toList();
-          var subtypedNames = computeSubtypedNames(unit).toList();
-          unlinkedUnitBytes = new AnalysisDriverUnlinkedUnitBuilder(
+    // Prepare bytes of the unlinked bundle - existing or new.
+    List<int> bytes;
+    {
+      bytes = _fsState._byteStore.get(_unlinkedKey);
+      if (bytes == null || bytes.isEmpty) {
+        CompilationUnit unit = parse();
+        _fsState._logger.run('Create unlinked for $path', () {
+          UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit);
+          DefinedNames definedNames = computeDefinedNames(unit);
+          List<String> referencedNames = computeReferencedNames(unit).toList();
+          List<String> subtypedNames = computeSubtypedNames(unit).toList();
+          bytes = new AnalysisDriverUnlinkedUnitBuilder(
                   unit: unlinkedUnit,
                   definedTopLevelNames: definedNames.topLevelNames.toList(),
                   definedClassMemberNames:
@@ -434,21 +423,21 @@
                   referencedNames: referencedNames,
                   subtypedNames: subtypedNames)
               .toBuffer();
-          _fsState._byteStore.put(unlinkedKey, unlinkedUnitBytes);
-        }
-      });
+          _fsState._byteStore.put(_unlinkedKey, bytes);
+        });
+      }
     }
 
     // Read the unlinked bundle.
-    _driverUnlinkedUnit =
-        new AnalysisDriverUnlinkedUnit.fromBuffer(unlinkedUnitBytes);
+    _driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
     _unlinked = _driverUnlinkedUnit.unit;
     _lineInfo = new LineInfo(_unlinked.lineStarts);
 
     // Prepare API signature.
+    List<int> newApiSignature = new Uint8List.fromList(_unlinked.apiSignature);
     bool apiSignatureChanged = _apiSignature != null &&
-        !_equalByteLists(_apiSignature, apiSignatureBytes);
-    _apiSignature = apiSignatureBytes;
+        !_equalByteLists(_apiSignature, newApiSignature);
+    _apiSignature = newApiSignature;
 
     // The API signature changed.
     //   Flush transitive signatures of affected files.
@@ -695,6 +684,8 @@
   final FileState file;
 
   FileStateTestView(this.file);
+
+  String get unlinkedKey => file._unlinkedKey;
 }
 
 /**
diff --git a/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart b/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart
deleted file mode 100644
index ffd8229..0000000
--- a/pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/src/dart/ast/token.dart';
-import 'package:analyzer/src/summary/api_signature.dart';
-
-/// Return the bytes of the unlinked API signature of the given [unit].
-///
-/// If API signatures of two units are different, they may have different APIs.
-List<int> computeUnlinkedApiSignature(CompilationUnit unit) {
-  var computer = new _UnitApiSignatureComputer();
-  computer.compute(unit);
-  return computer.signature.toByteList();
-}
-
-class _UnitApiSignatureComputer {
-  final signature = new ApiSignature();
-
-  void addClassOrMixin(ClassOrMixinDeclaration node) {
-    addTokens(node.beginToken, node.leftBracket);
-
-    bool hasConstConstructor = node.members
-        .any((m) => m is ConstructorDeclaration && m.constKeyword != null);
-
-    signature.addInt(node.members.length);
-    for (var member in node.members) {
-      if (member is ConstructorDeclaration) {
-        var lastInitializer = member.constKeyword != null &&
-                member.initializers != null &&
-                member.initializers.isNotEmpty
-            ? member.initializers.last
-            : null;
-        addTokens(
-          member.beginToken,
-          (lastInitializer ?? member.parameters ?? member.name).endToken,
-        );
-      } else if (member is FieldDeclaration) {
-        var variableList = member.fields;
-        addVariables(
-          member,
-          variableList,
-          !member.isStatic && variableList.isFinal && hasConstConstructor,
-        );
-      } else if (member is MethodDeclaration) {
-        addTokens(
-          member.beginToken,
-          (member.parameters ?? member.name).endToken,
-        );
-      } else {
-        addNode(member);
-      }
-    }
-
-    addToken(node.rightBracket);
-  }
-
-  void addNode(AstNode node) {
-    addTokens(node.beginToken, node.endToken);
-  }
-
-  void addToken(Token token) {
-    signature.addString(token.lexeme);
-  }
-
-  /// Appends tokens from [begin] (including), to [end] (also including).
-  void addTokens(Token begin, Token end) {
-    if (begin is CommentToken) {
-      begin = (begin as CommentToken).parent;
-    }
-
-    Token token = begin;
-    while (token != null) {
-      addToken(token);
-
-      if (token == end) {
-        break;
-      }
-
-      var nextToken = token.next;
-
-      // Stop if EOF.
-      if (nextToken == token) {
-        break;
-      }
-
-      token = nextToken;
-    }
-  }
-
-  void addVariables(
-    AstNode node,
-    VariableDeclarationList variableList,
-    bool includeInitializers,
-  ) {
-    if (variableList.type == null ||
-        variableList.isConst ||
-        includeInitializers) {
-      addTokens(node.beginToken, node.endToken);
-    } else {
-      addTokens(node.beginToken, variableList.type.endToken);
-
-      signature.addInt(variableList.variables.length);
-      for (var variable in variableList.variables) {
-        addTokens(variable.beginToken, variable.name.endToken);
-        addToken(variable.endToken.next); // `,` or `;`
-      }
-    }
-  }
-
-  void compute(CompilationUnit unit) {
-    signature.addInt(unit.directives.length);
-    unit.directives.forEach(addNode);
-
-    signature.addInt(unit.declarations.length);
-    for (var declaration in unit.declarations) {
-      if (declaration is ClassOrMixinDeclaration) {
-        addClassOrMixin(declaration);
-      } else if (declaration is FunctionDeclaration) {
-        var parameters = declaration.functionExpression.parameters;
-        addTokens(
-          declaration.beginToken,
-          (parameters ?? declaration.name).endToken,
-        );
-      } else if (declaration is TopLevelVariableDeclaration) {
-        addVariables(declaration, declaration.variables, false);
-      } else {
-        addNode(declaration);
-      }
-    }
-  }
-}
diff --git a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
index 1bbdb6d..091ec5c 100644
--- a/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/file_state_test.dart
@@ -698,6 +698,22 @@
     expect(file.apiSignature, signature);
   }
 
+  test_store_zeroLengthUnlinked() {
+    String path = _p('/test.dart');
+    provider.newFile(path, 'class A {}');
+
+    // Get the file, prepare unlinked.
+    FileState file = fileSystemState.getFileForPath(path);
+    expect(file.unlinked, isNotNull);
+
+    // Make the unlinked unit in the byte store zero-length, damaged.
+    byteStore.put(file.test.unlinkedKey, <int>[]);
+
+    // Refresh should not fail, zero bytes in the store are ignored.
+    file.refresh();
+    expect(file.unlinked, isNotNull);
+  }
+
   test_subtypedNames() {
     String path = _p('/test.dart');
     provider.newFile(path, r'''
diff --git a/pkg/analyzer/test/src/dart/analysis/test_all.dart b/pkg/analyzer/test/src/dart/analysis/test_all.dart
index ac21ffc..a8e0105 100644
--- a/pkg/analyzer/test/src/dart/analysis/test_all.dart
+++ b/pkg/analyzer/test/src/dart/analysis/test_all.dart
@@ -24,7 +24,6 @@
 import 'search_test.dart' as search;
 import 'session_helper_test.dart' as session_helper;
 import 'session_test.dart' as session;
-import 'unlinked_api_signature_test.dart' as unlinked_api_signature;
 import 'uri_converter_test.dart' as uri_converter;
 
 main() {
@@ -49,7 +48,6 @@
     search.main();
     session.main();
     session_helper.main();
-    unlinked_api_signature.main();
     uri_converter.main();
   }, name: 'analysis');
 }
diff --git a/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart b/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart
deleted file mode 100644
index 2c9d8e1..0000000
--- a/pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart
+++ /dev/null
@@ -1,884 +0,0 @@
-// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:typed_data';
-
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/src/dart/analysis/byte_store.dart';
-import 'package:analyzer/src/dart/analysis/file_state.dart';
-import 'package:analyzer/src/dart/analysis/performance_logger.dart';
-import 'package:analyzer/src/file_system/file_system.dart';
-import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
-import 'package:analyzer/src/generated/source.dart';
-import 'package:analyzer/src/source/package_map_resolver.dart';
-import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
-import 'package:test/test.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../../context/mock_sdk.dart';
-
-main() {
-  defineReflectiveSuite(() {
-    defineReflectiveTests(UnitApiSignatureTest);
-  });
-}
-
-@reflectiveTest
-class UnitApiSignatureTest extends Object with ResourceProviderMixin {
-  FileSystemState fileSystemState;
-
-  void assertNotSameSignature(String oldCode, String newCode) {
-    assertSignature(oldCode, newCode, same: false);
-  }
-
-  void assertSameSignature(String oldCode, String newCode) {
-    assertSignature(oldCode, newCode, same: true);
-  }
-
-  void assertSignature(String oldCode, String newCode, {bool same}) {
-    var path = convertPath('/test.dart');
-
-    newFile(path, content: oldCode);
-    var file = fileSystemState.getFileForPath(path);
-    var lastSignature = file.apiSignature;
-
-    newFile(path, content: newCode);
-    file.refresh();
-
-    var newSignature = file.apiSignature;
-    if (same) {
-      expect(newSignature, lastSignature);
-    } else {
-      expect(newSignature, isNot(lastSignature));
-    }
-  }
-
-  void setUp() {
-    var sdk = new MockSdk(resourceProvider: resourceProvider);
-    var sourceFactory = new SourceFactory([
-      new DartUriResolver(sdk),
-      new PackageMapUriResolver(resourceProvider, <String, List<Folder>>{
-        'aaa': [getFolder('/aaa/lib')],
-        'bbb': [getFolder('/bbb/lib')],
-      }),
-      new ResourceUriResolver(resourceProvider)
-    ], null, resourceProvider);
-    fileSystemState = new FileSystemState(
-        new PerformanceLog(new StringBuffer()),
-        new MemoryByteStore(),
-        new FileContentOverlay(),
-        resourceProvider,
-        sourceFactory,
-        new AnalysisOptionsImpl(),
-        new Uint32List(0),
-        new Uint32List(0));
-  }
-
-  test_class_annotation() async {
-    assertNotSameSignature(r'''
-const a = 0;
-
-class C {}
-''', r'''
-const a = 0;
-
-@a
-class C {}
-''');
-  }
-
-  test_class_constructor_block_to_empty() {
-    assertSameSignature(r'''
-class C {
-  C() {
-    var v = 1;
-  }
-}
-''', r'''
-class C {
-  C();
-}
-''');
-  }
-
-  test_class_constructor_body() {
-    assertSameSignature(r'''
-class C {
-  C() {
-    var v = 1;
-  }
-}
-''', r'''
-class C {
-  C() {
-    var v = 2;
-  }
-}
-''');
-  }
-
-  test_class_constructor_empty_to_block() {
-    assertSameSignature(r'''
-class C {
-  C();
-}
-''', r'''
-class C {
-  C() {
-    var v = 1;
-  }
-}
-''');
-  }
-
-  test_class_constructor_initializer_const() {
-    assertNotSameSignature(r'''
-class C {
-  final int f;
-  const C() : f = 1;
-}
-''', r'''
-class C {
-  final int f;
-  const C() : f = 2;
-}
-''');
-  }
-
-  test_class_constructor_initializer_empty() {
-    assertSameSignature(r'''
-class C {
-  C.foo() : ;
-}
-''', r'''
-class C {
-  C.foo() : f;
-}
-''');
-  }
-
-  test_class_constructor_initializer_notConst() {
-    assertSameSignature(r'''
-class C {
-  final int f;
-  C.foo() : f = 1;
-  const C.bar();
-}
-''', r'''
-class C {
-  final int f;
-  C.foo() : f = 2;
-  const C.bar();
-}
-''');
-  }
-
-  test_class_constructor_parameters_add() {
-    assertNotSameSignature(r'''
-class C {
-  C(int a);
-}
-''', r'''
-class C {
-  C(int a, int b);
-}
-''');
-  }
-
-  test_class_constructor_parameters_remove() {
-    assertNotSameSignature(r'''
-class C {
-  C(int a, int b);
-}
-''', r'''
-class C {
-  C(int a);
-}
-''');
-  }
-
-  test_class_constructor_parameters_rename() {
-    assertNotSameSignature(r'''
-class C {
-  C(int a);
-}
-''', r'''
-class C {
-  C(int b);
-}
-''');
-  }
-
-  test_class_constructor_parameters_type() {
-    assertNotSameSignature(r'''
-class C {
-  C(int p);
-}
-''', r'''
-class C {
-  C(double p);
-}
-''');
-  }
-
-  test_class_extends() {
-    assertNotSameSignature(r'''
-class A {}
-class B {}
-''', r'''
-class A {}
-class B extends A {}
-''');
-  }
-
-  test_class_field_withoutType() {
-    assertNotSameSignature(r'''
-class C {
-  var a = 1;
-}
-''', r'''
-class C {
-  var a = 2;
-}
-''');
-  }
-
-  test_class_field_withoutType2() {
-    assertNotSameSignature(r'''
-class C {
-  var a = 1, b = 2, c, d = 4;
-}
-''', r'''
-class C {
-  var a = 1, b, c = 3, d = 4;
-}
-''');
-  }
-
-  test_class_field_withType() {
-    assertSameSignature(r'''
-class C {
-  int a = 1, b, c = 3;
-}
-''', r'''
-class C {
-  int a = 0, b = 2, c;
-}
-''');
-  }
-
-  test_class_field_withType_const() {
-    assertNotSameSignature(r'''
-class C {
-  static const int a = 1;
-}
-''', r'''
-class C {
-  static const int a = 2;
-}
-''');
-  }
-
-  test_class_field_withType_final_hasConstConstructor() {
-    assertNotSameSignature(r'''
-class C {
-  final int a = 1;
-  const C();
-}
-''', r'''
-class C {
-  final int a = 2;
-  const C();
-}
-''');
-  }
-
-  test_class_field_withType_final_noConstConstructor() {
-    assertSameSignature(r'''
-class C {
-  final int a = 1;
-}
-''', r'''
-class C {
-  final int a = 2;
-}
-''');
-  }
-
-  test_class_field_withType_hasConstConstructor() {
-    assertSameSignature(r'''
-class C {
-  int a = 1;
-  const C();
-}
-''', r'''
-class C {
-  int a = 2;
-  const C();
-}
-''');
-  }
-
-  test_class_field_withType_static_final_hasConstConstructor() {
-    assertSameSignature(r'''
-class C {
-  static final int a = 1;
-  const C();
-}
-''', r'''
-class C {
-  static final int a = 2;
-  const C();
-}
-''');
-  }
-
-  test_class_field_withType_static_hasConstConstructor() {
-    assertSameSignature(r'''
-class C {
-  static int a = 1;
-  const C();
-}
-''', r'''
-class C {
-  static int a = 2;
-  const C();
-}
-''');
-  }
-
-  test_class_implements() {
-    assertNotSameSignature(r'''
-class A {}
-class B {}
-''', r'''
-class A {}
-class B implements A {}
-''');
-  }
-
-  test_class_method_annotation() {
-    assertNotSameSignature(r'''
-const a = 0;
-
-class C {
-  void foo() {}
-}
-''', r'''
-const a = 0;
-
-class C {
-  @a
-  void foo() {}
-}
-''');
-  }
-
-  test_class_method_body_async_to_sync() {
-    assertSameSignature(r'''
-class C {
-  Future foo() async {}
-}
-''', r'''
-class C {
-  Future foo() {}
-}
-''');
-  }
-
-  test_class_method_body_block() {
-    assertSameSignature(r'''
-class C {
-  int foo() {
-    return 1;
-  }
-}
-''', r'''
-class C {
-  int foo() {
-    return 2;
-  }
-}
-''');
-  }
-
-  test_class_method_body_block_to_expression() {
-    assertSameSignature(r'''
-class C {
-  int foo() {
-    return 1;
-  }
-}
-''', r'''
-class C {
-  int foo() => 2;
-}
-''');
-  }
-
-  test_class_method_body_empty_to_block() {
-    assertSameSignature(r'''
-class C {
-  int foo();
-}
-''', r'''
-class C {
-  int foo() {
-    var v = 0;
-  }
-}
-''');
-  }
-
-  test_class_method_body_expression() {
-    assertSameSignature(r'''
-class C {
-  int foo() => 1;
-}
-''', r'''
-class C {
-  int foo() => 2;
-}
-''');
-  }
-
-  test_class_method_body_sync_to_async() {
-    assertSameSignature(r'''
-class C {
-  Future foo() {}
-}
-''', r'''
-class C {
-  Future foo() async {}
-}
-''');
-  }
-
-  test_class_method_getter_body_block_to_expression() {
-    assertSameSignature(r'''
-class C {
-  int get foo {
-    return 1;
-  }
-}
-''', r'''
-class C {
-  int get foo => 2;
-}
-''');
-  }
-
-  test_class_method_getter_body_empty_to_expression() {
-    assertSameSignature(r'''
-class C {
-  int get foo;
-}
-''', r'''
-class C {
-  int get foo => 2;
-}
-''');
-  }
-
-  test_class_method_parameters_add() {
-    assertNotSameSignature(r'''
-class C {
-  foo(int a) {}
-}
-''', r'''
-class C {
-  foo(int a, int b) {}
-}
-''');
-  }
-
-  test_class_method_parameters_remove() {
-    assertNotSameSignature(r'''
-class C {
-  foo(int a, int b) {}
-}
-''', r'''
-class C {
-  foo(int a) {}
-}
-''');
-  }
-
-  test_class_method_parameters_rename() {
-    assertNotSameSignature(r'''
-class C {
-  void foo(int a) {}
-}
-''', r'''
-class C {
-  void foo(int b) {}
-}
-''');
-  }
-
-  test_class_method_parameters_type() {
-    assertNotSameSignature(r'''
-class C {
-  void foo(int p) {}
-}
-''', r'''
-class C {
-  void foo(double p) {}
-}
-''');
-  }
-
-  test_class_method_returnType() {
-    assertNotSameSignature(r'''
-class C {
-  int foo() => 0;
-}
-''', r'''
-class C {
-  num foo() => 0;
-}
-''');
-  }
-
-  test_class_method_typeParameters_add() async {
-    assertNotSameSignature(r'''
-class C {
-  void foo() {}
-}
-''', r'''
-class C {
-  void foo<T>() {}
-}
-''');
-  }
-
-  test_class_method_typeParameters_remove() {
-    assertNotSameSignature(r'''
-class C {
-  void foo<T>() {}
-}
-''', r'''
-class C {
-  void foo() {}
-}
-''');
-  }
-
-  test_class_method_typeParameters_rename() {
-    assertNotSameSignature(r'''
-class C {
-  void foo<T>() {}
-}
-''', r'''
-class C {
-  void foo<U>() {}
-}
-''');
-  }
-
-  test_class_modifier() {
-    assertNotSameSignature(r'''
-class C {}
-''', r'''
-abstract class C {}
-''');
-  }
-
-  test_class_with() {
-    assertNotSameSignature(r'''
-class A {}
-class B {}
-class C extends A {}
-''', r'''
-class A {}
-class B {}
-class C extends A with B {}
-''');
-  }
-
-  test_commentAdd() {
-    assertSameSignature(r'''
-var a = 1;
-var b = 2;
-var c = 3;
-''', r'''
-var a = 1; // comment
-
-/// comment 1
-/// comment 2
-var b = 2;
-
-/**
- *  Comment
- */
-var c = 3;
-''');
-  }
-
-  test_commentRemove() {
-    assertSameSignature(r'''
-var a = 1; // comment
-
-/// comment 1
-/// comment 2
-var b = 2;
-
-/**
- *  Comment
- */
-var c = 3;
-''', r'''
-var a = 1;
-var b = 2;
-var c = 3;
-''');
-  }
-
-  test_function_annotation() {
-    assertNotSameSignature(r'''
-const a = 0;
-
-void foo() {}
-''', r'''
-const a = 0;
-
-@a
-void foo() {}
-''');
-  }
-
-  test_function_body_async_to_sync() {
-    assertSameSignature(r'''
-Future foo() async {}
-''', r'''
-Future foo() {}
-''');
-  }
-
-  test_function_body_block() {
-    assertSameSignature(r'''
-int foo() {
-  return 1;
-}
-''', r'''
-int foo() {
-  return 2;
-}
-''');
-  }
-
-  test_function_body_block_to_expression() {
-    assertSameSignature(r'''
-int foo() {
-  return 1;
-}
-''', r'''
-int foo() => 2;
-''');
-  }
-
-  test_function_body_expression() {
-    assertSameSignature(r'''
-int foo() => 1;
-''', r'''
-int foo() => 2;
-''');
-  }
-
-  test_function_body_sync_to_async() {
-    assertSameSignature(r'''
-Future foo() {}
-''', r'''
-Future foo() async {}
-''');
-  }
-
-  test_function_getter_block_to_expression() {
-    assertSameSignature(r'''
-int get foo {
-  return 1;
-}
-''', r'''
-int get foo => 2;
-''');
-  }
-
-  test_function_parameters_rename() {
-    assertNotSameSignature(r'''
-void foo(int a) {}
-''', r'''
-void foo(int b) {}
-''');
-  }
-
-  test_function_parameters_type() {
-    assertNotSameSignature(r'''
-void foo(int p) {}
-''', r'''
-void foo(double p) {}
-''');
-  }
-
-  test_function_returnType() {
-    assertNotSameSignature(r'''
-int foo() => 0;
-''', r'''
-num foo() => 0;
-''');
-  }
-
-  test_function_typeParameters_add() {
-    assertNotSameSignature(r'''
-void foo() {}
-''', r'''
-void foo<T>() {}
-''');
-  }
-
-  test_function_typeParameters_remove() {
-    assertNotSameSignature(r'''
-void foo<T>() {}
-''', r'''
-void foo() {}
-''');
-  }
-
-  test_function_typeParameters_rename() {
-    assertNotSameSignature(r'''
-void foo<T>() {}
-''', r'''
-void foo<U>() {}
-''');
-  }
-
-  test_issue34850() {
-    assertNotSameSignature(r'''
-foo
-Future<List<int>> bar() {}
-''', r'''
-foo
-Future<List<int>> bar(int x) {}
-''');
-  }
-
-  test_mixin_field_withoutType() {
-    assertNotSameSignature(r'''
-mixin M {
-  var a = 1;
-}
-''', r'''
-mixin M {
-  var a = 2;
-}
-''');
-  }
-
-  test_mixin_field_withType() {
-    assertSameSignature(r'''
-mixin M {
-  int a = 1, b, c = 3;
-}
-''', r'''
-mixin M {
-  int a = 0, b = 2, c;
-}
-''');
-  }
-
-  test_mixin_implements() {
-    assertNotSameSignature(r'''
-class A {}
-mixin M {}
-''', r'''
-class A {}
-mixin M implements A {}
-''');
-  }
-
-  test_mixin_method_body_block() {
-    assertSameSignature(r'''
-mixin M {
-  int foo() {
-    return 1;
-  }
-}
-''', r'''
-mixin M {
-  int foo() {
-    return 2;
-  }
-}
-''');
-  }
-
-  test_mixin_method_body_expression() {
-    assertSameSignature(r'''
-mixin M {
-  int foo() => 1;
-}
-''', r'''
-mixin M {
-  int foo() => 2;
-}
-''');
-  }
-
-  test_mixin_on() {
-    assertNotSameSignature(r'''
-class A {}
-mixin M {}
-''', r'''
-class A {}
-mixin M on A {}
-''');
-  }
-
-  test_topLevelVariable_withoutType() {
-    assertNotSameSignature(r'''
-var a = 1;
-''', r'''
-var a = 2;
-''');
-  }
-
-  test_topLevelVariable_withoutType2() {
-    assertNotSameSignature(r'''
-var a = 1, b = 2, c, d = 4;;
-''', r'''
-var a = 1, b, c = 3, d = 4;;
-''');
-  }
-
-  test_topLevelVariable_withType() {
-    assertSameSignature(r'''
-int a = 1, b, c = 3;
-''', r'''
-int a = 0, b = 2, c;
-''');
-  }
-
-  test_topLevelVariable_withType_const() {
-    assertNotSameSignature(r'''
-const int a = 1;
-''', r'''
-const int a = 2;
-''');
-  }
-
-  test_topLevelVariable_withType_final() {
-    assertSameSignature(r'''
-final int a = 1;
-''', r'''
-final int a = 2;
-''');
-  }
-
-  test_typedef_generic_parameters_type() {
-    assertNotSameSignature(r'''
-typedef F = void Function(int);
-''', r'''
-typedef F = void Function(double);
-''');
-  }
-}