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

Unified Diff: lib/src/chunk.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 | « example/format.dart ('k') | lib/src/chunk_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/chunk.dart
diff --git a/lib/src/chunk.dart b/lib/src/chunk.dart
index d36f48d4cfcfd9e55882e4529af7159d6cd1a864..bb2d98bb56a2ccbcf51833645eb78299bf5679cd 100644
--- a/lib/src/chunk.dart
+++ b/lib/src/chunk.dart
@@ -5,7 +5,7 @@
library dart_style.src.chunk;
import 'fast_hash.dart';
-import 'nesting.dart';
+import 'nesting_level.dart';
import 'rule/rule.dart';
/// Tracks where a selection start or end point may appear in some piece of
@@ -131,7 +131,15 @@ class Chunk extends Selection {
///
/// Used for multi-line strings and commented out code.
bool get flushLeft => _flushLeft;
- bool _flushLeft;
+ bool _flushLeft = false;
+
+ /// If `true`, then the line after this chunk and its contained block should
+ /// be flush left.
+ bool get flushLeftAfter {
+ if (blockChunks.isEmpty) return _flushLeft;
+
+ return blockChunks.last.flushLeftAfter;
+ }
/// Whether this chunk should append an extra space if it does not split.
///
@@ -293,12 +301,6 @@ class Cost {
/// Splitting before a type argument or type parameter.
static const typeArgument = 4;
-
- /// The cost of a single character that goes past the page limit.
- ///
- /// This cost is high to ensure any solution that fits in the page is
- /// preferred over one that does not.
- static const overflowChar = 1000;
}
/// The in-progress state for a [Span] that has been started but has not yet
« no previous file with comments | « example/format.dart ('k') | lib/src/chunk_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698