55import 'package:analyzer/dart/analysis/features.dart' ;
66import 'package:analyzer/dart/ast/ast.dart' ;
77import 'package:analyzer/dart/ast/token.dart' ;
8- import 'package:analyzer/dart/element/element .dart' ;
8+ import 'package:analyzer/dart/element/element2 .dart' ;
99import 'package:analyzer/dart/element/type.dart' ;
1010import 'package:analyzer/src/dart/ast/extensions.dart' ;
1111import 'package:analyzer/src/dart/element/type.dart' ;
1212
13- /// Some [ConstructorElement ] s can be temporary marked as "const" to check
13+ /// Some [ConstructorElement2 ] s can be temporary marked as "const" to check
1414/// if doing this is valid.
1515final temporaryConstConstructorElements = Expando <bool >();
1616
@@ -39,8 +39,8 @@ bool isPotentiallyConstantTypeExpression(TypeAnnotation node) {
3939}
4040
4141bool _isConstantTypeName (Identifier name) {
42- var element = name.staticElement ;
43- if (element is InterfaceElement || element is TypeAliasElement ) {
42+ var element = name.element ;
43+ if (element is InterfaceElement2 || element is TypeAliasElement2 ) {
4444 if (name is PrefixedIdentifier ) {
4545 if (name.isDeferred) {
4646 return false ;
@@ -212,7 +212,7 @@ class _Collector {
212212 }
213213
214214 void _identifier (Identifier node) {
215- var element = node.staticElement ;
215+ var element = node.element ;
216216
217217 if (node is PrefixedIdentifier ) {
218218 if (node.isDeferred) {
@@ -223,17 +223,17 @@ class _Collector {
223223 collect (node.prefix);
224224 return ;
225225 }
226- if (element is MethodElement && element.isStatic) {
226+ if (element is MethodElement2 && element.isStatic) {
227227 if (! _isConstantTypeName (node.prefix)) {
228228 nodes.add (node);
229229 }
230230 return ;
231231 }
232232 }
233233
234- if (element is ParameterElement ) {
235- var enclosing = element.enclosingElement3 ;
236- if (enclosing is ConstructorElement &&
234+ if (element is FormalParameterElement ) {
235+ var enclosing = element.enclosingElement2 ;
236+ if (enclosing is ConstructorElement2 &&
237237 isConstConstructorElement (enclosing)) {
238238 if (node.thisOrAncestorOfType <ConstructorInitializer >() != null ) {
239239 return ;
@@ -243,14 +243,14 @@ class _Collector {
243243 return ;
244244 }
245245
246- if (element is VariableElement ) {
246+ if (element is VariableElement2 ) {
247247 if (! element.isConst) {
248248 nodes.add (node);
249249 }
250250 return ;
251251 }
252- if (element is PropertyAccessorElement && element.isGetter ) {
253- var variable = element.variable2 ;
252+ if (element is GetterElement ) {
253+ var variable = element.variable3 ;
254254 if (variable == null ) {
255255 return ;
256256 }
@@ -262,13 +262,13 @@ class _Collector {
262262 if (_isConstantTypeName (node)) {
263263 return ;
264264 }
265- if (element is FunctionElement ) {
265+ if (element is TopLevelFunctionElement ) {
266266 return ;
267267 }
268- if (element is MethodElement && element.isStatic) {
268+ if (element is MethodElement2 && element.isStatic) {
269269 return ;
270270 }
271- if (element is TypeParameterElement &&
271+ if (element is TypeParameterElement2 &&
272272 featureSet.isEnabled (Feature .constructor_tearoffs)) {
273273 return ;
274274 }
@@ -278,8 +278,8 @@ class _Collector {
278278 void _methodInvocation (MethodInvocation node) {
279279 var arguments = node.argumentList.arguments;
280280 if (arguments.length == 2 ) {
281- var element = node.methodName.staticElement ;
282- if (element is FunctionElement && element.isDartCoreIdentical) {
281+ var element = node.methodName.element ;
282+ if (element is TopLevelFunctionElement && element.isDartCoreIdentical) {
283283 collect (arguments[0 ]);
284284 collect (arguments[1 ]);
285285 return ;
@@ -304,9 +304,9 @@ class _Collector {
304304 return ;
305305 }
306306
307- var element = node.propertyName.staticElement ;
308- if (element is PropertyAccessorElement && element.isGetter ) {
309- var variable = element.variable2 ;
307+ var element = node.propertyName.element ;
308+ if (element is GetterElement ) {
309+ var variable = element.variable3 ;
310310 if (variable == null ) {
311311 return ;
312312 }
@@ -384,7 +384,7 @@ class _Collector {
384384 }
385385 }
386386
387- static bool isConstConstructorElement (ConstructorElement element) {
387+ static bool isConstConstructorElement (ConstructorElement2 element) {
388388 if (element.isConst) return true ;
389389 return temporaryConstConstructorElements[element] ?? false ;
390390 }
@@ -402,7 +402,7 @@ class _ConstantTypeChecker {
402402 }
403403 if (potentially &&
404404 node is NamedType &&
405- node.element is TypeParameterElement ) {
405+ node.element2 is TypeParameterElement2 ) {
406406 return true ;
407407 }
408408
@@ -467,8 +467,8 @@ class _ConstantTypeChecker {
467467
468468extension on NamedType {
469469 bool get isConstantNamedType {
470- var element = this .element ;
471- if (element is InterfaceElement || element is TypeAliasElement ) {
470+ var element2 = this .element2 ;
471+ if (element2 is InterfaceElement2 || element2 is TypeAliasElement2 ) {
472472 return ! isDeferred;
473473 }
474474 return false ;
0 commit comments