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/token.dart' ;
8- import 'package:analyzer/dart/element/element .dart' ;
6+ import 'package:analyzer/dart/element/element2 .dart' ;
97import 'package:analyzer/dart/element/type.dart' ;
108import 'package:analyzer/error/listener.dart' ;
119import 'package:analyzer/src/dart/ast/ast.dart' ;
@@ -52,14 +50,14 @@ class SimpleIdentifierResolver with ScopeHelpers {
5250 /// @return the type that should be recorded for a node that resolved to the given accessor
5351 ///
5452 // TODO(scheglov): this is duplicate
55- DartType _getTypeOfProperty (PropertyAccessorElement accessor) {
53+ DartType _getTypeOfProperty (PropertyAccessorElement2 accessor) {
5654 FunctionType functionType = accessor.type;
57- if (accessor.isSetter ) {
55+ if (accessor is SetterElement ) {
5856 var parameterTypes = functionType.normalParameterTypes;
5957 if (parameterTypes.isNotEmpty) {
6058 return parameterTypes[0 ];
6159 }
62- var getter = accessor.variable2 ? .getter ;
60+ var getter = accessor.variable3 ? .getter2 ;
6361 if (getter != null ) {
6462 functionType = getter.type;
6563 return functionType.returnType;
@@ -135,8 +133,8 @@ class SimpleIdentifierResolver with ScopeHelpers {
135133 if (node.inDeclarationContext ()) {
136134 return null ;
137135 }
138- if (node.staticElement is LocalVariableElement ||
139- node.staticElement is ParameterElement ) {
136+ if (node.element is LocalVariableElement2 ||
137+ node.element is FormalParameterElement ) {
140138 return null ;
141139 }
142140 var parent = node.parent;
@@ -187,9 +185,9 @@ class SimpleIdentifierResolver with ScopeHelpers {
187185 return null ;
188186 }
189187
190- var element = hasRead ? result.readElement : result.writeElement ;
188+ var element = hasRead ? result.readElement2 : result.writeElement2 ;
191189
192- var enclosingClass = _resolver.enclosingClass ? . augmented .firstFragment ;
190+ var enclosingClass = _resolver.enclosingClass2 ;
193191 if (_isFactoryConstructorReturnType (node) &&
194192 ! identical (element, enclosingClass)) {
195193 errorReporter.atNode (
@@ -200,15 +198,17 @@ class SimpleIdentifierResolver with ScopeHelpers {
200198 ! identical (element, enclosingClass)) {
201199 // This error is now reported by the parser.
202200 element = null ;
203- } else if (element is PrefixElement && ! _isValidAsPrefix (node)) {
204- errorReporter.atNode (
205- node,
206- CompileTimeErrorCode .PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT ,
207- arguments: [element.name],
208- );
201+ } else if (element is PrefixElement2 && ! _isValidAsPrefix (node)) {
202+ if (element.name3 case var name? ) {
203+ errorReporter.atNode (
204+ node,
205+ CompileTimeErrorCode .PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT ,
206+ arguments: [name],
207+ );
208+ }
209209 } else if (element == null ) {
210210 // TODO(brianwilkerson): Recover from this error.
211- if (node.name == "await" && _resolver.enclosingFunction != null ) {
211+ if (node.name == "await" && _resolver.enclosingFunction2 != null ) {
212212 errorReporter.atNode (
213213 node,
214214 CompileTimeErrorCode .UNDEFINED_IDENTIFIER_AWAIT ,
@@ -222,7 +222,7 @@ class SimpleIdentifierResolver with ScopeHelpers {
222222 );
223223 }
224224 }
225- node.staticElement = element;
225+ node.element = element;
226226 return result;
227227 }
228228
@@ -233,52 +233,52 @@ class SimpleIdentifierResolver with ScopeHelpers {
233233 return ;
234234 }
235235
236- var element = node.staticElement ;
236+ var element = node.element ;
237237
238- if (element is ExtensionElement ) {
238+ if (element is ExtensionElement2 ) {
239239 _setExtensionIdentifierType (node);
240240 inferenceLogWriter? .recordExpressionWithNoType (node);
241241 return ;
242242 }
243243
244244 DartType staticType = InvalidTypeImpl .instance;
245- if (element is InterfaceElement ) {
245+ if (element is InterfaceElement2 ) {
246246 if (_isExpressionIdentifier (node)) {
247247 node.recordStaticType (_typeProvider.typeType, resolver: _resolver);
248248 } else {
249249 inferenceLogWriter? .recordExpressionWithNoType (node);
250250 }
251251 return ;
252- } else if (element is TypeAliasElement ) {
252+ } else if (element is TypeAliasElement2 ) {
253253 if (_isExpressionIdentifier (node) ||
254254 element.aliasedType is ! InterfaceType ) {
255255 node.recordStaticType (_typeProvider.typeType, resolver: _resolver);
256256 } else {
257257 inferenceLogWriter? .recordExpressionWithNoType (node);
258258 }
259259 return ;
260- } else if (element is MethodElement ) {
260+ } else if (element is MethodElement2 ) {
261261 staticType = element.type;
262- } else if (element is PropertyAccessorElement ) {
262+ } else if (element is PropertyAccessorElement2 ) {
263263 staticType = propertyResult? .getType ?? _getTypeOfProperty (element);
264- } else if (element is ExecutableElement ) {
264+ } else if (element is ExecutableElement2 ) {
265265 staticType = element.type;
266- } else if (element is TypeParameterElement ) {
266+ } else if (element is TypeParameterElement2 ) {
267267 staticType = _typeProvider.typeType;
268- } else if (element is VariableElement ) {
268+ } else if (element is VariableElement2 ) {
269269 staticType = _resolver.localVariableTypeProvider
270270 .getType (node, isRead: node.inGetterContext ());
271- } else if (element is PrefixElement ) {
271+ } else if (element is PrefixElement2 ) {
272272 var parent = node.parent;
273273 if (parent is PrefixedIdentifier && parent.prefix == node ||
274274 parent is MethodInvocation && parent.target == node) {
275275 inferenceLogWriter? .recordExpressionWithNoType (node);
276276 return ;
277277 }
278278 staticType = InvalidTypeImpl .instance;
279- } else if (element is DynamicElementImpl ) {
279+ } else if (element is DynamicElementImpl2 ) {
280280 staticType = _typeProvider.typeType;
281- } else if (element is NeverElementImpl ) {
281+ } else if (element is NeverElementImpl2 ) {
282282 staticType = _typeProvider.typeType;
283283 } else {
284284 staticType = InvalidTypeImpl .instance;
0 commit comments