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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 visitForIn(ForIn node) { | 157 visitForIn(ForIn node) { |
158 visitNodeWithChildren(node, "ForIn"); | 158 visitNodeWithChildren(node, "ForIn"); |
159 } | 159 } |
160 | 160 |
161 visitFunctionDeclaration(FunctionDeclaration node) { | 161 visitFunctionDeclaration(FunctionDeclaration node) { |
162 visitNodeWithChildren(node, "FunctionDeclaration"); | 162 visitNodeWithChildren(node, "FunctionDeclaration"); |
163 } | 163 } |
164 | 164 |
165 visitFunctionExpression(FunctionExpression node) { | 165 visitFunctionExpression(FunctionExpression node) { |
166 visitNodeWithChildren(node, "FunctionExpression"); | 166 openNode("FunctionExpression", { |
| 167 "getOrSet" : tokenToStringOrNull(node.getOrSet) |
| 168 }); |
| 169 visitWithPrefix(node.modifiers, "modifiers:"); |
| 170 visitWithPrefix(node.returnType, "returnType:"); |
| 171 visitWithPrefix(node.name, "name:"); |
| 172 visitWithPrefix(node.parameters, "parameters:"); |
| 173 visitWithPrefix(node.initializers, "initializers:"); |
| 174 visitWithPrefix(node.body, "body:"); |
| 175 closeNode("FunctionExpression"); |
167 } | 176 } |
168 | 177 |
169 visitIdentifier(Identifier node) { | 178 visitIdentifier(Identifier node) { |
170 openAndCloseNode("Identifier", {"token" : node.token.slowToString()}); | 179 openAndCloseNode("Identifier", {"token" : node.token.slowToString()}); |
171 } | 180 } |
172 | 181 |
173 visitIf(If node) { | 182 visitIf(If node) { |
174 visitNodeWithChildren(node, "If"); | 183 visitNodeWithChildren(node, "If"); |
175 } | 184 } |
176 | 185 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 visitWithPrefix(Node node, String prefix) { | 289 visitWithPrefix(Node node, String prefix) { |
281 if (node === null) return; | 290 if (node === null) return; |
282 nextTypePrefix = prefix; | 291 nextTypePrefix = prefix; |
283 node.accept(this); | 292 node.accept(this); |
284 } | 293 } |
285 | 294 |
286 openSendNodeWithFields(Send node, String type) { | 295 openSendNodeWithFields(Send node, String type) { |
287 openNode(type, { | 296 openNode(type, { |
288 "isPrefix" : "${node.isPrefix}", | 297 "isPrefix" : "${node.isPrefix}", |
289 "isPostfix" : "${node.isPostfix}", | 298 "isPostfix" : "${node.isPostfix}", |
290 "isIndex" : "${node.isIndex}" | 299 "isIndex" : "${node.isIndex}", |
| 300 "beginToken" : tokenToStringOrNull(node.getBeginToken()), |
| 301 "endToken" : tokenToStringOrNull(node.getEndToken()) |
291 }); | 302 }); |
292 visitWithPrefix(node.receiver, "receiver:"); | 303 visitWithPrefix(node.receiver, "receiver:"); |
293 visitWithPrefix(node.selector, "selector:"); | 304 visitWithPrefix(node.selector, "selector:"); |
294 visitWithPrefix(node.argumentsNode, "argumentsNode:"); | 305 visitWithPrefix(node.argumentsNode, "argumentsNode:"); |
295 } | 306 } |
296 | 307 |
297 visitSend(Send node) { | 308 visitSend(Send node) { |
298 openSendNodeWithFields(node, "Send"); | 309 openSendNodeWithFields(node, "Send"); |
299 closeNode("Send"); | 310 closeNode("Send"); |
300 } | 311 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 visitWithPrefix(node.type, "type:"); | 364 visitWithPrefix(node.type, "type:"); |
354 visitWithPrefix(node.modifiers, "modifiers:"); | 365 visitWithPrefix(node.modifiers, "modifiers:"); |
355 visitWithPrefix(node.definitions, "definitions:"); | 366 visitWithPrefix(node.definitions, "definitions:"); |
356 closeNode("VariableDefinitions"); | 367 closeNode("VariableDefinitions"); |
357 } | 368 } |
358 | 369 |
359 visitWhile(While node) { | 370 visitWhile(While node) { |
360 visitNodeWithChildren(node, "While"); | 371 visitNodeWithChildren(node, "While"); |
361 } | 372 } |
362 } | 373 } |
OLD | NEW |