OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dart_style.src.rule.argument; | 5 library dart_style.src.rule.argument; |
6 | 6 |
7 import '../chunk.dart'; | 7 import '../chunk.dart'; |
8 import 'rule.dart'; | 8 import 'rule.dart'; |
9 | 9 |
10 /// Base class for a rule that handles argument or parameter lists. | 10 /// Base class for a rule that handles argument or parameter lists. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 bool hack = false; | 107 bool hack = false; |
108 | 108 |
109 /// Creates a new rule for a positional argument list. | 109 /// Creates a new rule for a positional argument list. |
110 /// | 110 /// |
111 /// If [collectionRule] is given, it is the rule used to split the | 111 /// If [collectionRule] is given, it is the rule used to split the |
112 /// collections in the list. If [splitsOnInnerRules] is `true`, then we will | 112 /// collections in the list. If [splitsOnInnerRules] is `true`, then we will |
113 /// split before the argument if the argument itself contains a split. | 113 /// split before the argument if the argument itself contains a split. |
114 SinglePositionalRule(Rule collectionRule, {bool splitsOnInnerRules}) | 114 SinglePositionalRule(Rule collectionRule, {bool splitsOnInnerRules}) |
115 : super(collectionRule), | 115 : super(collectionRule), |
116 splitsOnInnerRules = splitsOnInnerRules | 116 splitsOnInnerRules = |
117 != null | 117 splitsOnInnerRules != null ? splitsOnInnerRules : false; |
118 ? splitsOnInnerRules : false; | |
119 | 118 |
120 bool isSplit(int value, Chunk chunk) => value == 1; | 119 bool isSplit(int value, Chunk chunk) => value == 1; |
121 | 120 |
122 int constrain(int value, Rule other) { | 121 int constrain(int value, Rule other) { |
123 var constrained = super.constrain(value, other); | 122 var constrained = super.constrain(value, other); |
124 if (constrained != null) return constrained; | 123 if (constrained != null) return constrained; |
125 | 124 |
126 if (other != _collectionRule) return null; | 125 if (other != _collectionRule) return null; |
127 | 126 |
128 // If we aren't splitting any args, we can split the collection. | 127 // If we aren't splitting any args, we can split the collection. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 // If we aren't splitting any args, we can split the collection. | 301 // If we aren't splitting any args, we can split the collection. |
303 if (value == 0) return null; | 302 if (value == 0) return null; |
304 | 303 |
305 // Split before all of the arguments, even the collections, so don't let | 304 // Split before all of the arguments, even the collections, so don't let |
306 // them split. | 305 // them split. |
307 return 0; | 306 return 0; |
308 } | 307 } |
309 | 308 |
310 String toString() => "Named${super.toString()}"; | 309 String toString() => "Named${super.toString()}"; |
311 } | 310 } |
OLD | NEW |