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

Unified Diff: lib/src/chunk.dart

Issue 1492683002: Change the way hard splits are handled. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years 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/argument_list_visitor.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 a3825016148595a721419857de54712811391b76..da6d7bbc011ac9e7d82055ec4d43b76b66c48b52 100644
--- a/lib/src/chunk.dart
+++ b/lib/src/chunk.dart
@@ -114,10 +114,6 @@ class Chunk extends Selection {
Rule get rule => _rule;
Rule _rule;
- /// Whether this chunk is always followed by a newline or whether the line
- /// splitter may choose to keep the next chunk on the same line.
- bool get isHardSplit => _rule is HardSplitRule;
-
/// Whether or not an extra blank line should be output after this chunk if
/// it's split.
///
@@ -197,15 +193,6 @@ class Chunk extends Selection {
_text += text;
}
- /// Forces this soft split to become a hard split.
- ///
- /// This is called on the soft splits owned by a rule that decides to harden
- /// when it finds out another hard split occurs within its chunks.
- void harden() {
- _rule = new HardSplitRule();
- spans.clear();
- }
-
/// Finishes off this chunk with the given [rule] and split information.
///
/// This may be called multiple times on the same split since the splits
@@ -216,7 +203,7 @@ class Chunk extends Selection {
{bool flushLeft, bool isDouble, bool space}) {
if (flushLeft == null) flushLeft = false;
if (space == null) space = false;
- if (isHardSplit || rule is HardSplitRule) {
+ if (rule.isHardened) {
// A hard split always wins.
_rule = rule;
} else if (_rule == null) {
@@ -271,10 +258,9 @@ class Chunk extends Selection {
if (_rule == null) {
parts.add("(no split)");
- } else if (isHardSplit) {
- parts.add("hard");
} else {
parts.add(rule.toString());
+ if (rule.isHardened) parts.add("(hard)");
if (_rule.constrainedRules.isNotEmpty) {
parts.add("-> ${_rule.constrainedRules.join(' ')}");
« no previous file with comments | « lib/src/argument_list_visitor.dart ('k') | lib/src/chunk_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698