| Index: packages/dart_style/lib/src/line_writer.dart
|
| diff --git a/packages/dart_style/lib/src/line_writer.dart b/packages/dart_style/lib/src/line_writer.dart
|
| index 055892ea0b251639921cc77b7391411a96a5e421..9fb5d39f857177ec3c613ca92b4453a4d83d8c73 100644
|
| --- a/packages/dart_style/lib/src/line_writer.dart
|
| +++ b/packages/dart_style/lib/src/line_writer.dart
|
| @@ -82,7 +82,7 @@ class LineWriter {
|
| if (cached != null) return cached;
|
|
|
| var writer = new LineWriter._(
|
| - chunk.blockChunks, _lineEnding, pageWidth, column, _blockCache);
|
| + chunk.block.chunks, _lineEnding, pageWidth, column, _blockCache);
|
|
|
| // TODO(rnystrom): Passing in an initial indent here is hacky. The
|
| // LineWriter ensures all but the first chunk have a block indent, and this
|
| @@ -131,7 +131,7 @@ class LineWriter {
|
| _buffer.toString(), totalCost, _selectionStart, _selectionEnd);
|
| }
|
|
|
| - /// Takes the first [length] of the chunks with leading [indent], removes
|
| + /// Takes the chunks from [start] to [end] with leading [indent], removes
|
| /// them, and runs the [LineSplitter] on them.
|
| int _completeLine(int newlines, int indent, int start, int end,
|
| {bool flushLeft}) {
|
| @@ -144,7 +144,7 @@ class LineWriter {
|
|
|
| if (debug.traceLineWriter) {
|
| debug.log(debug.green("\nWriting:"));
|
| - debug.dumpChunks(start, chunks);
|
| + debug.dumpChunks(0, chunks);
|
| debug.log();
|
| }
|
|
|
| @@ -163,11 +163,11 @@ class LineWriter {
|
| var chunk = chunks[i];
|
| _writeChunk(chunk);
|
|
|
| - if (chunk.blockChunks.isNotEmpty) {
|
| + if (chunk.isBlock) {
|
| if (!splits.shouldSplitAt(i)) {
|
| // This block didn't split (which implies none of the child blocks
|
| // of that block split either, recursively), so write them all inline.
|
| - _writeChunksUnsplit(chunk.blockChunks);
|
| + _writeChunksUnsplit(chunk);
|
| } else {
|
| // Include the formatted block contents.
|
| var block = formatBlock(chunk, splits.getColumn(i));
|
| @@ -201,16 +201,18 @@ class LineWriter {
|
| return splits.cost;
|
| }
|
|
|
| - /// Writes [chunks] (and any child chunks of them, recursively) without any
|
| - /// splitting.
|
| - void _writeChunksUnsplit(List<Chunk> chunks) {
|
| - for (var chunk in chunks) {
|
| - _writeChunk(chunk);
|
| + /// Writes the block chunks of [chunk] (and any child chunks of them,
|
| + /// recursively) without any splitting.
|
| + void _writeChunksUnsplit(Chunk chunk) {
|
| + if (!chunk.isBlock) return;
|
| +
|
| + for (var blockChunk in chunk.block.chunks) {
|
| + _writeChunk(blockChunk);
|
|
|
| - if (chunk.spaceWhenUnsplit) _buffer.write(" ");
|
| + if (blockChunk.spaceWhenUnsplit) _buffer.write(" ");
|
|
|
| // Recurse into the block.
|
| - _writeChunksUnsplit(chunk.blockChunks);
|
| + _writeChunksUnsplit(blockChunk);
|
| }
|
| }
|
|
|
|
|