| Index: pkg/analyzer/lib/src/services/writer.dart
|
| ===================================================================
|
| --- pkg/analyzer/lib/src/services/writer.dart (revision 31766)
|
| +++ pkg/analyzer/lib/src/services/writer.dart (working copy)
|
| @@ -116,7 +116,7 @@
|
| if (work.fits(tok)) {
|
| work.add(tok);
|
| } else {
|
| - if (!isWhitespace(work)) {
|
| + if (!isAllWhitespace(work)) {
|
| current.add(work);
|
| }
|
| if (current.length > 0) {
|
| @@ -137,10 +137,7 @@
|
| return chunks;
|
| }
|
|
|
| - bool isWhitespace(Chunk chunk) {
|
| - var str = chunk.buffer.toString();
|
| - return str.lastIndexOf(new RegExp(r"(\w+)")) == str.length - 1;
|
| - }
|
| + bool isAllWhitespace(Chunk chunk) => isWhitespace(chunk.buffer.toString());
|
|
|
| /// Test whether this token is a good start for a new working chunk
|
| bool goodStart(LineToken tok, Chunk workingChunk) =>
|
| @@ -148,6 +145,9 @@
|
|
|
| }
|
|
|
| +/// Test if this [string] contains only whitespace characters
|
| +bool isWhitespace(String string) => string.codeUnits.every(
|
| + (c) => c == 0x09 || c == 0x20 || c == 0x0A || c == 0x0D);
|
|
|
| /// Special token indicating a line start
|
| final LINE_START = new SpaceToken(0);
|
| @@ -256,9 +256,9 @@
|
|
|
| SourceWriter({this.indentCount: 0, this.lineSeparator: NEW_LINE,
|
| bool useTabs: false, int spacesPerIndent: 2, int maxLineLength: 80}) {
|
| -// linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
|
| -// getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
|
| - linePrinter = new SimpleLinePrinter();
|
| + linePrinter = new SimpleLineBreaker(maxLineLength, (n) =>
|
| + getIndentString(n, useTabs: useTabs, spacesPerIndent: spacesPerIndent));
|
| +// linePrinter = new SimpleLinePrinter();
|
| currentLine = new Line(indent: indentCount, printer: linePrinter);
|
| }
|
|
|
|
|