|
4 | 4 |
|
5 | 5 | import 'package:analyzer/dart/ast/ast.dart';
|
6 | 6 | import 'package:analyzer/dart/ast/visitor.dart';
|
7 |
| -import 'package:analyzer/dart/element/element.dart'; |
| 7 | +import 'package:analyzer/dart/element/element2.dart'; |
8 | 8 | import 'package:analyzer/dart/element/type.dart';
|
9 | 9 |
|
10 | 10 | import '../analyzer.dart';
|
@@ -32,22 +32,22 @@ class AvoidCatchesWithoutOnClauses extends LintRule {
|
32 | 32 | }
|
33 | 33 |
|
34 | 34 | class _CaughtExceptionUseVisitor extends RecursiveAstVisitor<void> {
|
35 |
| - final Element caughtException; |
| 35 | + final Element2 caughtException; |
36 | 36 |
|
37 | 37 | var exceptionWasUsed = false;
|
38 | 38 |
|
39 | 39 | _CaughtExceptionUseVisitor(this.caughtException);
|
40 | 40 |
|
41 | 41 | @override
|
42 | 42 | void visitSimpleIdentifier(SimpleIdentifier node) {
|
43 |
| - if (node.staticElement == caughtException) { |
| 43 | + if (node.element == caughtException) { |
44 | 44 | exceptionWasUsed = true;
|
45 | 45 | }
|
46 | 46 | }
|
47 | 47 | }
|
48 | 48 |
|
49 | 49 | class _ValidUseVisitor extends RecursiveAstVisitor<void> {
|
50 |
| - final Element caughtException; |
| 50 | + final Element2 caughtException; |
51 | 51 |
|
52 | 52 | bool hasValidUse = false;
|
53 | 53 |
|
@@ -86,8 +86,8 @@ class _ValidUseVisitor extends RecursiveAstVisitor<void> {
|
86 | 86 | _checkUseInArgument(node.argumentList);
|
87 | 87 | } else if (node.methodName.name == 'reportError') {
|
88 | 88 | var target = node.realTarget;
|
89 |
| - var targetElement = target is Identifier ? target.staticElement : null; |
90 |
| - if (targetElement is ClassElement && |
| 89 | + var targetElement = target is Identifier ? target.element : null; |
| 90 | + if (targetElement is ClassElement2 && |
91 | 91 | targetElement.name == 'FlutterError') {
|
92 | 92 | _checkUseInArgument(node.argumentList);
|
93 | 93 | }
|
@@ -136,7 +136,7 @@ class _Visitor extends SimpleAstVisitor<void> {
|
136 | 136 | @override
|
137 | 137 | void visitCatchClause(CatchClause node) {
|
138 | 138 | if (node.onKeyword != null) return;
|
139 |
| - var caughtException = node.exceptionParameter?.declaredElement; |
| 139 | + var caughtException = node.exceptionParameter?.declaredElement2; |
140 | 140 | if (caughtException == null) return;
|
141 | 141 |
|
142 | 142 | var validUseVisitor = _ValidUseVisitor(caughtException);
|
|
0 commit comments