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-
75/// The models used to represent Dart types, all subclasses of [ElementType] .
86///
97/// The only entrypoint for constructing these classes is [ElementType.for_] .
108library ;
119
12- import 'package:analyzer/dart/element/element.dart' ;
1310import 'package:analyzer/dart/element/element2.dart' ;
1411import 'package:analyzer/dart/element/nullability_suffix.dart' ;
1512import 'package:analyzer/dart/element/type.dart' ;
@@ -37,13 +34,13 @@ abstract class ElementType with CommentReferable, Nameable {
3734 factory ElementType .for_ (
3835 DartType type, Library library, PackageGraph packageGraph) {
3936 runtimeStats.incrementAccumulator ('elementTypeInstantiation' );
40- var fElement = type.documentableElement ;
37+ var fElement = type.documentableElement2 ;
4138 if (fElement == null ||
4239 fElement.kind == ElementKind .DYNAMIC ||
4340 fElement.kind == ElementKind .NEVER ) {
4441 return UndefinedElementType ._from (type, library, packageGraph);
4542 }
46- var modelElement = packageGraph.getModelForElement (fElement);
43+ var modelElement = packageGraph.getModelForElement2 (fElement);
4744 return DefinedElementType ._from (type, modelElement, library, packageGraph);
4845 }
4946
@@ -70,7 +67,7 @@ abstract class ElementType with CommentReferable, Nameable {
7067 String toString () => '$type ' ;
7168}
7269
73- /// An [ElementType] that isn't pinned to an [Element ] (or one that is, but
70+ /// An [ElementType] that isn't pinned to an [Element2 ] (or one that is, but
7471/// whose element is irrelevant).
7572class UndefinedElementType extends ElementType {
7673 UndefinedElementType ._(super .type, super .library, super .packageGraph)
@@ -105,9 +102,9 @@ class UndefinedElementType extends ElementType {
105102 // We can not simply throw here because not all SDK libraries resolve
106103 // all types.
107104 if (type is InvalidType ) return 'dynamic' ;
108- assert (const {'Never' }.contains (type.documentableElement ? .name ),
105+ assert (const {'Never' }.contains (type.documentableElement2 ? .name3 ),
109106 'Unrecognized type for UndefinedElementType: $type ' );
110- return type.documentableElement ! .name ! ;
107+ return type.documentableElement2 ! .name3 ! ;
111108 }
112109
113110 @override
@@ -132,15 +129,15 @@ class UndefinedElementType extends ElementType {
132129 Iterable <CommentReferable >? get referenceGrandparentOverrides => null ;
133130}
134131
135- /// A [FunctionType] that does not have an underpinning [Element ] .
132+ /// A [FunctionType] that does not have an underpinning [Element2 ] .
136133class FunctionTypeElementType extends UndefinedElementType
137134 with Rendered , Callable {
138135 FunctionTypeElementType ._(
139136 FunctionType super .type, super .library, super .packageGraph)
140137 : super ._();
141138
142- List <TypeParameter > get typeFormals => type.typeFormals
143- .map ((p) => getModelFor (p, library) as TypeParameter )
139+ List <TypeParameter > get typeFormals => type.typeParameters
140+ .map ((p) => getModelFor2 (p, library) as TypeParameter )
144141 .toList (growable: false );
145142
146143 @override
@@ -208,18 +205,16 @@ class ParameterizedElementType extends DefinedElementType with Rendered {
208205
209206/// An [ElementType] whose underlying type was referred to by a type alias.
210207mixin Aliased implements ElementType {
211- Element get typeAliasElement => type.alias! .element;
212-
213208 Element2 get typeAliasElement2 => type.alias! .element2;
214209
215210 @override
216- String get name => typeAliasElement.name ! ;
211+ String get name => typeAliasElement2.name3 ! ;
217212
218213 @override
219214 bool get isTypedef => true ;
220215
221216 late final ModelElement aliasElement =
222- ModelElement .forElement (typeAliasElement , packageGraph);
217+ ModelElement .forElement2 (typeAliasElement2 , packageGraph);
223218
224219 late final List <ElementType > aliasArguments = type.alias! .typeArguments
225220 .map ((f) => getTypeFor (f, library))
@@ -258,7 +253,7 @@ class TypeParameterElementType extends DefinedElementType {
258253 String get nameWithGenericsPlain => '$name $nullabilitySuffix ' ;
259254}
260255
261- /// An [ElementType] associated with an [Element ] .
256+ /// An [ElementType] associated with an [Element2 ] .
262257abstract class DefinedElementType extends ElementType {
263258 final ModelElement modelElement;
264259
@@ -268,7 +263,7 @@ abstract class DefinedElementType extends ElementType {
268263
269264 factory DefinedElementType ._from (DartType type, ModelElement modelElement,
270265 Library library, PackageGraph packageGraph) {
271- if (type is ! TypeAliasElement && type.alias != null ) {
266+ if (type is ! TypeAliasElement2 && type.alias != null ) {
272267 // Here, `alias.element` signals that this is a type referring to an
273268 // alias. (`TypeAliasElement.alias.element` has different implications.
274269 // In that case it is an actual type alias of some kind (generic or
@@ -293,7 +288,7 @@ abstract class DefinedElementType extends ElementType {
293288 }
294289
295290 @override
296- String get name => type.documentableElement ! .name ! ;
291+ String get name => type.documentableElement2 ! .name3 ! ;
297292
298293 @override
299294 String get fullyQualifiedName => modelElement.fullyQualifiedName;
@@ -327,14 +322,14 @@ abstract class DefinedElementType extends ElementType {
327322 @internal
328323 @override
329324 CommentReferable get definingCommentReferable =>
330- ModelElement .forElement (modelElement.element , packageGraph);
325+ ModelElement .forElement2 (modelElement.element2 , packageGraph);
331326}
332327
333328/// Any callable [ElementType] will mix-in this class, whether anonymous or not,
334329/// unless it is an alias reference.
335330mixin Callable on ElementType {
336- List <Parameter > get parameters => type.parameters
337- .map ((p) => getModelFor (p, library) as Parameter )
331+ List <Parameter > get parameters => type.formalParameters
332+ .map ((p) => getModelFor2 (p, library) as Parameter )
338333 .toList (growable: false );
339334
340335 late final ElementType returnType = getTypeFor (type.returnType, library);
0 commit comments