Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Unified Diff: lib/src/line_writer.dart

Issue 1255643002: New, simpler and faster line splitter. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Optimize nesting. Reformat. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/line_splitter.dart ('k') | lib/src/nesting.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/line_writer.dart
diff --git a/lib/src/line_writer.dart b/lib/src/line_writer.dart
index a2aef01b818166ab78c42d810c18f3f3151acd82..29c536eba306935288c141d3440e52bb3835bd16 100644
--- a/lib/src/line_writer.dart
+++ b/lib/src/line_writer.dart
@@ -149,8 +149,9 @@ class LineWriter {
}
// Run the line splitter.
- var splitter = new LineSplitter(this, chunks, _blockIndentation);
- var solution = splitter.apply(indent, flushLeft: flushLeft);
+ var splitter = new LineSplitter(this, chunks, _blockIndentation, indent,
+ flushLeft: flushLeft);
+ var splits = splitter.apply();
// Write the indentation of the first line.
if (!flushLeft) {
@@ -163,13 +164,13 @@ class LineWriter {
_writeChunk(chunk);
if (chunk.blockChunks.isNotEmpty) {
- if (!solution.splits.shouldSplitAt(i)) {
+ 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);
} else {
// Include the formatted block contents.
- var block = formatBlock(chunk, solution.splits.getColumn(i));
+ var block = formatBlock(chunk, splits.getColumn(i));
// If this block contains one of the selection markers, tell the
// writer where it ended up in the final output.
@@ -187,17 +188,17 @@ class LineWriter {
if (i == chunks.length - 1) {
// Don't write trailing whitespace after the last chunk.
- } else if (solution.splits.shouldSplitAt(i)) {
+ } else if (splits.shouldSplitAt(i)) {
_buffer.write(_lineEnding);
if (chunk.isDouble) _buffer.write(_lineEnding);
- _buffer.write(" " * (solution.splits.getColumn(i)));
+ _buffer.write(" " * (splits.getColumn(i)));
} else {
if (chunk.spaceWhenUnsplit) _buffer.write(" ");
}
}
- return solution.cost;
+ return splits.cost;
}
/// Writes [chunks] (and any child chunks of them, recursively) without any
« no previous file with comments | « lib/src/line_splitter.dart ('k') | lib/src/nesting.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698