| 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 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 class Line { | 9 class Line { |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 length = 0; | 150 length = 0; |
| 151 continue; | 151 continue; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 length += token.length; | 154 length += token.length; |
| 155 } | 155 } |
| 156 if (start < tokens.length) { | 156 if (start < tokens.length) { |
| 157 newChunks.add(chunk.subChunk(newIndent, start)); | 157 newChunks.add(chunk.subChunk(newIndent, start)); |
| 158 } | 158 } |
| 159 } else { | 159 } else { |
| 160 List<LineToken> part = []; | |
| 161 int start = 0; | 160 int start = 0; |
| 162 for (int i = 0; i < tokens.length; i++) { | 161 for (int i = 0; i < tokens.length; i++) { |
| 163 LineToken token = tokens[i]; | 162 LineToken token = tokens[i]; |
| 164 if (token is SpaceToken && token.breakWeight == weight) { | 163 if (token is SpaceToken && token.breakWeight == weight) { |
| 165 newChunks.add(chunk.subChunk(newIndent, start, i)); | 164 newChunks.add(chunk.subChunk(newIndent, start, i)); |
| 166 newIndent = chunk.indent + 2; | 165 newIndent = chunk.indent + 2; |
| 167 start = i + 1; | 166 start = i + 1; |
| 168 } | 167 } |
| 169 } | 168 } |
| 170 if (start < tokens.length) { | 169 if (start < tokens.length) { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 508 |
| 510 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n); | 509 String getTabs(int n) => n < TABS.length ? TABS[n] : repeat('\t', n); |
| 511 | 510 |
| 512 String repeat(String ch, int times) { | 511 String repeat(String ch, int times) { |
| 513 var sb = new StringBuffer(); | 512 var sb = new StringBuffer(); |
| 514 for (var i = 0; i < times; ++i) { | 513 for (var i = 0; i < times; ++i) { |
| 515 sb.write(ch); | 514 sb.write(ch); |
| 516 } | 515 } |
| 517 return sb.toString(); | 516 return sb.toString(); |
| 518 } | 517 } |
| OLD | NEW |