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

Unified Diff: lib/src/whitespace.dart

Issue 1180443003: Don't allow inline block comments to eat pending newlines. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Add a test. Created 5 years, 6 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/chunk_builder.dart ('k') | test/comments/top_level.unit » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/whitespace.dart
diff --git a/lib/src/whitespace.dart b/lib/src/whitespace.dart
index 7c953056e19e1e08bb541ab09bbab66ff7b57596..0f7b2cba146c8fa47b389a316e150fe3dd7e97b5 100644
--- a/lib/src/whitespace.dart
+++ b/lib/src/whitespace.dart
@@ -10,6 +10,9 @@ library dart_style.src.whitespace;
/// We defer actually writing whitespace until a non-whitespace token is
/// encountered to avoid trailing whitespace.
class Whitespace {
+ /// No whitespace.
+ static const none = const Whitespace._("none");
+
/// A single non-breaking space.
static const space = const Whitespace._("space");
@@ -45,6 +48,23 @@ class Whitespace {
final String name;
+ /// Gets the minimum number of newlines contained in this whitespace.
+ int get minimumLines {
+ switch (this) {
+ case Whitespace.newline:
+ case Whitespace.nestedNewline:
+ case Whitespace.newlineFlushLeft:
+ case Whitespace.oneOrTwoNewlines:
+ return 1;
+
+ case Whitespace.twoNewlines:
+ return 2;
+
+ default:
+ return 0;
+ }
+ }
+
const Whitespace._(this.name);
String toString() => name;
« no previous file with comments | « lib/src/chunk_builder.dart ('k') | test/comments/top_level.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698