@@ -9,18 +9,6 @@ abstract class ArgumentRule extends Rule {
9
9
/// The chunks prior to each positional argument.
10
10
final List <Chunk ?> _arguments = [];
11
11
12
- /// The number of leading collection arguments.
13
- ///
14
- /// This and [_trailingCollections] cannot both be positive. If every
15
- /// argument is a collection, this will be [_arguments.length] and
16
- /// [_trailingCollections] will be 0.
17
- final int _leadingCollections;
18
-
19
- /// The number of trailing collections.
20
- ///
21
- /// This and [_leadingCollections] cannot both be positive.
22
- final int _trailingCollections;
23
-
24
12
/// If true, then inner rules that are written will force this rule to split.
25
13
///
26
14
/// Temporarily disabled while writing collection arguments so that they can
@@ -31,8 +19,6 @@ abstract class ArgumentRule extends Rule {
31
19
@override
32
20
bool get splitsOnInnerRules => _trackInnerRules;
33
21
34
- ArgumentRule ._(this ._leadingCollections, this ._trailingCollections);
35
-
36
22
/// Remembers [chunk] as containing the split that occurs right before an
37
23
/// argument in the list.
38
24
void beforeArgument (Chunk ? chunk) {
@@ -70,6 +56,18 @@ abstract class ArgumentRule extends Rule {
70
56
/// splits before all of the non-collection arguments, but does not split
71
57
/// before the collections, so that they can split internally.
72
58
class PositionalRule extends ArgumentRule {
59
+ /// The number of leading collection arguments.
60
+ ///
61
+ /// This and [_trailingCollections] cannot both be positive. If every
62
+ /// argument is a collection, this will be [_arguments.length] and
63
+ /// [_trailingCollections] will be 0.
64
+ final int _leadingCollections;
65
+
66
+ /// The number of trailing collections.
67
+ ///
68
+ /// This and [_leadingCollections] cannot both be positive.
69
+ final int _trailingCollections;
70
+
73
71
/// Creates a new rule for a positional argument list.
74
72
///
75
73
/// [argumentCount] is the number of arguments that will be added to the rule
@@ -82,33 +80,32 @@ class PositionalRule extends ArgumentRule {
82
80
{required int argumentCount,
83
81
int leadingCollections = 0 ,
84
82
int trailingCollections = 0 })
85
- : super ._(leadingCollections, trailingCollections) {
86
- if (collectionRule != null ) {
87
- // Don't split inside collections if there are leading collections and
88
- // we split before the first argument.
89
- if (leadingCollections > 0 ) {
90
- addConstraint (1 , collectionRule, Rule .unsplit);
91
- }
83
+ : _leadingCollections = leadingCollections,
84
+ _trailingCollections = trailingCollections {
85
+ // Don't split inside collections if there are leading collections and
86
+ // we split before the first argument.
87
+ if (leadingCollections > 0 ) {
88
+ addConstraint (1 , collectionRule! , Rule .unsplit);
89
+ }
92
90
93
- // If we're only splitting before the non-collection arguments, the
94
- // intent is to split inside the collections, so force that here.
95
- if (leadingCollections > 0 || trailingCollections > 0 ) {
96
- addConstraint (argumentCount + 1 , collectionRule, 1 );
97
- }
91
+ // If we're only splitting before the non-collection arguments, the
92
+ // intent is to split inside the collections, so force that here.
93
+ if (leadingCollections > 0 || trailingCollections > 0 ) {
94
+ addConstraint (argumentCount + 1 , collectionRule! , 1 );
95
+ }
98
96
99
- // Split before a single argument. If it's in the middle of the collection
100
- // arguments, don't allow them to split.
101
- for (var argument = 0 ; argument < leadingCollections; argument++ ) {
102
- var value = argumentCount - argument + 1 ;
103
- addConstraint (value, collectionRule, Rule .unsplit);
104
- }
97
+ // Split before a single argument. If it's in the middle of the collection
98
+ // arguments, don't allow them to split.
99
+ for (var argument = 0 ; argument < leadingCollections; argument++ ) {
100
+ var value = argumentCount - argument + 1 ;
101
+ addConstraint (value, collectionRule! , Rule .unsplit);
102
+ }
105
103
106
- for (var argument = argumentCount - trailingCollections;
107
- argument < argumentCount;
108
- argument++ ) {
109
- var value = argumentCount - argument + 1 ;
110
- addConstraint (value, collectionRule, Rule .unsplit);
111
- }
104
+ for (var argument = argumentCount - trailingCollections;
105
+ argument < argumentCount;
106
+ argument++ ) {
107
+ var value = argumentCount - argument + 1 ;
108
+ addConstraint (value, collectionRule! , Rule .unsplit);
112
109
}
113
110
}
114
111
@@ -201,8 +198,7 @@ class NamedRule extends ArgumentRule {
201
198
/// arguments in the list. It must be provided if [leadingCollections] or
202
199
/// [trailingCollections] is non-zero.
203
200
NamedRule (
204
- Rule ? collectionRule, int leadingCollections, int trailingCollections)
205
- : super ._(leadingCollections, trailingCollections) {
201
+ Rule ? collectionRule, int leadingCollections, int trailingCollections) {
206
202
if (leadingCollections > 0 || trailingCollections > 0 ) {
207
203
// Split only before the first argument. Don't allow the collections to
208
204
// split.
0 commit comments