44
55import 'package:analyzer/dart/ast/ast.dart' ;
66import 'package:analyzer/dart/ast/visitor.dart' ;
7- import 'package:analyzer/dart/element/element .dart' ;
7+ import 'package:analyzer/dart/element/element2 .dart' ;
88import 'package:analyzer/dart/element/type.dart' ;
99import 'package:collection/collection.dart' ;
1010
@@ -52,7 +52,7 @@ class _Visitor extends SimpleAstVisitor<void> {
5252 // Don't lint augmentations.
5353 if (node.isAugmentation) return ;
5454
55- var declaredElement = node.declaredElement ;
55+ var declaredElement = node.declaredFragment ? .element ;
5656 if (declaredElement != null && ! declaredElement.isPrivate) {
5757 checkParams (node.parameters.parameters);
5858 }
@@ -63,8 +63,8 @@ class _Visitor extends SimpleAstVisitor<void> {
6363 // Don't lint augmentations.
6464 if (node.isAugmentation) return ;
6565
66- var declaredElement = node.declaredElement ;
67- if (declaredElement != null && ! declaredElement .isPrivate) {
66+ var element = node.element ;
67+ if (element != null && ! element .isPrivate) {
6868 checkParams (node.functionExpression.parameters? .parameters);
6969 }
7070 }
@@ -79,7 +79,7 @@ class _Visitor extends SimpleAstVisitor<void> {
7979 // Don't lint augmentations.
8080 if (node.isAugmentation) return ;
8181
82- var declaredElement = node.declaredElement ;
82+ var declaredElement = node.declaredFragment ? .element ;
8383 if (declaredElement != null &&
8484 ! node.isSetter &&
8585 ! declaredElement.isPrivate &&
@@ -90,21 +90,28 @@ class _Visitor extends SimpleAstVisitor<void> {
9090 }
9191 }
9292
93- bool _isOverridingMember (Element member) {
94- var classElement = member.thisOrAncestorOfType < ClassElement >();
93+ bool _isOverridingMember (Element2 member) {
94+ var classElement = member.thisOrAncestorOfType2 < ClassElement2 >();
9595 if (classElement == null ) return false ;
9696
97- var name = member.name ;
97+ var name = member.name3 ;
9898 if (name == null ) return false ;
9999
100- var libraryUri = classElement.library .source.uri;
100+ var libraryUri = classElement.library2.firstFragment .source.uri;
101101 return context.inheritanceManager
102- .getInherited (classElement.thisType, Name (libraryUri, name)) !=
102+ .getInherited3 (classElement.thisType, Name (libraryUri, name)) !=
103103 null ;
104104 }
105105
106106 static bool _isBoolean (FormalParameter node) {
107- var type = node.declaredElement ? .type;
107+ var type = node.declaredFragment ? .element .type;
108108 return ! node.isNamed && type is InterfaceType && type.isDartCoreBool;
109109 }
110110}
111+
112+ // TODO(pq): consider moving to `extensions.dart`
113+ extension on FunctionDeclaration {
114+ ExecutableElement2 ? get element =>
115+ // Check for a local function first.
116+ declaredElement2 ?? declaredFragment? .element;
117+ }
0 commit comments