| OLD | NEW |
| 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 | 8 |
| 9 class Line { | 9 class Line { |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 void addSpaces(int n, {breakWeight: DEFAULT_SPACE_WEIGHT}) { | 28 void addSpaces(int n, {breakWeight: DEFAULT_SPACE_WEIGHT}) { |
| 29 tokens.add(new SpaceToken(n, breakWeight: breakWeight)); | 29 tokens.add(new SpaceToken(n, breakWeight: breakWeight)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void addToken(LineToken token) { | 32 void addToken(LineToken token) { |
| 33 tokens.add(token); | 33 tokens.add(token); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void clear() { |
| 37 tokens.clear(); |
| 38 } |
| 39 |
| 36 bool isEmpty() => tokens.isEmpty; | 40 bool isEmpty() => tokens.isEmpty; |
| 37 | 41 |
| 38 bool isWhitespace() => tokens.every( | 42 bool isWhitespace() => tokens.every( |
| 39 (tok) => tok is SpaceToken || tok is TabToken); | 43 (tok) => tok is SpaceToken || tok is TabToken); |
| 40 | 44 |
| 41 void indent(int n) { | 45 void indent(int n) { |
| 42 tokens.insert(0, | 46 tokens.insert(0, |
| 43 useTabs ? new TabToken(n) : new SpaceToken(n * spacesPerIndent)); | 47 useTabs ? new TabToken(n) : new SpaceToken(n * spacesPerIndent)); |
| 44 } | 48 } |
| 45 | 49 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 436 |
| 433 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n); | 437 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n); |
| 434 | 438 |
| 435 String repeat(String ch, int times) { | 439 String repeat(String ch, int times) { |
| 436 var sb = new StringBuffer(); | 440 var sb = new StringBuffer(); |
| 437 for (var i = 0; i < times; ++i) { | 441 for (var i = 0; i < times; ++i) { |
| 438 sb.write(ch); | 442 sb.write(ch); |
| 439 } | 443 } |
| 440 return sb.toString(); | 444 return sb.toString(); |
| 441 } | 445 } |
| OLD | NEW |