| Index: pkg/analyzer/lib/src/services/writer.dart
|
| ===================================================================
|
| --- pkg/analyzer/lib/src/services/writer.dart (revision 32022)
|
| +++ pkg/analyzer/lib/src/services/writer.dart (working copy)
|
| @@ -5,10 +5,7 @@
|
| library source_writer;
|
|
|
|
|
| -/// DEBUG flag indicating whether to use the experimental line-breaker
|
| -const _USE_LINE_BREAKER = false;
|
|
|
| -
|
| class Line {
|
|
|
| final tokens = <LineToken>[];
|
| @@ -122,10 +119,9 @@
|
| if (work.fits(tok)) {
|
| work.add(tok);
|
| } else {
|
| - if (!isAllWhitespace(work)) {
|
| + if (!isAllWhitespace(work) || isLineStart(current)) {
|
| current.add(work);
|
| - }
|
| - if (current.length > 0) {
|
| + } else if (current.length > 0) {
|
| chunks.add(current);
|
| current = new Chunk(maxLength: maxLength);
|
| }
|
| @@ -176,6 +172,8 @@
|
|
|
| bool isAllWhitespace(Chunk chunk) => isWhitespace(chunk.buffer.toString());
|
|
|
| + bool isLineStart(chunk) => chunk.length == 0 && chunk.start == LINE_START;
|
| +
|
| /// Test whether this token is a good start for a new working chunk
|
| bool goodStart(LineToken tok, Chunk workingChunk) =>
|
| tok is SpaceToken && tok.breakWeight >= workingChunk.start.breakWeight;
|
| @@ -293,7 +291,7 @@
|
|
|
| SourceWriter({this.indentCount: 0, this.lineSeparator: NEW_LINE,
|
| bool useTabs: false, int spacesPerIndent: 2, int maxLineLength: 80}) {
|
| - if (_USE_LINE_BREAKER) {
|
| + if (maxLineLength > 0) {
|
| linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
|
| getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
|
| } else {
|
|
|