@@ -44,7 +44,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
44
44
executor, macroUri, identifierResolver, instanceId);
45
45
await typesBenchmark.report ();
46
46
BuildAugmentationLibraryBenchmark .reportAndPrint (
47
- executor, typesBenchmark.results, identifierDeclarations);
47
+ executor,
48
+ [if (typesBenchmark.result != null ) typesBenchmark.result! ],
49
+ identifierDeclarations);
48
50
final declarationsBenchmark = DataClassDeclarationsPhaseBenchmark (
49
51
executor,
50
52
macroUri,
@@ -54,7 +56,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
54
56
typeDeclarationResolver);
55
57
await declarationsBenchmark.report ();
56
58
BuildAugmentationLibraryBenchmark .reportAndPrint (
57
- executor, declarationsBenchmark.results, identifierDeclarations);
59
+ executor,
60
+ [if (declarationsBenchmark.result != null ) declarationsBenchmark.result! ],
61
+ identifierDeclarations);
58
62
final definitionsBenchmark = DataClassDefinitionPhaseBenchmark (
59
63
executor,
60
64
macroUri,
@@ -64,7 +68,9 @@ Future<void> runBenchmarks(MacroExecutor executor, Uri macroUri) async {
64
68
typeDeclarationResolver);
65
69
await definitionsBenchmark.report ();
66
70
BuildAugmentationLibraryBenchmark .reportAndPrint (
67
- executor, definitionsBenchmark.results, identifierDeclarations);
71
+ executor,
72
+ [if (definitionsBenchmark.result != null ) definitionsBenchmark.result! ],
73
+ identifierDeclarations);
68
74
}
69
75
70
76
class DataClassInstantiateBenchmark extends AsyncBenchmarkBase {
@@ -86,19 +92,17 @@ class DataClassTypesPhaseBenchmark extends AsyncBenchmarkBase {
86
92
final Uri macroUri;
87
93
final IdentifierResolver identifierResolver;
88
94
final MacroInstanceIdentifier instanceIdentifier;
89
- late List < MacroExecutionResult > results ;
95
+ MacroExecutionResult ? result ;
90
96
91
97
DataClassTypesPhaseBenchmark (this .executor, this .macroUri,
92
98
this .identifierResolver, this .instanceIdentifier)
93
99
: super ('DataClassTypesPhase' );
94
100
95
101
Future <void > run () async {
96
- results = < MacroExecutionResult > [];
97
102
if (instanceIdentifier.shouldExecute (
98
103
DeclarationKind .classType, Phase .types)) {
99
- var result = await executor.executeTypesPhase (
104
+ result = await executor.executeTypesPhase (
100
105
instanceIdentifier, myClass, identifierResolver);
101
- results.add (result);
102
106
}
103
107
}
104
108
}
@@ -111,7 +115,7 @@ class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
111
115
final TypeIntrospector typeIntrospector;
112
116
final TypeDeclarationResolver typeDeclarationResolver;
113
117
114
- late List < MacroExecutionResult > results ;
118
+ MacroExecutionResult ? result ;
115
119
116
120
DataClassDeclarationsPhaseBenchmark (
117
121
this .executor,
@@ -123,17 +127,16 @@ class DataClassDeclarationsPhaseBenchmark extends AsyncBenchmarkBase {
123
127
: super ('DataClassDeclarationsPhase' );
124
128
125
129
Future <void > run () async {
126
- results = < MacroExecutionResult > [] ;
130
+ result = null ;
127
131
if (instanceIdentifier.shouldExecute (
128
132
DeclarationKind .classType, Phase .declarations)) {
129
- var result = await executor.executeDeclarationsPhase (
133
+ result = await executor.executeDeclarationsPhase (
130
134
instanceIdentifier,
131
135
myClass,
132
136
identifierResolver,
133
137
typeDeclarationResolver,
134
138
SimpleTypeResolver (),
135
139
typeIntrospector);
136
- results.add (result);
137
140
}
138
141
}
139
142
}
@@ -146,7 +149,7 @@ class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
146
149
final TypeIntrospector typeIntrospector;
147
150
final TypeDeclarationResolver typeDeclarationResolver;
148
151
149
- late List < MacroExecutionResult > results ;
152
+ MacroExecutionResult ? result ;
150
153
151
154
DataClassDefinitionPhaseBenchmark (
152
155
this .executor,
@@ -158,18 +161,17 @@ class DataClassDefinitionPhaseBenchmark extends AsyncBenchmarkBase {
158
161
: super ('DataClassDefinitionPhase' );
159
162
160
163
Future <void > run () async {
161
- results = < MacroExecutionResult > [] ;
164
+ result = null ;
162
165
if (instanceIdentifier.shouldExecute (
163
166
DeclarationKind .classType, Phase .definitions)) {
164
- var result = await executor.executeDefinitionsPhase (
167
+ result = await executor.executeDefinitionsPhase (
165
168
instanceIdentifier,
166
169
myClass,
167
170
identifierResolver,
168
171
typeDeclarationResolver,
169
- SimpleTypeResolver (),
172
+ const SimpleTypeResolver (),
170
173
typeIntrospector,
171
- FakeTypeInferrer ());
172
- results.add (result);
174
+ const FakeTypeInferrer ());
173
175
}
174
176
}
175
177
}
@@ -179,6 +181,7 @@ final myClassIdentifier =
179
181
final myClass = IntrospectableClassDeclarationImpl (
180
182
id: RemoteInstance .uniqueId,
181
183
identifier: myClassIdentifier,
184
+ library: fooLibrary,
182
185
interfaces: [],
183
186
hasAbstract: false ,
184
187
hasBase: false ,
@@ -201,6 +204,7 @@ final myClassFields = [
201
204
definingType: myClassIdentifier,
202
205
id: RemoteInstance .uniqueId,
203
206
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myString' ),
207
+ library: fooLibrary,
204
208
isExternal: false ,
205
209
isFinal: true ,
206
210
isLate: false ,
@@ -210,6 +214,7 @@ final myClassFields = [
210
214
definingType: myClassIdentifier,
211
215
id: RemoteInstance .uniqueId,
212
216
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'myBool' ),
217
+ library: fooLibrary,
213
218
isExternal: false ,
214
219
isFinal: true ,
215
220
isLate: false ,
@@ -222,6 +227,7 @@ final myClassMethods = [
222
227
definingType: myClassIdentifier,
223
228
id: RemoteInstance .uniqueId,
224
229
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: '==' ),
230
+ library: fooLibrary,
225
231
isAbstract: false ,
226
232
isExternal: false ,
227
233
isGetter: false ,
@@ -233,6 +239,7 @@ final myClassMethods = [
233
239
ParameterDeclarationImpl (
234
240
id: RemoteInstance .uniqueId,
235
241
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'other' ),
242
+ library: fooLibrary,
236
243
isNamed: false ,
237
244
isRequired: true ,
238
245
type: NamedTypeAnnotationImpl (
@@ -249,6 +256,7 @@ final myClassMethods = [
249
256
definingType: myClassIdentifier,
250
257
id: RemoteInstance .uniqueId,
251
258
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'hashCode' ),
259
+ library: fooLibrary,
252
260
isAbstract: false ,
253
261
isExternal: false ,
254
262
isOperator: false ,
@@ -264,6 +272,7 @@ final myClassMethods = [
264
272
definingType: myClassIdentifier,
265
273
id: RemoteInstance .uniqueId,
266
274
identifier: IdentifierImpl (id: RemoteInstance .uniqueId, name: 'toString' ),
275
+ library: fooLibrary,
267
276
isAbstract: false ,
268
277
isExternal: false ,
269
278
isGetter: false ,
0 commit comments