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

Side by Side Diff: pkg/analyzer_experimental/lib/src/services/writer.dart

Issue 18487005: Initial indent fix and a few more tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | pkg/analyzer_experimental/test/services/formatter_test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library source_writer; 5 library source_writer;
6 6
7 7
8 class Line { 8 class Line {
9 9
10 final int lineLength; 10 final int lineLength;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class NewlineToken extends LineToken { 71 class NewlineToken extends LineToken {
72 72
73 NewlineToken(String value) : super(value); 73 NewlineToken(String value) : super(value);
74 } 74 }
75 75
76 76
77 77
78 class SourceWriter { 78 class SourceWriter {
79 79
80 final StringBuffer buffer = new StringBuffer(); 80 final StringBuffer buffer = new StringBuffer();
81 Line currentLine = new Line(); 81 Line currentLine;
82 82
83 final String lineSeparator; 83 final String lineSeparator;
84 int indentCount = 0; 84 int indentCount = 0;
85 85
86 SourceWriter({int initialIndent: 0, this.lineSeparator: '\n'}) : 86 SourceWriter({int initialIndent: 0, this.lineSeparator: '\n'}) :
Brian Wilkerson 2013/07/08 21:49:11 Just out of curiosity, why not SourceWriter({th
pquitslund 2013/07/08 21:56:38 I like that better. Thanks!
87 indentCount = initialIndent; 87 indentCount = initialIndent {
88 currentLine = new Line(indent: indentCount);
89 }
88 90
89 indent() { 91 indent() {
90 ++indentCount; 92 ++indentCount;
91 } 93 }
92 94
93 unindent() { 95 unindent() {
94 --indentCount; 96 --indentCount;
95 } 97 }
96 98
97 print(x) { 99 print(x) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 173
172 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n); 174 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n);
173 175
174 String repeat(String ch, int times) { 176 String repeat(String ch, int times) {
175 var sb = new StringBuffer(); 177 var sb = new StringBuffer();
176 for (var i = 0; i < times; ++i) { 178 for (var i = 0; i < times; ++i) {
177 sb.write(ch); 179 sb.write(ch);
178 } 180 }
179 return sb.toString(); 181 return sb.toString();
180 } 182 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_experimental/test/services/formatter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698