22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // ignore_for_file: analyzer_use_new_elements
6-
75import 'package:analyzer/dart/ast/ast.dart' ;
8- import 'package:analyzer/dart/element/element.dart' ;
96import 'package:analyzer/src/dart/element/element.dart' ;
107import 'package:analyzer/src/summary2/link.dart' ;
118
@@ -18,19 +15,18 @@ class SuperConstructorResolver {
1815
1916 void perform () {
2017 for (var builder in _linker.builders.values) {
21- for (var unitElement in builder.element.units) {
22- for (var classElement in unitElement.classes) {
23- for (var constructorElement in classElement.constructors) {
24- _constructor (classElement, constructorElement);
25- }
18+ for (var classElement in builder.element.classes) {
19+ for (var constructorElement in classElement.constructors2) {
20+ _constructor (classElement, constructorElement);
2621 }
2722 }
2823 }
2924 }
3025
31- void _constructor (ClassElement classElement, ConstructorElement element) {
32- element as ConstructorElementImpl ;
33-
26+ void _constructor (
27+ ClassElementImpl2 classElement,
28+ ConstructorElementImpl2 element,
29+ ) {
3430 // Constructors of mixin applications are already configured.
3531 if (classElement.isMixinApplication) {
3632 return ;
@@ -42,24 +38,26 @@ class SuperConstructorResolver {
4238 }
4339
4440 var invokesDefaultSuperConstructor = true ;
45- var node = _linker.getLinkingNode (element);
46- if (node is ConstructorDeclaration ) {
47- for (var initializer in node.initializers) {
48- if (initializer is RedirectingConstructorInvocation ) {
49- invokesDefaultSuperConstructor = false ;
50- } else if (initializer is SuperConstructorInvocation ) {
51- invokesDefaultSuperConstructor = false ;
52- var name = initializer.constructorName? .name ?? '' ;
53- element.superConstructor = classElement.supertype? .constructors
54- .where ((element) => element.name == name)
55- .firstOrNull;
41+ for (var fragment in element.fragments) {
42+ var node = _linker.getLinkingNode3 (fragment);
43+ if (node is ConstructorDeclaration ) {
44+ for (var initializer in node.initializers) {
45+ if (initializer is RedirectingConstructorInvocation ) {
46+ invokesDefaultSuperConstructor = false ;
47+ } else if (initializer is SuperConstructorInvocation ) {
48+ invokesDefaultSuperConstructor = false ;
49+ var name = initializer.constructorName? .name ?? 'new' ;
50+ element.superConstructor2 = classElement.supertype? .constructors2
51+ .where ((element) => element.name3 == name)
52+ .firstOrNull;
53+ }
5654 }
5755 }
5856 }
5957
6058 if (invokesDefaultSuperConstructor) {
61- element.superConstructor = classElement.supertype? .constructors
62- .where ((element) => element.name.isEmpty )
59+ element.superConstructor2 = classElement.supertype? .constructors2
60+ .where ((element) => element.name3 == 'new' )
6361 .firstOrNull;
6462 }
6563 }
0 commit comments