Skip to content

Commit 2015686

Browse files
pqCommit Queue
authored and
Commit Queue
committed
[element model] migrate avoid_catches_without_on_clauses
See: https://github.com/dart-lang/linter/issues/5099 Change-Id: I32c758c76df7e80c465efb13dacf3ebd4854e9a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387141 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 8448628 commit 2015686

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pkg/linter/lib/src/rules/avoid_catches_without_on_clauses.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:analyzer/dart/element/type.dart';
99

1010
import '../analyzer.dart';
@@ -32,22 +32,22 @@ class AvoidCatchesWithoutOnClauses extends LintRule {
3232
}
3333

3434
class _CaughtExceptionUseVisitor extends RecursiveAstVisitor<void> {
35-
final Element caughtException;
35+
final Element2 caughtException;
3636

3737
var exceptionWasUsed = false;
3838

3939
_CaughtExceptionUseVisitor(this.caughtException);
4040

4141
@override
4242
void visitSimpleIdentifier(SimpleIdentifier node) {
43-
if (node.staticElement == caughtException) {
43+
if (node.element == caughtException) {
4444
exceptionWasUsed = true;
4545
}
4646
}
4747
}
4848

4949
class _ValidUseVisitor extends RecursiveAstVisitor<void> {
50-
final Element caughtException;
50+
final Element2 caughtException;
5151

5252
bool hasValidUse = false;
5353

@@ -86,8 +86,8 @@ class _ValidUseVisitor extends RecursiveAstVisitor<void> {
8686
_checkUseInArgument(node.argumentList);
8787
} else if (node.methodName.name == 'reportError') {
8888
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 &&
9191
targetElement.name == 'FlutterError') {
9292
_checkUseInArgument(node.argumentList);
9393
}
@@ -136,7 +136,7 @@ class _Visitor extends SimpleAstVisitor<void> {
136136
@override
137137
void visitCatchClause(CatchClause node) {
138138
if (node.onKeyword != null) return;
139-
var caughtException = node.exceptionParameter?.declaredElement;
139+
var caughtException = node.exceptionParameter?.declaredElement2;
140140
if (caughtException == null) return;
141141

142142
var validUseVisitor = _ValidUseVisitor(caughtException);

0 commit comments

Comments
 (0)