[roll] Update third-party dart packages

Roller-URL: https://ci.chromium.org/b/8816879366603384497
Roller-Owners: chaselatta@google.com, godofredoc@google.com
Cq-Cl-Tag: roller-builder:flutter-with-deps-roller
Cq-Cl-Tag: roller-bid:8816879366603384497
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: Id4385ddd0bede82fdd94ce82bdbf2839ec0e2383
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/dart-pkg/+/669450
Commit-Queue: GI Roller <global-integration-roller@fuchsia-infra.iam.gserviceaccount.com>
diff --git a/build/BUILD.gn b/build/BUILD.gn
index 717fa52..2f67db1 100644
--- a/build/BUILD.gn
+++ b/build/BUILD.gn
@@ -1,4 +1,4 @@
-# This file is generated by package_importer.py for build-2.2.1
+# This file is generated by package_importer.py for build-2.2.2
 
 import("//build/dart/dart_library.gni")
 
diff --git a/build/CHANGELOG.md b/build/CHANGELOG.md
index a98179e..249d428 100644
--- a/build/CHANGELOG.md
+++ b/build/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.2.2
+
+- Allow analyzer version 4.x.
+
 ## 2.2.1
 
 - Fix a bug where builders were allowed to write to the same asset multiple
diff --git a/build/lib/src/analyzer/resolver.dart b/build/lib/src/analyzer/resolver.dart
index 3e544db..0d437cd 100644
--- a/build/lib/src/analyzer/resolver.dart
+++ b/build/lib/src/analyzer/resolver.dart
@@ -175,8 +175,8 @@
 
       // Output messages like "foo.dart:3:4: Expected a semicolon here."
       buffer.writeln(
-          '$sourceName:${position.lineNumber}:${position.columnNumber}: ' +
-              error.message);
+          '$sourceName:${position.lineNumber}:${position.columnNumber}: '
+          '${error.message}');
     }
 
     final additionalErrors = entries.length - _maxErrorsInToString;
diff --git a/build/pubspec.yaml b/build/pubspec.yaml
index 0c703fe..39869dd 100644
--- a/build/pubspec.yaml
+++ b/build/pubspec.yaml
@@ -1,5 +1,5 @@
 name: build
-version: 2.2.1
+version: 2.2.2
 description: A package for authoring build_runner compatible code generators.
 repository: https://github.com/dart-lang/build/tree/master/build
 
@@ -7,7 +7,7 @@
   sdk: ">=2.14.0 <3.0.0"
 
 dependencies:
-  analyzer: ">=1.5.0 <4.0.0"
+  analyzer: ">=1.5.0 <5.0.0"
   async: ^2.5.0
   convert: ^3.0.0
   crypto: ^3.0.0
@@ -19,5 +19,5 @@
 dev_dependencies:
   build_resolvers: ^2.0.0
   build_test: ^2.0.0
-  lints: ^1.0.0
+  lints: '>=1.0.0 <3.0.0'
   test: ^1.16.0
diff --git a/source_gen/BUILD.gn b/source_gen/BUILD.gn
index 1746422..bc1a2b1 100644
--- a/source_gen/BUILD.gn
+++ b/source_gen/BUILD.gn
@@ -1,4 +1,4 @@
-# This file is generated by package_importer.py for source_gen-1.2.1
+# This file is generated by package_importer.py for source_gen-1.2.2
 
 import("//build/dart/dart_library.gni")
 
diff --git a/source_gen/CHANGELOG.md b/source_gen/CHANGELOG.md
index e7257d5..d80c37b 100644
--- a/source_gen/CHANGELOG.md
+++ b/source_gen/CHANGELOG.md
@@ -1,3 +1,10 @@
+## 1.2.2
+
+* Enable the fix for single cascade statements when formatting Dart code.
+  * Individual builders can opt out of this by providing a custom `formatOutput`
+    function to the `PartBuilder` or `LibraryBuilder` constructors.
+* Allow analyzer version 4.x.
+
 ## 1.2.1
 
 - Allow reviving constants which are static fields defined on the class which
@@ -57,6 +64,10 @@
   - `ConstantReader.anyValue`.
   - `LibraryReader.classElements`.
 
+## 0.9.10+5
+
+* Widen `dart_style` range to include v2.x.
+
 ## 0.9.10+4
 
 * Upgrade to `package:build` version `2.0.0`.
diff --git a/source_gen/lib/builder.dart b/source_gen/lib/builder.dart
index 8bf0c7a..8db449f 100644
--- a/source_gen/lib/builder.dart
+++ b/source_gen/lib/builder.dart
@@ -83,14 +83,16 @@
 
     // Pattern used to ensure items are only considered if they match
     // [file name without extension].[valid part id].[part file extension]
-    final restrictedPattern = RegExp([
-      '^', // start of string
-      RegExp.escape(inputBaseName), // file name, without extension
-      '.', // `.` character
-      partIdRegExpLiteral, // A valid part ID
-      RegExp.escape(_partFiles), // the ending part extension
-      '\$', // end of string
-    ].join());
+    final restrictedPattern = RegExp(
+      [
+        '^', // start of string
+        RegExp.escape(inputBaseName), // file name, without extension
+        '.', // `.` character
+        partIdRegExpLiteral, // A valid part ID
+        RegExp.escape(_partFiles), // the ending part extension
+        '\$', // end of string
+      ].join(),
+    );
 
     final assetIds = await buildStep
         .findAssets(Glob(pattern))
@@ -119,8 +121,10 @@
         await buildStep.resolver.compilationUnitFor(buildStep.inputId);
     final part = computePartUrl(buildStep.inputId, outputId);
     if (!hasExpectedPartDirective(libraryUnit, part)) {
-      log.warning('$part must be included as a part directive in '
-          'the input library with:\n    part \'$part\';');
+      log.warning(
+        '$part must be included as a part directive in '
+        'the input library with:\n    part \'$part\';',
+      );
       return;
     }
 
diff --git a/source_gen/lib/src/builder.dart b/source_gen/lib/src/builder.dart
index a85dabd..61b61c6 100644
--- a/source_gen/lib/src/builder.dart
+++ b/source_gen/lib/src/builder.dart
@@ -60,17 +60,22 @@
         formatOutput = formatOutput ?? _formatter.format,
         _header = (header ?? defaultFileHeader).trim() {
     if (_generatedExtension.isEmpty || !_generatedExtension.startsWith('.')) {
-      throw ArgumentError.value(_generatedExtension, 'generatedExtension',
-          'Extension must be in the format of .*');
+      throw ArgumentError.value(
+        _generatedExtension,
+        'generatedExtension',
+        'Extension must be in the format of .*',
+      );
     }
     if (_isLibraryBuilder && _generators.length > 1) {
       throw ArgumentError(
-          'A standalone file can only be generated from a single Generator.');
+        'A standalone file can only be generated from a single Generator.',
+      );
     }
     if (options != null && additionalOutputExtensions.isNotEmpty) {
       throw ArgumentError(
-          'Either `options` or `additionalOutputExtensions` parameter '
-          'can be given. Not both.');
+        'Either `options` or `additionalOutputExtensions` parameter '
+        'can be given. Not both.',
+      );
     }
   }
 
@@ -82,7 +87,10 @@
 
     if (_generators.every((g) => g is GeneratorForAnnotation) &&
         !(await _hasAnyTopLevelAnnotations(
-            buildStep.inputId, resolver, buildStep))) {
+          buildStep.inputId,
+          resolver,
+          buildStep,
+        ))) {
       return;
     }
 
@@ -128,8 +136,10 @@
             hasExpectedPartDirective(libraryUnit, part);
         if (!hasLibraryPartDirectiveWithOutputUri) {
           // TODO: Upgrade to error in a future breaking change?
-          log.warning('$part must be included as a part directive in '
-              'the input library with:\n    part \'$part\';');
+          log.warning(
+            '$part must be included as a part directive in '
+            'the input library with:\n    part \'$part\';',
+          );
           return;
         }
       } else {
@@ -221,10 +231,11 @@
         ) {
     if (!_partIdRegExp.hasMatch(partId)) {
       throw ArgumentError.value(
-          partId,
-          'partId',
-          '`partId` can only contain letters, numbers, `_` and `.`. '
-              'It cannot start or end with `.`.');
+        partId,
+        'partId',
+        '`partId` can only contain letters, numbers, `_` and `.`. '
+            'It cannot start or end with `.`.',
+      );
     }
   }
 }
@@ -354,7 +365,10 @@
 }
 
 Future<bool> _hasAnyTopLevelAnnotations(
-    AssetId input, Resolver resolver, BuildStep buildStep) async {
+  AssetId input,
+  Resolver resolver,
+  BuildStep buildStep,
+) async {
   if (!await buildStep.canRead(input)) return false;
   final parsed = await resolver.compilationUnitFor(input);
   final partIds = <AssetId>[];
@@ -377,7 +391,7 @@
   return false;
 }
 
-final _formatter = DartFormatter();
+final _formatter = DartFormatter(fixes: [StyleFix.singleCascadeStatements]);
 
 const defaultFileHeader = '// GENERATED CODE - DO NOT MODIFY BY HAND';
 
diff --git a/source_gen/lib/src/constants/revive.dart b/source_gen/lib/src/constants/revive.dart
index 9dd7149..6608573 100644
--- a/source_gen/lib/src/constants/revive.dart
+++ b/source_gen/lib/src/constants/revive.dart
@@ -46,7 +46,8 @@
 
   if (element is ClassElement) {
     for (final e in element.fields.where(
-        (f) => f.isPublic && f.isConst && f.computeConstantValue() == object)) {
+      (f) => f.isPublic && f.isConst && f.computeConstantValue() == object,
+    )) {
       return Revivable._(
         source: url.removeFragment(),
         accessor: '${element.name}.${e.name}',
@@ -63,8 +64,7 @@
     return !result.isPrivate;
   }
 
-  // ignore: deprecated_member_use
-  for (final type in origin!.definingCompilationUnit.types) {
+  for (final type in origin!.definingCompilationUnit.classes) {
     for (final e in type.fields
         .where((f) => f.isConst && f.computeConstantValue() == object)) {
       final result = Revivable._(
diff --git a/source_gen/lib/src/generator_for_annotation.dart b/source_gen/lib/src/generator_for_annotation.dart
index 6edf426..4d53fcf 100644
--- a/source_gen/lib/src/generator_for_annotation.dart
+++ b/source_gen/lib/src/generator_for_annotation.dart
@@ -51,7 +51,10 @@
 
     for (var annotatedElement in library.annotatedWith(typeChecker)) {
       final generatedValue = generateForAnnotatedElement(
-          annotatedElement.element, annotatedElement.annotation, buildStep);
+        annotatedElement.element,
+        annotatedElement.annotation,
+        buildStep,
+      );
       await for (var value in normalizeGeneratorOutput(generatedValue)) {
         assert(value.length == value.trim().length);
         values.add(value);
@@ -73,5 +76,8 @@
   /// Implementations should return `null` when no content is generated. Empty
   /// or whitespace-only [String] instances are also ignored.
   dynamic generateForAnnotatedElement(
-      Element element, ConstantReader annotation, BuildStep buildStep);
+    Element element,
+    ConstantReader annotation,
+    BuildStep buildStep,
+  );
 }
diff --git a/source_gen/lib/src/library.dart b/source_gen/lib/src/library.dart
index 92f0f1e..32f9939 100644
--- a/source_gen/lib/src/library.dart
+++ b/source_gen/lib/src/library.dart
@@ -37,8 +37,10 @@
   Iterable<Element> get allElements => [element, ...element.topLevelElements];
 
   /// All of the declarations in this library annotated with [checker].
-  Iterable<AnnotatedElement> annotatedWith(TypeChecker checker,
-      {bool throwOnUnresolved = true}) sync* {
+  Iterable<AnnotatedElement> annotatedWith(
+    TypeChecker checker, {
+    bool throwOnUnresolved = true,
+  }) sync* {
     for (final element in allElements) {
       final annotation = checker.firstAnnotationOf(
         element,
@@ -51,11 +53,15 @@
   }
 
   /// All of the declarations in this library annotated with exactly [checker].
-  Iterable<AnnotatedElement> annotatedWithExact(TypeChecker checker,
-      {bool throwOnUnresolved = true}) sync* {
+  Iterable<AnnotatedElement> annotatedWithExact(
+    TypeChecker checker, {
+    bool throwOnUnresolved = true,
+  }) sync* {
     for (final element in allElements) {
-      final annotation = checker.firstAnnotationOfExact(element,
-          throwOnUnresolved: throwOnUnresolved);
+      final annotation = checker.firstAnnotationOfExact(
+        element,
+        throwOnUnresolved: throwOnUnresolved,
+      );
       if (annotation != null) {
         yield AnnotatedElement(ConstantReader(annotation), element);
       }
@@ -119,10 +125,12 @@
           // a valid import URL in Dart source code.
           return Uri(path: to.pathSegments.last);
         }
-        final relative = p.toUri(p.relative(
-          to.toString(),
-          from: from.toString(),
-        ));
+        final relative = p.toUri(
+          p.relative(
+            to.toString(),
+            from: from.toString(),
+          ),
+        );
         // We now have a URL like "../b.dart", but we just want "b.dart".
         return relative.replace(
           pathSegments: relative.pathSegments.skip(1),
@@ -151,8 +159,8 @@
   }
 
   /// All of the elements representing classes in this library.
-  // ignore: deprecated_member_use
-  Iterable<ClassElement> get classes => element.units.expand((cu) => cu.types);
+  Iterable<ClassElement> get classes =>
+      element.units.expand((cu) => cu.classes);
 
   /// All of the elements representing enums in this library.
   Iterable<ClassElement> get enums => element.units.expand((cu) => cu.enums);
diff --git a/source_gen/lib/src/output_helpers.dart b/source_gen/lib/src/output_helpers.dart
index e9106ac..2e028b4 100644
--- a/source_gen/lib/src/output_helpers.dart
+++ b/source_gen/lib/src/output_helpers.dart
@@ -33,5 +33,6 @@
 }
 
 ArgumentError _argError(Object value) => ArgumentError(
-    'Must be a String or be an Iterable/Stream containing String values. '
-    'Found `${Error.safeToString(value)}` (${value.runtimeType}).');
+      'Must be a String or be an Iterable/Stream containing String values. '
+      'Found `${Error.safeToString(value)}` (${value.runtimeType}).',
+    );
diff --git a/source_gen/lib/src/type_checker.dart b/source_gen/lib/src/type_checker.dart
index ae60e12..347b5a7 100644
--- a/source_gen/lib/src/type_checker.dart
+++ b/source_gen/lib/src/type_checker.dart
@@ -316,7 +316,8 @@
         metadata = node.metadata;
       } else {
         throw StateError(
-            'Unhandled Annotated AST node type: ${node.runtimeType}');
+          'Unhandled Annotated AST node type: ${node.runtimeType}',
+        );
       }
       final annotation = metadata[annotationIndex];
       final start = annotation.offset;
diff --git a/source_gen/lib/src/utils.dart b/source_gen/lib/src/utils.dart
index ecd0578..c8f2d46 100644
--- a/source_gen/lib/src/utils.dart
+++ b/source_gen/lib/src/utils.dart
@@ -72,7 +72,8 @@
 ///
 /// For example, will return `test_lib.g.dart` for `test_lib.dart`.
 String computePartUrl(AssetId input, AssetId output) => p.url.joinAll(
-    p.url.split(p.url.relative(output.path, from: input.path)).skip(1));
+      p.url.split(p.url.relative(output.path, from: input.path)).skip(1),
+    );
 
 /// Returns a URL representing [element].
 String urlOfElement(Element element) => element.kind == ElementKind.DYNAMIC
@@ -108,7 +109,9 @@
 Uri fileToAssetUrl(Uri url) {
   if (!p.isWithin(p.url.current, url.path)) return url;
   return Uri(
-      scheme: 'asset', path: p.join(rootPackageName, p.relative(url.path)));
+    scheme: 'asset',
+    path: p.join(rootPackageName, p.relative(url.path)),
+  );
 }
 
 /// Returns a `package:` URL converted to a `asset:` URL.
@@ -142,10 +145,13 @@
 Uri assetToPackageUrl(Uri url) => url.scheme == 'asset' &&
         url.pathSegments.isNotEmpty &&
         url.pathSegments[1] == 'lib'
-    ? url.replace(scheme: 'package', pathSegments: [
-        url.pathSegments.first,
-        ...url.pathSegments.skip(2),
-      ])
+    ? url.replace(
+        scheme: 'package',
+        pathSegments: [
+          url.pathSegments.first,
+          ...url.pathSegments.skip(2),
+        ],
+      )
     : url;
 
 final String rootPackageName = () {
@@ -153,8 +159,9 @@
       (loadYaml(File('pubspec.yaml').readAsStringSync()) as Map)['name'];
   if (name is! String) {
     throw StateError(
-        'Your pubspec.yaml file is missing a `name` field or it isn\'t '
-        'a String.');
+      'Your pubspec.yaml file is missing a `name` field or it isn\'t '
+      'a String.',
+    );
   }
   return name;
 }();
@@ -165,14 +172,16 @@
 /// Modifies [optionsMap] by removing the `build_extensions` key from it, if
 /// present.
 Map<String, List<String>> validatedBuildExtensionsFrom(
-    Map<String, dynamic>? optionsMap,
-    Map<String, List<String>> defaultExtensions) {
+  Map<String, dynamic>? optionsMap,
+  Map<String, List<String>> defaultExtensions,
+) {
   final extensionsOption = optionsMap?.remove('build_extensions');
   if (extensionsOption == null) return defaultExtensions;
 
   if (extensionsOption is! Map) {
     throw ArgumentError(
-        'Configured build_extensions should be a map from inputs to outputs.');
+      'Configured build_extensions should be a map from inputs to outputs.',
+    );
   }
 
   final result = <String, List<String>>{};
@@ -180,14 +189,18 @@
   for (final entry in extensionsOption.entries) {
     final input = entry.key;
     if (input is! String || !input.endsWith('.dart')) {
-      throw ArgumentError('Invalid key in build_extensions option: `$input` '
-          'should be a string ending with `.dart`');
+      throw ArgumentError(
+        'Invalid key in build_extensions option: `$input` '
+        'should be a string ending with `.dart`',
+      );
     }
 
     final output = entry.value;
     if (output is! String || !output.endsWith('.dart')) {
-      throw ArgumentError('Invalid output extension `$output`. It should be a '
-          'string ending with `.dart`');
+      throw ArgumentError(
+        'Invalid output extension `$output`. It should be a '
+        'string ending with `.dart`',
+      );
     }
 
     result[input] = [output];
diff --git a/source_gen/mono_pkg.yaml b/source_gen/mono_pkg.yaml
index 1d4af6a..d3c08f5 100644
--- a/source_gen/mono_pkg.yaml
+++ b/source_gen/mono_pkg.yaml
@@ -1,6 +1,6 @@
 # See https://github.com/google/mono_repo.dart for details
 sdk:
-- 2.12.0
+- 2.12.3
 - dev
 
 os:
@@ -15,7 +15,7 @@
     sdk: dev
   - group:
     - analyze
-    sdk: 2.12.0
+    sdk: 2.12.3
 - unit_test:
   - test
 
diff --git a/source_gen/pubspec.yaml b/source_gen/pubspec.yaml
index 1db0e29..3b45a62 100644
--- a/source_gen/pubspec.yaml
+++ b/source_gen/pubspec.yaml
@@ -1,5 +1,5 @@
 name: source_gen
-version: 1.2.1
+version: 1.2.2
 description: >-
   Source code generation builders and utilities for the Dart build system
 repository: https://github.com/dart-lang/source_gen
@@ -8,7 +8,7 @@
   sdk: ">=2.12.0 <3.0.0"
 
 dependencies:
-  analyzer: '>=2.1.0 <4.0.0'
+  analyzer: '>=2.1.0 <5.0.0'
   async: ^2.5.0
   build: ^2.1.0
   dart_style: ^2.0.0