Version 2.15.0-155.0.dev

Merge commit '67c1f75d2be5b86f1f125f095a3f3b5fd5a1e104' into 'dev'
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 780bd0b..fd9daec 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -23,7 +23,6 @@
 import 'package:analysis_server/src/domain_execution.dart';
 import 'package:analysis_server/src/domain_kythe.dart';
 import 'package:analysis_server/src/domain_server.dart';
-import 'package:analysis_server/src/domains/analysis/macro_files.dart';
 import 'package:analysis_server/src/domains/analysis/occurrences.dart';
 import 'package:analysis_server/src/domains/analysis/occurrences_dart.dart';
 import 'package:analysis_server/src/edit/edit_domain.dart';
@@ -54,7 +53,6 @@
 import 'package:analyzer/src/util/file_paths.dart' as file_paths;
 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
 import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
-import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
 import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
 import 'package:http/http.dart' as http;
 import 'package:telemetry/crash_reporting.dart';
@@ -723,10 +721,7 @@
   server.AnalysisNavigationParams _computeNavigationParams(
       String path, CompilationUnit unit) {
     var collector = NavigationCollectorImpl();
-    computeDartNavigation(resourceProvider, collector, unit, null, null,
-        analyzerConverter: AnalyzerConverter(
-            locationProvider:
-                MacroElementLocationProvider(MacroFiles(resourceProvider))));
+    computeDartNavigation(resourceProvider, collector, unit, null, null);
     collector.createRegions();
     return server.AnalysisNavigationParams(
         path, collector.regions, collector.targets, collector.files);
diff --git a/pkg/analysis_server/lib/src/domains/analysis/macro_files.dart b/pkg/analysis_server/lib/src/domains/analysis/macro_files.dart
deleted file mode 100644
index be391be..0000000
--- a/pkg/analysis_server/lib/src/domains/analysis/macro_files.dart
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (c) 2021, 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/element/element.dart';
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/source/line_info.dart';
-import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/util/file_paths.dart' as file_paths;
-import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol;
-import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
-
-class MacroElementLocationProvider implements ElementLocationProvider {
-  final MacroFiles _macroFiles;
-
-  MacroElementLocationProvider(this._macroFiles);
-
-  @override
-  protocol.Location? forElement(Element element) {
-    if (element is HasMacroGenerationData) {
-      var macro = (element as HasMacroGenerationData).macro;
-      if (macro != null) {
-        return _forElement(element, macro);
-      }
-    }
-  }
-
-  protocol.Location? _forElement(Element element, MacroGenerationData macro) {
-    var unitElement = element.thisOrAncestorOfType<CompilationUnitElement>();
-    if (unitElement is! CompilationUnitElementImpl) {
-      return null;
-    }
-
-    var generatedFile = _macroFiles.generatedFile(unitElement);
-    if (generatedFile == null) {
-      return null;
-    }
-
-    var nameOffset = element.nameOffset;
-    var nameLength = element.nameLength;
-
-    var lineInfo = generatedFile.lineInfo;
-    var offsetLocation = lineInfo.getLocation(nameOffset);
-    var endLocation = lineInfo.getLocation(nameOffset + nameLength);
-
-    return protocol.Location(generatedFile.path, nameOffset, nameLength,
-        offsetLocation.lineNumber, offsetLocation.columnNumber,
-        endLine: endLocation.lineNumber, endColumn: endLocation.columnNumber);
-  }
-}
-
-/// Note, this class changes the file system.
-class MacroFiles {
-  final ResourceProvider _resourceProvider;
-
-  /// Keys are source paths.
-  final Map<String, _MacroGeneratedFile> _files = {};
-
-  MacroFiles(this._resourceProvider);
-
-  /// If [unitElement] has macro-generated elements, write the combined
-  /// content into a new file in `.dart_tool`, and return the description of
-  /// this file.
-  _MacroGeneratedFile? generatedFile(CompilationUnitElementImpl unitElement) {
-    var sourcePath = unitElement.source.fullName;
-
-    var result = _files[sourcePath];
-    if (result != null) {
-      return result;
-    }
-
-    var sourceFile = _resourceProvider.getFile(sourcePath);
-
-    // TODO(scheglov) Use workspace?
-    Folder? packageRoot;
-    for (var parent in sourceFile.parent2.withAncestors) {
-      if (parent.getChildAssumingFile(file_paths.pubspecYaml).exists) {
-        packageRoot = parent;
-        break;
-      }
-    }
-    if (packageRoot == null) {
-      return null;
-    }
-
-    var pathContext = _resourceProvider.pathContext;
-    var relativePath = pathContext.relative(
-      sourcePath,
-      from: packageRoot.path,
-    );
-    var generatedPath = pathContext.join(
-        packageRoot.path, '.dart_tool', 'analyzer', 'macro', relativePath);
-
-    var generatedContent = unitElement.macroGeneratedContent;
-    if (generatedContent == null) {
-      return null;
-    }
-
-    try {
-      _resourceProvider.getFile(generatedPath)
-        ..parent2.create()
-        ..writeAsStringSync(generatedContent);
-    } on FileSystemException {
-      return null;
-    }
-
-    return _files[sourcePath] = _MacroGeneratedFile(
-      generatedPath,
-      generatedContent,
-    );
-  }
-}
-
-class _MacroGeneratedFile {
-  final String path;
-  final String content;
-  final LineInfo lineInfo;
-
-  _MacroGeneratedFile(this.path, this.content)
-      : lineInfo = LineInfo.fromContent(content);
-}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
index d203ef9..a9bc050 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_definition.dart
@@ -6,7 +6,6 @@
 import 'package:analysis_server/lsp_protocol/protocol_special.dart';
 import 'package:analysis_server/protocol/protocol_generated.dart'
     hide AnalysisGetNavigationParams;
-import 'package:analysis_server/src/domains/analysis/macro_files.dart';
 import 'package:analysis_server/src/lsp/handlers/handlers.dart';
 import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
 import 'package:analysis_server/src/lsp/mapping.dart';
@@ -16,7 +15,6 @@
 import 'package:analyzer/source/line_info.dart';
 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
 import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
-import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
 import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
 import 'package:collection/collection.dart';
 
@@ -56,10 +54,8 @@
     final result = await server.getResolvedUnit(path);
     final unit = result?.unit;
     if (result?.state == ResultState.VALID && unit != null) {
-      computeDartNavigation(server.resourceProvider, collector, unit, offset, 0,
-          analyzerConverter: AnalyzerConverter(
-              locationProvider: MacroElementLocationProvider(
-                  MacroFiles(server.resourceProvider))));
+      computeDartNavigation(
+          server.resourceProvider, collector, unit, offset, 0);
       collector.createRegions();
     }
 
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
index 71cc613..979ab11 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/suggestion_builder.dart
@@ -141,6 +141,22 @@
 /// An object used to build a list of suggestions in response to a single
 /// completion request.
 class SuggestionBuilder {
+  /// The cache of suggestions for [Element]s. We use it to avoid computing
+  /// the same documentation, parameters, return type, etc for elements that
+  /// are exactly the same (the same instances) as they were the last time.
+  ///
+  /// This cache works because:
+  /// 1. Flutter applications usually reference many libraries, which they
+  /// consume, but don't change. So, all their elements stay unchanged.
+  /// 2. The analyzer keeps the same library instances loaded as the user
+  /// types in the application, so the instances of all elements stay the
+  /// same, and the cache works.
+  /// 3. The analyzer does not patch elements (at least not after the linking
+  /// process is done, and the elements are exposed to any client code). So,
+  /// any type information, or documentation, stays the same. If this changes,
+  /// we would need a signal, e.g. some modification counter on the element.
+  static final _elementSuggestionCache = Expando<_CompletionSuggestionEntry>();
+
   /// The completion request for which suggestions are being built.
   final DartCompletionRequest request;
 
@@ -1004,6 +1020,50 @@
       CompletionSuggestionKind? kind,
       String? prefix,
       required int relevance}) {
+    var inputs = _CompletionSuggestionInputs(
+      completion: completion,
+      elementKind: elementKind,
+      kind: kind,
+      prefix: prefix,
+    );
+
+    var cacheEntry = _elementSuggestionCache[element];
+    if (cacheEntry != null) {
+      if (cacheEntry.inputs == inputs) {
+        final suggestion = cacheEntry.suggestion;
+        suggestion.relevance = relevance;
+        return suggestion;
+      }
+    }
+
+    var suggestion = _createSuggestion0(
+      element,
+      completion: completion,
+      elementKind: elementKind,
+      kind: kind,
+      prefix: prefix,
+      relevance: relevance,
+    );
+    if (suggestion == null) {
+      return null;
+    }
+
+    _elementSuggestionCache[element] = _CompletionSuggestionEntry(
+      inputs: inputs,
+      suggestion: suggestion,
+    );
+    return suggestion;
+  }
+
+  /// The non-caching implementation of [_createSuggestion].
+  CompletionSuggestion? _createSuggestion0(
+    Element element, {
+    required String? completion,
+    required protocol.ElementKind? elementKind,
+    required CompletionSuggestionKind? kind,
+    required String? prefix,
+    required int relevance,
+  }) {
     if (element is ExecutableElement && element.isOperator) {
       // Do not include operators in suggestions
       return null;
@@ -1159,3 +1219,41 @@
   /// no `elementKindRelevance` table associated with the [completionLocation].
   void missingElementKindTableFor(String completionLocation);
 }
+
+/// The entry of the element to suggestion cache.
+class _CompletionSuggestionEntry {
+  final _CompletionSuggestionInputs inputs;
+
+  /// The suggestion computed for the element and [inputs].
+  final CompletionSuggestion suggestion;
+
+  _CompletionSuggestionEntry({
+    required this.inputs,
+    required this.suggestion,
+  });
+}
+
+/// The inputs, other than the [Element], that were provided to create an
+/// instance of [CompletionSuggestion].
+class _CompletionSuggestionInputs {
+  final String? completion;
+  final protocol.ElementKind? elementKind;
+  final CompletionSuggestionKind? kind;
+  final String? prefix;
+
+  _CompletionSuggestionInputs({
+    required this.completion,
+    required this.elementKind,
+    required this.kind,
+    required this.prefix,
+  });
+
+  @override
+  bool operator ==(Object other) {
+    return other is _CompletionSuggestionInputs &&
+        other.completion == completion &&
+        other.elementKind == elementKind &&
+        other.kind == kind &&
+        other.prefix == prefix;
+  }
+}
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
index f334a64..035909b 100644
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
@@ -918,63 +918,6 @@
     assertHasTargetString('my.lib');
   }
 
-  Future<void> test_macro_simpleIdentifier_getter() async {
-    // TODO(scheglov) Use PubPackageResolutionTest?
-    newFile('$projectPath/pubspec.yaml', content: '');
-
-    newFile('$projectPath/bin/macro_annotations.dart', content: r'''
-library analyzer.macro.annotations;
-const observable = 0;
-''');
-
-    addTestFile(r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-}
-
-void f(A a) {
-  a.foo;
-}
-''');
-
-    await prepareNavigation();
-    assertHasRegionString('foo;', 3);
-
-    var generatedFile = getFile(
-      '/project/.dart_tool/analyzer/macro/bin/test.dart',
-    );
-
-    var generatedContent = generatedFile.readAsStringSync();
-    expect(generatedContent, r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-
-  int get foo => _foo;
-
-  set foo(int val) {
-    print('Setting foo to ${val}');
-    _foo = val;
-  }
-}
-
-void f(A a) {
-  a.foo;
-}
-''');
-
-    assertHasFileTarget(
-      generatedFile.path,
-      generatedContent.indexOf('foo =>'),
-      'foo'.length,
-    );
-  }
-
   Future<void> test_multiplyDefinedElement() async {
     newFile('$projectPath/bin/libA.dart', content: 'library A; int TEST = 1;');
     newFile('$projectPath/bin/libB.dart', content: 'library B; int TEST = 2;');
diff --git a/pkg/analysis_server/test/lsp/definition_test.dart b/pkg/analysis_server/test/lsp/definition_test.dart
index 083158c..f15c592 100644
--- a/pkg/analysis_server/test/lsp/definition_test.dart
+++ b/pkg/analysis_server/test/lsp/definition_test.dart
@@ -188,71 +188,6 @@
     );
   }
 
-  Future<void> test_macro_simpleIdentifier_getter() async {
-    final macroAnnotationsContents = '''
-library analyzer.macro.annotations;
-const observable = 0;
-''';
-
-    final mainContents = '''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-}
-
-void f(A a) {
-  a.[[foo^]];
-}
-''';
-
-    final combinedContents = r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-
-  int get [[foo]] => _foo;
-
-  set foo(int val) {
-    print('Setting foo to ${val}');
-    _foo = val;
-  }
-}
-
-void f(A a) {
-  a.[[foo^]];
-}
-''';
-
-    final macroAnnotationsFileUri =
-        Uri.file(join(projectFolderPath, 'lib', 'macro_annotations.dart'));
-    final pubspecFileUri = Uri.file(join(projectFolderPath, 'pubspec.yaml'));
-    final combinedFileUri = Uri.file(join(projectFolderPath, '.dart_tool',
-        'analyzer', 'macro', 'lib', 'main.dart'));
-
-    await initialize(
-        textDocumentCapabilities:
-            withLocationLinkSupport(emptyTextDocumentClientCapabilities));
-    await openFile(pubspecFileUri, '');
-    await openFile(
-        macroAnnotationsFileUri, withoutMarkers(macroAnnotationsContents));
-    await openFile(mainFileUri, withoutMarkers(mainContents));
-    final res = await getDefinitionAsLocationLinks(
-        mainFileUri, positionFromMarker(mainContents));
-
-    expect(res, hasLength(1));
-    final loc = res.single;
-    expect(loc.originSelectionRange, equals(rangeFromMarkers(mainContents)));
-    expect(loc.targetUri, equals(combinedFileUri.toString()));
-
-    final getFooRange = rangesFromMarkers(combinedContents)[0];
-    expect(loc.targetRange, equals(getFooRange));
-    expect(loc.targetSelectionRange, equals(getFooRange));
-  }
-
   Future<void> test_nonDartFile() async {
     newFile(pubspecFilePath, content: simplePubspecContent);
     await initialize();
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index c07ce8f..cbbb42b 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -270,7 +270,6 @@
   CompileTimeErrorCode.LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR,
   CompileTimeErrorCode.LATE_FINAL_LOCAL_ALREADY_ASSIGNED,
   CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
-  CompileTimeErrorCode.MACRO_EXECUTION_ERROR,
   CompileTimeErrorCode.MAIN_FIRST_POSITIONAL_PARAMETER_TYPE,
   CompileTimeErrorCode.MAIN_HAS_REQUIRED_NAMED_PARAMETERS,
   CompileTimeErrorCode.MAIN_HAS_TOO_MANY_REQUIRED_POSITIONAL_PARAMETERS,
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 5b6574a..1255129 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -80,7 +80,7 @@
 /// TODO(scheglov) Clean up the list of implicitly analyzed files.
 class AnalysisDriver implements AnalysisDriverGeneric {
   /// The version of data format, should be incremented on every format change.
-  static const int DATA_VERSION = 180;
+  static const int DATA_VERSION = 181;
 
   /// The number of exception contexts allowed to write. Once this field is
   /// zero, we stop writing any new exception contexts in this process.
@@ -950,7 +950,7 @@
 
     FileState file = _fileTracker.getFile(path);
     RecordingErrorListener listener = RecordingErrorListener();
-    CompilationUnit unit = file.parse(errorListener: listener);
+    CompilationUnit unit = file.parse(listener);
     return ParsedUnitResultImpl(currentSession, file.path, file.uri,
         file.content, file.lineInfo, file.isPart, unit, listener.errors);
   }
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index eff19a9..620c43d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -368,21 +368,10 @@
   }
 
   /// Return a new parsed unresolved [CompilationUnit].
-  ///
-  /// If [content] is provided, then it is parsed instead, for example because
-  /// it contains macro-generated declarations, and we want to resolve the
-  /// unit with these declarations.
-  CompilationUnitImpl parse({
-    String? content,
-    AnalysisErrorListener? errorListener,
-  }) {
-    content ??= this.content;
+  CompilationUnitImpl parse([AnalysisErrorListener? errorListener]) {
     errorListener ??= AnalysisErrorListener.NULL_LISTENER;
     try {
-      return _parse(
-        content: content,
-        errorListener: errorListener,
-      );
+      return _parse(errorListener);
     } catch (exception, stackTrace) {
       throw CaughtExceptionWithFiles(
         exception,
@@ -560,10 +549,7 @@
     }
   }
 
-  CompilationUnitImpl _parse({
-    required String content,
-    required AnalysisErrorListener errorListener,
-  }) {
+  CompilationUnitImpl _parse(AnalysisErrorListener errorListener) {
     CharSequenceReader reader = CharSequenceReader(content);
     Scanner scanner = Scanner(source, reader, errorListener)
       ..configureFeatures(
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 78e7fc4e..d2a5859 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analyzer/dart/analysis/declared_variables.dart';
+import 'package:analyzer/dart/analysis/features.dart';
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/error/error.dart';
@@ -50,6 +51,7 @@
 
 var timerLibraryAnalyzer = Stopwatch();
 var timerLibraryAnalyzerConst = Stopwatch();
+var timerLibraryAnalyzerFreshUnit = Stopwatch();
 var timerLibraryAnalyzerResolve = Stopwatch();
 var timerLibraryAnalyzerSplicer = Stopwatch();
 var timerLibraryAnalyzerVerify = Stopwatch();
@@ -104,9 +106,24 @@
   /// Compute analysis results for all units of the library.
   Map<FileState, UnitAnalysisResult> analyzeSync() {
     timerLibraryAnalyzer.start();
+    Map<FileState, CompilationUnitImpl> units = {};
+
+    // Parse all files.
+    timerLibraryAnalyzerFreshUnit.start();
+    for (FileState file in _library.libraryFiles) {
+      units[file] = _parse(file);
+    }
+    timerLibraryAnalyzerFreshUnit.stop();
+
+    // Resolve URIs in directives to corresponding sources.
+    FeatureSet featureSet = units[_library]!.featureSet;
+    units.forEach((file, unit) {
+      _validateFeatureSet(unit, featureSet);
+      _resolveUriBasedDirectives(file, unit);
+    });
 
     timerLibraryAnalyzerResolve.start();
-    var units = _resolveDirectives();
+    _resolveDirectives(units);
 
     units.forEach((file, unit) {
       _resolveFile(file, unit);
@@ -173,9 +190,7 @@
     units.forEach((file, unit) {
       List<AnalysisError> errors = _getErrorListener(file).errors;
       errors = _filterIgnoredErrors(file, errors);
-      var combinedResult = UnitAnalysisResult(file, unit, errors);
-      var writtenResult = _transformToWrittenCode(combinedResult);
-      results[file] = writtenResult;
+      results[file] = UnitAnalysisResult(file, unit, errors);
     });
     timerLibraryAnalyzer.stop();
     return results;
@@ -483,16 +498,10 @@
   }
 
   /// Return a new parsed unresolved [CompilationUnit].
-  CompilationUnitImpl _parse(
-    FileState file,
-    CompilationUnitElementImpl element,
-  ) {
+  CompilationUnitImpl _parse(FileState file) {
     AnalysisErrorListener errorListener = _getErrorListener(file);
-    String content = element.macroGeneratedContent ?? file.content;
-    var unit = file.parse(
-      content: content,
-      errorListener: errorListener,
-    );
+    String content = file.content;
+    var unit = file.parse(errorListener);
 
     LineInfo lineInfo = unit.lineInfo!;
     _fileToLineInfo[file] = lineInfo;
@@ -501,17 +510,9 @@
     return unit;
   }
 
-  Map<FileState, CompilationUnitImpl> _resolveDirectives() {
-    var units = <FileState, CompilationUnitImpl>{};
-
-    var definingElement = _libraryElement.definingCompilationUnit;
-    definingElement as CompilationUnitElementImpl;
-
-    var definingUnit = _parse(_library, definingElement);
-    units[_library] = definingUnit;
-
-    definingUnit.element = definingElement;
-    _resolveUriBasedDirectives(_library, definingUnit);
+  void _resolveDirectives(Map<FileState, CompilationUnitImpl> units) {
+    var definingCompilationUnit = units[_library]!;
+    definingCompilationUnit.element = _libraryElement.definingCompilationUnit;
 
     bool matchNodeElement(Directive node, Element element) {
       return node.keyword.offset == element.nameOffset;
@@ -524,7 +525,7 @@
     var directivesToResolve = <DirectiveImpl>[];
     int partDirectiveIndex = 0;
     int partElementIndex = 0;
-    for (Directive directive in definingUnit.directives) {
+    for (Directive directive in definingCompilationUnit.directives) {
       if (directive is LibraryDirectiveImpl) {
         libraryNameNode = directive.name;
         directivesToResolve.add(directive);
@@ -567,15 +568,10 @@
           continue;
         }
 
+        var partUnit = units[partFile]!;
         var partElement = _libraryElement.parts[partElementIndex++];
-        partElement as CompilationUnitElementImpl;
-
-        var partUnit = _parse(partFile, partElement);
-        units[partFile] = partUnit;
-
         partUnit.element = partElement;
         directive.element = partElement;
-        _resolveUriBasedDirectives(partFile, partUnit);
 
         Source? partSource = directive.uriSource;
         if (partSource == null) {
@@ -641,7 +637,6 @@
     }
 
     // TODO(scheglov) remove DirectiveResolver class
-    return units;
   }
 
   void _resolveFile(FileState file, CompilationUnit unit) {
@@ -760,74 +755,13 @@
     return directive.uri.stringValue ?? '';
   }
 
-  /// The [combined] result was resolved, potentially with macro-generated
-  /// declarations. But the result (at least the version that corresponds to
-  /// the original, user-written file) should not include these declarations.
-  /// So, we remove these nodes, and correspondingly patch the token sequence.
-  ///
-  /// Similarly, we transform any reported diagnostics.
-  UnitAnalysisResult _transformToWrittenCode(UnitAnalysisResult combined) {
-    var unit = combined.unit;
-    var unitElement = unit.declaredElement as CompilationUnitElementImpl;
-
-    var macroGenerationDataList = unitElement.macroGenerationDataList;
-    if (macroGenerationDataList == null) {
-      return combined;
+  /// Validate that the feature set associated with the compilation [unit] is
+  /// the same as the [expectedSet] of features supported by the library.
+  void _validateFeatureSet(CompilationUnit unit, FeatureSet expectedSet) {
+    FeatureSet actualSet = unit.featureSet;
+    if (actualSet != expectedSet) {
+      // TODO(brianwilkerson) Generate a diagnostic.
     }
-
-    for (var macroData in macroGenerationDataList.reversed) {
-      var classIndex = macroData.classDeclarationIndex;
-      if (classIndex != null) {
-        var classDeclaration = unit.declarations
-            .whereType<ClassDeclaration>()
-            .toList()[classIndex];
-        // A macro-generated declaration is always the last one.
-        var removed = classDeclaration.members.removeAt(
-          classDeclaration.members.length - 1,
-        );
-        // Patch the token sequence.
-        var followToken = removed.endToken.next!;
-        removed.beginToken.previous!.next = followToken;
-        // Shift the following tokens.
-        for (var t = followToken; t != unit.endToken; t = t.next!) {
-          t.offset -= macroData.insertLength;
-        }
-      } else {
-        // TODO(scheglov) implement top-level
-        throw UnimplementedError();
-      }
-    }
-
-    var errors = <AnalysisError>[];
-    for (var combinedError in combined.errors) {
-      var offset = combinedError.offset;
-      var isInWritten = true;
-      for (var macroData in macroGenerationDataList.reversed) {
-        if (offset > macroData.insertOffset) {
-          if (offset < macroData.insertOffset + macroData.insertLength) {
-            isInWritten = false;
-            break;
-          } else {
-            offset -= macroData.insertLength;
-          }
-        }
-      }
-      if (isInWritten) {
-        errors.add(
-          AnalysisError.forValues(
-            combinedError.source,
-            offset,
-            combinedError.length,
-            combinedError.errorCode,
-            combinedError.message,
-            combinedError.correction,
-            contextMessages: combinedError.contextMessages,
-          ),
-        );
-      }
-    }
-
-    return UnitAnalysisResult(combined.file, unit, errors);
   }
 
   /// Check the given [directive] to see if the referenced source exists and
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index cab5839..461b256 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -20,7 +20,6 @@
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/summary/package_bundle_reader.dart';
 import 'package:analyzer/src/summary2/bundle_reader.dart';
-import 'package:analyzer/src/summary2/informative_data.dart';
 import 'package:analyzer/src/summary2/link.dart' as link2;
 import 'package:analyzer/src/summary2/linked_element_factory.dart';
 import 'package:analyzer/src/summary2/reference.dart';
@@ -115,13 +114,10 @@
 
       cycle.directDependencies.forEach(loadBundle);
 
-      var unitsInformativeData = <Uri, InformativeUnitData>{};
+      var unitsInformativeBytes = <Uri, Uint8List>{};
       for (var library in cycle.libraries) {
         for (var file in library.libraryFiles) {
-          unitsInformativeData[file.uri] = InformativeUnitData(
-            content: file.content,
-            bytes: file.getInformativeBytes(),
-          );
+          unitsInformativeBytes[file.uri] = file.getInformativeBytes();
         }
       }
 
@@ -200,7 +196,7 @@
         elementFactory.addBundle(
           BundleReader(
             elementFactory: elementFactory,
-            unitsInformativeData: unitsInformativeData,
+            unitsInformativeBytes: unitsInformativeBytes,
             resolutionBytes: resolutionBytes,
           ),
         );
@@ -249,7 +245,7 @@
           BundleReader(
             elementFactory: elementFactory,
             resolutionBytes: bundle.resolutionBytes,
-            unitsInformativeData: {},
+            unitsInformativeBytes: {},
           ),
         );
       }
diff --git a/pkg/analyzer/lib/src/dart/ast/extensions.dart b/pkg/analyzer/lib/src/dart/ast/extensions.dart
index 6ca554a..3df0bb6 100644
--- a/pkg/analyzer/lib/src/dart/ast/extensions.dart
+++ b/pkg/analyzer/lib/src/dart/ast/extensions.dart
@@ -6,7 +6,6 @@
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/dart/element/type.dart';
 import 'package:analyzer/src/dart/ast/ast.dart';
-import 'package:analyzer/src/dart/element/element.dart';
 
 /// TODO(scheglov) https://github.com/dart-lang/sdk/issues/43608
 Element? _readElement(AstNode node) {
@@ -92,13 +91,6 @@
   }
 }
 
-extension FieldDeclarationExtension on FieldDeclaration {
-  /// Return the element of the first field.
-  FieldElementImpl get firstElement {
-    return fields.variables.first.declaredElement as FieldElementImpl;
-  }
-}
-
 extension FormalParameterExtension on FormalParameter {
   bool get isOfLocalFunction {
     return thisOrAncestorOfType<FunctionBody>() != null;
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 994614b..f1b79a3 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:collection';
-import 'dart:typed_data';
 
 import 'package:analyzer/dart/analysis/features.dart';
 import 'package:analyzer/dart/analysis/session.dart';
@@ -42,7 +41,6 @@
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/generated/utilities_collection.dart';
 import 'package:analyzer/src/generated/utilities_dart.dart';
-import 'package:analyzer/src/macro/impl/error.dart' as macro;
 import 'package:analyzer/src/summary2/ast_binary_tokens.dart';
 import 'package:analyzer/src/summary2/bundle_reader.dart';
 import 'package:analyzer/src/summary2/reference.dart';
@@ -416,7 +414,7 @@
 
 /// An [AbstractClassElementImpl] which is a class.
 class ClassElementImpl extends AbstractClassElementImpl
-    with TypeParameterizedElementMixin, HasMacroExecutionErrors {
+    with TypeParameterizedElementMixin {
   /// The superclass of the class, or `null` for [Object].
   InterfaceType? _supertype;
 
@@ -985,22 +983,6 @@
   @override
   late Source librarySource;
 
-  /// If this unit has macro-generated elements, and is created in the
-  /// environment where the file content is available (e.g. interactive
-  /// analysis, and not batch analysis), then this is a combination of the
-  /// user-written code and macro-generated declarations.
-  ///
-  /// For elements created from the user-written code [Element.nameOffset]s
-  /// are offsets in the user-written code.
-  ///
-  /// For macro-generated elements [Element.nameOffset]s are offsets in the
-  /// combined file containing both user-written and generated code.
-  String? macroGeneratedContent;
-
-  /// If this unit has macro-generated elements, information about each one
-  /// is stored here, so that it can be combined to [macroGeneratedContent].
-  List<MacroGenerationData>? macroGenerationDataList;
-
   /// A list containing all of the top-level accessors (getters and setters)
   /// contained in this compilation unit.
   List<PropertyAccessorElement> _accessors = const [];
@@ -1427,7 +1409,7 @@
 /// A concrete implementation of a [ConstructorElement].
 class ConstructorElementImpl extends ExecutableElementImpl
     with ConstructorElementMixin
-    implements ConstructorElement, HasMacroGenerationData {
+    implements ConstructorElement {
   /// The constructor to which this constructor is redirecting.
   ConstructorElement? _redirectedConstructor;
 
@@ -1436,9 +1418,6 @@
   List<ConstructorInitializer> _constantInitializers = const [];
 
   @override
-  MacroGenerationData? macro;
-
-  @override
   int? periodOffset;
 
   @override
@@ -2409,11 +2388,6 @@
   /// children of this element's parent.
   String get identifier => name!;
 
-  /// The informative data, or `null` if the element is synthetic, or if the
-  /// informative data is not available in this environment (e.g. semantics
-  /// only summaries in Bazel).
-  ElementInformativeDataSetImpl? get informative => null;
-
   bool get isNonFunctionTypeAliasesEnabled {
     return library!.featureSet.isEnabled(Feature.nonfunction_type_aliases);
   }
@@ -2630,51 +2604,6 @@
   FunctionType get typeInternal;
 }
 
-/// Informative data about an [ElementImpl].
-class ElementInformativeDataImpl {
-  /// The offset of the beginning of the element's code in the file.
-  final int codeOffset;
-
-  /// The length of the element's code in the file.
-  final int codeLength;
-
-  /// The documentation comment for this element.
-  final String? docComment;
-
-  /// The offset of the name of this element in the file that contains the
-  /// declaration of this element.
-  final int nameOffset;
-
-  ElementInformativeDataImpl({
-    required this.codeOffset,
-    required this.codeLength,
-    required this.docComment,
-    required this.nameOffset,
-  });
-}
-
-/// The set of informative data about an [ElementImpl].
-class ElementInformativeDataSetImpl {
-  /// Informative data in the user-written file.
-  ///
-  /// This property is `null` if the element was macro-generated.
-  final ElementInformativeDataImpl? written;
-
-  /// Informative data in the combined file, which is the user-written file
-  /// augmented with macro-generated declarations.
-  ///
-  /// This property cannot be `null`, because each element is either declared
-  /// by the user directly (so has [written] which is then transformed), or
-  /// is macro-generated, or is synthetic (so we don't have this object
-  /// at all).
-  final ElementInformativeDataImpl combined;
-
-  ElementInformativeDataSetImpl({
-    required this.written,
-    required this.combined,
-  });
-}
-
 /// A concrete implementation of an [ElementLocation].
 class ElementLocationImpl implements ElementLocation {
   /// The character used to separate components in the encoded form.
@@ -3314,7 +3243,6 @@
 
 /// A concrete implementation of a [FieldElement].
 class FieldElementImpl extends PropertyInducingElementImpl
-    with HasMacroExecutionErrors
     implements FieldElement {
   /// True if this field inherits from a covariant parameter. This happens
   /// when it overrides a field in a supertype that is covariant.
@@ -3570,19 +3498,6 @@
   }
 }
 
-mixin HasMacroExecutionErrors {
-  /// The list of errors recorded during execution of macro builders
-  /// over this element.
-  List<macro.MacroExecutionError> macroExecutionErrors = [];
-}
-
-/// This interface is implemented by [Element]s that can be added by macros.
-abstract class HasMacroGenerationData {
-  /// If this element was added by a macro, the code of a declaration that
-  /// was produced by the macro.
-  MacroGenerationData? macro;
-}
-
 /// A concrete implementation of a [HideElementCombinator].
 class HideElementCombinatorImpl implements HideElementCombinator {
   @override
@@ -4267,56 +4182,8 @@
       visitor.visitLocalVariableElement(this);
 }
 
-/// Information about a macro-produced [Element].
-class MacroGenerationData {
-  /// The sequential id of this macro-produced element, for an element created
-  /// for a declaration that was macro-generated later this value is greater.
-  ///
-  /// This is different from [ElementImpl.id], which is also incrementing,
-  /// but shows the order in which elements were built from declarations,
-  /// not the order of declarations, and we process all field declarations
-  /// before method declarations.
-  final int id;
-
-  /// The code that was produced by the macro. It is used to compose full
-  /// code of a unit to display to the user, so that new declarations are
-  /// added to the end of the unit or existing classes.
-  ///
-  /// When a class is generated, its code might have some members, or might
-  /// be empty, and new elements might be macro-generated into it.
-  final String code;
-
-  /// Informative data derived from the [code], such as offsets.
-  final Uint8List informative;
-
-  /// If this element is macro-generated into a class declaration, this is
-  /// the index of this class declaration in the unit.
-  final int? classDeclarationIndex;
-
-  /// The offset in [CompilationUnitElementImpl.macroGeneratedContent],
-  /// where the [code] is located. This offset depends on the informative
-  /// data, as any other offset.
-  late int codeOffset;
-
-  /// Similar to [codeOffset], but the offset of the prefix before [code].
-  late int insertOffset;
-
-  /// The length of the string inserted at [insertOffset]. This string
-  /// consists of the [code] itself, with leading and trailing whitespaces
-  /// and newlines for better formatting.
-  late int insertLength;
-
-  MacroGenerationData({
-    required this.id,
-    required this.code,
-    required this.informative,
-    required this.classDeclarationIndex,
-  });
-}
-
 /// A concrete implementation of a [MethodElement].
-class MethodElementImpl extends ExecutableElementImpl
-    implements MethodElement, HasMacroGenerationData {
+class MethodElementImpl extends ExecutableElementImpl implements MethodElement {
   /// Is `true` if this method is `operator==`, and there is no explicit
   /// type specified for its formal parameter, in this method or in any
   /// overridden methods other than the one declared in `Object`.
@@ -4326,9 +4193,6 @@
   /// this variable is not a subject of type inference, or there was no error.
   TopLevelInferenceError? typeInferenceError;
 
-  @override
-  MacroGenerationData? macro;
-
   /// Initialize a newly created method element to have the given [name] at the
   /// given [offset].
   MethodElementImpl(String name, int offset) : super(name, offset);
@@ -5130,14 +4994,11 @@
 
 /// A concrete implementation of a [PropertyAccessorElement].
 class PropertyAccessorElementImpl extends ExecutableElementImpl
-    implements PropertyAccessorElement, HasMacroGenerationData {
+    implements PropertyAccessorElement {
   /// The variable associated with this accessor.
   @override
   late PropertyInducingElement variable;
 
-  @override
-  MacroGenerationData? macro;
-
   /// Initialize a newly created property accessor element to have the given
   /// [name] and [offset].
   PropertyAccessorElementImpl(String name, int offset) : super(name, offset);
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index 26f8a6d..d52742b 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -31,7 +31,6 @@
 import 'package:analyzer/src/summary/format.dart';
 import 'package:analyzer/src/summary/idl.dart';
 import 'package:analyzer/src/summary2/bundle_reader.dart';
-import 'package:analyzer/src/summary2/informative_data.dart';
 import 'package:analyzer/src/summary2/link.dart' as link2;
 import 'package:analyzer/src/summary2/linked_element_factory.dart';
 import 'package:analyzer/src/summary2/reference.dart';
@@ -835,15 +834,12 @@
       var resolutionData = byteStore.get(resolutionKey, cycle.signature);
       var resolutionBytes = resolutionData?.bytes;
 
-      var unitsInformativeData = <Uri, InformativeUnitData>{};
+      var unitsInformativeBytes = <Uri, Uint8List>{};
       for (var library in cycle.libraries) {
         for (var file in library.libraryFiles) {
           var informativeBytes = file.informativeBytes;
           if (informativeBytes != null) {
-            unitsInformativeData[file.uri] = InformativeUnitData(
-              content: file.getContentWithSameDigest(),
-              bytes: informativeBytes,
-            );
+            unitsInformativeBytes[file.uri] = informativeBytes;
           }
         }
       }
@@ -913,7 +909,7 @@
         elementFactory.addBundle(
           BundleReader(
             elementFactory: elementFactory,
-            unitsInformativeData: unitsInformativeData,
+            unitsInformativeBytes: unitsInformativeBytes,
             resolutionBytes: resolutionBytes as Uint8List,
           ),
         );
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 0754988..0b43ce7 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -7831,15 +7831,6 @@
           hasPublishedDocs: true);
 
   /**
-   * Parameters:
-   * 0: the name of the macro
-   * 1: the message
-   */
-  static const CompileTimeErrorCode MACRO_EXECUTION_ERROR =
-      CompileTimeErrorCode(
-          'MACRO_EXECUTION_ERROR', "Exception thrown by macro {0}: {1}");
-
-  /**
    * No parameters.
    */
   // #### Description
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 5c03dd2..ecedd89 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -45,7 +45,6 @@
 import 'package:analyzer/src/generated/java_engine.dart';
 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
 import 'package:analyzer/src/generated/this_access_tracker.dart';
-import 'package:analyzer/src/macro/impl/error.dart' as macro;
 import 'package:collection/collection.dart';
 
 class EnclosingExecutableContext {
@@ -445,8 +444,7 @@
     var outerClass = _enclosingClass;
     try {
       _isInNativeClass = node.nativeClause != null;
-      var enclosingClass = node.declaredElement as ClassElementImpl;
-      _enclosingClass = enclosingClass;
+      _enclosingClass = node.declaredElement as ClassElementImpl;
 
       List<ClassMember> members = node.members;
       _duplicateDefinitionVerifier.checkClass(node);
@@ -470,10 +468,6 @@
       _checkForBadFunctionUse(node);
       _checkForWrongTypeParameterVarianceInSuperinterfaces();
       _checkForMainFunction(node.name);
-      _reportMacroExecutionErrors(
-        node.metadata,
-        enclosingClass.macroExecutionErrors,
-      );
       super.visitClassDeclaration(node);
     } finally {
       _isInNativeClass = false;
@@ -654,10 +648,6 @@
       _checkForNotInitializedNonNullableStaticField(node);
       _checkForWrongTypeParameterVarianceInField(node);
       _checkForLateFinalFieldWithConstConstructor(node);
-      _reportMacroExecutionErrors(
-        node.metadata,
-        node.firstElement.macroExecutionErrors,
-      );
       super.visitFieldDeclaration(node);
     } finally {
       _isInStaticVariableDeclaration = false;
@@ -4999,23 +4989,6 @@
     return null;
   }
 
-  /// Report [macroExecutionErrors] at the corresponding [annotations].
-  void _reportMacroExecutionErrors(
-    List<Annotation> annotations,
-    List<macro.MacroExecutionError> macroExecutionErrors,
-  ) {
-    for (var macroExecutionError in macroExecutionErrors) {
-      errorReporter.reportErrorForNode(
-        CompileTimeErrorCode.MACRO_EXECUTION_ERROR,
-        annotations[macroExecutionError.annotationIndex],
-        [
-          macroExecutionError.macroName,
-          macroExecutionError.message,
-        ],
-      );
-    }
-  }
-
   void _withEnclosingExecutable(
     ExecutableElement element,
     void Function() operation,
diff --git a/pkg/analyzer/lib/src/macro/api/code.dart b/pkg/analyzer/lib/src/macro/api/code.dart
deleted file mode 100644
index a3fed07..0000000
--- a/pkg/analyzer/lib/src/macro/api/code.dart
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2021, 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.
-
-/// Combines [parts] into a [String].
-/// Must only contain [Code] or [String] instances.
-String _combineParts(List<Object> parts) {
-  var buffer = StringBuffer();
-
-  void write(Object part) {
-    if (part is String) {
-      buffer.write(part);
-    } else if (part is Code) {
-      buffer.write(part.code);
-    } else if (part is Iterable<Object>) {
-      part.forEach(write);
-    } else {
-      throw UnsupportedError(
-        'Only String, Code, and List(s) of them are '
-        'allowed but got ${part.runtimeType}',
-      );
-    }
-  }
-
-  write(parts);
-  return buffer.toString();
-}
-
-/// The representation of a piece of code.
-abstract class Code {
-  String get code;
-
-  @override
-  String toString() => code;
-}
-
-/// A piece of code representing a syntactically valid declaration.
-class Declaration extends Code {
-  @override
-  final String code;
-
-  Declaration(this.code);
-
-  /// Creates a [Declaration] from [parts], which must be of type [Code],
-  /// [String], or [Iterable]s of them.
-  factory Declaration.fromParts(List<Object> parts) =>
-      Declaration(_combineParts(parts));
-}
-
-/// A piece of code that can't be parsed into a valid language construct in its
-/// current form. No validation or parsing is performed.
-class Fragment extends Code {
-  @override
-  final String code;
-
-  Fragment(this.code);
-
-  /// Creates a [Fragment] from [parts], which must be of type [Code],
-  /// [String], or [Iterable]s of them.
-  factory Fragment.fromParts(List<Object> parts) =>
-      Fragment(_combineParts(parts));
-}
diff --git a/pkg/analyzer/lib/src/macro/api/macro.dart b/pkg/analyzer/lib/src/macro/api/macro.dart
deleted file mode 100644
index 78eb6c0..0000000
--- a/pkg/analyzer/lib/src/macro/api/macro.dart
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2021, 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' as ast;
-import 'package:analyzer/src/macro/api/code.dart';
-
-/// The api used by [DeclarationMacro]s to contribute new declarations to the
-/// current class.
-///
-/// Note that this is available to macros that run directly on classes, as well
-/// as macros that run on any members of a class.
-abstract class ClassDeclarationBuilder implements DeclarationBuilder {
-  /// Adds a new declaration to the surrounding class.
-  void addToClass(Declaration declaration);
-}
-
-/// The interface for [DeclarationMacro]s that can be applied to classes.
-abstract class ClassDeclarationMacro implements DeclarationMacro {
-  void visitClassDeclaration(
-      ast.ClassDeclaration declaration, ClassDeclarationBuilder builder);
-}
-
-/// The api used by [DeclarationMacro]s to contribute new declarations to the
-/// current library.
-abstract class DeclarationBuilder {
-  /// Adds a new regular declaration to the surrounding library.
-  ///
-  /// Note that type declarations are not supported.
-  void addToLibrary(Declaration declaration);
-
-  /// Return the [Code] of the [node].
-  Code typeAnnotationCode(ast.TypeAnnotation node);
-}
-
-/// The marker interface for macros that are allowed to contribute new
-/// declarations to the program, including both top level and class level
-/// declarations.
-///
-/// These macros run after [TypeMacro] macros, but before [DefinitionMacro]
-/// macros.
-///
-/// These macros can resolve type annotations to specific declarations, and
-/// inspect type hierarchies, but they cannot inspect the declarations on those
-/// type annotations, since new declarations could still be added in this phase.
-abstract class DeclarationMacro implements Macro {}
-
-/// The marker interface for macros that are only allowed to implement or wrap
-/// existing declarations in the program. They cannot introduce any new
-/// declarations that are visible to the program, but are allowed to add
-/// declarations that only they can see.
-///
-/// These macros run after all other types of macros.
-///
-/// These macros can fully reflect on the program since the static shape is
-/// fully defined by the time they run.
-abstract class DefinitionMacro implements Macro {}
-
-/// The interface for [DeclarationMacro]s that can be applied to fields.
-abstract class FieldDeclarationMacro implements DeclarationMacro {
-  void visitFieldDeclaration(
-    ast.FieldDeclaration declaration,
-    ClassDeclarationBuilder builder,
-  );
-}
-
-/// The marker interface for all types of macros.
-abstract class Macro {}
-
-/// The marker interface for macros that are allowed to contribute new type
-/// declarations into the program.
-///
-/// These macros run before all other types of macros.
-///
-/// In exchange for the power to add new type declarations, these macros have
-/// limited introspections capabilities, since new types can be added in this
-/// phase you cannot follow type references back to their declarations.
-abstract class TypeMacro implements Macro {}
diff --git a/pkg/analyzer/lib/src/macro/builders/data_class.dart b/pkg/analyzer/lib/src/macro/builders/data_class.dart
deleted file mode 100644
index a4a0393..0000000
--- a/pkg/analyzer/lib/src/macro/builders/data_class.dart
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) 2021, 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' as ast;
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/src/macro/api/code.dart';
-import 'package:analyzer/src/macro/api/macro.dart';
-
-class AutoConstructorMacro implements ClassDeclarationMacro {
-  const AutoConstructorMacro();
-
-  @override
-  void visitClassDeclaration(
-    ast.ClassDeclaration node,
-    ClassDeclarationBuilder builder,
-  ) {
-    // TODO(scheglov) Should we provide the element as a parameter?
-    var classElement = node.declaredElement!;
-    var typeSystem = classElement.library.typeSystem;
-
-    if (classElement.unnamedConstructor != null) {
-      throw ArgumentError(
-        'Cannot generate a constructor because one already exists',
-      );
-    }
-
-    var fieldsCode = classElement.fields.map((field) {
-      var isNullable = typeSystem.isNullable(field.type);
-      var requiredKeyword = isNullable ? '' : 'required ';
-      return '${requiredKeyword}this.${field.name}';
-    }).join(', ');
-
-    // TODO(scheglov) super constructor
-
-    builder.addToClass(
-      Declaration('${classElement.name}({$fieldsCode});'),
-    );
-  }
-}
-
-class DataClassMacro implements ClassDeclarationMacro {
-  const DataClassMacro();
-
-  @override
-  void visitClassDeclaration(
-    ast.ClassDeclaration declaration,
-    ClassDeclarationBuilder builder,
-  ) {
-    const AutoConstructorMacro().visitClassDeclaration(declaration, builder);
-    const HashCodeMacro().visitClassDeclaration(declaration, builder);
-    const ToStringMacro().visitClassDeclaration(declaration, builder);
-  }
-}
-
-class HashCodeMacro implements ClassDeclarationMacro {
-  const HashCodeMacro();
-
-  @override
-  void visitClassDeclaration(
-    ast.ClassDeclaration node,
-    ClassDeclarationBuilder builder,
-  ) {
-    var expression = node.declaredElement!.allFields
-        .map((e) => '${e.name}.hashCode')
-        .join(' ^ ');
-    builder.addToClass(
-      Declaration('''
-  @override
-  int get hashCode => $expression;
-'''),
-    );
-  }
-}
-
-class ToStringMacro implements ClassDeclarationMacro {
-  const ToStringMacro();
-
-  @override
-  void visitClassDeclaration(
-    ast.ClassDeclaration node,
-    ClassDeclarationBuilder builder,
-  ) {
-    var classElement = node.declaredElement!;
-    var fieldsCode = classElement.allFields.map((field) {
-      var name = field.name;
-      return '$name: \$$name';
-    }).join(', ');
-    builder.addToClass(
-      Declaration('''
-  @override
-  String toString() => '${classElement.name}($fieldsCode)';
-'''),
-    );
-  }
-}
-
-extension on ClassElement {
-  Iterable<FieldElement> get allFields sync* {
-    for (ClassElement? class_ = this; class_ != null;) {
-      yield* class_.fields.where((e) => !e.isSynthetic);
-      class_ = class_.supertype?.element;
-    }
-  }
-}
diff --git a/pkg/analyzer/lib/src/macro/builders/observable.dart b/pkg/analyzer/lib/src/macro/builders/observable.dart
deleted file mode 100644
index dac5565..0000000
--- a/pkg/analyzer/lib/src/macro/builders/observable.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2021, 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' as ast;
-import 'package:analyzer/src/macro/api/code.dart';
-import 'package:analyzer/src/macro/api/macro.dart';
-
-class ObservableMacro implements FieldDeclarationMacro {
-  const ObservableMacro();
-
-  @override
-  void visitFieldDeclaration(
-    ast.FieldDeclaration node,
-    ClassDeclarationBuilder builder,
-  ) {
-    var typeNode = node.fields.type;
-    if (typeNode == null) {
-      throw ArgumentError('@observable can only annotate typed fields.');
-    }
-    var typeCode = builder.typeAnnotationCode(typeNode);
-
-    var fields = node.fields.variables;
-    for (var field in fields) {
-      var name = field.name.name;
-      if (!name.startsWith('_')) {
-        throw ArgumentError(
-          '@observable can only annotate private fields, and it will create '
-          'public getters and setters for them, but the public field '
-          '$name was annotated.',
-        );
-      }
-      var publicName = name.substring(1);
-
-      var getter = Declaration(
-        '  $typeCode get $publicName => $name;',
-      );
-      builder.addToClass(getter);
-
-      var setter = Declaration('''
-  set $publicName($typeCode val) {
-    print('Setting $publicName to \${val}');
-    $name = val;
-  }
-''');
-      builder.addToClass(setter);
-    }
-  }
-}
diff --git a/pkg/analyzer/lib/src/macro/impl/error.dart b/pkg/analyzer/lib/src/macro/impl/error.dart
deleted file mode 100644
index 8c2780c..0000000
--- a/pkg/analyzer/lib/src/macro/impl/error.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2021, 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.
-
-/// Error that happened during executing a macro builder.
-class MacroExecutionError {
-  final int annotationIndex;
-  final String macroName;
-  final String message;
-
-  MacroExecutionError({
-    required this.annotationIndex,
-    required this.macroName,
-    required this.message,
-  });
-}
diff --git a/pkg/analyzer/lib/src/macro/impl/macro.dart b/pkg/analyzer/lib/src/macro/impl/macro.dart
deleted file mode 100644
index 32c6358..0000000
--- a/pkg/analyzer/lib/src/macro/impl/macro.dart
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/analysis/utilities.dart';
-import 'package:analyzer/dart/ast/ast.dart' as ast;
-import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/dart/element/element.dart';
-import 'package:analyzer/dart/element/visitor.dart';
-import 'package:analyzer/src/dart/ast/ast.dart' as ast;
-import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/macro/api/code.dart';
-import 'package:analyzer/src/macro/api/macro.dart';
-import 'package:analyzer/src/summary2/informative_data.dart';
-import 'package:analyzer/src/summary2/library_builder.dart';
-
-class ClassDeclarationBuilderImpl extends DeclarationBuilderImpl
-    implements ClassDeclarationBuilder {
-  final LinkingUnit linkingUnit;
-
-  /// The index of [node] among other [ast.ClassDeclarationImpl]s.
-  final int nodeIndex;
-
-  final ast.ClassDeclarationImpl node;
-
-  ClassDeclarationBuilderImpl(
-    this.linkingUnit,
-    this.nodeIndex,
-    this.node,
-  );
-
-  @override
-  void addToClass(Declaration declaration) {
-    var declarationCode = declaration.code.trim();
-
-    // TODO(scheglov) feature set
-    // TODO(scheglov) throw if errors?
-    var parseResult = parseString(
-      content: 'class ${node.name.name} { $declarationCode }',
-    );
-    var parsedDeclarations = parseResult.unit.declarations;
-    var parsedClass = parsedDeclarations.single as ast.ClassDeclaration;
-    var parsedMember = parsedClass.members.single;
-    _rebaseOffsets(parsedMember);
-
-    node.members.add(parsedMember);
-
-    var macroGeneratedContent = linkingUnit.macroGeneratedContent;
-    var collected = _Declaration(
-      data: MacroGenerationData(
-        id: macroGeneratedContent.nextId++,
-        code: declarationCode,
-        informative: writeDeclarationInformative(parsedMember),
-        classDeclarationIndex: nodeIndex,
-      ),
-      node: parsedMember,
-    );
-    macroGeneratedContent._declarations.add(collected);
-  }
-
-  /// We parsed [node] in the context of some synthetic code string, its
-  /// current offsets only have meaning relative to the begin offset of the
-  /// [node]. So, we update offsets accordingly.
-  static void _rebaseOffsets(ast.AstNode node) {
-    var baseOffset = node.offset;
-    for (Token? t = node.beginToken;
-        t != null && t != node.endToken;
-        t = t.next) {
-      t.offset -= baseOffset;
-    }
-  }
-}
-
-class DeclarationBuilderImpl implements DeclarationBuilder {
-  @override
-  void addToLibrary(Declaration declaration) {
-    // TODO: implement addToLibrary
-  }
-
-  @override
-  Code typeAnnotationCode(ast.TypeAnnotation node) {
-    return Fragment(node.toSource());
-  }
-}
-
-class MacroGeneratedContent {
-  final LinkingUnit linkingUnit;
-  final List<_Declaration> _declarations = [];
-  int nextId = 0;
-
-  MacroGeneratedContent(this.linkingUnit);
-
-  /// Finish building of elements: combine the source code of the unit with
-  /// macro-generated pieces of code; update offsets of macro-generated
-  /// elements to use offsets inside this combined code.
-  void finish() {
-    // Don't set empty values, keep it null.
-    if (_declarations.isEmpty) {
-      return;
-    }
-
-    // Sort declarations by:
-    // 1. The top-level declaration location.
-    // 2. The ordering in the top-level declaration.
-    // We need (2) because `sort` is not stable.
-    _declarations.sort((a, b) {
-      const indexForUnit = 1 << 24;
-      var aIndex = a.data.classDeclarationIndex ?? indexForUnit;
-      var bIndex = b.data.classDeclarationIndex ?? indexForUnit;
-      if (aIndex != bIndex) {
-        return aIndex - bIndex;
-      }
-      return a.data.id - b.data.id;
-    });
-
-    const classMemberCodePrefix = '\n  ';
-    const classMemberCodeSuffix = '\n';
-    // TODO(scheglov) make it required?
-    var generatedContent = linkingUnit.input.sourceContent!;
-    var shift = 0;
-    var classDeclarations = linkingUnit.input.unit.declarations
-        .whereType<ast.ClassDeclaration>()
-        .toList();
-    for (var declaration in _declarations) {
-      var classIndex = declaration.data.classDeclarationIndex;
-      if (classIndex != null) {
-        var targetClass = classDeclarations[classIndex];
-        var code = classMemberCodePrefix +
-            declaration.data.code +
-            classMemberCodeSuffix;
-        var insertOffset = shift + targetClass.rightBracket.offset;
-        declaration.data.insertOffset = insertOffset;
-        declaration.data.codeOffset =
-            insertOffset + classMemberCodePrefix.length;
-        generatedContent = generatedContent.substring(0, insertOffset) +
-            code +
-            generatedContent.substring(insertOffset);
-        declaration.data.insertLength = code.length;
-        shift += code.length;
-      } else {
-        throw UnimplementedError();
-      }
-
-      var node = declaration.node;
-      if (node is ast.Declaration) {
-        var element = node.declaredElement as ElementImpl;
-        element.accept(
-          _ShiftOffsetsElementVisitor(declaration.data.codeOffset),
-        );
-        if (element is HasMacroGenerationData) {
-          (element as HasMacroGenerationData).macro = declaration.data;
-        }
-      }
-    }
-
-    linkingUnit.element.macroGeneratedContent = generatedContent;
-    linkingUnit.element.macroGenerationDataList =
-        _declarations.map((e) => e.data).toList();
-  }
-}
-
-/// [MacroGenerationData] plus its linking [node] (to get the element).
-class _Declaration {
-  final MacroGenerationData data;
-  final ast.AstNode node;
-
-  _Declaration({
-    required this.data,
-    required this.node,
-  });
-}
-
-/// TODO(scheglov) Enhance to support more nodes.
-/// For now only nodes that are currently used in tests are supported.
-/// Which is probably enough for experiments, but should be improved if this
-/// is something we are going to do for real.
-class _ShiftOffsetsAstVisitor extends RecursiveAstVisitor<void> {
-  final int shift;
-
-  _ShiftOffsetsAstVisitor(this.shift);
-
-  @override
-  void visitAnnotation(ast.Annotation node) {
-    _token(node.atSign);
-    super.visitAnnotation(node);
-  }
-
-  @override
-  void visitSimpleIdentifier(ast.SimpleIdentifier node) {
-    _token(node.token);
-  }
-
-  void _token(Token token) {
-    token.offset += shift;
-  }
-}
-
-/// Macro-generated elements are created from pieces of code that are rebased
-/// to start at zero-th offset. When we later know that actual offset in the
-/// combined (source + generated) code of the unit, we shift the offsets.
-class _ShiftOffsetsElementVisitor extends GeneralizingElementVisitor<void> {
-  final int shift;
-
-  _ShiftOffsetsElementVisitor(this.shift);
-
-  @override
-  void visitElement(covariant ElementImpl element) {
-    element.nameOffset += shift;
-    _metadata(element.metadata);
-    super.visitElement(element);
-  }
-
-  void _metadata(List<ElementAnnotation> metadata) {
-    for (var annotation in metadata) {
-      annotation as ElementAnnotationImpl;
-      annotation.annotationAst.accept(
-        _ShiftOffsetsAstVisitor(shift),
-      );
-    }
-  }
-}
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 2b75f9e..bd9248b 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -18,7 +18,6 @@
 import 'package:analyzer/src/dart/resolver/variance.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/generated/utilities_dart.dart';
-import 'package:analyzer/src/macro/impl/error.dart' as macro;
 import 'package:analyzer/src/summary2/ast_binary_reader.dart';
 import 'package:analyzer/src/summary2/ast_binary_tag.dart';
 import 'package:analyzer/src/summary2/data_reader.dart';
@@ -31,16 +30,16 @@
 
 class BundleReader {
   final SummaryDataReader _reader;
-  final Map<Uri, InformativeUnitData> _unitsInformativeData;
+  final Map<Uri, Uint8List> _unitsInformativeBytes;
 
   final Map<String, LibraryReader> libraryMap = {};
 
   BundleReader({
     required LinkedElementFactory elementFactory,
     required Uint8List resolutionBytes,
-    Map<Uri, InformativeUnitData> unitsInformativeData = const {},
+    Map<Uri, Uint8List> unitsInformativeBytes = const {},
   })  : _reader = SummaryDataReader(resolutionBytes),
-        _unitsInformativeData = unitsInformativeData {
+        _unitsInformativeBytes = unitsInformativeBytes {
     _reader.offset = _reader.bytes.length - 4 * 4;
     var baseResolutionOffset = _reader.readUInt32();
     var librariesOffset = _reader.readUInt32();
@@ -70,7 +69,7 @@
       libraryMap[uriStr] = LibraryReader._(
         elementFactory: elementFactory,
         reader: _reader,
-        unitsInformativeData: _unitsInformativeData,
+        unitsInformativeBytes: _unitsInformativeBytes,
         baseResolutionOffset: baseResolutionOffset,
         referenceReader: referenceReader,
         reference: reference,
@@ -413,12 +412,11 @@
 class LibraryReader {
   final LinkedElementFactory _elementFactory;
   final SummaryDataReader _reader;
-  final Map<Uri, InformativeUnitData> _unitsInformativeData;
+  final Map<Uri, Uint8List> _unitsInformativeBytes;
   final int _baseResolutionOffset;
   final _ReferenceReader _referenceReader;
   final Reference _reference;
   final int _offset;
-  final Map<int, MacroGenerationData> _macroDeclarations = {};
 
   final Uint32List _classMembersLengths;
   int _classMembersLengthsIndex = 0;
@@ -428,7 +426,7 @@
   LibraryReader._({
     required LinkedElementFactory elementFactory,
     required SummaryDataReader reader,
-    required Map<Uri, InformativeUnitData> unitsInformativeData,
+    required Map<Uri, Uint8List> unitsInformativeBytes,
     required int baseResolutionOffset,
     required _ReferenceReader referenceReader,
     required Reference reference,
@@ -436,7 +434,7 @@
     required Uint32List classMembersLengths,
   })  : _elementFactory = elementFactory,
         _reader = reader,
-        _unitsInformativeData = unitsInformativeData,
+        _unitsInformativeBytes = unitsInformativeBytes,
         _baseResolutionOffset = baseResolutionOffset,
         _referenceReader = referenceReader,
         _reference = reference,
@@ -494,10 +492,8 @@
 
     _declareDartCoreDynamicNever();
 
-    InformativeDataApplier(_elementFactory).applyTo(
-      _unitsInformativeData,
-      libraryElement,
-    );
+    InformativeDataApplier(_elementFactory, _unitsInformativeBytes)
+        .applyTo(libraryElement);
 
     return libraryElement;
   }
@@ -529,10 +525,6 @@
     element.setLinkedData(reference, linkedData);
     ClassElementFlags.read(_reader, element);
 
-    element.macroExecutionErrors = _reader.readTypedList(
-      _readMacroExecutionError,
-    );
-
     element.typeParameters = _readTypeParameters();
 
     if (!element.isMixinApplication) {
@@ -595,7 +587,6 @@
       element.setLinkedData(reference, linkedData);
       ConstructorElementFlags.read(_reader, element);
       element.parameters = _readParameters(element, reference);
-      _readMacro(element, element);
       return element;
     });
   }
@@ -765,9 +756,6 @@
 
     FieldElementFlags.read(_reader, element);
     element.typeInferenceError = _readTopLevelInferenceError();
-    element.macroExecutionErrors = _reader.readTypedList(
-      _readMacroExecutionError,
-    );
     element.createImplicitAccessors(classReference, name);
 
     return element;
@@ -859,29 +847,6 @@
     return LibraryLanguageVersion(package: package, override: override);
   }
 
-  void _readMacro(Element element, HasMacroGenerationData hasMacro) {
-    var id = _reader.readOptionalUInt30();
-    if (id != null) {
-      var data = _macroDeclarations[id]!;
-      hasMacro.macro = data;
-      InformativeDataApplier(
-        _elementFactory,
-        baseOffset: data.codeOffset,
-      ).applyToDeclaration(
-        element,
-        data.informative,
-      );
-    }
-  }
-
-  macro.MacroExecutionError _readMacroExecutionError() {
-    return macro.MacroExecutionError(
-      annotationIndex: _reader.readUInt30(),
-      macroName: _reader.readStringReference(),
-      message: _reader.readStringReference(),
-    );
-  }
-
   List<MethodElementImpl> _readMethods(
     CompilationUnitElementImpl unitElement,
     ElementImpl enclosingElement,
@@ -905,7 +870,6 @@
       element.typeParameters = _readTypeParameters();
       element.parameters = _readParameters(element, reference);
       element.typeInferenceError = _readTopLevelInferenceError();
-      _readMacro(element, element);
       return element;
     });
   }
@@ -1047,7 +1011,6 @@
     element.setLinkedData(reference, linkedData);
 
     element.parameters = _readParameters(element, reference);
-    _readMacro(element, element);
     return element;
   }
 
@@ -1267,7 +1230,6 @@
     unitElement.uri = _reader.readOptionalStringReference();
     unitElement.isSynthetic = _reader.readBool();
 
-    _readUnitMacroGenerationDataList(unitElement);
     _readClasses(unitElement, unitReference);
     _readEnums(unitElement, unitReference);
     _readExtensions(unitElement, unitReference);
@@ -1285,28 +1247,6 @@
     return unitElement;
   }
 
-  void _readUnitMacroGenerationDataList(
-    CompilationUnitElementImpl unitElement,
-  ) {
-    var length = _reader.readUInt30();
-    if (length == 0) {
-      return;
-    }
-
-    var dataList = List.generate(length, (index) {
-      return MacroGenerationData(
-        id: _reader.readUInt30(),
-        code: _reader.readStringUtf8(),
-        informative: _reader.readUint8List(),
-        classDeclarationIndex: _reader.readOptionalUInt30(),
-      );
-    });
-    unitElement.macroGenerationDataList = dataList;
-    for (var data in dataList) {
-      _macroDeclarations[data.id] = data;
-    }
-  }
-
   static Variance? _decodeVariance(int index) {
     var tag = TypeParameterVarianceTag.values[index];
     switch (tag) {
diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
index 33e913e..f6fdf85 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart
@@ -14,7 +14,6 @@
 import 'package:analyzer/src/dart/element/member.dart';
 import 'package:analyzer/src/dart/element/type_algebra.dart';
 import 'package:analyzer/src/dart/resolver/variance.dart';
-import 'package:analyzer/src/macro/impl/error.dart' as macro;
 import 'package:analyzer/src/summary2/ast_binary_tag.dart';
 import 'package:analyzer/src/summary2/ast_binary_writer.dart';
 import 'package:analyzer/src/summary2/data_writer.dart';
@@ -130,11 +129,6 @@
     _sink._writeStringReference(element.name);
     ClassElementFlags.write(_sink, element);
 
-    _writeList(
-      element.macroExecutionErrors,
-      _sink._writeMacroExecutionError,
-    );
-
     _resolutionSink._writeAnnotationList(element.metadata);
 
     _writeTypeParameters(element.typeParameters, () {
@@ -168,7 +162,6 @@
 
     _resolutionSink.localElements.withElements(element.parameters, () {
       _writeList(element.parameters, _writeParameterElement);
-      _writeMacro(element.macro);
       _resolutionSink.writeElement(element.redirectedConstructor);
       _resolutionSink._writeNodeList(element.constantInitializers);
     });
@@ -231,10 +224,6 @@
     _sink.writeBool(element is ConstFieldElementImpl);
     FieldElementFlags.write(_sink, element);
     _sink._writeTopLevelInferenceError(element.typeInferenceError);
-    _writeList(
-      element.macroExecutionErrors,
-      _sink._writeMacroExecutionError,
-    );
     _resolutionSink._writeAnnotationList(element.metadata);
     _resolutionSink.writeType(element.type);
     _resolutionSink._writeOptionalNode(element.constantInitializer);
@@ -285,10 +274,6 @@
     }
   }
 
-  void _writeMacro(MacroGenerationData? macro) {
-    _sink.writeOptionalUInt30(macro?.id);
-  }
-
   void _writeMethodElement(MethodElement element) {
     element as MethodElementImpl;
     _sink.writeUInt30(_resolutionSink.offset);
@@ -302,8 +287,6 @@
       _sink._writeTopLevelInferenceError(element.typeInferenceError);
       _resolutionSink.writeType(element.returnType);
     });
-
-    _writeMacro(element.macro);
   }
 
   void _writeMixinElement(ClassElement element) {
@@ -378,9 +361,7 @@
 
     _resolutionSink._writeAnnotationList(element.metadata);
     _resolutionSink.writeType(element.returnType);
-
     _writeList(element.parameters, _writeParameterElement);
-    _writeMacro(element.macro);
   }
 
   void _writeReferences(List<Reference> references) {
@@ -450,7 +431,6 @@
     _sink._writeOptionalStringReference(unitElement.uri);
     _sink.writeBool(unitElement.isSynthetic);
     _resolutionSink._writeAnnotationList(unitElement.metadata);
-    _writeUnitElementMacroGenerationDataList(unitElement);
     _writeList(unitElement.classes, _writeClassElement);
     _writeList(unitElement.enums, _writeEnumElement);
     _writeList(unitElement.extensions, _writeExtensionElement);
@@ -470,18 +450,6 @@
     );
   }
 
-  void _writeUnitElementMacroGenerationDataList(
-    CompilationUnitElementImpl unitElement,
-  ) {
-    var dataList = unitElement.macroGenerationDataList ?? [];
-    _writeList<MacroGenerationData>(dataList, (data) {
-      _sink.writeUInt30(data.id);
-      _sink.writeStringUtf8(data.code);
-      _sink.writeUint8List(data.informative);
-      _sink.writeOptionalUInt30(data.classDeclarationIndex);
-    });
-  }
-
   static TypeParameterVarianceTag _encodeVariance(
       TypeParameterElementImpl element) {
     if (element.isLegacyCovariant) {
@@ -983,12 +951,6 @@
     }
   }
 
-  void _writeMacroExecutionError(macro.MacroExecutionError error) {
-    writeUInt30(error.annotationIndex);
-    _writeStringReference(error.macroName);
-    _writeStringReference(error.message);
-  }
-
   void _writeOptionalStringReference(String? value) {
     if (value != null) {
       writeBool(true);
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index d10835a..c375b8c 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -89,19 +89,6 @@
     }
   }
 
-  /// Build elements for [members] and add into the [element].
-  void buildMacroClassMembers(
-    ClassElementImpl element,
-    List<ClassMember> members,
-  ) {
-    var holder = _buildClassMembers(element, members);
-
-    element.accessors.addAll(holder.propertyAccessors);
-    element.constructors.addAll(holder.constructors);
-    element.fields.addAll(holder.properties.whereType<FieldElementImpl>());
-    element.methods.addAll(holder.methods);
-  }
-
   @override
   void visitClassDeclaration(covariant ClassDeclarationImpl node) {
     var nameNode = node.name;
@@ -903,7 +890,7 @@
   }
 
   _EnclosingContext _buildClassMembers(
-      ElementImpl element, List<ClassMember> members) {
+      ElementImpl element, NodeList<ClassMember> members) {
     var hasConstConstructor = members.any((e) {
       return e is ConstructorDeclaration && e.constKeyword != null;
     });
@@ -919,9 +906,29 @@
     var element = node.declaredElement as ClassElementImpl;
     var holder = _buildClassMembers(element, node.members);
     element.accessors = holder.propertyAccessors;
-    element.constructors = holder.constructors;
     element.fields = holder.properties.whereType<FieldElement>().toList();
     element.methods = holder.methods;
+
+    var constructors = holder.constructors;
+    if (constructors.isEmpty) {
+      var containerRef = element.reference!.getChild('@constructor');
+      constructors = [
+        ConstructorElementImpl('', -1)
+          ..isSynthetic = true
+          ..reference = containerRef.getChild(''),
+      ];
+    }
+    element.constructors = constructors;
+
+    // We have all fields and constructors.
+    // Now we can resolve field formal parameters.
+    for (var constructor in constructors) {
+      for (var parameter in constructor.parameters) {
+        if (parameter is FieldFormalParameterElementImpl) {
+          parameter.field = element.getField(parameter.name);
+        }
+      }
+    }
   }
 
   void _buildExecutableElementChildren({
diff --git a/pkg/analyzer/lib/src/summary2/element_flags.dart b/pkg/analyzer/lib/src/summary2/element_flags.dart
index 529a06f..e808000 100644
--- a/pkg/analyzer/lib/src/summary2/element_flags.dart
+++ b/pkg/analyzer/lib/src/summary2/element_flags.dart
@@ -8,8 +8,8 @@
 
 class ClassElementFlags {
   static const int _isAbstract = 1 << 0;
-  static const int _isMixinApplication = 1 << 2;
-  static const int _isSimplyBounded = 1 << 3;
+  static const int _isMixinApplication = 1 << 1;
+  static const int _isSimplyBounded = 1 << 2;
 
   static void read(SummaryDataReader reader, ClassElementImpl element) {
     var byte = reader.readByte();
@@ -60,8 +60,8 @@
   static const int _isCovariant = 1 << 5;
   static const int _isExternal = 1 << 6;
   static const int _isFinal = 1 << 7;
-  static const int _isLate = 1 << 9;
-  static const int _isStatic = 1 << 10;
+  static const int _isLate = 1 << 8;
+  static const int _isStatic = 1 << 9;
 
   static void read(SummaryDataReader reader, FieldElementImpl element) {
     var byte = reader.readUInt30();
@@ -161,8 +161,8 @@
   static const int _isAbstract = 1 << 1;
   static const int _isAsynchronous = 1 << 2;
   static const int _isExternal = 1 << 3;
-  static const int _isGenerator = 1 << 5;
-  static const int _isStatic = 1 << 6;
+  static const int _isGenerator = 1 << 4;
+  static const int _isStatic = 1 << 5;
 
   static void read(SummaryDataReader reader, MethodElementImpl element) {
     var byte = reader.readByte();
@@ -217,8 +217,8 @@
   static const int _isAbstract = 1 << 3;
   static const int _isAsynchronous = 1 << 4;
   static const int _isExternal = 1 << 5;
-  static const int _isGenerator = 1 << 7;
-  static const int _isStatic = 1 << 8;
+  static const int _isGenerator = 1 << 6;
+  static const int _isStatic = 1 << 7;
 
   static void read(
     SummaryDataReader reader,
diff --git a/pkg/analyzer/lib/src/summary2/informative_data.dart b/pkg/analyzer/lib/src/summary2/informative_data.dart
index 3914a90..c592b1f 100644
--- a/pkg/analyzer/lib/src/summary2/informative_data.dart
+++ b/pkg/analyzer/lib/src/summary2/informative_data.dart
@@ -19,15 +19,6 @@
 import 'package:analyzer/src/util/comment.dart';
 import 'package:collection/collection.dart';
 
-/// Write the informative data (mostly offsets) of the given [node].
-/// Throw [UnimplementedError] if [node] is not supported.
-Uint8List writeDeclarationInformative(AstNode node) {
-  var byteSink = ByteSink();
-  var sink = BufferedSink(byteSink);
-  _InformativeDataWriter(sink).writeDeclaration(node);
-  return sink.flushAndTake();
-}
-
 Uint8List writeUnitInformative(CompilationUnit unit) {
   var byteSink = ByteSink();
   var sink = BufferedSink(byteSink);
@@ -41,15 +32,10 @@
 /// offsets are different from `nameOffset` for example, which are applied
 /// directly after creating corresponding elements during a library loading.
 class ApplyConstantOffsets {
-  final int _baseOffset;
   Uint32List? _offsets;
   void Function(_OffsetsApplier)? _function;
 
-  ApplyConstantOffsets(
-    this._offsets,
-    this._function, {
-    int baseOffset = 0,
-  }) : _baseOffset = baseOffset;
+  ApplyConstantOffsets(this._offsets, this._function);
 
   void perform() {
     var offsets = _offsets;
@@ -57,7 +43,6 @@
     if (offsets != null && function != null) {
       var applier = _OffsetsApplier(
         _SafeListIterator(offsets),
-        baseOffset: _baseOffset,
       );
       function.call(applier);
       // Clear the references to possible closure data.
@@ -70,17 +55,14 @@
 
 class InformativeDataApplier {
   final LinkedElementFactory _elementFactory;
-  final int _baseOffset;
+  final Map<Uri, Uint8List> _unitsInformativeBytes2;
 
   InformativeDataApplier(
-    this._elementFactory, {
-    int baseOffset = 0,
-  }) : _baseOffset = baseOffset;
+    this._elementFactory,
+    this._unitsInformativeBytes2,
+  );
 
-  void applyTo(
-    Map<Uri, InformativeUnitData> unitsInformativeData,
-    LibraryElementImpl libraryElement,
-  ) {
+  void applyTo(LibraryElementImpl libraryElement) {
     if (_elementFactory.isApplyingInformativeData) {
       throw StateError('Unexpected recursion.');
     }
@@ -90,9 +72,9 @@
     for (var i = 0; i < unitElements.length; i++) {
       var unitElement = unitElements[i] as CompilationUnitElementImpl;
       var unitUri = unitElement.source.uri;
-      var unitInfoData = unitsInformativeData[unitUri];
-      if (unitInfoData != null) {
-        var unitReader = SummaryDataReader(unitInfoData.bytes);
+      var unitInfoBytes = _unitsInformativeBytes2[unitUri];
+      if (unitInfoBytes != null) {
+        var unitReader = SummaryDataReader(unitInfoBytes);
         var unitInfo = _InfoUnit(unitReader);
 
         if (i == 0) {
@@ -101,7 +83,6 @@
 
         unitElement.setCodeRange(unitInfo.codeOffset, unitInfo.codeLength);
         unitElement.lineInfo = LineInfo(unitInfo.lineStarts);
-        _setUnitMacroGeneratedContent(unitElement, unitInfoData, unitInfo);
 
         _applyToAccessors(unitElement.accessors, unitInfo.accessors);
 
@@ -159,49 +140,35 @@
     _elementFactory.isApplyingInformativeData = false;
   }
 
-  /// Read informative data from [bytes], and apply it to [element].
-  /// The data and the [element] must correspond to each other.
-  void applyToDeclaration(Element element, Uint8List bytes) {
-    if (_elementFactory.isApplyingInformativeData) {
-      throw StateError('Unexpected recursion.');
-    }
-    _elementFactory.isApplyingInformativeData = true;
-
-    var reader = SummaryDataReader(bytes);
-
-    var kindIndex = reader.readByte();
-    var kind = _DeclarationKind.values[kindIndex];
-
-    if (kind == _DeclarationKind.constructorDeclaration &&
-        element is ConstructorElement) {
-      var info = _InfoConstructorDeclaration(reader);
-      _applyToConstructor(element, info);
-    } else if (kind == _DeclarationKind.methodDeclaration &&
-        element is MethodElement) {
-      var info = _InfoMethodDeclaration(reader);
-      _applyToMethod(element, info);
-    } else if (kind == _DeclarationKind.methodDeclaration &&
-        element is PropertyAccessorElement) {
-      var info = _InfoMethodDeclaration(reader);
-      _applyToPropertyAccessor(element, info);
-    } else {
-      throw UnimplementedError(
-        'Unsupported kind: $kind, '
-        'or element: ${element.runtimeType}',
-      );
-    }
-
-    _elementFactory.isApplyingInformativeData = false;
-  }
-
   void _applyToAccessors(
     List<PropertyAccessorElement> elementList,
     List<_InfoMethodDeclaration> infoList,
   ) {
-    forCorrespondingPairs(
+    forCorrespondingPairs<PropertyAccessorElement, _InfoMethodDeclaration>(
       elementList.notSynthetic,
       infoList,
-      _applyToPropertyAccessor,
+      (element, info) {
+        element as PropertyAccessorElementImpl;
+        element.setCodeRange(info.codeOffset, info.codeLength);
+        element.nameOffset = info.nameOffset;
+        element.documentationComment = info.documentationComment;
+        _applyToFormalParameters(
+          element.parameters_unresolved,
+          info.parameters,
+        );
+
+        var linkedData = element.linkedData;
+        if (linkedData is PropertyAccessorElementLinkedData) {
+          linkedData.applyConstantOffsets = ApplyConstantOffsets(
+            info.constantOffsets,
+            (applier) {
+              applier.applyToMetadata(element);
+              applier.applyToTypeParameters(element.typeParameters);
+              applier.applyToFormalParameters(element.parameters);
+            },
+          );
+        }
+      },
     );
   }
 
@@ -273,32 +240,6 @@
     );
   }
 
-  void _applyToConstructor(
-    ConstructorElement element,
-    _InfoConstructorDeclaration info,
-  ) {
-    element as ConstructorElementImpl;
-    element.setCodeRange(info.codeOffset, info.codeLength);
-    element.periodOffset = info.periodOffset;
-    element.nameOffset = _baseOffset + info.nameOffset;
-    element.nameEnd = info.nameEnd;
-    element.documentationComment = info.documentationComment;
-    _applyToFormalParameters(
-      element.parameters_unresolved,
-      info.parameters,
-    );
-
-    var linkedData = element.linkedData as ConstructorElementLinkedData;
-    linkedData.applyConstantOffsets = ApplyConstantOffsets(
-      info.constantOffsets,
-      (applier) {
-        applier.applyToMetadata(element);
-        applier.applyToFormalParameters(element.parameters);
-        applier.applyToConstructorInitializers(element);
-      },
-    );
-  }
-
   void _applyToConstructors(
     List<ConstructorElement> elementList,
     List<_InfoConstructorDeclaration> infoList,
@@ -306,7 +247,28 @@
     forCorrespondingPairs<ConstructorElement, _InfoConstructorDeclaration>(
       elementList,
       infoList,
-      _applyToConstructor,
+      (element, info) {
+        element as ConstructorElementImpl;
+        element.setCodeRange(info.codeOffset, info.codeLength);
+        element.periodOffset = info.periodOffset;
+        element.nameOffset = info.nameOffset;
+        element.nameEnd = info.nameEnd;
+        element.documentationComment = info.documentationComment;
+        _applyToFormalParameters(
+          element.parameters_unresolved,
+          info.parameters,
+        );
+
+        var linkedData = element.linkedData as ConstructorElementLinkedData;
+        linkedData.applyConstantOffsets = ApplyConstantOffsets(
+          info.constantOffsets,
+          (applier) {
+            applier.applyToMetadata(element);
+            applier.applyToFormalParameters(element.parameters);
+            applier.applyToConstructorInitializers(element);
+          },
+        );
+      },
     );
   }
 
@@ -401,7 +363,7 @@
       (element, info) {
         element as ParameterElementImpl;
         element.setCodeRange(info.codeOffset, info.codeLength);
-        element.nameOffset = _baseOffset + info.nameOffset;
+        element.nameOffset = info.nameOffset;
         _applyToTypeParameters(element.typeParameters, info.typeParameters);
         _applyToFormalParameters(element.parameters, info.parameters);
       },
@@ -537,32 +499,6 @@
     );
   }
 
-  void _applyToMethod(MethodElement element, _InfoMethodDeclaration info) {
-    element as MethodElementImpl;
-    element.setCodeRange(info.codeOffset, info.codeLength);
-    element.nameOffset = _baseOffset + info.nameOffset;
-    element.documentationComment = info.documentationComment;
-    _applyToTypeParameters(
-      element.typeParameters_unresolved,
-      info.typeParameters,
-    );
-    _applyToFormalParameters(
-      element.parameters_unresolved,
-      info.parameters,
-    );
-
-    var linkedData = element.linkedData as MethodElementLinkedData;
-    linkedData.applyConstantOffsets = ApplyConstantOffsets(
-      info.constantOffsets,
-      (applier) {
-        applier.applyToMetadata(element);
-        applier.applyToTypeParameters(element.typeParameters);
-        applier.applyToFormalParameters(element.parameters);
-      },
-      baseOffset: _baseOffset,
-    );
-  }
-
   void _applyToMethods(
     List<MethodElement> elementList,
     List<_InfoMethodDeclaration> infoList,
@@ -570,7 +506,30 @@
     forCorrespondingPairs<MethodElement, _InfoMethodDeclaration>(
       elementList,
       infoList,
-      _applyToMethod,
+      (element, info) {
+        element as MethodElementImpl;
+        element.setCodeRange(info.codeOffset, info.codeLength);
+        element.nameOffset = info.nameOffset;
+        element.documentationComment = info.documentationComment;
+        _applyToTypeParameters(
+          element.typeParameters_unresolved,
+          info.typeParameters,
+        );
+        _applyToFormalParameters(
+          element.parameters_unresolved,
+          info.parameters,
+        );
+
+        var linkedData = element.linkedData as MethodElementLinkedData;
+        linkedData.applyConstantOffsets = ApplyConstantOffsets(
+          info.constantOffsets,
+          (applier) {
+            applier.applyToMetadata(element);
+            applier.applyToTypeParameters(element.typeParameters);
+            applier.applyToFormalParameters(element.parameters);
+          },
+        );
+      },
     );
   }
 
@@ -601,33 +560,6 @@
     );
   }
 
-  void _applyToPropertyAccessor(
-    PropertyAccessorElement element,
-    _InfoMethodDeclaration info,
-  ) {
-    element as PropertyAccessorElementImpl;
-    element.setCodeRange(info.codeOffset, info.codeLength);
-    element.nameOffset = _baseOffset + info.nameOffset;
-    element.documentationComment = info.documentationComment;
-    _applyToFormalParameters(
-      element.parameters_unresolved,
-      info.parameters,
-    );
-
-    var linkedData = element.linkedData;
-    if (linkedData is PropertyAccessorElementLinkedData) {
-      linkedData.applyConstantOffsets = ApplyConstantOffsets(
-        info.constantOffsets,
-        (applier) {
-          applier.applyToMetadata(element);
-          applier.applyToTypeParameters(element.typeParameters);
-          applier.applyToFormalParameters(element.parameters);
-        },
-        baseOffset: _baseOffset,
-      );
-    }
-  }
-
   void _applyToTopLevelVariable(
     TopLevelVariableElement element,
     _InfoTopLevelVariable info,
@@ -662,38 +594,6 @@
     );
   }
 
-  void _setUnitMacroGeneratedContent(
-    CompilationUnitElementImpl unitElement,
-    InformativeUnitData unitInfoData,
-    _InfoUnit unitInfo,
-  ) {
-    var macroGenerationDataList = unitElement.macroGenerationDataList;
-    if (macroGenerationDataList != null) {
-      const classMemberCodePrefix = '\n  ';
-      const classMemberCodeSuffix = '\n';
-      var generatedContent = unitInfoData.content;
-      var shift = 0;
-      for (var data in macroGenerationDataList) {
-        var classIndex = data.classDeclarationIndex;
-        if (classIndex != null) {
-          var targetClass = unitInfo.classDeclarations[classIndex];
-          var code = classMemberCodePrefix + data.code + classMemberCodeSuffix;
-          var insertOffset = shift + targetClass.rightBracketOffset;
-          data.insertOffset = insertOffset;
-          data.codeOffset = insertOffset + classMemberCodePrefix.length;
-          generatedContent = generatedContent.substring(0, insertOffset) +
-              code +
-              generatedContent.substring(insertOffset);
-          data.insertLength = code.length;
-          shift += code.length;
-        } else {
-          throw UnimplementedError();
-        }
-      }
-      unitElement.macroGeneratedContent = generatedContent;
-    }
-  }
-
   void _setupApplyConstantOffsetsForTypeAlias(
     TypeAliasElementImpl element,
     Uint32List constantOffsets, {
@@ -729,30 +629,10 @@
   }
 }
 
-/// Informative data about a source file.
-class InformativeUnitData {
-  /// The content of the file.
-  final String content;
-
-  /// Informative data derived from the [content], such as offsets.
-  final Uint8List bytes;
-
-  InformativeUnitData({
-    required this.content,
-    required this.bytes,
-  });
-}
-
-enum _DeclarationKind {
-  constructorDeclaration,
-  methodDeclaration,
-}
-
 class _InfoClassDeclaration {
   final int codeOffset;
   final int codeLength;
   final int nameOffset;
-  final int rightBracketOffset;
   final String? documentationComment;
   final List<_InfoTypeParameter> typeParameters;
   final List<_InfoConstructorDeclaration> constructors;
@@ -767,7 +647,6 @@
       codeOffset: reader.readUInt30(),
       codeLength: reader.readUInt30(),
       nameOffset: reader.readUInt30() - nameOffsetDelta,
-      rightBracketOffset: reader.readUInt30(),
       documentationComment: reader.readStringUtf8().nullIfEmpty,
       typeParameters: reader.readTypedList(
         () => _InfoTypeParameter(reader),
@@ -792,7 +671,6 @@
     required this.codeOffset,
     required this.codeLength,
     required this.nameOffset,
-    required this.rightBracketOffset,
     required this.documentationComment,
     required this.typeParameters,
     required this.constructors,
@@ -1256,7 +1134,6 @@
       sink.writeUInt30(node.offset);
       sink.writeUInt30(node.length);
       sink.writeUInt30(node.name.offset);
-      sink.writeUInt30(node.rightBracket.offset);
       _writeDocumentationComment(node);
       _writeTypeParameters(node.typeParameters);
       _writeConstructors(node.members);
@@ -1302,7 +1179,6 @@
       sink.writeUInt30(node.offset);
       sink.writeUInt30(node.length);
       sink.writeUInt30(1 + (node.name?.offset ?? -1));
-      sink.writeUInt30(node.rightBracket.offset);
       _writeDocumentationComment(node);
       _writeTypeParameters(node.typeParameters);
       _writeConstructors(node.members);
@@ -1392,7 +1268,6 @@
       sink.writeUInt30(node.offset);
       sink.writeUInt30(node.length);
       sink.writeUInt30(node.name.offset);
-      sink.writeUInt30(node.rightBracket.offset);
       _writeDocumentationComment(node);
       _writeTypeParameters(node.typeParameters);
       _writeConstructors(node.members);
@@ -1414,18 +1289,6 @@
     );
   }
 
-  void writeDeclaration(AstNode node) {
-    if (node is ConstructorDeclaration) {
-      sink.addByte(_DeclarationKind.constructorDeclaration.index);
-      _writeConstructor(node);
-    } else if (node is MethodDeclaration) {
-      sink.addByte(_DeclarationKind.methodDeclaration.index);
-      _writeMethod(node);
-    } else {
-      throw UnimplementedError('(${node.runtimeType}) $node');
-    }
-  }
-
   int _codeOffsetForVariable(VariableDeclaration node) {
     var codeOffset = node.offset;
     var variableList = node.parent as VariableDeclarationList;
@@ -1442,24 +1305,22 @@
     });
   }
 
-  void _writeConstructor(ConstructorDeclaration node) {
-    sink.writeUInt30(node.offset);
-    sink.writeUInt30(node.length);
-    sink.writeOptionalUInt30(node.period?.offset);
-    var nameNode = node.name ?? node.returnType;
-    sink.writeUInt30(nameNode.offset);
-    sink.writeUInt30(nameNode.end);
-    _writeDocumentationComment(node);
-    _writeFormalParameters(node.parameters);
-    _writeOffsets(
-      metadata: node.metadata,
-      formalParameters: node.parameters,
-      constructorInitializers: node.initializers,
-    );
-  }
-
   void _writeConstructors(List<ClassMember> members) {
-    sink.writeList2<ConstructorDeclaration>(members, _writeConstructor);
+    sink.writeList2<ConstructorDeclaration>(members, (node) {
+      sink.writeUInt30(node.offset);
+      sink.writeUInt30(node.length);
+      sink.writeOptionalUInt30(node.period?.offset);
+      var nameNode = node.name ?? node.returnType;
+      sink.writeUInt30(nameNode.offset);
+      sink.writeUInt30(nameNode.end);
+      _writeDocumentationComment(node);
+      _writeFormalParameters(node.parameters);
+      _writeOffsets(
+        metadata: node.metadata,
+        formalParameters: node.parameters,
+        constructorInitializers: node.initializers,
+      );
+    });
   }
 
   void _writeDocumentationComment(AnnotatedNode node) {
@@ -1522,7 +1383,19 @@
           .whereType<MethodDeclaration>()
           .where((e) => e.isGetter || e.isSetter)
           .toList(),
-      _writeMethod,
+      (node) {
+        sink.writeUInt30(node.offset);
+        sink.writeUInt30(node.length);
+        sink.writeUInt30(node.name.offset);
+        _writeDocumentationComment(node);
+        _writeTypeParameters(node.typeParameters);
+        _writeFormalParameters(node.parameters);
+        _writeOffsets(
+          metadata: node.metadata,
+          typeParameters: node.typeParameters,
+          formalParameters: node.parameters,
+        );
+      },
     );
   }
 
@@ -1547,27 +1420,25 @@
     );
   }
 
-  void _writeMethod(MethodDeclaration node) {
-    sink.writeUInt30(node.offset);
-    sink.writeUInt30(node.length);
-    sink.writeUInt30(node.name.offset);
-    _writeDocumentationComment(node);
-    _writeTypeParameters(node.typeParameters);
-    _writeFormalParameters(node.parameters);
-    _writeOffsets(
-      metadata: node.metadata,
-      typeParameters: node.typeParameters,
-      formalParameters: node.parameters,
-    );
-  }
-
   void _writeMethods(List<ClassMember> members) {
     sink.writeList<MethodDeclaration>(
       members
           .whereType<MethodDeclaration>()
           .where((e) => !(e.isGetter || e.isSetter))
           .toList(),
-      _writeMethod,
+      (node) {
+        sink.writeUInt30(node.offset);
+        sink.writeUInt30(node.length);
+        sink.writeUInt30(node.name.offset);
+        _writeDocumentationComment(node);
+        _writeTypeParameters(node.typeParameters);
+        _writeFormalParameters(node.parameters);
+        _writeOffsets(
+          metadata: node.metadata,
+          typeParameters: node.typeParameters,
+          formalParameters: node.parameters,
+        );
+      },
     );
   }
 
@@ -1803,12 +1674,8 @@
 
 class _OffsetsApplier extends _OffsetsAstVisitor {
   final _SafeListIterator<int> _iterator;
-  final int _baseOffset;
 
-  _OffsetsApplier(
-    this._iterator, {
-    int baseOffset = 0,
-  }) : _baseOffset = baseOffset;
+  _OffsetsApplier(this._iterator);
 
   void applyToConstantInitializer(Element element) {
     if (element is ConstVariableElement) {
@@ -1862,7 +1729,7 @@
   void handleToken(Token token) {
     var offset = _iterator.take();
     if (offset != null) {
-      token.offset = _baseOffset + offset;
+      token.offset = offset;
     }
   }
 
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index fc66eed..f389647 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -5,15 +5,9 @@
 import 'package:analyzer/dart/ast/ast.dart' as ast;
 import 'package:analyzer/dart/element/element.dart';
 import 'package:analyzer/src/dart/ast/ast.dart' as ast;
-import 'package:analyzer/src/dart/ast/extensions.dart';
 import 'package:analyzer/src/dart/ast/mixin_super_invoked_names.dart';
 import 'package:analyzer/src/dart/element/element.dart';
 import 'package:analyzer/src/dart/resolver/scope.dart';
-import 'package:analyzer/src/macro/api/macro.dart' as macro;
-import 'package:analyzer/src/macro/builders/data_class.dart' as macro;
-import 'package:analyzer/src/macro/builders/observable.dart' as macro;
-import 'package:analyzer/src/macro/impl/error.dart' as macro;
-import 'package:analyzer/src/macro/impl/macro.dart' as macro;
 import 'package:analyzer/src/summary2/combinator.dart';
 import 'package:analyzer/src/summary2/constructor_initializer_resolver.dart';
 import 'package:analyzer/src/summary2/default_value_resolver.dart';
@@ -147,38 +141,6 @@
     }
   }
 
-  /// We don't create default constructors during building elements from AST,
-  /// there might be macros that will add one later. So, this method is
-  /// invoked after all macros that affect element models.
-  void processClassConstructors() {
-    // TODO(scheglov) We probably don't need constructors for mixins.
-    var classes = element.topLevelElements
-        .whereType<ClassElementImpl>()
-        .where((e) => !e.isMixinApplication)
-        .toList();
-
-    for (var element in classes) {
-      if (element.constructors.isEmpty) {
-        var containerRef = element.reference!.getChild('@constructor');
-        element.constructors = [
-          ConstructorElementImpl('', -1)
-            ..isSynthetic = true
-            ..reference = containerRef.getChild(''),
-        ];
-      }
-
-      // We have all fields and constructors.
-      // Now we can resolve field formal parameters.
-      for (var constructor in element.constructors) {
-        for (var parameter in constructor.parameters) {
-          if (parameter is FieldFormalParameterElementImpl) {
-            parameter.field = element.getField(parameter.name);
-          }
-        }
-      }
-    }
-  }
-
   void resolveConstructors() {
     ConstructorInitializerResolver(linker, element).resolve();
   }
@@ -201,139 +163,6 @@
     }
   }
 
-  /// Run built-in declaration macros.
-  void runDeclarationMacros() {
-    /// If [node] has a macro annotation with the required [name],
-    /// return the index of this annotation node.
-    int? hasMacroAnnotation(ast.AnnotatedNode node, String name) {
-      var metadata = node.metadata;
-      for (var i = 0; i < metadata.length; i++) {
-        var annotation = metadata[i];
-        var nameNode = annotation.name;
-        if (nameNode is ast.SimpleIdentifier &&
-            annotation.arguments == null &&
-            annotation.constructorName == null &&
-            nameNode.name == name) {
-          var nameElement = element.scope.lookup(name).getter;
-          if (nameElement != null &&
-              nameElement.library?.name == 'analyzer.macro.annotations') {
-            return i;
-          }
-        }
-      }
-      return null;
-    }
-
-    /// Build types for type annotations in new [nodes].
-    void resolveTypeAnnotations(
-      List<ast.AstNode> nodes, {
-      ClassElementImpl? classElement,
-    }) {
-      var nodesToBuildType = NodesToBuildType();
-      var resolver = ReferenceResolver(linker, nodesToBuildType, element);
-      if (classElement != null) {
-        resolver.enterScopeClassElement(classElement);
-      }
-      for (var node in nodes) {
-        node.accept(resolver);
-      }
-      TypesBuilder(linker).build(nodesToBuildType);
-    }
-
-    for (var linkingUnit in units) {
-      var classDeclarationIndex = -1;
-      for (var declaration in linkingUnit.node.declarations) {
-        if (declaration is ast.ClassDeclarationImpl) {
-          classDeclarationIndex++;
-          var macroExecutionErrors = <macro.MacroExecutionError>[];
-
-          var members = declaration.members.toList();
-          var classBuilder = macro.ClassDeclarationBuilderImpl(
-            linkingUnit,
-            classDeclarationIndex,
-            declaration,
-          );
-
-          void runClassMacro(
-            String name,
-            macro.ClassDeclarationMacro Function() newInstance,
-          ) {
-            var annotationIndex = hasMacroAnnotation(declaration, name);
-            if (annotationIndex != null) {
-              try {
-                newInstance().visitClassDeclaration(
-                  declaration,
-                  classBuilder,
-                );
-              } catch (e) {
-                macroExecutionErrors.add(
-                  macro.MacroExecutionError(
-                    annotationIndex: annotationIndex,
-                    macroName: name,
-                    message: e.toString(),
-                  ),
-                );
-              }
-            }
-          }
-
-          runClassMacro('autoConstructor', () => macro.AutoConstructorMacro());
-          runClassMacro('dataClass', () => macro.DataClassMacro());
-          runClassMacro('hashCode', () => macro.HashCodeMacro());
-          runClassMacro('toString', () => macro.ToStringMacro());
-
-          var classElement = declaration.declaredElement as ClassElementImpl;
-          classElement.macroExecutionErrors = macroExecutionErrors;
-
-          for (var member in members) {
-            if (member is ast.FieldDeclarationImpl) {
-              var macroExecutionErrors = <macro.MacroExecutionError>[];
-
-              void runFieldMacro(
-                String name,
-                macro.FieldDeclarationMacro Function() newInstance,
-              ) {
-                var annotationIndex = hasMacroAnnotation(member, name);
-                if (annotationIndex != null) {
-                  try {
-                    newInstance().visitFieldDeclaration(member, classBuilder);
-                  } catch (e) {
-                    macroExecutionErrors.add(
-                      macro.MacroExecutionError(
-                        annotationIndex: annotationIndex,
-                        macroName: name,
-                        message: e.toString(),
-                      ),
-                    );
-                  }
-                }
-              }
-
-              runFieldMacro('observable', () => macro.ObservableMacro());
-              member.firstElement.macroExecutionErrors = macroExecutionErrors;
-            }
-          }
-
-          var newMembers = declaration.members.sublist(members.length);
-          if (newMembers.isNotEmpty) {
-            var elementBuilder = ElementBuilder(
-              libraryBuilder: this,
-              unitReference: linkingUnit.reference,
-              unitElement: linkingUnit.element,
-            );
-            var classElement = declaration.declaredElement as ClassElementImpl;
-            elementBuilder.buildMacroClassMembers(classElement, newMembers);
-            resolveTypeAnnotations(newMembers, classElement: classElement);
-          }
-        }
-      }
-    }
-
-    for (var linkingUnit in units) {
-      linkingUnit.macroGeneratedContent.finish();
-    }
-  }
-
   void storeExportScope() {
     exports = exportScope.map.values.toList();
     linker.elementFactory.setExportsOfLibrary('$uri', exports);
@@ -460,8 +289,6 @@
   final Reference reference;
   final ast.CompilationUnitImpl node;
   final CompilationUnitElementImpl element;
-  late final macro.MacroGeneratedContent macroGeneratedContent =
-      macro.MacroGeneratedContent(this);
 
   LinkingUnit({
     required this.input,
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 18118c5..db4d362 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -92,7 +92,6 @@
     _createTypeSystem();
     _buildEnumChildren();
     _resolveTypes();
-    _runDeclarationMacros();
     _performTopLevelInference();
     _resolveConstructors();
     _resolveConstantInitializers();
@@ -213,13 +212,6 @@
     TypesBuilder(this).build(nodesToBuildType);
   }
 
-  void _runDeclarationMacros() {
-    for (var library in builders.values) {
-      library.runDeclarationMacros();
-      library.processClassConstructors();
-    }
-  }
-
   void _writeLibraries() {
     var bundleWriter = BundleWriter(
       elementFactory.dynamicRef,
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index 2475bbb..ef6c180 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -45,10 +45,6 @@
         scope = libraryElement.scope,
         isNNBD = libraryElement.isNonNullableByDefault;
 
-  void enterScopeClassElement(ClassElementImpl element) {
-    scope = TypeParameterScope(scope, element.typeParameters);
-  }
-
   @override
   void visitBlockFunctionBody(BlockFunctionBody node) {}
 
diff --git a/pkg/analyzer/test/src/dart/resolution/macro_test.dart b/pkg/analyzer/test/src/dart/resolution/macro_test.dart
deleted file mode 100644
index 6d88fd7..0000000
--- a/pkg/analyzer/test/src/dart/resolution/macro_test.dart
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:analyzer/dart/analysis/utilities.dart';
-import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/ast/token.dart';
-import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/src/dart/error/syntactic_errors.dart';
-import 'package:analyzer/src/error/codes.dart';
-import 'package:test/test.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'context_collection_resolution.dart';
-
-main() {
-  defineReflectiveSuite(() {
-    defineReflectiveTests(MacroResolutionTest);
-  });
-}
-
-@reflectiveTest
-class MacroResolutionTest extends PubPackageResolutionTest {
-  @override
-  void setUp() {
-    super.setUp();
-
-    newFile('$testPackageLibPath/macro_annotations.dart', content: r'''
-library analyzer.macro.annotations;
-const autoConstructor = 0;
-const observable = 0;
-''');
-  }
-
-  test_autoConstructor() async {
-    var code = r'''
-import 'macro_annotations.dart';
-
-@autoConstructor
-class A {
-  final int a;
-}
-
-void f() {
-  A(a: 0);
-}
-''';
-
-    // No diagnostics, specifically:
-    // 1. The constructor `A()` is declared.
-    // 2. The final field `a` is not marked, because the macro-generated
-    //    constructor does initialize it.
-    await assertNoErrorsInCode(code);
-
-    _assertResolvedUnitWithParsed(code);
-  }
-
-  test_errors_parse_shiftToWritten() async {
-    await assertErrorsInCode(r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-}
-
-int a = 0
-''', [
-      error(ParserErrorCode.EXPECTED_TOKEN, 85, 1),
-    ]);
-  }
-
-  test_errors_resolution_removeInGenerated() async {
-    // The generated `set foo(int x) { _foo = x; }` has an error, it attempts
-    // to assign to a final field `_foo`. But this error does not exist in
-    // the written code, so it is not present.
-    await assertNoErrorsInCode(r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  final int _foo = 0;
-}
-''');
-  }
-
-  test_errors_resolution_shiftToWritten() async {
-    await assertErrorsInCode(r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-}
-
-notInt a = 0;
-''', [
-      error(CompileTimeErrorCode.UNDEFINED_CLASS, 77, 6),
-    ]);
-  }
-
-  test_executionError_autoConstructor() async {
-    await assertErrorsInCode(r'''
-import 'macro_annotations.dart';
-
-@autoConstructor
-class A {
-  final int a;
-  A(this.a);
-}
-''', [
-      error(CompileTimeErrorCode.MACRO_EXECUTION_ERROR, 34, 16),
-    ]);
-  }
-
-  test_executionError_observable_implicitlyTyped() async {
-    await assertErrorsInCode(r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  var _a = 0;
-}
-''', [
-      error(CompileTimeErrorCode.MACRO_EXECUTION_ERROR, 46, 11),
-      error(HintCode.UNUSED_FIELD, 64, 2),
-    ]);
-  }
-
-  test_observable() async {
-    var code = r'''
-import 'macro_annotations.dart';
-
-class A {
-  @observable
-  int _foo = 0;
-}
-
-void f(A a) {
-  a.foo;
-  a.foo = 2;
-}
-''';
-
-    // No diagnostics, such as unused `_foo`.
-    // We generate a getter/setter pair, so it is used.
-    await assertNoErrorsInCode(code);
-
-    _assertResolvedUnitWithParsed(code);
-  }
-
-  void _assertResolvedUnitWithParsed(String code) {
-    // The resolved content is the original code.
-    expect(result.content, code);
-
-    var resolvedUnit = result.unit;
-    var parsedUnit = parseString(content: code).unit;
-
-    // The token stream was patched to keep only tokens that existed in the
-    // original code.
-    _assertEqualTokens(resolvedUnit, parsedUnit);
-
-    // The AST was patched to keep only nodes that existed in the
-    // original code.
-    var resolvedTokenString = _nodeTokenString(resolvedUnit);
-    var parsedTokenString = _nodeTokenString(parsedUnit);
-    expect(resolvedTokenString, parsedTokenString);
-  }
-
-  static void _assertEqualTokens(AstNode first, AstNode second) {
-    var firstToken = first.beginToken;
-    var secondToken = second.beginToken;
-    while (true) {
-      if (firstToken == first.endToken && secondToken == second.endToken) {
-        break;
-      }
-      expect(firstToken.lexeme, secondToken.lexeme);
-      expect(firstToken.offset, secondToken.offset);
-      firstToken = firstToken.next!;
-      secondToken = secondToken.next!;
-    }
-  }
-
-  /// Return the string dump of all tokens in [node] and its children.
-  static String _nodeTokenString(AstNode node) {
-    var tokens = <Token>[];
-    node.accept(
-      _RecursiveTokenCollector(tokens),
-    );
-
-    // `AstNode.childEntities` does not return tokens in any specific order.
-    // So, we sort them to make the sequence look reasonable.
-    tokens.sort((a, b) => a.offset - b.offset);
-
-    var buffer = StringBuffer();
-    for (var token in tokens) {
-      buffer.writeln('${token.lexeme} @${token.offset}');
-    }
-    return buffer.toString();
-  }
-}
-
-class _RecursiveTokenCollector extends GeneralizingAstVisitor<void> {
-  final List<Token> _tokens;
-
-  _RecursiveTokenCollector(this._tokens);
-
-  @override
-  void visitNode(AstNode node) {
-    _tokens.addAll(
-      node.childEntities.whereType<Token>(),
-    );
-    super.visitNode(node);
-  }
-}
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index 70b37ab..0c72655 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -44,7 +44,6 @@
 import 'library_element_test.dart' as library_element;
 import 'local_function_test.dart' as local_function;
 import 'local_variable_test.dart' as local_variable;
-import 'macro_test.dart' as macro;
 import 'metadata_test.dart' as metadata;
 import 'method_declaration_test.dart' as method_declaration;
 import 'method_invocation_test.dart' as method_invocation;
@@ -106,7 +105,6 @@
     library_element.main();
     local_function.main();
     local_variable.main();
-    macro.main();
     metadata.main();
     method_declaration.main();
     method_invocation.main();
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 1c07a3e..fb0093f 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -395,14 +395,17 @@
       expect(e.nameOffset, -1);
       expect(e.nonSynthetic, same(e.enclosingElement));
     } else {
-      expect(e.nameOffset, isNonNegative);
+      expect(e.nameOffset, isPositive);
     }
   }
 
   void _writeDocumentation(Element element) {
     var documentation = element.documentationComment;
     if (documentation != null) {
-      _writelnMultiLineWithIndent('documentationComment: $documentation');
+      var str = documentation;
+      str = str.replaceAll('\n', r'\n');
+      str = str.replaceAll('\r', r'\r');
+      _writelnWithIndent('documentationComment: $str');
     }
   }
 
@@ -518,12 +521,6 @@
     buffer.writeln();
   }
 
-  void _writelnMultiLineWithIndent(String str) {
-    str = str.replaceAll('\n', r'\n');
-    str = str.replaceAll('\r', r'\r');
-    _writelnWithIndent(str);
-  }
-
   void _writelnWithIndent(String line) {
     buffer.write(indent);
     buffer.writeln(line);
@@ -648,8 +645,6 @@
   }
 
   void _writePropertyAccessorElement(PropertyAccessorElement e) {
-    e as PropertyAccessorElementImpl;
-
     PropertyInducingElement variable = e.variable;
     expect(variable, isNotNull);
 
@@ -858,7 +853,6 @@
   }
 
   void _writeUnitElement(CompilationUnitElement e) {
-    e as CompilationUnitElementImpl;
     _writeElements('classes', e.classes, _writeClassElement);
     _writeElements('enums', e.enums, _writeClassElement);
     _writeElements('extensions', e.extensions, _writeExtensionElement);
@@ -875,12 +869,6 @@
       _writePropertyAccessorElement,
     );
     _writeElements('functions', e.functions, _writeFunctionElement);
-
-    var macroGeneratedContent = e.macroGeneratedContent;
-    if (macroGeneratedContent != null) {
-      _writelnWithIndent('macroGeneratedContent');
-      buffer.write(macroGeneratedContent);
-    }
   }
 
   void _writeUri(Source? source) {
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
index d85eb96..bc041e1 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast2_test.dart
@@ -59,9 +59,11 @@
     var inputLibraries = <LinkInputLibrary>[];
     for (var sdkLibrary in sdk.sdkLibraries) {
       var source = sourceFactory.resolveUri(null, sdkLibrary.shortName)!;
+      var text = getFile(source.fullName).readAsStringSync();
+      var unit = parseText(text, featureSet);
 
       var inputUnits = <LinkInputUnit>[];
-      _addLibraryUnits(source, inputUnits, featureSet);
+      _addLibraryUnits(source, unit, inputUnits, featureSet);
       inputLibraries.add(
         LinkInputLibrary(
           source: source,
@@ -97,17 +99,11 @@
     var inputLibraries = <LinkInputLibrary>[];
     _addNonDartLibraries({}, inputLibraries, source);
 
-    var unitsInformativeData = <Uri, InformativeUnitData>{};
+    var unitsInformativeBytes = <Uri, Uint8List>{};
     for (var inputLibrary in inputLibraries) {
       for (var inputUnit in inputLibrary.units) {
-        var content = inputUnit.sourceContent;
-        if (content != null) {
-          var informativeBytes = writeUnitInformative(inputUnit.unit);
-          unitsInformativeData[inputUnit.uri] = InformativeUnitData(
-            content: content,
-            bytes: informativeBytes,
-          );
-        }
+        var informativeBytes = writeUnitInformative(inputUnit.unit);
+        unitsInformativeBytes[inputUnit.uri] = informativeBytes;
       }
     }
 
@@ -127,7 +123,7 @@
     elementFactory.addBundle(
       BundleReader(
         elementFactory: elementFactory,
-        unitsInformativeData: {},
+        unitsInformativeBytes: {},
         resolutionBytes: sdkBundle.resolutionBytes,
       ),
     );
@@ -141,7 +137,7 @@
       elementFactory.addBundle(
         BundleReader(
           elementFactory: elementFactory,
-          unitsInformativeData: unitsInformativeData,
+          unitsInformativeBytes: unitsInformativeBytes,
           resolutionBytes: linkResult.resolutionBytes,
         ),
       );
@@ -156,16 +152,14 @@
 
   void _addLibraryUnits(
     Source definingSource,
+    CompilationUnit definingUnit,
     List<LinkInputUnit> units,
     FeatureSet featureSet,
   ) {
-    var definingContent = _readSafely(definingSource.fullName);
-    var definingUnit = parseText(definingContent, featureSet);
     units.add(
       LinkInputUnit(
         partDirectiveIndex: null,
         source: definingSource,
-        sourceContent: definingContent,
         isSynthetic: false,
         unit: definingUnit,
       ),
@@ -190,7 +184,6 @@
               partDirectiveIndex: partDirectiveIndex,
               partUriStr: relativeUriStr,
               source: partSource,
-              sourceContent: text,
               isSynthetic: false,
               unit: unit,
             ),
@@ -215,7 +208,7 @@
     var unit = parseText(text, featureSet);
 
     var units = <LinkInputUnit>[];
-    _addLibraryUnits(source, units, featureSet);
+    _addLibraryUnits(source, unit, units, featureSet);
     libraries.add(
       LinkInputLibrary(
         source: source,
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 487ad9e..6040c16 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -21543,478 +21543,6 @@
 ''');
   }
 
-  test_macro_autoConstructor() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const autoConstructor = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-@autoConstructor
-class A {
-  final int a;
-  final int? b;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @56
-        metadata
-          Annotation
-            atSign: @ @33
-            element: macro_annotations.dart::@getter::autoConstructor
-            name: SimpleIdentifier
-              staticElement: macro_annotations.dart::@getter::autoConstructor
-              staticType: null
-              token: autoConstructor @34
-        fields
-          final a @72
-            type: int
-          final b @88
-            type: int?
-        constructors
-          @94
-            parameters
-              requiredName final this.a @111
-                type: int
-              optionalNamed final this.b @119
-                type: int?
-        accessors
-          synthetic get a @-1
-            returnType: int
-          synthetic get b @-1
-            returnType: int?
-    macroGeneratedContent
-import 'macro_annotations.dart';
-@autoConstructor
-class A {
-  final int a;
-  final int? b;
-
-  A({required this.a, this.b});
-}
-''');
-  }
-
-  test_macro_dataClass() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const dataClass = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-@dataClass
-class A {
-  final int a;
-  final int b;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @50
-        metadata
-          Annotation
-            atSign: @ @33
-            element: macro_annotations.dart::@getter::dataClass
-            name: SimpleIdentifier
-              staticElement: macro_annotations.dart::@getter::dataClass
-              staticType: null
-              token: dataClass @34
-        fields
-          final a @66
-            type: int
-          final b @81
-            type: int
-          synthetic hashCode @-1
-            type: int
-        constructors
-          @87
-            parameters
-              requiredName final this.a @104
-                type: int
-              requiredName final this.b @121
-                type: int
-        accessors
-          synthetic get a @-1
-            returnType: int
-          synthetic get b @-1
-            returnType: int
-          get hashCode @149
-            metadata
-              Annotation
-                atSign: @ @129
-                element: dart:core::@getter::override
-                name: SimpleIdentifier
-                  staticElement: dart:core::@getter::override
-                  staticType: null
-                  token: override @130
-            returnType: int
-        methods
-          toString @208
-            metadata
-              Annotation
-                atSign: @ @189
-                element: dart:core::@getter::override
-                name: SimpleIdentifier
-                  staticElement: dart:core::@getter::override
-                  staticType: null
-                  token: override @190
-            returnType: String
-    macroGeneratedContent
-import 'macro_annotations.dart';
-@dataClass
-class A {
-  final int a;
-  final int b;
-
-  A({required this.a, required this.b});
-
-  @override
-  int get hashCode => a.hashCode ^ b.hashCode;
-
-  @override
-  String toString() => 'A(a: $a, b: $b)';
-}
-''');
-  }
-
-  test_macro_hashCode() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @49
-        metadata
-          Annotation
-            atSign: @ @33
-            element: macro_annotations.dart::@getter::hashCode
-            name: SimpleIdentifier
-              staticElement: macro_annotations.dart::@getter::hashCode
-              staticType: null
-              token: hashCode @34
-        fields
-          final a @65
-            type: int
-          final b @80
-            type: int
-          synthetic hashCode @-1
-            type: int
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get a @-1
-            returnType: int
-          synthetic get b @-1
-            returnType: int
-          get hashCode @106
-            metadata
-              Annotation
-                atSign: @ @0
-                element: dart:core::@getter::override
-                name: SimpleIdentifier
-                  staticElement: dart:core::@getter::override
-                  staticType: null
-                  token: override @1
-            returnType: int
-    macroGeneratedContent
-import 'macro_annotations.dart';
-@hashCode
-class A {
-  final int a;
-  final int b;
-
-  @override
-  int get hashCode => a.hashCode ^ b.hashCode;
-}
-''');
-  }
-
-  test_macro_hashCode_withSuper() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const hashCode = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-
-class A {
-  final int a;
-}
-
-@hashCode
-class B extends A {
-  final int b;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @40
-        fields
-          final a @56
-            type: int
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get a @-1
-            returnType: int
-      class B @78
-        metadata
-          Annotation
-            atSign: @ @62
-            element: macro_annotations.dart::@getter::hashCode
-            name: SimpleIdentifier
-              staticElement: macro_annotations.dart::@getter::hashCode
-              staticType: null
-              token: hashCode @63
-        supertype: A
-        fields
-          final b @104
-            type: int
-          synthetic hashCode @-1
-            type: int
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get b @-1
-            returnType: int
-          get hashCode @130
-            metadata
-              Annotation
-                atSign: @ @110
-                element: dart:core::@getter::override
-                name: SimpleIdentifier
-                  staticElement: dart:core::@getter::override
-                  staticType: null
-                  token: override @111
-            returnType: int
-    macroGeneratedContent
-import 'macro_annotations.dart';
-
-class A {
-  final int a;
-}
-
-@hashCode
-class B extends A {
-  final int b;
-
-  @override
-  int get hashCode => b.hashCode ^ a.hashCode;
-}
-''');
-  }
-
-  test_macro_observable() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const observable = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-class A {
-  @observable
-  int _f = 0;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @39
-        fields
-          _f @63
-            metadata
-              Annotation
-                atSign: @ @45
-                element: macro_annotations.dart::@getter::observable
-                name: SimpleIdentifier
-                  staticElement: macro_annotations.dart::@getter::observable
-                  staticType: null
-                  token: observable @46
-            type: int
-          synthetic f @-1
-            type: int
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get _f @-1
-            returnType: int
-          synthetic set _f @-1
-            parameters
-              requiredPositional __f @-1
-                type: int
-            returnType: void
-          get f @82
-            returnType: int
-          set f @98
-            parameters
-              requiredPositional val @104
-                type: int
-            returnType: void
-    macroGeneratedContent
-import 'macro_annotations.dart';
-class A {
-  @observable
-  int _f = 0;
-
-  int get f => _f;
-
-  set f(int val) {
-    print('Setting f to ${val}');
-    _f = val;
-  }
-}
-''');
-  }
-
-  test_macro_observable_generic() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const observable = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-class A<T> {
-  @observable
-  T _f;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @39
-        typeParameters
-          covariant T @41
-            defaultType: dynamic
-        fields
-          _f @64
-            metadata
-              Annotation
-                atSign: @ @48
-                element: macro_annotations.dart::@getter::observable
-                name: SimpleIdentifier
-                  staticElement: macro_annotations.dart::@getter::observable
-                  staticType: null
-                  token: observable @49
-            type: T
-          synthetic f @-1
-            type: T
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get _f @-1
-            returnType: T
-          synthetic set _f @-1
-            parameters
-              requiredPositional __f @-1
-                type: T
-            returnType: void
-          get f @77
-            returnType: T
-          set f @93
-            parameters
-              requiredPositional val @97
-                type: T
-            returnType: void
-    macroGeneratedContent
-import 'macro_annotations.dart';
-class A<T> {
-  @observable
-  T _f;
-
-  T get f => _f;
-
-  set f(T val) {
-    print('Setting f to ${val}');
-    _f = val;
-  }
-}
-''');
-  }
-
-  test_macro_toString() async {
-    addLibrarySource('/macro_annotations.dart', r'''
-library analyzer.macro.annotations;
-const toString = 0;
-''');
-    var library = await checkLibrary(r'''
-import 'macro_annotations.dart';
-@toString
-class A {
-  final int a;
-  final int b;
-}
-''');
-    checkElementText(library, r'''
-library
-  imports
-    macro_annotations.dart
-  definingUnit
-    classes
-      class A @49
-        metadata
-          Annotation
-            atSign: @ @33
-            element: macro_annotations.dart::@getter::toString
-            name: SimpleIdentifier
-              staticElement: macro_annotations.dart::@getter::toString
-              staticType: null
-              token: toString @34
-        fields
-          final a @65
-            type: int
-          final b @80
-            type: int
-        constructors
-          synthetic @-1
-        accessors
-          synthetic get a @-1
-            returnType: int
-          synthetic get b @-1
-            returnType: int
-        methods
-          toString @105
-            metadata
-              Annotation
-                atSign: @ @86
-                element: dart:core::@getter::override
-                name: SimpleIdentifier
-                  staticElement: dart:core::@getter::override
-                  staticType: null
-                  token: override @87
-            returnType: String
-    macroGeneratedContent
-import 'macro_annotations.dart';
-@toString
-class A {
-  final int a;
-  final int b;
-
-  @override
-  String toString() => 'A(a: $a, b: $b)';
-}
-''');
-  }
-
   test_main_class() async {
     var library = await checkLibrary('class main {}');
     checkElementText(library, r'''
diff --git a/pkg/analyzer/tool/macro/generate.dart b/pkg/analyzer/tool/macro/generate.dart
deleted file mode 100644
index 2cc9a41..0000000
--- a/pkg/analyzer/tool/macro/generate.dart
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2021, 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:io' as io;
-
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/util/file_paths.dart' as file_paths;
-
-void main(List<String> arguments) async {
-  if (arguments.length != 1) {
-    _printUsage();
-    io.exit(1);
-  }
-
-  var resourceProvider = PhysicalResourceProvider.INSTANCE;
-  var pathContext = resourceProvider.pathContext;
-
-  // The directory must exist.
-  var packagePath = arguments[0];
-  var packageFolder = resourceProvider.getFolder(packagePath);
-  if (!packageFolder.exists) {
-    print('Error: $packagePath does not exist.');
-    io.exit(1);
-  }
-
-  // The directory must be a Pub package.
-  var pubspecYamlFile = packageFolder.getChildAssumingFile(
-    file_paths.pubspecYaml,
-  );
-  if (!pubspecYamlFile.exists) {
-    print('Error: ${pubspecYamlFile.path} does not exist.');
-    io.exit(1);
-  }
-
-  var collection = AnalysisContextCollection(
-    includedPaths: [packagePath],
-  );
-  for (var analysisContext in collection.contexts) {
-    var analyzedPaths = analysisContext.contextRoot.analyzedFiles();
-    for (var path in analyzedPaths) {
-      if (file_paths.isDart(pathContext, path)) {
-        var session = analysisContext.currentSession;
-        var unitElementResult = await session.getUnitElement(path);
-        if (unitElementResult is UnitElementResult) {
-          var unitElement =
-              unitElementResult.element as CompilationUnitElementImpl;
-          // If has macro-generated content, write it.
-          var macroGeneratedContent = unitElement.macroGeneratedContent;
-          if (macroGeneratedContent != null) {
-            var relativePath = pathContext.relative(path, from: packagePath);
-            var combinedPath = pathContext.join(
-                packagePath, '.dart_tool', 'analyzer', 'macro', relativePath);
-            resourceProvider.getFile(combinedPath)
-              ..parent2.create()
-              ..writeAsStringSync(macroGeneratedContent);
-          }
-        }
-      }
-    }
-  }
-}
-
-void _printUsage() {
-  print('''
-Usage: dart generate.dart path-to-pub-package
-Write combined code of files that have macro-generated declarations.
-''');
-}
diff --git a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
index 10640fc..575cd5b 100644
--- a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
+++ b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
@@ -17,13 +17,6 @@
 ///
 /// Clients may not extend, implement or mix-in this class.
 class AnalyzerConverter {
-  /// Optional provider for [analyzer.Element] location, used for example to
-  /// override the location of macro-generated elements.
-  final ElementLocationProvider? _locationProvider;
-
-  AnalyzerConverter({ElementLocationProvider? locationProvider})
-      : _locationProvider = locationProvider;
-
   /// Convert the analysis [error] from the 'analyzer' package to an analysis
   /// error defined by the plugin API. If a [lineInfo] is provided then the
   /// error's location will have a start line and start column. If a [severity]
@@ -206,12 +199,6 @@
     if (element == null || element.source == null) {
       return null;
     }
-
-    var result = _locationProvider?.forElement(element);
-    if (result != null) {
-      return result;
-    }
-
     offset ??= element.nameOffset;
     length ??= element.nameLength;
     if (element is analyzer.CompilationUnitElement ||
@@ -425,9 +412,3 @@
         endLine: endLine, endColumn: endColumn);
   }
 }
-
-abstract class ElementLocationProvider {
-  /// Return the location of [element] that this provider wants to override,
-  /// or `null` if the default location should be used.
-  plugin.Location? forElement(analyzer.Element element);
-}
diff --git a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
index 532762c..8d5106f 100644
--- a/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
+++ b/pkg/analyzer_plugin/lib/utilities/navigation/navigation_dart.dart
@@ -16,15 +16,12 @@
 import 'package:analyzer_plugin/utilities/navigation/navigation.dart';
 
 NavigationCollector computeDartNavigation(
-  ResourceProvider resourceProvider,
-  NavigationCollector collector,
-  CompilationUnit unit,
-  int? offset,
-  int? length, {
-  AnalyzerConverter? analyzerConverter,
-}) {
-  var dartCollector = _DartNavigationCollector(
-      collector, offset, length, analyzerConverter ?? AnalyzerConverter());
+    ResourceProvider resourceProvider,
+    NavigationCollector collector,
+    CompilationUnit unit,
+    int? offset,
+    int? length) {
+  var dartCollector = _DartNavigationCollector(collector, offset, length);
   var visitor = _DartNavigationComputerVisitor(resourceProvider, dartCollector);
   if (offset == null || length == null) {
     unit.accept(visitor);
@@ -69,14 +66,9 @@
   final NavigationCollector collector;
   final int? requestedOffset;
   final int? requestedLength;
-  final AnalyzerConverter _analyzerConverter;
 
   _DartNavigationCollector(
-    this.collector,
-    this.requestedOffset,
-    this.requestedLength,
-    this._analyzerConverter,
-  );
+      this.collector, this.requestedOffset, this.requestedLength);
 
   void _addRegion(int offset, int length, Element? element) {
     element = element?.nonSynthetic;
@@ -93,14 +85,15 @@
     if (!_isWithinRequestedRange(offset, length)) {
       return;
     }
-    var kind = _analyzerConverter.convertElementKind(element.kind);
-    var location = _analyzerConverter.locationFromElement(element);
+    var converter = AnalyzerConverter();
+    var kind = converter.convertElementKind(element.kind);
+    var location = converter.locationFromElement(element);
     if (location == null) {
       return;
     }
 
     var codeLocation = collector.collectCodeLocations
-        ? _getCodeLocation(element, location)
+        ? _getCodeLocation(element, location, converter)
         : null;
 
     collector.addRegion(offset, length, kind, location,
@@ -129,8 +122,8 @@
   }
 
   /// Get the location of the code (excluding leading doc comments) for this element.
-  protocol.Location? _getCodeLocation(
-      Element element, protocol.Location location) {
+  protocol.Location? _getCodeLocation(Element element,
+      protocol.Location location, AnalyzerConverter converter) {
     var codeElement = element;
     // For synthetic getters created for fields, we need to access the associated
     // variable to get the codeOffset/codeLength.
@@ -169,7 +162,7 @@
       codeOffset = offsetAfterDocs;
     }
 
-    return _analyzerConverter.locationFromElement(element,
+    return converter.locationFromElement(element,
         offset: codeOffset, length: codeLength);
   }
 
diff --git a/pkg/compiler/lib/src/ssa/interceptor_finalizer.dart b/pkg/compiler/lib/src/ssa/interceptor_finalizer.dart
index fc51912..2c20593 100644
--- a/pkg/compiler/lib/src/ssa/interceptor_finalizer.dart
+++ b/pkg/compiler/lib/src/ssa/interceptor_finalizer.dart
@@ -233,12 +233,9 @@
   }
 
   void _replaceReceiverArgumentWithDummy(HInvoke node, int receiverIndex) {
-    HInstruction receiverArgument = node.inputs[receiverIndex];
     ConstantValue constant = DummyInterceptorConstantValue();
     HConstant dummy = _graph.addConstant(constant, _closedWorld);
-    receiverArgument.usedBy.remove(node);
-    node.inputs[receiverIndex] = dummy;
-    dummy.usedBy.add(node);
+    node.replaceInput(receiverIndex, dummy);
   }
 }
 
diff --git a/pkg/compiler/lib/src/ssa/nodes.dart b/pkg/compiler/lib/src/ssa/nodes.dart
index 6f187a3..7bd3dde 100644
--- a/pkg/compiler/lib/src/ssa/nodes.dart
+++ b/pkg/compiler/lib/src/ssa/nodes.dart
@@ -1313,8 +1313,8 @@
     removeFromList(usedBy, user);
   }
 
-  // Change all uses of [oldInput] by [this] to [newInput]. Also
-  // updates the [usedBy] of [oldInput] and [newInput].
+  // Change all uses of [oldInput] by [this] to [newInput]. Also updates the
+  // [usedBy] of [oldInput] and [newInput].
   void changeUse(HInstruction oldInput, HInstruction newInput) {
     assert(newInput != null && !identical(oldInput, newInput));
     for (int i = 0; i < inputs.length; i++) {
@@ -1326,6 +1326,16 @@
     removeFromList(oldInput.usedBy, this);
   }
 
+  /// Replace a single input.
+  ///
+  /// Use [changeUse] to change all inputs that are the same value.
+  void replaceInput(int index, HInstruction replacement) {
+    assert(replacement.isInBasicBlock());
+    inputs[index].usedBy.remove(this);
+    inputs[index] = replacement;
+    replacement.usedBy.add(this);
+  }
+
   void replaceAllUsersDominatedBy(
       HInstruction cursor, HInstruction newInstruction) {
     DominatedUses.of(this, cursor).replaceWith(newInstruction);
@@ -1439,9 +1449,7 @@
           identical(oldInstruction, _source),
           'Input ${index} of ${user} changed.'
           '\n  Found: ${oldInstruction}\n  Expected: ${_source}');
-      user.inputs[index] = newInstruction;
-      oldInstruction.usedBy.remove(user);
-      newInstruction.usedBy.add(user);
+      user.replaceInput(index, newInstruction);
     }
   }
 
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 7fc8c53..d600d7e 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -1158,6 +1158,79 @@
     return null;
   }
 
+  FieldEntity _indexFieldOfEnumClass(ClassEntity enumClass) {
+    MemberEntity member =
+        _closedWorld.elementEnvironment.lookupClassMember(enumClass, 'index');
+    if (member is FieldEntity) return member;
+    throw StateError('$enumClass should have index field, found $member');
+  }
+
+  IntConstantValue _indexValueOfEnumConstant(
+      ConstantValue constant, ClassEntity enumClass, FieldEntity field) {
+    if (constant is ConstructedConstantValue) {
+      if (constant.type.element == enumClass) {
+        final value = constant.fields[field];
+        if (value is IntConstantValue) return value;
+      }
+    }
+    throw StateError(
+        'Enum constant ${constant.toStructuredText(_closedWorld.dartTypes)}'
+        ' should have $field');
+  }
+
+  // The `enum` class of the [node], or `null` if [node] does not have an
+  // non-nullable enum type.
+  ClassEntity _enumClass(HInstruction node) {
+    final cls = _abstractValueDomain.getExactClass(node.instructionType);
+    if (cls == null) return null;
+    if (_closedWorld.elementEnvironment.isEnumClass(cls)) return cls;
+    return null;
+  }
+
+  // Try to replace enum labels in a switch with the index values. This is
+  // usually smaller, faster, and might allow the JavaScript engine to compile
+  // the switch to a jump-table.
+  void _tryReduceEnumsInSwitch(HSwitch node) {
+    final enumClass = _enumClass(node.expression);
+    if (enumClass == null) return;
+
+    FieldEntity indexField = _indexFieldOfEnumClass(enumClass);
+    // In some cases the `index` field is elided. We can't load an elided field.
+    //
+    // TODO(sra): The ConstantValue has the index value, so we can still reduce
+    // the enum to the index value. We could handle an elided `index` field in
+    // some cases by doing this optimization more like scalar replacement or
+    // unboxing, replacing all enums in the method at once, possibly reducing
+    // phis of enums to phis of indexes.
+    if (_closedWorld.fieldAnalysis.getFieldData(indexField).isElided) return;
+
+    // All the label expressions should be of the same enum class as the switch
+    // expression.
+    for (final label in node.inputs.skip(1)) {
+      if (label is! HConstant) return;
+      if (_enumClass(label) != enumClass) return;
+    }
+
+    final loadIndex = _directFieldGet(node.expression, indexField, node);
+    node.block.addBefore(node, loadIndex);
+    node.replaceInput(0, loadIndex);
+
+    for (int i = 1; i < node.inputs.length; i++) {
+      ConstantValue labelConstant = (node.inputs[i] as HConstant).constant;
+      node.replaceInput(
+          i,
+          _graph.addConstant(
+              _indexValueOfEnumConstant(labelConstant, enumClass, indexField),
+              _closedWorld));
+    }
+  }
+
+  @override
+  HInstruction visitSwitch(HSwitch node) {
+    _tryReduceEnumsInSwitch(node);
+    return node;
+  }
+
   @override
   HInstruction visitIdentity(HIdentity node) {
     HInstruction newInstruction = handleIdentityCheck(node);
@@ -1281,10 +1354,7 @@
 
   /// Returns [node] after replacing condition.
   HInstruction _replaceHIfCondition(HIf node, HInstruction newCondition) {
-    HInstruction condition = node.condition;
-    node.inputs[0] = newCondition;
-    condition.usedBy.remove(node);
-    newCondition.usedBy.add(node);
+    node.replaceInput(0, newCondition);
     return node;
   }
 
@@ -2506,9 +2576,7 @@
       // Pick the 'live' branch to be the smallest subgraph.
       bool value = thenSize <= elseSize;
       HInstruction newCondition = _graph.addConstantBool(value, closedWorld);
-      instruction.inputs[0] = newCondition;
-      condition.usedBy.remove(instruction);
-      newCondition.usedBy.add(instruction);
+      instruction.replaceInput(0, newCondition);
     }
   }
 
@@ -2563,7 +2631,7 @@
       block.forEachPhi((HPhi phi) {
         for (int i = 0; i < phi.inputs.length; ++i) {
           if (!predecessors[i].isLive && phi.inputs[i] != zapInstruction) {
-            replaceInput(i, phi, zapInstruction);
+            phi.replaceInput(i, zapInstruction);
           }
         }
       });
@@ -2598,12 +2666,6 @@
     }
   }
 
-  void replaceInput(int i, HInstruction from, HInstruction by) {
-    from.inputs[i].usedBy.remove(from);
-    from.inputs[i] = by;
-    by.usedBy.add(from);
-  }
-
   void removeUsers(HInstruction instruction) {
     instruction.usedBy.forEach((user) {
       removeInput(user, instruction);
diff --git a/runtime/platform/globals.h b/runtime/platform/globals.h
index ed20219..7d69548 100644
--- a/runtime/platform/globals.h
+++ b/runtime/platform/globals.h
@@ -356,9 +356,13 @@
 
 // Determine whether we will be using the simulator.
 #if defined(TARGET_ARCH_IA32)
-// No simulator used.
+#if !defined(HOST_ARCH_IA32)
+#define USING_SIMULATOR 1
+#endif
 #elif defined(TARGET_ARCH_X64)
-// No simulator used.
+#if !defined(HOST_ARCH_X64)
+#define USING_SIMULATOR 1
+#endif
 #elif defined(TARGET_ARCH_ARM)
 #if !defined(HOST_ARCH_ARM)
 #define TARGET_HOST_MISMATCH 1
diff --git a/runtime/tools/dartfuzz/dartfuzz.dart b/runtime/tools/dartfuzz/dartfuzz.dart
index c2e2d6c..a62e235 100644
--- a/runtime/tools/dartfuzz/dartfuzz.dart
+++ b/runtime/tools/dartfuzz/dartfuzz.dart
@@ -14,7 +14,7 @@
 // Version of DartFuzz. Increase this each time changes are made
 // to preserve the property that a given version of DartFuzz yields
 // the same fuzzed program for a deterministic random seed.
-const String version = '1.92';
+const String version = '1.93';
 
 // Restriction on statements and expressions.
 const int stmtDepth = 1;
@@ -550,6 +550,8 @@
     emitBraceWrapped(() => tryBody());
     emit(' on OutOfMemoryError ');
     emitBraceWrapped(() => emitLn('exit($oomExitCode);', newline: false));
+    emit(' on StackOverflowError ');
+    emitBraceWrapped(() => emitLn('exit($oomExitCode);', newline: false));
     emit(' catch (e, st) ');
     emitBraceWrapped(catchBody);
     if (finallyBody != null) {
@@ -1391,6 +1393,8 @@
     emitBraceWrapped(emitStatementsClosure);
     emit(' on OutOfMemoryError ');
     emitBraceWrapped(() => emitLn('exit($oomExitCode);', newline: false));
+    emit(' on StackOverflowError ');
+    emitBraceWrapped(() => emitLn('exit($oomExitCode);', newline: false));
     emit(' catch (exception, stackTrace) ', newline: false);
     emitBraceWrapped(emitStatementsClosure);
     if (coinFlip()) {
diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc
index 21399b7..1d74f0a 100644
--- a/runtime/vm/app_snapshot.cc
+++ b/runtime/vm/app_snapshot.cc
@@ -534,6 +534,12 @@
         required_capacity++;
       }
     }
+    // Over-allocate capacity so a few inserts can happen at startup without
+    // causing a rehash.
+    const intptr_t kSpareCapacity = 32;
+    required_capacity = static_cast<intptr_t>(
+        static_cast<double>(required_capacity + kSpareCapacity) /
+        HashTables::kMaxLoadFactor);
 
     intptr_t num_occupied = 0;
 
@@ -5365,6 +5371,10 @@
       if (d->isolate_group() == Dart::vm_isolate_group()) {
         Symbols::InitFromSnapshot(d->isolate_group());
       }
+#if defined(DEBUG)
+      Symbols::New(Thread::Current(), ":some:new:symbol:");
+      ASSERT(object_store->symbol_table() == table_.ptr());  // Did not rehash.
+#endif
     }
   }
 };
diff --git a/runtime/vm/cpu_arm64.cc b/runtime/vm/cpu_arm64.cc
index e27ac58..d193d23 100644
--- a/runtime/vm/cpu_arm64.cc
+++ b/runtime/vm/cpu_arm64.cc
@@ -64,7 +64,7 @@
   return
 #if defined(USING_SIMULATOR)
       "sim"
-#endif  // !defined(HOST_ARCH_ARM64)
+#endif  // !defined(USING_SIMULATOR)
       "arm64";
 }
 
diff --git a/runtime/vm/cpu_ia32.cc b/runtime/vm/cpu_ia32.cc
index a2ed128..27ae5c5 100644
--- a/runtime/vm/cpu_ia32.cc
+++ b/runtime/vm/cpu_ia32.cc
@@ -24,7 +24,11 @@
 }
 
 const char* CPU::Id() {
-  return "ia32";
+  return
+#if defined(USING_SIMULATOR)
+      "sim"
+#endif  // !defined(USING_SIMULATOR)
+      "ia32";
 }
 
 const char* HostCPUFeatures::hardware_ = nullptr;
diff --git a/runtime/vm/cpu_x64.cc b/runtime/vm/cpu_x64.cc
index 7f5981c..cf0acf3 100644
--- a/runtime/vm/cpu_x64.cc
+++ b/runtime/vm/cpu_x64.cc
@@ -23,7 +23,11 @@
 }
 
 const char* CPU::Id() {
-  return "x64";
+  return
+#if defined(USING_SIMULATOR)
+      "sim"
+#endif  // !defined(USING_SIMULATOR)
+      "x64";
 }
 
 const char* HostCPUFeatures::hardware_ = nullptr;
diff --git a/runtime/vm/hash_table.h b/runtime/vm/hash_table.h
index 318dbf4..d917aae 100644
--- a/runtime/vm/hash_table.h
+++ b/runtime/vm/hash_table.h
@@ -553,6 +553,8 @@
     }
   }
 
+  static constexpr double kMaxLoadFactor = 0.71;
+
   template <typename Table>
   static void EnsureLoadFactor(double high, const Table& table) {
     // We count deleted elements because they take up space just
@@ -707,8 +709,7 @@
 
  protected:
   void EnsureCapacity() const {
-    static const double kMaxLoadFactor = 0.71;
-    HashTables::EnsureLoadFactor(kMaxLoadFactor, *this);
+    HashTables::EnsureLoadFactor(HashTables::kMaxLoadFactor, *this);
   }
 };
 
@@ -793,8 +794,7 @@
 
  protected:
   void EnsureCapacity() const {
-    static const double kMaxLoadFactor = 0.71;
-    HashTables::EnsureLoadFactor(kMaxLoadFactor, *this);
+    HashTables::EnsureLoadFactor(HashTables::kMaxLoadFactor, *this);
   }
 };
 
diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc
index 76a9ecd..97850c6 100644
--- a/runtime/vm/heap/heap.cc
+++ b/runtime/vm/heap/heap.cc
@@ -364,6 +364,7 @@
 
 void Heap::NotifyIdle(int64_t deadline) {
   Thread* thread = Thread::Current();
+  TIMELINE_FUNCTION_GC_DURATION(thread, "NotifyIdle");
   GcSafepointOperationScope safepoint_operation(thread);
 
   // Check if we want to collect new-space first, because if we want to collect
@@ -371,7 +372,6 @@
   // to shrink the root set (make old-space GC faster) and avoid
   // intergenerational garbage (make old-space GC free more memory).
   if (new_space_.ShouldPerformIdleScavenge(deadline)) {
-    TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC");
     CollectNewSpaceGarbage(thread, kIdle);
   }
 
@@ -383,7 +383,6 @@
     // We prefer mark-compact over other old space GCs if we have enough time,
     // since it removes old space fragmentation and frees up most memory.
     // Blocks for O(heap), roughtly twice as costly as mark-sweep.
-    TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC");
     CollectOldSpaceGarbage(thread, kMarkCompact, kIdle);
   } else if (old_space_.ReachedHardThreshold()) {
     // Even though the following GC may exceed our idle deadline, we need to
@@ -393,7 +392,6 @@
     // the only place that checks the old space allocation limit.
     // Compare the tail end of Heap::CollectNewSpaceGarbage.
     // Blocks for O(heap).
-    TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC");
     CollectOldSpaceGarbage(thread, kMarkSweep, kIdle);
   } else if (old_space_.ShouldStartIdleMarkSweep(deadline) ||
              old_space_.ReachedSoftThreshold()) {
@@ -408,16 +406,15 @@
       phase = old_space_.phase();
     }
     if (phase == PageSpace::kAwaitingFinalization) {
-      TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC");
       CollectOldSpaceGarbage(thread, Heap::kMarkSweep, Heap::kFinalize);
     } else if (phase == PageSpace::kDone) {
-      TIMELINE_FUNCTION_GC_DURATION(thread, "IdleGC");
       StartConcurrentMarking(thread);
     }
   }
 }
 
 void Heap::NotifyLowMemory() {
+  TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "NotifyLowMemory");
   CollectMostGarbage(kLowMemory);
 }
 
diff --git a/runtime/vm/simulator.h b/runtime/vm/simulator.h
index 3194aa9..e08337c 100644
--- a/runtime/vm/simulator.h
+++ b/runtime/vm/simulator.h
@@ -9,8 +9,7 @@
 
 #if defined(USING_SIMULATOR)
 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
-// No simulator used.
-#error Simulator not supported.
+#error Simulator not implemented.
 #elif defined(TARGET_ARCH_ARM)
 #include "vm/simulator_arm.h"
 #elif defined(TARGET_ARCH_ARM64)
diff --git a/tools/VERSION b/tools/VERSION
index 9936ef2..e72b70a 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 15
 PATCH 0
-PRERELEASE 154
+PRERELEASE 155
 PRERELEASE_PATCH 0
\ No newline at end of file