-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-182. fixed throw expression (#183)
* issue-182. fixed throw expression * issue-182. added new test case * issue-182. added changelog --------- Co-authored-by: shaark <[email protected]>
- Loading branch information
1 parent
9dcdb64
commit 956d433
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
lib/src/lints/prefer_early_return/visitors/throw_expression_visitor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:analyzer/dart/ast/ast.dart'; | ||
import 'package:analyzer/dart/ast/visitor.dart'; | ||
|
||
/// The AST visitor that will collect every Return statement | ||
class ThrowExpressionVisitor extends RecursiveAstVisitor<void> { | ||
final _nodes = <ThrowExpression>[]; | ||
|
||
/// All unnecessary return statements | ||
Iterable<ThrowExpression> get nodes => _nodes; | ||
|
||
@override | ||
void visitThrowExpression(ThrowExpression node) { | ||
super.visitThrowExpression(node); | ||
_nodes.add(node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters