Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1682)

Unified Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 2492633002: Create AST structure for asserts in constructor initializers (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/ast/utilities.dart
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 654772c5f6e6190509861ce57111b67e60adda48..e4e2008a10b701deb8c1a6bd49348310d161d9e2 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -143,6 +143,16 @@ class AstCloner implements AstVisitor<AstNode> {
cloneNode(node.type));
@override
+ AstNode visitAssertInitializer(AssertInitializer node) =>
+ new AssertInitializer(
+ cloneToken(node.assertKeyword),
+ cloneToken(node.leftParenthesis),
+ cloneNode(node.condition),
+ cloneToken(node.comma),
+ cloneNode(node.message),
+ cloneToken(node.rightParenthesis));
+
+ @override
AstNode visitAssertStatement(AssertStatement node) => new AssertStatement(
cloneToken(node.assertKeyword),
cloneToken(node.leftParenthesis),
@@ -1116,6 +1126,17 @@ class AstComparator implements AstVisitor<bool> {
}
@override
+ bool visitAssertInitializer(AssertInitializer node) {
+ AssertStatement other = _other as AssertStatement;
+ return isEqualTokens(node.assertKeyword, other.assertKeyword) &&
+ isEqualTokens(node.leftParenthesis, other.leftParenthesis) &&
+ isEqualNodes(node.condition, other.condition) &&
+ isEqualTokens(node.comma, other.comma) &&
+ isEqualNodes(node.message, other.message) &&
+ isEqualTokens(node.rightParenthesis, other.rightParenthesis);
+ }
+
+ @override
bool visitAssertStatement(AssertStatement node) {
AssertStatement other = _other as AssertStatement;
return isEqualTokens(node.assertKeyword, other.assertKeyword) &&
@@ -2763,6 +2784,16 @@ class IncrementalAstCloner implements AstVisitor<AstNode> {
}
@override
+ AstNode visitAssertInitializer(AssertInitializer node) =>
+ new AssertInitializer(
+ _mapToken(node.assertKeyword),
+ _mapToken(node.leftParenthesis),
+ _cloneNode(node.condition),
+ _mapToken(node.comma),
+ _cloneNode(node.message),
+ _mapToken(node.rightParenthesis));
+
+ @override
AstNode visitAssertStatement(AssertStatement node) => new AssertStatement(
_mapToken(node.assertKeyword),
_mapToken(node.leftParenthesis),
@@ -4043,6 +4074,19 @@ class NodeReplacer implements AstVisitor<bool> {
}
@override
+ bool visitAssertInitializer(AssertInitializer node) {
+ if (identical(node.condition, _oldNode)) {
+ node.condition = _newNode as Expression;
+ return true;
+ }
+ if (identical(node.message, _oldNode)) {
+ node.message = _newNode as Expression;
+ return true;
+ }
+ return visitNode(node);
+ }
+
+ @override
bool visitAssertStatement(AssertStatement node) {
if (identical(node.condition, _oldNode)) {
node.condition = _newNode as Expression;
@@ -5221,6 +5265,18 @@ class ResolutionCopier implements AstVisitor<bool> {
}
@override
+ bool visitAssertInitializer(AssertInitializer node) {
+ AssertInitializer toNode = this._toNode as AssertInitializer;
+ return _and(
+ _isEqualTokens(node.assertKeyword, toNode.assertKeyword),
+ _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
+ _isEqualNodes(node.condition, toNode.condition),
+ _isEqualTokens(node.comma, toNode.comma),
+ _isEqualNodes(node.message, toNode.message),
+ _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
+ }
+
+ @override
bool visitAssertStatement(AssertStatement node) {
AssertStatement toNode = this._toNode as AssertStatement;
return _and(
@@ -6817,6 +6873,18 @@ class ToSourceVisitor implements AstVisitor<Object> {
}
@override
+ bool visitAssertInitializer(AssertInitializer node) {
+ _writer.print("assert (");
+ _visitNode(node.condition);
+ if (node.message != null) {
+ _writer.print(', ');
+ _visitNode(node.message);
+ }
+ _writer.print(")");
+ return null;
+ }
+
+ @override
Object visitAssertStatement(AssertStatement node) {
_writer.print("assert (");
_visitNode(node.condition);
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698