DeCo. Switch linter/ and analyzer_plugin/ to ConstructorDeclaration.typeName

Not actual migration, uses null asserts.
Should be made safe as part of implementation in linter.

Bug: https://github.com/dart-lang/sdk/issues/61701
Bug: https://github.com/dart-lang/sdk/issues/62055
Change-Id: I08f709b9f9c74dbab1b41c4e12ed498135450531
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463465
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index 8a574a4..582b5ea 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -523,7 +523,8 @@
 
   @override
   void visitConstructorDeclaration(ConstructorDeclaration node) {
-    if (identical(entity, node.returnType)) {
+    // TODO(scheglov): support primary constructors
+    if (identical(entity, node.typeName!)) {
       optype.completionLocation = 'ConstructorDeclaration_returnType';
       optype.includeTypeNameSuggestions = true;
     } else if (node.initializers.contains(entity)) {
diff --git a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart
index 07d13a1..6fe7525 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart
@@ -338,11 +338,13 @@
     var nameToken = node.name;
     if (nameToken == null) {
       computer._addRegionForElement(
-        node.returnType,
+        // TODO(scheglov): support primary constructors
+        node.typeName!,
         node.declaredFragment?.element,
       );
     } else {
-      node.returnType.accept(this);
+      // TODO(scheglov): support primary constructors
+      node.typeName!.accept(this);
       computer._addRegionForFragment(nameToken, node.declaredFragment);
     }
 
diff --git a/pkg/linter/lib/src/ast.dart b/pkg/linter/lib/src/ast.dart
index 5b9180c..3101a62 100644
--- a/pkg/linter/lib/src/ast.dart
+++ b/pkg/linter/lib/src/ast.dart
@@ -53,7 +53,8 @@
     return node.name;
   }
   if (node is ConstructorDeclaration) {
-    return node.name ?? node.returnType;
+    // TODO(scheglov): support primary constructors
+    return node.name ?? node.typeName!;
   }
   if (node is EnumConstantDeclaration) {
     return node.name;
diff --git a/pkg/linter/lib/src/rules/deprecated_consistency.dart b/pkg/linter/lib/src/rules/deprecated_consistency.dart
index 624394b..e53565d 100644
--- a/pkg/linter/lib/src/rules/deprecated_consistency.dart
+++ b/pkg/linter/lib/src/rules/deprecated_consistency.dart
@@ -48,7 +48,8 @@
     if (constructorElement != null &&
         constructorElement.enclosingElement.hasDeprecated &&
         !constructorElement.hasDeprecated) {
-      var nodeToAnnotate = node.name ?? node.returnType;
+      // TODO(scheglov): support primary constructors
+      var nodeToAnnotate = node.name ?? node.typeName!;
       rule.reportAtOffset(
         nodeToAnnotate.offset,
         nodeToAnnotate.length,
diff --git a/pkg/linter/lib/src/rules/sort_constructors_first.dart b/pkg/linter/lib/src/rules/sort_constructors_first.dart
index ad6f046..1f96aed 100644
--- a/pkg/linter/lib/src/rules/sort_constructors_first.dart
+++ b/pkg/linter/lib/src/rules/sort_constructors_first.dart
@@ -44,7 +44,8 @@
     for (var member in members) {
       if (member is ConstructorDeclaration) {
         if (other) {
-          rule.reportAtNode(member.returnType);
+          // TODO(scheglov): support primary constructors
+          rule.reportAtNode(member.typeName);
         }
       } else {
         other = true;
diff --git a/pkg/linter/lib/src/rules/sort_unnamed_constructors_first.dart b/pkg/linter/lib/src/rules/sort_unnamed_constructors_first.dart
index 45d90696..fbd9b31 100644
--- a/pkg/linter/lib/src/rules/sort_unnamed_constructors_first.dart
+++ b/pkg/linter/lib/src/rules/sort_unnamed_constructors_first.dart
@@ -48,7 +48,8 @@
       if (member is ConstructorDeclaration) {
         if (member.name == null) {
           if (seenConstructor) {
-            rule.reportAtNode(member.returnType);
+            // TODO(scheglov): support primary constructors
+            rule.reportAtNode(member.typeName);
           }
         } else {
           seenConstructor = true;
diff --git a/pkg/linter/lib/src/rules/unreachable_from_main.dart b/pkg/linter/lib/src/rules/unreachable_from_main.dart
index 313c328..d65d62c 100644
--- a/pkg/linter/lib/src/rules/unreachable_from_main.dart
+++ b/pkg/linter/lib/src/rules/unreachable_from_main.dart
@@ -555,7 +555,8 @@
           var name = member.name;
           if (name == null) {
             rule.reportAtNode(
-              member.returnType,
+              // TODO(scheglov): support primary constructors
+              member.typeName,
               arguments: [member.nameForError],
             );
           } else {
@@ -708,7 +709,8 @@
         return self.namePart.typeName.lexeme;
       case ConstructorDeclaration():
         var name = self.name?.lexeme ?? 'new';
-        return '${self.returnType.name}.$name';
+        // TODO(scheglov): support primary constructors
+        return '${self.typeName!.name}.$name';
       case EnumConstantDeclaration():
         return self.name.lexeme;
       case EnumDeclaration():
diff --git a/pkg/linter/lib/src/rules/use_key_in_widget_constructors.dart b/pkg/linter/lib/src/rules/use_key_in_widget_constructors.dart
index af4f9fe..ec07208 100644
--- a/pkg/linter/lib/src/rules/use_key_in_widget_constructors.dart
+++ b/pkg/linter/lib/src/rules/use_key_in_widget_constructors.dart
@@ -83,7 +83,8 @@
           }
           return false;
         })) {
-      var errorNode = node.name ?? node.returnType;
+      // TODO(scheglov): support primary constructors
+      var errorNode = node.name ?? node.typeName!;
       rule.reportAtOffset(errorNode.offset, errorNode.length);
     }
     super.visitConstructorDeclaration(node);
diff --git a/pkg/linter/lib/src/rules/use_super_parameters.dart b/pkg/linter/lib/src/rules/use_super_parameters.dart
index 9a9f7fe..d3ccf89 100644
--- a/pkg/linter/lib/src/rules/use_super_parameters.dart
+++ b/pkg/linter/lib/src/rules/use_super_parameters.dart
@@ -255,7 +255,8 @@
 
   void _reportLint(ConstructorDeclaration node, List<String> identifiers) {
     if (identifiers.isEmpty) return;
-    var target = node.name ?? node.returnType;
+    // TODO(scheglov): support primary constructors
+    var target = node.name ?? node.typeName!;
     if (identifiers.length > 1) {
       var msg = identifiers.quotedAndCommaSeparatedWithAnd;
       rule.reportAtOffset(