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' ;
86import 'package:analyzer/dart/ast/visitor.dart' ;
9- import 'package:analyzer/dart/element/element .dart' ;
7+ import 'package:analyzer/dart/element/element2 .dart' ;
108import 'package:analyzer/error/listener.dart' ;
119import 'package:analyzer/src/dart/element/inheritance_manager3.dart' ;
1210import 'package:analyzer/src/error/codes.dart' ;
@@ -18,42 +16,37 @@ class OverrideVerifier extends RecursiveAstVisitor<void> {
1816 /// The inheritance manager used to find overridden methods.
1917 final InheritanceManager3 _inheritance;
2018
21- /// The URI of the library being verified.
22- final Uri _libraryUri;
23-
2419 /// The error reporter used to report errors.
2520 final ErrorReporter _errorReporter;
2621
2722 /// The current class or mixin.
28- InterfaceElement ? _currentClass;
23+ InterfaceElement2 ? _currentClass;
2924
30- OverrideVerifier (
31- this ._inheritance, LibraryElement library, this ._errorReporter)
32- : _libraryUri = library.source.uri;
25+ OverrideVerifier (this ._inheritance, this ._errorReporter);
3326
3427 @override
3528 void visitClassDeclaration (ClassDeclaration node) {
36- _currentClass = node.declaredElement ;
29+ _currentClass = node.declaredFragment ? .element ;
3730 super .visitClassDeclaration (node);
3831 _currentClass = null ;
3932 }
4033
4134 @override
4235 void visitEnumDeclaration (EnumDeclaration node) {
43- _currentClass = node.declaredElement ;
36+ _currentClass = node.declaredFragment ? .element ;
4437 super .visitEnumDeclaration (node);
4538 _currentClass = null ;
4639 }
4740
4841 @override
4942 void visitFieldDeclaration (FieldDeclaration node) {
5043 for (VariableDeclaration field in node.fields.variables) {
51- var fieldElement = field.declaredElement as FieldElement ;
52- if (fieldElement.hasOverride) {
53- var getter = fieldElement.getter ;
44+ var fieldElement = field.declaredFragment ? .element as FieldElement2 ;
45+ if (fieldElement.metadata2. hasOverride) {
46+ var getter = fieldElement.getter2 ;
5447 if (getter != null && _isOverride (getter)) continue ;
5548
56- var setter = fieldElement.setter ;
49+ var setter = fieldElement.setter2 ;
5750 if (setter != null && _isOverride (setter)) continue ;
5851
5952 _errorReporter.atToken (
@@ -66,15 +59,15 @@ class OverrideVerifier extends RecursiveAstVisitor<void> {
6659
6760 @override
6861 void visitMethodDeclaration (MethodDeclaration node) {
69- var element = node.declaredElement ! ;
70- if (element.hasOverride && ! _isOverride (element)) {
71- if (element is MethodElement ) {
62+ var element = node.declaredFragment ! .element ;
63+ if (element.metadata2. hasOverride && ! _isOverride (element)) {
64+ if (element is MethodElement2 ) {
7265 _errorReporter.atToken (
7366 node.name,
7467 WarningCode .OVERRIDE_ON_NON_OVERRIDING_METHOD ,
7568 );
76- } else if (element is PropertyAccessorElement ) {
77- if (element.isGetter ) {
69+ } else if (element is PropertyAccessorElement2 ) {
70+ if (element is GetterElement ) {
7871 _errorReporter.atToken (
7972 node.name,
8073 WarningCode .OVERRIDE_ON_NON_OVERRIDING_GETTER ,
@@ -91,17 +84,17 @@ class OverrideVerifier extends RecursiveAstVisitor<void> {
9184
9285 @override
9386 void visitMixinDeclaration (MixinDeclaration node) {
94- _currentClass = node.declaredElement ;
87+ _currentClass = node.declaredFragment ? .element ;
9588 super .visitMixinDeclaration (node);
9689 _currentClass = null ;
9790 }
9891
9992 /// Return `true` if the [member] overrides a member from a superinterface.
100- bool _isOverride (ExecutableElement member) {
101- var currentClass = _currentClass? .augmented . firstFragment;
93+ bool _isOverride (ExecutableElement2 member) {
94+ var currentClass = _currentClass? .firstFragment;
10295 if (currentClass != null ) {
103- var name = Name (_libraryUri, member.name) ;
104- return _inheritance.getOverridden2 (currentClass, name) != null ;
96+ var name = Name . forElement ( member) ! ;
97+ return _inheritance.getOverridden4 (currentClass.element , name) != null ;
10598 } else {
10699 return false ;
107100 }
0 commit comments