From 7b989ce93ecbf6767b654ade6de8c1d465a7c0d8 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:30:07 -0700
Subject: [PATCH 1/8] Fix trivial NamedType.name deprecations

---
 .../ast_util/classish_declaration_test.dart   | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/test/vm_tests/builder/parsing/ast_util/classish_declaration_test.dart b/test/vm_tests/builder/parsing/ast_util/classish_declaration_test.dart
index 5ca27c3dd..5bfe6a424 100644
--- a/test/vm_tests/builder/parsing/ast_util/classish_declaration_test.dart
+++ b/test/vm_tests/builder/parsing/ast_util/classish_declaration_test.dart
@@ -65,7 +65,7 @@ main() {
 
             expect(parseAndGetSingleClassish('''
               abstract class Foo implements Bar, Baz {}
-            ''').interfaces.map((i) => i.name.name), ['Bar', 'Baz']);
+            ''').interfaces.map((i) => i.name2.name), ['Bar', 'Baz']);
           });
 
           test('withClause', () {
@@ -105,7 +105,7 @@ main() {
 
             expect(parseAndGetSingleClassish('''
               class Foo extends Bar {}
-            ''').superclass?.name.name, 'Bar');
+            ''').superclass?.name2.name, 'Bar');
           });
 
           test('mixins', () {
@@ -115,13 +115,13 @@ main() {
 
             expect(parseAndGetSingleClassish('''
               class Foo extends Object with Bar, Baz {}
-            ''').mixins.map((m) => m.name.name), ['Bar', 'Baz']);
+            ''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
           });
 
           test('allSuperTypes', () {
             expect(parseAndGetSingleClassish('''
               class Foo extends Bar with Baz implements Qux {}
-            ''').allSuperTypes.map((m) => m.name.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
+            ''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
           });
         });
       });
@@ -148,7 +148,7 @@ main() {
 
             expect(parseAndGetSingleClassish('''
               abstract class Foo = Object with Something implements Bar, Baz;
-            ''').interfaces.map((i) => i.name.name), ['Bar', 'Baz']);
+            ''').interfaces.map((i) => i.name2.name), ['Bar', 'Baz']);
           });
 
           test('withClause', () {
@@ -180,19 +180,19 @@ main() {
           test('superclass', () {
             expect(parseAndGetSingleClassish('''
               class Foo = Bar with Baz;
-            ''').superclass?.name.name, 'Bar');
+            ''').superclass?.name2.name, 'Bar');
           });
 
           test('mixins', () {
             expect(parseAndGetSingleClassish('''
               class Foo = Object with Bar, Baz;
-            ''').mixins.map((m) => m.name.name), ['Bar', 'Baz']);
+            ''').mixins.map((m) => m.name2.name), ['Bar', 'Baz']);
           });
 
           test('allSuperTypes', () {
             expect(parseAndGetSingleClassish('''
               class Foo = Bar with Baz implements Qux;
-            ''').allSuperTypes.map((m) => m.name.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
+            ''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz', 'Qux']));
           });
         });
       });
@@ -232,7 +232,7 @@ main() {
 
             expect(parseAndGetSingleClassish('''
               mixin Foo on Bar implements Baz {}
-            ''').interfaces.map((i) => i.name.name), unorderedEquals(['Bar', 'Baz']));
+            ''').interfaces.map((i) => i.name2.name), unorderedEquals(['Bar', 'Baz']));
           });
 
           test('withClause', () {
@@ -268,7 +268,7 @@ main() {
           test('allSuperTypes', () {
             expect(parseAndGetSingleClassish('''
               mixin Foo on Bar implements Baz {}
-            ''').allSuperTypes.map((m) => m.name.name), unorderedEquals(['Bar', 'Baz']));
+            ''').allSuperTypes.map((m) => m.name2.name), unorderedEquals(['Bar', 'Baz']));
           });
         });
       });

From 4b2150e15497a1dc5da0c2268bf57bb895537d6f Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:30:55 -0700
Subject: [PATCH 2/8] Fix NamedType.name deprecations that should include
 import prefix

---
 .../builder/codegen/typed_map_impl_generator.dart    |  2 +-
 lib/src/builder/parsing/ast_util.dart                | 12 +++++++++++-
 lib/src/builder/parsing/declarations.dart            |  4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/src/builder/codegen/typed_map_impl_generator.dart b/lib/src/builder/codegen/typed_map_impl_generator.dart
index 89c796f4b..e27968925 100644
--- a/lib/src/builder/codegen/typed_map_impl_generator.dart
+++ b/lib/src/builder/codegen/typed_map_impl_generator.dart
@@ -556,7 +556,7 @@ class _TypedMapImplGenerator extends TypedMapImplGenerator {
         for (var i = 0; i < mixins.length; i++) {
           final mixin = mixins[i];
           final typeArguments = mixin.typeArguments?.toSource() ?? '';
-          final names = TypedMapNames(mixin.name.name);
+          final names = TypedMapNames(mixin.nameWithPrefix);
           header.write('${names.consumerName}$typeArguments');
           header.write(',');
           // Add a space at the beginning of the line so that dartfmt indents it
diff --git a/lib/src/builder/parsing/ast_util.dart b/lib/src/builder/parsing/ast_util.dart
index d34409d49..2294bb273 100644
--- a/lib/src/builder/parsing/ast_util.dart
+++ b/lib/src/builder/parsing/ast_util.dart
@@ -69,7 +69,17 @@ extension TypeAnnotationNameHelper on TypeAnnotation {
 /// field of [Identifier]s.
 extension TypeNameHelper on NamedType {
   /// The type name without any namespace prefixes.
-  String get nameWithoutPrefix => name.nameWithoutPrefix;
+  String get nameWithoutPrefix => name2.lexeme;
+
+  /// The type name including the namespace prefix.
+  String get nameWithPrefix {
+    final prefix = importPrefix?.name.lexeme;
+    final name = name2.lexeme;
+    return [
+      if (prefix != null) prefix,
+      name,
+    ].join('.');
+  }
 }
 
 /// Utilities related to simplifying access to node identifier fields.
diff --git a/lib/src/builder/parsing/declarations.dart b/lib/src/builder/parsing/declarations.dart
index 1bdb384ae..a6c630a55 100644
--- a/lib/src/builder/parsing/declarations.dart
+++ b/lib/src/builder/parsing/declarations.dart
@@ -204,7 +204,7 @@ mixin _TypedMapMixinShorthandDeclaration {
         .toList();
 
     if (badConstraints != null && badConstraints.isNotEmpty) {
-      final badConstraintsString = badConstraints.map((c) => c.name.name).join(', ');
+      final badConstraintsString = badConstraints.map((c) => c.nameWithPrefix).join(', ');
 
       final suggestedImplName = mixin.name.name.endsWith('Mixin')
           ? mixin.name.name.replaceFirst(RegExp(r'Mixin$'), '')
@@ -229,7 +229,7 @@ extension on Union<BoilerplateProps, BoilerplatePropsMixin> {
   /// This is the safest way to retrieve that information because it takes
   /// into account the nature of the [Union] typing of `props`.
   List<String> get allPropsMixins => this.switchCase(
-        (a) => a.nodeHelper.mixins.map((name) => name.name.name).toList(),
+        (a) => a.nodeHelper.mixins.map((name) => name.nameWithPrefix).toList(),
         (b) => [b.name.name],
       );
 }

From 765ab9ce7996f887ace763970c064ae48da1f99f Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:32:18 -0700
Subject: [PATCH 3/8] Allow analyzer 6

---
 pubspec.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pubspec.yaml b/pubspec.yaml
index 0f3e4a77d..9cc175313 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -7,7 +7,7 @@ environment:
 
 dependencies:
   collection: ^1.15.0
-  analyzer: ^5.13.0
+  analyzer: '>=5.13.0 <7.0.0'
   build: ^2.0.0
   dart_style: ^2.0.0
   js: ^0.6.1+1

From ae4530fc831cc66293b14cb414184f2971a54aa4 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:34:17 -0700
Subject: [PATCH 4/8] Validate analyzer 6 in CI

---
 .github/workflows/dart_ci.yml | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml
index b0f10510a..8946d9376 100644
--- a/.github/workflows/dart_ci.yml
+++ b/.github/workflows/dart_ci.yml
@@ -131,9 +131,13 @@ jobs:
       matrix:
         sdk: [ 2.19.6, stable ]
         analyzer:
-          # We only have one version currently, but we'll leave this CI step in place
-          # for the next time we need to support multiple analyzer versions.
           - ^5.1.0
+          - ^6.0.0
+        exclude:
+          # Analyzer 6 only resolves in Dart 3
+          - sdk: 2.19.6
+            analyzer: ^6.0.0
+
     steps:
       - uses: actions/checkout@v4
       - id: setup-dart

From e1176848063b209e6736afafd68fdf445050de32 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:40:50 -0700
Subject: [PATCH 5/8] Update test to not assume type names are parsed as
 Identifiers

In analyzer 6, they are not
---
 test/vm_tests/builder/parsing/ast_util_test.dart | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/vm_tests/builder/parsing/ast_util_test.dart b/test/vm_tests/builder/parsing/ast_util_test.dart
index c08beefcd..e0c29cd14 100644
--- a/test/vm_tests/builder/parsing/ast_util_test.dart
+++ b/test/vm_tests/builder/parsing/ast_util_test.dart
@@ -160,8 +160,8 @@ main() {
           SomeName foo;
         ''')).nameWithoutPrefix, 'SomeName');
 
-        expect(NameHelper(parseAndGetFirstWithType('''
-          foo.SomeName foo;
+        expect(NameHelper(parseAndGetFirstWithType<PrefixedIdentifier>('''
+          example() => foo.SomeName;
         ''')).nameWithoutPrefix, 'SomeName');
       });
     });

From 9ad9a67e50f755820a29112edd115fc57aed6560 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Tue, 15 Oct 2024 20:42:16 -0700
Subject: [PATCH 6/8] Add test for new nameWithPrefix utility

---
 test/vm_tests/builder/parsing/ast_util_test.dart | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/vm_tests/builder/parsing/ast_util_test.dart b/test/vm_tests/builder/parsing/ast_util_test.dart
index e0c29cd14..6dd834d18 100644
--- a/test/vm_tests/builder/parsing/ast_util_test.dart
+++ b/test/vm_tests/builder/parsing/ast_util_test.dart
@@ -152,6 +152,16 @@ main() {
           foo.SomeTypeName foo;
         ''')).nameWithoutPrefix, 'SomeTypeName');
       });
+
+      test('nameWithPrefix', () {
+        expect(TypeNameHelper(parseAndGetSingleWithType('''
+          SomeTypeName foo;
+        ''')).nameWithPrefix, 'SomeTypeName');
+
+        expect(TypeNameHelper(parseAndGetSingleWithType('''
+          foo.SomeTypeName foo;
+        ''')).nameWithPrefix, 'foo.SomeTypeName');
+      });
     });
 
     group('NameHelper', () {

From d780ca6b1f12a2a9dd0bd7bfb769cdd76512d466 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Wed, 16 Oct 2024 09:03:11 -0700
Subject: [PATCH 7/8] Fix test setup for analyzer 6

---
 test/vm_tests/builder/parsing/ast_util_test.dart | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/vm_tests/builder/parsing/ast_util_test.dart b/test/vm_tests/builder/parsing/ast_util_test.dart
index 6dd834d18..39020d9e2 100644
--- a/test/vm_tests/builder/parsing/ast_util_test.dart
+++ b/test/vm_tests/builder/parsing/ast_util_test.dart
@@ -166,13 +166,14 @@ main() {
 
     group('NameHelper', () {
       test('nameWithoutPrefix', () {
-        expect(NameHelper(parseAndGetFirstWithType('''
-          SomeName foo;
-        ''')).nameWithoutPrefix, 'SomeName');
+        final identifier = parseAndGetSingleWithType<ExpressionFunctionBody>('''
+          example() => identifier;
+        ''').expression as Identifier;
+        expect(NameHelper(identifier).nameWithoutPrefix, 'identifier');
 
         expect(NameHelper(parseAndGetFirstWithType<PrefixedIdentifier>('''
-          example() => foo.SomeName;
-        ''')).nameWithoutPrefix, 'SomeName');
+          example() => foo.identifier;
+        ''')).nameWithoutPrefix, 'identifier');
       });
     });
 

From bf0fa9ca2e536981449e76c7ee258daee742b868 Mon Sep 17 00:00:00 2001
From: Greg Littlefield <greg.littlefield@workiva.com>
Date: Wed, 16 Oct 2024 15:54:59 -0700
Subject: [PATCH 8/8] Update matrix to match lower bound

---
 .github/workflows/dart_ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml
index 8946d9376..05393756c 100644
--- a/.github/workflows/dart_ci.yml
+++ b/.github/workflows/dart_ci.yml
@@ -131,7 +131,7 @@ jobs:
       matrix:
         sdk: [ 2.19.6, stable ]
         analyzer:
-          - ^5.1.0
+          - ^5.13.0 # This should match the lower bound
           - ^6.0.0
         exclude:
           # Analyzer 6 only resolves in Dart 3
