| 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 /** | 5 /** |
| 6 * Pretty-prints Node tree in XML-like format. | 6 * Pretty-prints Node tree in XML-like format. |
| 7 * | 7 * |
| 8 * TODO(smok): Add main() to run from command-line to print out tree for given | 8 * TODO(smok): Add main() to run from command-line to print out tree for given |
| 9 * .dart file. | 9 * .dart file. |
| 10 */ | 10 */ |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 visitOperator(Operator node) { | 235 visitOperator(Operator node) { |
| 236 openAndCloseNode("Operator", {"value" : node.token.slowToString()}); | 236 openAndCloseNode("Operator", {"value" : node.token.slowToString()}); |
| 237 } | 237 } |
| 238 | 238 |
| 239 visitParenthesizedExpression(ParenthesizedExpression node) { | 239 visitParenthesizedExpression(ParenthesizedExpression node) { |
| 240 visitNodeWithChildren(node, "ParenthesizedExpression"); | 240 visitNodeWithChildren(node, "ParenthesizedExpression"); |
| 241 } | 241 } |
| 242 | 242 |
| 243 visitReturn(Return node) { | 243 visitReturn(Return node) { |
| 244 visitNodeWithChildren(node, "Return"); | 244 var beginToken = |
| 245 node.beginToken !== null ? node.beginToken.stringValue : "null"; |
| 246 var endToken = node.endToken !== null ? node.endToken.stringValue : "null"; |
| 247 openNode("Return", {"beginToken" : beginToken, "endToken" : endToken}); |
| 248 if (node.hasExpression) visitWithPrefix(node.expression, "expression:"); |
| 249 closeNode("Return"); |
| 245 } | 250 } |
| 246 | 251 |
| 247 visitScriptTag(ScriptTag node) { | 252 visitScriptTag(ScriptTag node) { |
| 248 visitNodeWithChildren(node, "ScriptTag"); | 253 visitNodeWithChildren(node, "ScriptTag"); |
| 249 } | 254 } |
| 250 | 255 |
| 251 /** Custom helper to visit given node and print its type with prefix. */ | 256 /** Custom helper to visit given node and print its type with prefix. */ |
| 252 visitWithPrefix(Node node, String prefix) { | 257 visitWithPrefix(Node node, String prefix) { |
| 253 nextTypePrefix = prefix; | 258 nextTypePrefix = prefix; |
| 254 node.accept(this); | 259 node.accept(this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 324 } |
| 320 | 325 |
| 321 visitVariableDefinitions(VariableDefinitions node) { | 326 visitVariableDefinitions(VariableDefinitions node) { |
| 322 visitNodeWithChildren(node, "VariableDefinitions"); | 327 visitNodeWithChildren(node, "VariableDefinitions"); |
| 323 } | 328 } |
| 324 | 329 |
| 325 visitWhile(While node) { | 330 visitWhile(While node) { |
| 326 visitNodeWithChildren(node, "While"); | 331 visitNodeWithChildren(node, "While"); |
| 327 } | 332 } |
| 328 } | 333 } |
| OLD | NEW |