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

Side by Side Diff: utils/template/tree.dart

Issue 12473003: Remove deprecated StringBuffer.add, addAll and addCharCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * The base type for all nodes in a dart abstract syntax tree. 5 * The base type for all nodes in a dart abstract syntax tree.
6 */ 6 */
7 class ASTNode { 7 class ASTNode {
8 /** The source code this [ASTNode] represents. */ 8 /** The source code this [ASTNode] represents. */
9 SourceSpan span; 9 SourceSpan span;
10 10
(...skipping 23 matching lines...) Expand all
34 var o = new TreeOutput(); 34 var o = new TreeOutput();
35 node.visit(new TreePrinter(o)); 35 node.visit(new TreePrinter(o));
36 print(o.buf); 36 print(o.buf);
37 } 37 }
38 38
39 TreeOutput(): this.depth = 0, this.buf = new StringBuffer() { 39 TreeOutput(): this.depth = 0, this.buf = new StringBuffer() {
40 } 40 }
41 41
42 void write(String s) { 42 void write(String s) {
43 for (int i=0; i < depth; i++) { 43 for (int i=0; i < depth; i++) {
44 buf.add(' '); 44 buf.write(' ');
45 } 45 }
46 buf.add(s); 46 buf.write(s);
47 } 47 }
48 48
49 void writeln(String s) { 49 void writeln(String s) {
50 write(s); 50 buf.writeln(s);
51 buf.add('\n');
52 } 51 }
53 52
54 void heading(String name, span) { 53 void heading(String name, span) {
55 write(name); 54 write(name);
56 buf.add(' (${span.locationText})'); 55 buf.writeln(' (${span.locationText})');
57 buf.add('\n');
58 } 56 }
59 57
60 String toValue(value) { 58 String toValue(value) {
61 if (value == null) return 'null'; 59 if (value == null) return 'null';
62 else if (value is Identifier) return value.name; 60 else if (value is Identifier) return value.name;
63 else return value.toString(); 61 else return value.toString();
64 } 62 }
65 63
66 void writeNode(String label, ASTNode node) { 64 void writeNode(String label, ASTNode node) {
67 write(label + ': '); 65 write(label + ': ');
68 depth += 1; 66 depth += 1;
69 if (node != null) node.visit(printer); 67 if (node != null) node.visit(printer);
70 else writeln('null'); 68 else writeln('null');
71 depth -= 1; 69 depth -= 1;
72 } 70 }
73 71
74 void writeValue(String label, value) { 72 void writeValue(String label, value) {
75 var v = toValue(value); 73 var v = toValue(value);
76 writeln('${label}: ${v}'); 74 writeln('${label}: ${v}');
77 } 75 }
78 76
79 void writeList(String label, List list) { 77 void writeList(String label, List list) {
80 write(label + ': '); 78 write(label + ': ');
81 if (list == null) { 79 if (list == null) {
82 buf.add('null'); 80 buf.writeln('null');
83 buf.add('\n');
84 } else { 81 } else {
85 for (var item in list) { 82 for (var item in list) {
86 buf.add(item.toString()); 83 buf.write(item.toString());
87 buf.add(', '); 84 buf.write(', ');
88 } 85 }
89 buf.add('\n'); 86 buf.write('\n');
Anders Johnsen 2013/03/06 14:31:00 writeln('')?
floitsch 2013/03/08 13:18:39 Missed it before committing... Yes "writeln" would
90 } 87 }
91 } 88 }
92 89
93 void writeNodeList(String label, List list) { 90 void writeNodeList(String label, List list) {
94 writeln('${label} ['); 91 writeln('${label} [');
95 if (list != null) { 92 if (list != null) {
96 depth += 1; 93 depth += 1;
97 for (var node in list) { 94 for (var node in list) {
98 if (node != null) { 95 if (node != null) {
99 node.visit(printer); 96 node.visit(printer);
100 } else { 97 } else {
101 writeln('null'); 98 writeln('null');
102 } 99 }
103 } 100 }
104 depth -= 1; 101 depth -= 1;
105 writeln(']'); 102 writeln(']');
106 } 103 }
107 } 104 }
108 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698