| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_ast; | 5 part of js_ast; |
| 6 | 6 |
| 7 abstract class NodeVisitor<T> { | 7 abstract class NodeVisitor<T> { |
| 8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
| 9 | 9 |
| 10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1127 |
| 1128 void visitChildren(NodeVisitor visitor) {} | 1128 void visitChildren(NodeVisitor visitor) {} |
| 1129 | 1129 |
| 1130 ArrayHole _clone() => new ArrayHole(); | 1130 ArrayHole _clone() => new ArrayHole(); |
| 1131 | 1131 |
| 1132 int get precedenceLevel => PRIMARY; | 1132 int get precedenceLevel => PRIMARY; |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 class ObjectInitializer extends Expression { | 1135 class ObjectInitializer extends Expression { |
| 1136 final List<Property> properties; | 1136 final List<Property> properties; |
| 1137 /** |
| 1138 * If set to true, forces a vertical layout when using the [Printer]. |
| 1139 * Otherwise, layout will be vertical if and only if any [properties] |
| 1140 * are [FunctionExpression]s. |
| 1141 */ |
| 1142 final bool _vertical; |
| 1143 bool get vertical { |
| 1144 return _vertical || properties.any((p) => p.value is FunctionExpression); |
| 1145 } |
| 1137 | 1146 |
| 1138 /** | 1147 /** |
| 1139 * Constructs a new object-initializer containing the given [properties]. | 1148 * Constructs a new object-initializer containing the given [properties]. |
| 1140 */ | 1149 */ |
| 1141 ObjectInitializer(this.properties); | 1150 ObjectInitializer(this.properties, {vertical: false}) : _vertical = vertical; |
| 1142 | 1151 |
| 1143 accept(NodeVisitor visitor) => visitor.visitObjectInitializer(this); | 1152 accept(NodeVisitor visitor) => visitor.visitObjectInitializer(this); |
| 1144 | 1153 |
| 1145 void visitChildren(NodeVisitor visitor) { | 1154 void visitChildren(NodeVisitor visitor) { |
| 1146 for (Property init in properties) init.accept(visitor); | 1155 for (Property init in properties) init.accept(visitor); |
| 1147 } | 1156 } |
| 1148 | 1157 |
| 1149 ObjectInitializer _clone() => new ObjectInitializer(properties); | 1158 ObjectInitializer _clone() => new ObjectInitializer(properties); |
| 1150 | 1159 |
| 1151 int get precedenceLevel => PRIMARY; | 1160 int get precedenceLevel => PRIMARY; |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 final Expression expression; | 1449 final Expression expression; |
| 1441 | 1450 |
| 1442 CommentExpression(this.comment, this.expression); | 1451 CommentExpression(this.comment, this.expression); |
| 1443 | 1452 |
| 1444 int get precedenceLevel => PRIMARY; | 1453 int get precedenceLevel => PRIMARY; |
| 1445 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); | 1454 accept(NodeVisitor visitor) => visitor.visitCommentExpression(this); |
| 1446 CommentExpression _clone() => new CommentExpression(comment, expression); | 1455 CommentExpression _clone() => new CommentExpression(comment, expression); |
| 1447 | 1456 |
| 1448 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); | 1457 void visitChildren(NodeVisitor visitor) => expression.accept(visitor); |
| 1449 } | 1458 } |
| OLD | NEW |