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

Unified Diff: lib/src/rule/argument.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/line_writer.dart ('k') | lib/src/rule/combinator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/rule/argument.dart
diff --git a/lib/src/rule/argument.dart b/lib/src/rule/argument.dart
index f991232e022925958cd4dd057ef55d143898a4fa..046ff10ca27f6ee55300c037063719f50541d79a 100644
--- a/lib/src/rule/argument.dart
+++ b/lib/src/rule/argument.dart
@@ -124,8 +124,6 @@ class SinglePositionalRule extends PositionalRule {
splitsOnInnerRules =
splitsOnInnerRules != null ? splitsOnInnerRules : false;
- bool isSplit(int value, Chunk chunk) => value != Rule.unsplit;
-
int constrain(int value, Rule other) {
var constrained = super.constrain(value, other);
if (constrained != null) return constrained;
@@ -194,10 +192,7 @@ class MultiplePositionalRule extends PositionalRule {
String toString() => "*Pos${super.toString()}";
- bool isSplit(int value, Chunk chunk) {
- // Don't split at all.
- if (value == Rule.unsplit) return false;
-
+ bool isSplitAtValue(int value, Chunk chunk) {
// Split only before the first argument. Keep the entire argument list
// together on the next line.
if (value == 1) return chunk == _arguments.first;
@@ -298,17 +293,12 @@ class NamedRule extends ArgumentRule {
_first = chunk;
}
- bool isSplit(int value, Chunk chunk) {
- switch (value) {
- case Rule.unsplit:
- return false;
- case 1:
- return chunk == _first;
- case 2:
- return true;
- }
+ bool isSplitAtValue(int value, Chunk chunk) {
+ // Only split before the first argument.
+ if (value == 1) return chunk == _first;
- throw "unreachable";
+ // Split before every argument.
+ return true;
}
String toString() => "Named${super.toString()}";
« no previous file with comments | « lib/src/line_writer.dart ('k') | lib/src/rule/combinator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698