Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit db564b1

Browse files
authored
Accept Iterable for positionalArguments (#173)
1 parent 258fbc8 commit db564b1

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void main() {
8686

8787
* Added `nullSafeProperty` to `Expression` to access properties with `?.`
8888
* Added `conditional` to `Expression` to use the ternary operator `? : `
89+
* Methods taking `positionalArguments` accept `Iterable<Expression>`
8990

9091
## 2.2.0
9192

lib/src/specs/expression.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ abstract class Expression implements Spec {
158158

159159
/// Call this expression as a method.
160160
Expression call(
161-
List<Expression> positionalArguments, [
161+
Iterable<Expression> positionalArguments, [
162162
Map<String, Expression> namedArguments = const {},
163163
List<Reference> typeArguments = const [],
164164
]) {
165165
return new InvokeExpression._(
166166
this,
167-
positionalArguments,
167+
positionalArguments.toList(),
168168
namedArguments,
169169
typeArguments,
170170
);
@@ -193,7 +193,7 @@ abstract class Expression implements Spec {
193193
/// Returns an annotation as a result of calling this constructor.
194194
@Deprecated('Use "call" instead. Will be removed in 3.0.0.')
195195
Expression annotation([
196-
List<Expression> positionalArguments,
196+
Iterable<Expression> positionalArguments,
197197
Map<String, Expression> namedArguments = const {},
198198
List<Reference> typeArguments = const [],
199199
]) {
@@ -205,7 +205,7 @@ abstract class Expression implements Spec {
205205
return new Annotation((b) {
206206
b.code = new InvokeExpression._(
207207
this,
208-
positionalArguments,
208+
positionalArguments.toList(),
209209
namedArguments,
210210
typeArguments,
211211
)
@@ -217,14 +217,14 @@ abstract class Expression implements Spec {
217217
@Deprecated('Use a combination of "property" and "call". Removing in 3.0.0.')
218218
Expression annotationNamed(
219219
String name,
220-
List<Expression> positionalArguments, [
220+
Iterable<Expression> positionalArguments, [
221221
Map<String, Expression> namedArguments = const {},
222222
List<Reference> typeArguments = const [],
223223
]) {
224224
// ignore: deprecated_member_use
225225
return new Annotation((b) => b
226-
..code = new InvokeExpression._(
227-
this, positionalArguments, namedArguments, typeArguments, name)
226+
..code = new InvokeExpression._(this, positionalArguments.toList(),
227+
namedArguments, typeArguments, name)
228228
.code);
229229
}
230230

lib/src/specs/reference.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class Reference extends Expression implements Spec {
5151

5252
/// Returns a new instance of this expression.
5353
Expression newInstance(
54-
List<Expression> positionalArguments, [
54+
Iterable<Expression> positionalArguments, [
5555
Map<String, Expression> namedArguments = const {},
5656
List<Reference> typeArguments = const [],
5757
]) {
5858
return new InvokeExpression.newOf(
5959
this,
60-
positionalArguments,
60+
positionalArguments.toList(),
6161
namedArguments,
6262
typeArguments,
6363
null,
@@ -67,13 +67,13 @@ class Reference extends Expression implements Spec {
6767
/// Returns a new instance of this expression with a named constructor.
6868
Expression newInstanceNamed(
6969
String name,
70-
List<Expression> positionalArguments, [
70+
Iterable<Expression> positionalArguments, [
7171
Map<String, Expression> namedArguments = const {},
7272
List<Reference> typeArguments = const [],
7373
]) {
7474
return new InvokeExpression.newOf(
7575
this,
76-
positionalArguments,
76+
positionalArguments.toList(),
7777
namedArguments,
7878
typeArguments,
7979
name,
@@ -82,13 +82,13 @@ class Reference extends Expression implements Spec {
8282

8383
/// Returns a const instance of this expression.
8484
Expression constInstance(
85-
List<Expression> positionalArguments, [
85+
Iterable<Expression> positionalArguments, [
8686
Map<String, Expression> namedArguments = const {},
8787
List<Reference> typeArguments = const [],
8888
]) {
8989
return new InvokeExpression.constOf(
9090
this,
91-
positionalArguments,
91+
positionalArguments.toList(),
9292
namedArguments,
9393
typeArguments,
9494
null,
@@ -98,13 +98,13 @@ class Reference extends Expression implements Spec {
9898
/// Returns a const instance of this expression with a named constructor.
9999
Expression constInstanceNamed(
100100
String name,
101-
List<Expression> positionalArguments, [
101+
Iterable<Expression> positionalArguments, [
102102
Map<String, Expression> namedArguments = const {},
103103
List<Reference> typeArguments = const [],
104104
]) {
105105
return new InvokeExpression.constOf(
106106
this,
107-
positionalArguments,
107+
positionalArguments.toList(),
108108
namedArguments,
109109
typeArguments,
110110
name,

lib/src/specs/type_function.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ abstract class FunctionType extends Expression
6262

6363
@override
6464
Expression newInstance(
65-
List<Expression> positionalArguments, [
65+
Iterable<Expression> positionalArguments, [
6666
Map<String, Expression> namedArguments = const {},
6767
List<Reference> typeArguments = const [],
6868
]) =>
@@ -71,15 +71,15 @@ abstract class FunctionType extends Expression
7171
@override
7272
Expression newInstanceNamed(
7373
String name,
74-
List<Expression> positionalArguments, [
74+
Iterable<Expression> positionalArguments, [
7575
Map<String, Expression> namedArguments = const {},
7676
List<Reference> typeArguments = const [],
7777
]) =>
7878
throw new UnsupportedError('Cannot "new" a function type.');
7979

8080
@override
8181
Expression constInstance(
82-
List<Expression> positionalArguments, [
82+
Iterable<Expression> positionalArguments, [
8383
Map<String, Expression> namedArguments = const {},
8484
List<Reference> typeArguments = const [],
8585
]) =>
@@ -88,7 +88,7 @@ abstract class FunctionType extends Expression
8888
@override
8989
Expression constInstanceNamed(
9090
String name,
91-
List<Expression> positionalArguments, [
91+
Iterable<Expression> positionalArguments, [
9292
Map<String, Expression> namedArguments = const {},
9393
List<Reference> typeArguments = const [],
9494
]) =>

lib/src/specs/type_reference.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ abstract class TypeReference extends Expression
5858

5959
@override
6060
Expression newInstance(
61-
List<Expression> positionalArguments, [
61+
Iterable<Expression> positionalArguments, [
6262
Map<String, Expression> namedArguments = const {},
6363
List<Reference> typeArguments = const [],
6464
]) {
6565
return new InvokeExpression.newOf(
6666
this,
67-
positionalArguments,
67+
positionalArguments.toList(),
6868
namedArguments,
6969
typeArguments,
7070
null,
@@ -74,13 +74,13 @@ abstract class TypeReference extends Expression
7474
@override
7575
Expression newInstanceNamed(
7676
String name,
77-
List<Expression> positionalArguments, [
77+
Iterable<Expression> positionalArguments, [
7878
Map<String, Expression> namedArguments = const {},
7979
List<Reference> typeArguments = const [],
8080
]) {
8181
return new InvokeExpression.newOf(
8282
this,
83-
positionalArguments,
83+
positionalArguments.toList(),
8484
namedArguments,
8585
typeArguments,
8686
name,
@@ -89,13 +89,13 @@ abstract class TypeReference extends Expression
8989

9090
@override
9191
Expression constInstance(
92-
List<Expression> positionalArguments, [
92+
Iterable<Expression> positionalArguments, [
9393
Map<String, Expression> namedArguments = const {},
9494
List<Reference> typeArguments = const [],
9595
]) {
9696
return new InvokeExpression.constOf(
9797
this,
98-
positionalArguments,
98+
positionalArguments.toList(),
9999
namedArguments,
100100
typeArguments,
101101
null,
@@ -105,13 +105,13 @@ abstract class TypeReference extends Expression
105105
@override
106106
Expression constInstanceNamed(
107107
String name,
108-
List<Expression> positionalArguments, [
108+
Iterable<Expression> positionalArguments, [
109109
Map<String, Expression> namedArguments = const {},
110110
List<Reference> typeArguments = const [],
111111
]) {
112112
return new InvokeExpression.constOf(
113113
this,
114-
positionalArguments,
114+
positionalArguments.toList(),
115115
namedArguments,
116116
typeArguments,
117117
name,

0 commit comments

Comments
 (0)