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

Side by Side Diff: pkg/compiler/lib/src/tree/prettyprint.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/tree/nodes.dart ('k') | pkg/compiler/lib/src/tree/unparser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import '../tokens/token.dart' show BeginGroupToken, Token; 5 import '../tokens/token.dart' show BeginGroupToken, Token;
6 import '../util/util.dart'; 6 import '../util/util.dart';
7 import 'nodes.dart'; 7 import 'nodes.dart';
8 8
9 /** 9 /**
10 * Pretty-prints Node tree in XML-like format. 10 * Pretty-prints Node tree in XML-like format.
(...skipping 29 matching lines...) Expand all
40 node.visitChildren(this); 40 node.visitChildren(this);
41 closeNode(); 41 closeNode();
42 } 42 }
43 43
44 visitAssert(Assert node) { 44 visitAssert(Assert node) {
45 visitNodeWithChildren(node, "Assert"); 45 visitNodeWithChildren(node, "Assert");
46 } 46 }
47 47
48 visitAsyncModifier(AsyncModifier node) { 48 visitAsyncModifier(AsyncModifier node) {
49 openAndCloseNode(node, "AsyncModifier", 49 openAndCloseNode(node, "AsyncModifier",
50 {'asyncToken': node.asyncToken, 50 {'asyncToken': node.asyncToken, 'starToken': node.starToken});
51 'starToken': node.starToken});
52 } 51 }
53 52
54 visitBlock(Block node) { 53 visitBlock(Block node) {
55 visitNodeWithChildren(node, "Block"); 54 visitNodeWithChildren(node, "Block");
56 } 55 }
57 56
58 visitBreakStatement(BreakStatement node) { 57 visitBreakStatement(BreakStatement node) {
59 visitNodeWithChildren(node, "BreakStatement"); 58 visitNodeWithChildren(node, "BreakStatement");
60 } 59 }
61 60
62 visitCascade(Cascade node) { 61 visitCascade(Cascade node) {
63 visitNodeWithChildren(node, "Cascade"); 62 visitNodeWithChildren(node, "Cascade");
64 } 63 }
65 64
66 visitCascadeReceiver(CascadeReceiver node) { 65 visitCascadeReceiver(CascadeReceiver node) {
67 visitNodeWithChildren(node, "CascadeReceiver"); 66 visitNodeWithChildren(node, "CascadeReceiver");
68 } 67 }
69 68
70 visitCaseMatch(CaseMatch node) { 69 visitCaseMatch(CaseMatch node) {
71 visitNodeWithChildren(node, "CaseMatch"); 70 visitNodeWithChildren(node, "CaseMatch");
72 } 71 }
73 72
74 visitCatchBlock(CatchBlock node) { 73 visitCatchBlock(CatchBlock node) {
75 visitNodeWithChildren(node, "CatchBlock"); 74 visitNodeWithChildren(node, "CatchBlock");
76 } 75 }
77 76
78 visitClassNode(ClassNode node) { 77 visitClassNode(ClassNode node) {
79 openNode(node, "ClassNode", { 78 openNode(node, "ClassNode",
80 "extendsKeyword" : tokenToStringOrNull(node.extendsKeyword) 79 {"extendsKeyword": tokenToStringOrNull(node.extendsKeyword)});
81 });
82 visitChildNode(node.name, "name"); 80 visitChildNode(node.name, "name");
83 visitChildNode(node.superclass, "superclass"); 81 visitChildNode(node.superclass, "superclass");
84 visitChildNode(node.interfaces, "interfaces"); 82 visitChildNode(node.interfaces, "interfaces");
85 visitChildNode(node.typeParameters, "typeParameters"); 83 visitChildNode(node.typeParameters, "typeParameters");
86 closeNode(); 84 closeNode();
87 } 85 }
88 86
89 visitConditional(Conditional node) { 87 visitConditional(Conditional node) {
90 visitNodeWithChildren(node, "Conditional"); 88 visitNodeWithChildren(node, "Conditional");
91 } 89 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 openNode(node, "ForIn"); 130 openNode(node, "ForIn");
133 node.visitChildren(this); 131 node.visitChildren(this);
134 closeNode(); 132 closeNode();
135 } 133 }
136 134
137 visitFunctionDeclaration(FunctionDeclaration node) { 135 visitFunctionDeclaration(FunctionDeclaration node) {
138 visitNodeWithChildren(node, "FunctionDeclaration"); 136 visitNodeWithChildren(node, "FunctionDeclaration");
139 } 137 }
140 138
141 visitFunctionExpression(FunctionExpression node) { 139 visitFunctionExpression(FunctionExpression node) {
142 openNode(node, "FunctionExpression", { 140 openNode(node, "FunctionExpression",
143 "getOrSet" : tokenToStringOrNull(node.getOrSet) 141 {"getOrSet": tokenToStringOrNull(node.getOrSet)});
144 });
145 visitChildNode(node.modifiers, "modifiers"); 142 visitChildNode(node.modifiers, "modifiers");
146 visitChildNode(node.returnType, "returnType"); 143 visitChildNode(node.returnType, "returnType");
147 visitChildNode(node.name, "name"); 144 visitChildNode(node.name, "name");
148 visitChildNode(node.parameters, "parameters"); 145 visitChildNode(node.parameters, "parameters");
149 visitChildNode(node.initializers, "initializers"); 146 visitChildNode(node.initializers, "initializers");
150 visitChildNode(node.body, "body"); 147 visitChildNode(node.body, "body");
151 closeNode(); 148 closeNode();
152 } 149 }
153 150
154 visitIdentifier(Identifier node) { 151 visitIdentifier(Identifier node) {
155 openAndCloseNode(node, "Identifier", {"token" : node.token}); 152 openAndCloseNode(node, "Identifier", {"token": node.token});
156 } 153 }
157 154
158 visitIf(If node) { 155 visitIf(If node) {
159 visitNodeWithChildren(node, "If"); 156 visitNodeWithChildren(node, "If");
160 } 157 }
161 158
162 visitLabel(Label node) { 159 visitLabel(Label node) {
163 visitNodeWithChildren(node, "Label"); 160 visitNodeWithChildren(node, "Label");
164 } 161 }
165 162
166 visitLabeledStatement(LabeledStatement node) { 163 visitLabeledStatement(LabeledStatement node) {
167 visitNodeWithChildren(node, "LabeledStatement"); 164 visitNodeWithChildren(node, "LabeledStatement");
168 } 165 }
169 166
170 // Custom. 167 // Custom.
171 printLiteral(Literal node, String type) { 168 printLiteral(Literal node, String type) {
172 openAndCloseNode(node, type, {"value" : node.value.toString()}); 169 openAndCloseNode(node, type, {"value": node.value.toString()});
173 } 170 }
174 171
175 visitLiteralBool(LiteralBool node) { 172 visitLiteralBool(LiteralBool node) {
176 printLiteral(node, "LiteralBool"); 173 printLiteral(node, "LiteralBool");
177 } 174 }
178 175
179 visitLiteralDouble(LiteralDouble node) { 176 visitLiteralDouble(LiteralDouble node) {
180 printLiteral(node, "LiteralDouble"); 177 printLiteral(node, "LiteralDouble");
181 } 178 }
182 179
183 visitLiteralInt(LiteralInt node) { 180 visitLiteralInt(LiteralInt node) {
184 printLiteral(node, "LiteralInt"); 181 printLiteral(node, "LiteralInt");
185 } 182 }
186 183
187 /** Returns token string value or [:null:] if token is [:null:]. */ 184 /** Returns token string value or [:null:] if token is [:null:]. */
188 tokenToStringOrNull(Token token) => token == null ? null : token.stringValue; 185 tokenToStringOrNull(Token token) => token == null ? null : token.stringValue;
189 186
190 visitLiteralList(LiteralList node) { 187 visitLiteralList(LiteralList node) {
191 openNode(node, "LiteralList", { 188 openNode(node, "LiteralList",
192 "constKeyword" : tokenToStringOrNull(node.constKeyword) 189 {"constKeyword": tokenToStringOrNull(node.constKeyword)});
193 });
194 visitChildNode(node.typeArguments, "typeArguments"); 190 visitChildNode(node.typeArguments, "typeArguments");
195 visitChildNode(node.elements, "elements"); 191 visitChildNode(node.elements, "elements");
196 closeNode(); 192 closeNode();
197 } 193 }
198 194
199 visitLiteralMap(LiteralMap node) { 195 visitLiteralMap(LiteralMap node) {
200 visitNodeWithChildren(node, "LiteralMap"); 196 visitNodeWithChildren(node, "LiteralMap");
201 } 197 }
202 198
203 visitLiteralMapEntry(LiteralMapEntry node) { 199 visitLiteralMapEntry(LiteralMapEntry node) {
204 visitNodeWithChildren(node, "LiteralMapEntry"); 200 visitNodeWithChildren(node, "LiteralMapEntry");
205 } 201 }
206 202
207 visitLiteralNull(LiteralNull node) { 203 visitLiteralNull(LiteralNull node) {
208 printLiteral(node, "LiteralNull"); 204 printLiteral(node, "LiteralNull");
209 } 205 }
210 206
211 visitLiteralString(LiteralString node) { 207 visitLiteralString(LiteralString node) {
212 openAndCloseNode(node, "LiteralString", 208 openAndCloseNode(node, "LiteralString", {"value": node.token});
213 {"value" : node.token});
214 } 209 }
215 210
216 visitMixinApplication(MixinApplication node) { 211 visitMixinApplication(MixinApplication node) {
217 visitNodeWithChildren(node, "MixinApplication"); 212 visitNodeWithChildren(node, "MixinApplication");
218 } 213 }
219 214
220 visitModifiers(Modifiers node) { 215 visitModifiers(Modifiers node) {
221 visitNodeWithChildren(node, "Modifiers"); 216 visitNodeWithChildren(node, "Modifiers");
222 } 217 }
223 218
224 visitNamedArgument(NamedArgument node) { 219 visitNamedArgument(NamedArgument node) {
225 visitNodeWithChildren(node, "NamedArgument"); 220 visitNodeWithChildren(node, "NamedArgument");
226 } 221 }
227 222
228 visitNamedMixinApplication(NamedMixinApplication node) { 223 visitNamedMixinApplication(NamedMixinApplication node) {
229 visitNodeWithChildren(node, "NamedMixinApplication"); 224 visitNodeWithChildren(node, "NamedMixinApplication");
230 } 225 }
231 226
232 visitNewExpression(NewExpression node) { 227 visitNewExpression(NewExpression node) {
233 visitNodeWithChildren(node, "NewExpression"); 228 visitNodeWithChildren(node, "NewExpression");
234 } 229 }
235 230
236 visitNodeList(NodeList node) { 231 visitNodeList(NodeList node) {
237 var params = { "delimiter" : node.delimiter }; 232 var params = {"delimiter": node.delimiter};
238 if (node.isEmpty) { 233 if (node.isEmpty) {
239 openAndCloseNode(node, "NodeList", params); 234 openAndCloseNode(node, "NodeList", params);
240 } else { 235 } else {
241 openNode(node, "NodeList", params); 236 openNode(node, "NodeList", params);
242 node.visitChildren(this); 237 node.visitChildren(this);
243 closeNode(); 238 closeNode();
244 } 239 }
245 } 240 }
246 241
247 visitOperator(Operator node) { 242 visitOperator(Operator node) {
248 openAndCloseNode(node, "Operator", {"value" : node.token}); 243 openAndCloseNode(node, "Operator", {"value": node.token});
249 } 244 }
250 245
251 visitParenthesizedExpression(ParenthesizedExpression node) { 246 visitParenthesizedExpression(ParenthesizedExpression node) {
252 visitNodeWithChildren(node, "ParenthesizedExpression"); 247 visitNodeWithChildren(node, "ParenthesizedExpression");
253 } 248 }
254 249
255 visitRedirectingFactoryBody(RedirectingFactoryBody node) { 250 visitRedirectingFactoryBody(RedirectingFactoryBody node) {
256 openNode(node, "RedirectingFactoryBody"); 251 openNode(node, "RedirectingFactoryBody");
257 visitChildNode(node.constructorReference, "constructorReference"); 252 visitChildNode(node.constructorReference, "constructorReference");
258 closeNode(); 253 closeNode();
(...skipping 21 matching lines...) Expand all
280 sb.write("<$fieldName>\n"); 275 sb.write("<$fieldName>\n");
281 pushTag(fieldName); 276 pushTag(fieldName);
282 node.accept(this); 277 node.accept(this);
283 popTag(); 278 popTag();
284 addCurrentIndent(); 279 addCurrentIndent();
285 sb.write("</$fieldName>\n"); 280 sb.write("</$fieldName>\n");
286 } 281 }
287 282
288 openSendNodeWithFields(Send node, String type) { 283 openSendNodeWithFields(Send node, String type) {
289 openNode(node, type, { 284 openNode(node, type, {
290 "isPrefix" : "${node.isPrefix}", 285 "isPrefix": "${node.isPrefix}",
291 "isPostfix" : "${node.isPostfix}", 286 "isPostfix": "${node.isPostfix}",
292 "isIndex" : "${node.isIndex}" 287 "isIndex": "${node.isIndex}"
293 }); 288 });
294 visitChildNode(node.receiver, "receiver"); 289 visitChildNode(node.receiver, "receiver");
295 visitChildNode(node.selector, "selector"); 290 visitChildNode(node.selector, "selector");
296 visitChildNode(node.argumentsNode, "argumentsNode"); 291 visitChildNode(node.argumentsNode, "argumentsNode");
297 } 292 }
298 293
299 visitSend(Send node) { 294 visitSend(Send node) {
300 openSendNodeWithFields(node, "Send"); 295 openSendNodeWithFields(node, "Send");
301 closeNode(); 296 closeNode();
302 } 297 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 visitChildNode(node.modifiers, "modifiers"); 364 visitChildNode(node.modifiers, "modifiers");
370 visitChildNode(node.definitions, "definitions"); 365 visitChildNode(node.definitions, "definitions");
371 closeNode(); 366 closeNode();
372 } 367 }
373 368
374 visitWhile(While node) { 369 visitWhile(While node) {
375 visitNodeWithChildren(node, "While"); 370 visitNodeWithChildren(node, "While");
376 } 371 }
377 372
378 visitMetadata(Metadata node) { 373 visitMetadata(Metadata node) {
379 openNode(node, "Metadata", { 374 openNode(node, "Metadata", {"token": node.token});
380 "token": node.token
381 });
382 visitChildNode(node.expression, "expression"); 375 visitChildNode(node.expression, "expression");
383 closeNode(); 376 closeNode();
384 } 377 }
385 378
386 visitCombinator(Combinator node) { 379 visitCombinator(Combinator node) {
387 openNode(node, "Combinator", {"isShow" : "${node.isShow}", 380 openNode(node, "Combinator",
388 "isHide" : "${node.isHide}"}); 381 {"isShow": "${node.isShow}", "isHide": "${node.isHide}"});
389 closeNode(); 382 closeNode();
390 } 383 }
391 384
392 visitExport(Export node) { 385 visitExport(Export node) {
393 openNode(node, "Export"); 386 openNode(node, "Export");
394 visitChildNode(node.uri, "uri"); 387 visitChildNode(node.uri, "uri");
395 if (node.conditionalUris != null) { 388 if (node.conditionalUris != null) {
396 visitChildNode(node.conditionalUris, "conditionalUris"); 389 visitChildNode(node.conditionalUris, "conditionalUris");
397 } 390 }
398 visitChildNode(node.combinators, "combinators"); 391 visitChildNode(node.combinators, "combinators");
399 closeNode(); 392 closeNode();
400 } 393 }
401 394
402 visitImport(Import node) { 395 visitImport(Import node) {
403 openNode(node, "Import", { 396 openNode(node, "Import", {"isDeferred": "${node.isDeferred}"});
404 "isDeferred" : "${node.isDeferred}"});
405 visitChildNode(node.uri, "uri"); 397 visitChildNode(node.uri, "uri");
406 if (node.conditionalUris != null) { 398 if (node.conditionalUris != null) {
407 visitChildNode(node.conditionalUris, "conditionalUris"); 399 visitChildNode(node.conditionalUris, "conditionalUris");
408 } 400 }
409 visitChildNode(node.combinators, "combinators"); 401 visitChildNode(node.combinators, "combinators");
410 if (node.prefix != null) { 402 if (node.prefix != null) {
411 visitChildNode(node.prefix, "prefix"); 403 visitChildNode(node.prefix, "prefix");
412 } 404 }
413 closeNode(); 405 closeNode();
414 } 406 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 464 }
473 465
474 visitGotoStatement(GotoStatement node) { 466 visitGotoStatement(GotoStatement node) {
475 unimplemented('visitNode', node: node); 467 unimplemented('visitNode', node: node);
476 } 468 }
477 469
478 unimplemented(String message, {Node node}) { 470 unimplemented(String message, {Node node}) {
479 throw message; 471 throw message;
480 } 472 }
481 } 473 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree/nodes.dart ('k') | pkg/compiler/lib/src/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698