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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 // }), | 206 // }), |
207 // argument, | 207 // argument, |
208 // ... | 208 // ... |
209 // argument; | 209 // argument; |
210 if (value == _arguments.length + 1) { | 210 if (value == _arguments.length + 1) { |
211 for (var i = 0; i < _leadingBlocks; i++) { | 211 for (var i = 0; i < _leadingBlocks; i++) { |
212 if (chunk == _arguments[i]) return false; | 212 if (chunk == _arguments[i]) return false; |
213 } | 213 } |
214 | 214 |
215 for (var i = _arguments.length - _trailingBlocks; | 215 for (var i = _arguments.length - _trailingBlocks; |
216 i < _arguments.length; i++) { | 216 i < _arguments.length; |
| 217 i++) { |
217 if (chunk == _arguments[i]) return false; | 218 if (chunk == _arguments[i]) return false; |
218 } | 219 } |
219 | 220 |
220 return true; | 221 return true; |
221 } | 222 } |
222 | 223 |
223 // Split before all of the arguments, even the block ones. | 224 // Split before all of the arguments, even the block ones. |
224 return true; | 225 return true; |
225 } | 226 } |
226 | 227 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 278 |
278 NamedRule(Rule blockRule) : super(blockRule); | 279 NamedRule(Rule blockRule) : super(blockRule); |
279 | 280 |
280 void beforeArguments(Chunk chunk) { | 281 void beforeArguments(Chunk chunk) { |
281 assert(_first == null); | 282 assert(_first == null); |
282 _first = chunk; | 283 _first = chunk; |
283 } | 284 } |
284 | 285 |
285 bool isSplit(int value, Chunk chunk) { | 286 bool isSplit(int value, Chunk chunk) { |
286 switch (value) { | 287 switch (value) { |
287 case 0: return false; | 288 case 0: |
288 case 1: return chunk == _first; | 289 return false; |
289 case 2: return true; | 290 case 1: |
| 291 return chunk == _first; |
| 292 case 2: |
| 293 return true; |
290 } | 294 } |
291 | 295 |
292 throw "unreachable"; | 296 throw "unreachable"; |
293 } | 297 } |
294 | 298 |
295 int constrain(int value, Rule other) { | 299 int constrain(int value, Rule other) { |
296 var constrained = super.constrain(value, other); | 300 var constrained = super.constrain(value, other); |
297 if (constrained != null) return constrained; | 301 if (constrained != null) return constrained; |
298 | 302 |
299 if (other != _blockRule) return null; | 303 if (other != _blockRule) return null; |
300 | 304 |
301 // If we aren't splitting any args, we can split the block. | 305 // If we aren't splitting any args, we can split the block. |
302 if (value == 0) return null; | 306 if (value == 0) return null; |
303 | 307 |
304 // Split before all of the arguments, even the block ones, so don't let | 308 // Split before all of the arguments, even the block ones, so don't let |
305 // them split. | 309 // them split. |
306 return 0; | 310 return 0; |
307 } | 311 } |
308 | 312 |
309 String toString() => "Named${super.toString()}"; | 313 String toString() => "Named${super.toString()}"; |
310 } | 314 } |
OLD | NEW |