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.type_argument; | 5 library dart_style.src.rule.type_argument; |
6 | 6 |
7 import '../chunk.dart'; | 7 import '../chunk.dart'; |
8 import 'rule.dart'; | 8 import 'rule.dart'; |
9 | 9 |
10 /// Rule for splitting a list of type arguments or type parameters. Type | 10 /// Rule for splitting a list of type arguments or type parameters. Type |
(...skipping 25 matching lines...) Expand all Loading... |
36 int get numValues => _arguments.length == 1 ? 2 : _arguments.length + 2; | 36 int get numValues => _arguments.length == 1 ? 2 : _arguments.length + 2; |
37 | 37 |
38 /// Remembers [chunk] as containing the split that occurs right before a type | 38 /// Remembers [chunk] as containing the split that occurs right before a type |
39 /// argument in the list. | 39 /// argument in the list. |
40 void beforeArgument(Chunk chunk) { | 40 void beforeArgument(Chunk chunk) { |
41 _arguments.add(chunk); | 41 _arguments.add(chunk); |
42 } | 42 } |
43 | 43 |
44 bool isSplit(int value, Chunk chunk) { | 44 bool isSplit(int value, Chunk chunk) { |
45 // Don't split at all. | 45 // Don't split at all. |
46 if (value == 0) return false; | 46 if (value == Rule.unsplit) return false; |
47 | 47 |
48 // Split before every argument. | 48 // Split before every argument. |
49 if (value == numValues - 1) return true; | 49 if (value == numValues - 1) return true; |
50 | 50 |
51 // Split before a single argument. Try later arguments before earlier ones | 51 // Split before a single argument. Try later arguments before earlier ones |
52 // to try to keep as much on the first line as possible. | 52 // to try to keep as much on the first line as possible. |
53 return chunk == _arguments[_arguments.length - value]; | 53 return chunk == _arguments[_arguments.length - value]; |
54 } | 54 } |
| 55 |
| 56 String toString() => "TypeArg${super.toString()}"; |
55 } | 57 } |
OLD | NEW |