Skip to content

Commit e3b4d84

Browse files
committed
update macro examples to the latest APIs and 3.2.0 SDK
1 parent c13682a commit e3b4d84

File tree

6 files changed

+72
-72
lines changed

6 files changed

+72
-72
lines changed

working/macros/example/benchmark/src/data_class.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ final myClassFields = [
168168
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'myString'),
169169
library: fooLibrary,
170170
metadata: [],
171-
isExternal: false,
172-
isFinal: true,
173-
isLate: false,
171+
hasExternal: false,
172+
hasFinal: true,
173+
hasLate: false,
174174
isStatic: false,
175175
type: stringType),
176176
FieldDeclarationImpl(
@@ -179,9 +179,9 @@ final myClassFields = [
179179
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'myBool'),
180180
library: fooLibrary,
181181
metadata: [],
182-
isExternal: false,
183-
isFinal: true,
184-
isLate: false,
182+
hasExternal: false,
183+
hasFinal: true,
184+
hasLate: false,
185185
isStatic: false,
186186
type: boolType),
187187
];
@@ -193,8 +193,8 @@ final myClassMethods = [
193193
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: '=='),
194194
library: fooLibrary,
195195
metadata: [],
196-
isAbstract: false,
197-
isExternal: false,
196+
hasAbstract: false,
197+
hasExternal: false,
198198
isGetter: false,
199199
isOperator: true,
200200
isSetter: false,
@@ -224,8 +224,8 @@ final myClassMethods = [
224224
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'hashCode'),
225225
library: fooLibrary,
226226
metadata: [],
227-
isAbstract: false,
228-
isExternal: false,
227+
hasAbstract: false,
228+
hasExternal: false,
229229
isOperator: false,
230230
isGetter: true,
231231
isSetter: false,
@@ -241,8 +241,8 @@ final myClassMethods = [
241241
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'toString'),
242242
library: fooLibrary,
243243
metadata: [],
244-
isAbstract: false,
245-
isExternal: false,
244+
hasAbstract: false,
245+
hasExternal: false,
246246
isGetter: false,
247247
isOperator: false,
248248
isSetter: false,

working/macros/example/benchmark/src/functional_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ final myFunction = FunctionDeclarationImpl(
8484
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: '_myWidget'),
8585
library: fooLibrary,
8686
metadata: [],
87-
isAbstract: false,
88-
isExternal: false,
87+
hasAbstract: false,
88+
hasExternal: false,
8989
isGetter: false,
9090
isOperator: false,
9191
isSetter: false,

working/macros/example/benchmark/src/injectable.dart

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ final electricHeaterConstructors = [
359359
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: ''),
360360
library: fooLibrary,
361361
metadata: [],
362-
isAbstract: false,
363-
isExternal: false,
362+
hasAbstract: false,
363+
hasExternal: false,
364364
isGetter: false,
365365
isOperator: false,
366366
isSetter: false,
@@ -383,8 +383,8 @@ final generatedElectricHeaterMethods = [
383383
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'provider'),
384384
library: fooLibrary,
385385
metadata: [],
386-
isAbstract: false,
387-
isExternal: false,
386+
hasAbstract: false,
387+
hasExternal: false,
388388
isGetter: false,
389389
isOperator: false,
390390
isSetter: false,
@@ -462,9 +462,9 @@ final thermosiphonFields = [
462462
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'heater'),
463463
library: fooLibrary,
464464
metadata: [],
465-
isExternal: false,
466-
isFinal: true,
467-
isLate: false,
465+
hasExternal: false,
466+
hasFinal: true,
467+
hasLate: false,
468468
type: NamedTypeAnnotationImpl(
469469
id: RemoteInstance.uniqueId,
470470
isNullable: false,
@@ -479,8 +479,8 @@ final thermosiphonConstructors = [
479479
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: ''),
480480
library: fooLibrary,
481481
metadata: [],
482-
isAbstract: false,
483-
isExternal: false,
482+
hasAbstract: false,
483+
hasExternal: false,
484484
isGetter: false,
485485
isOperator: false,
486486
isSetter: false,
@@ -515,8 +515,8 @@ final generatedThermosiphonMethods = [
515515
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'provider'),
516516
library: fooLibrary,
517517
metadata: [],
518-
isAbstract: false,
519-
isExternal: false,
518+
hasAbstract: false,
519+
hasExternal: false,
520520
isGetter: false,
521521
isOperator: false,
522522
isSetter: false,
@@ -589,9 +589,9 @@ final coffeeMakerFields = [
589589
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'heater'),
590590
library: fooLibrary,
591591
metadata: [],
592-
isExternal: false,
593-
isFinal: true,
594-
isLate: false,
592+
hasExternal: false,
593+
hasFinal: true,
594+
hasLate: false,
595595
type: NamedTypeAnnotationImpl(
596596
id: RemoteInstance.uniqueId,
597597
isNullable: false,
@@ -604,9 +604,9 @@ final coffeeMakerFields = [
604604
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'pump'),
605605
library: fooLibrary,
606606
metadata: [],
607-
isExternal: false,
608-
isFinal: true,
609-
isLate: false,
607+
hasExternal: false,
608+
hasFinal: true,
609+
hasLate: false,
610610
type: NamedTypeAnnotationImpl(
611611
id: RemoteInstance.uniqueId,
612612
isNullable: false,
@@ -621,8 +621,8 @@ final coffeeMakerConstructors = [
621621
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: ''),
622622
library: fooLibrary,
623623
metadata: [],
624-
isAbstract: false,
625-
isExternal: false,
624+
hasAbstract: false,
625+
hasExternal: false,
626626
isGetter: false,
627627
isOperator: false,
628628
isSetter: false,
@@ -659,8 +659,8 @@ final generatedCoffeeMakerMethods = [
659659
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: 'provider'),
660660
library: fooLibrary,
661661
metadata: [],
662-
isAbstract: false,
663-
isExternal: false,
662+
hasAbstract: false,
663+
hasExternal: false,
664664
isGetter: false,
665665
isOperator: false,
666666
isSetter: false,
@@ -752,8 +752,8 @@ final dripCoffeeModuleMethods = [
752752
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'provideHeater'),
753753
library: fooLibrary,
754754
metadata: [],
755-
isAbstract: false,
756-
isExternal: false,
755+
hasAbstract: false,
756+
hasExternal: false,
757757
isGetter: false,
758758
isOperator: false,
759759
isSetter: false,
@@ -787,8 +787,8 @@ final dripCoffeeModuleMethods = [
787787
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'providePump'),
788788
library: fooLibrary,
789789
metadata: [],
790-
isAbstract: false,
791-
isExternal: false,
790+
hasAbstract: false,
791+
hasExternal: false,
792792
isGetter: false,
793793
isOperator: false,
794794
isSetter: false,
@@ -829,8 +829,8 @@ final generatedDripCoffeeModuleMethods = [
829829
id: RemoteInstance.uniqueId, name: 'provideHeaterProvider'),
830830
library: fooLibrary,
831831
metadata: [],
832-
isAbstract: false,
833-
isExternal: false,
832+
hasAbstract: false,
833+
hasExternal: false,
834834
isGetter: false,
835835
isOperator: false,
836836
isSetter: false,
@@ -876,8 +876,8 @@ final generatedDripCoffeeModuleMethods = [
876876
id: RemoteInstance.uniqueId, name: 'providePumpProvider'),
877877
library: fooLibrary,
878878
metadata: [],
879-
isAbstract: false,
880-
isExternal: false,
879+
hasAbstract: false,
880+
hasExternal: false,
881881
isGetter: false,
882882
isOperator: false,
883883
isSetter: false,
@@ -952,8 +952,8 @@ final dripCoffeeComponentMethods = [
952952
IdentifierImpl(id: RemoteInstance.uniqueId, name: 'coffeeMaker'),
953953
library: fooLibrary,
954954
metadata: [],
955-
isAbstract: false,
956-
isExternal: true,
955+
hasAbstract: false,
956+
hasExternal: true,
957957
isGetter: false,
958958
isOperator: false,
959959
isSetter: false,
@@ -974,8 +974,8 @@ final dripCoffeeComponentConstructors = [
974974
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: ''),
975975
library: fooLibrary,
976976
metadata: [],
977-
isAbstract: false,
978-
isExternal: true,
977+
hasAbstract: false,
978+
hasExternal: true,
979979
isGetter: false,
980980
isOperator: false,
981981
isSetter: false,
@@ -1013,8 +1013,8 @@ final generatedDripCoffeeComponentConstructors = [
10131013
identifier: IdentifierImpl(id: RemoteInstance.uniqueId, name: '_'),
10141014
library: fooLibrary,
10151015
metadata: [],
1016-
isAbstract: false,
1017-
isExternal: false,
1016+
hasAbstract: false,
1017+
hasExternal: false,
10181018
isGetter: false,
10191019
isOperator: false,
10201020
isSetter: false,
@@ -1048,9 +1048,9 @@ final generatedDripCoffeeComponentFields = [
10481048
id: RemoteInstance.uniqueId, name: '_coffeeMakerProvider'),
10491049
library: fooLibrary,
10501050
metadata: [],
1051-
isExternal: false,
1052-
isFinal: true,
1053-
isLate: false,
1051+
hasExternal: false,
1052+
hasFinal: true,
1053+
hasLate: false,
10541054
type: NamedTypeAnnotationImpl(
10551055
id: RemoteInstance.uniqueId,
10561056
isNullable: false,

working/macros/example/lib/auto_dispose.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ macro class AutoDispose implements ClassDeclarationsMacro, ClassDefinitionMacro
5858
var disposeBuilder = await builder.buildMethod(disposeMethod.identifier);
5959
disposeBuilder.augment(FunctionBodyCode.fromParts([
6060
'{\n',
61-
if (disposeMethod.isExternal) 'super.dispose();' else 'augment super();',
61+
if (disposeMethod.hasExternal) 'super.dispose();' else 'augment super();',
6262
...disposeCalls,
6363
'}',
6464
]));

working/macros/example/lib/injectable.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ macro class Component implements ClassDeclarationsMacro, ClassDefinitionMacro {
202202
final fieldNames = <String>[];
203203
for (final method in methods) {
204204
// We are filling in just the external methods.
205-
if (!method.isExternal) continue;
205+
if (!method.hasExternal) continue;
206206

207207
// We use the method name because it is always a valid field name.
208208
final fieldName = '_${method.identifier.name}Provider';
@@ -254,7 +254,7 @@ macro class Component implements ClassDeclarationsMacro, ClassDefinitionMacro {
254254
// For each external method, find the field we declared in the last step,
255255
// and fill in the body of the method to just invoke it.
256256
for (final method in methods) {
257-
if (!method.isExternal) continue;
257+
if (!method.hasExternal) continue;
258258
final methodBuilder = await builder.buildMethod(method.identifier);
259259
final field = fields.firstWhere((field) =>
260260
field.identifier.name == '_${method.identifier.name}Provider');
@@ -278,7 +278,7 @@ macro class Component implements ClassDeclarationsMacro, ClassDefinitionMacro {
278278
final constructors = await builder.constructorsOf(clazz);
279279
final factoryConstructor = constructors.singleWhere((constructor) =>
280280
constructor.isFactory &&
281-
constructor.isExternal &&
281+
constructor.hasExternal &&
282282
constructor.identifier.name == '');
283283
final constructorBuilder =
284284
await builder.buildConstructor(factoryConstructor.identifier);

working/macros/example/pubspec.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: macro_proposal
22
publish_to: none
33
environment:
4-
sdk: ">=3.1.0-0 <4.0.0"
4+
sdk: ">=3.2.0-0 <4.0.0"
55
dev_dependencies:
66
args: ^2.3.0
77
benchmark_harness: ^2.2.1
@@ -15,74 +15,74 @@ dependency_overrides:
1515
git:
1616
url: https://github.com/dart-lang/sdk.git
1717
path: pkg/_fe_analyzer_shared
18-
ref: 3.1.0-327.0.dev
18+
ref: 3.2.0-18.0.dev
1919
_js_interop_checks:
2020
git:
2121
url: https://github.com/dart-lang/sdk.git
2222
path: pkg/_js_interop_checks
23-
ref: 3.1.0-327.0.dev
23+
ref: 3.2.0-18.0.dev
2424
analyzer:
2525
git:
2626
url: https://github.com/dart-lang/sdk.git
2727
path: pkg/analyzer
28-
ref: 3.1.0-327.0.dev
28+
ref: 3.2.0-18.0.dev
2929
build_integration:
3030
git:
3131
url: https://github.com/dart-lang/sdk.git
3232
path: pkg/build_integration
33-
ref: 3.1.0-327.0.dev
33+
ref: 3.2.0-18.0.dev
3434
compiler:
3535
git:
3636
url: https://github.com/dart-lang/sdk.git
3737
path: pkg/compiler
38-
ref: 3.1.0-327.0.dev
38+
ref: 3.2.0-18.0.dev
3939
dart2js_info:
4040
git:
4141
url: https://github.com/dart-lang/sdk.git
4242
path: pkg/dart2js_info
43-
ref: 3.1.0-327.0.dev
43+
ref: 3.2.0-18.0.dev
4444
dev_compiler:
4545
git:
4646
url: https://github.com/dart-lang/sdk.git
4747
path: pkg/dev_compiler
48-
ref: 3.1.0-327.0.dev
48+
ref: 3.2.0-18.0.dev
4949
front_end:
5050
git:
5151
url: https://github.com/dart-lang/sdk.git
5252
path: pkg/front_end
53-
ref: 3.1.0-327.0.dev
53+
ref: 3.2.0-18.0.dev
5454
frontend_server:
5555
git:
5656
url: https://github.com/dart-lang/sdk.git
5757
path: pkg/frontend_server
58-
ref: 3.1.0-327.0.dev
58+
ref: 3.2.0-18.0.dev
5959
js_ast:
6060
git:
6161
url: https://github.com/dart-lang/sdk.git
6262
path: pkg/js_ast
63-
ref: 3.1.0-327.0.dev
63+
ref: 3.2.0-18.0.dev
6464
js_runtime:
6565
git:
6666
url: https://github.com/dart-lang/sdk.git
6767
path: pkg/js_runtime
68-
ref: 3.1.0-327.0.dev
68+
ref: 3.2.0-18.0.dev
6969
js_shared:
7070
git:
7171
url: https://github.com/dart-lang/sdk.git
7272
path: pkg/js_shared
73-
ref: 3.1.0-327.0.dev
73+
ref: 3.2.0-18.0.dev
7474
kernel:
7575
git:
7676
url: https://github.com/dart-lang/sdk.git
7777
path: pkg/kernel
78-
ref: 3.1.0-327.0.dev
78+
ref: 3.2.0-18.0.dev
7979
mmap:
8080
git:
8181
url: https://github.com/dart-lang/sdk.git
8282
path: pkg/mmap
83-
ref: 3.1.0-327.0.dev
83+
ref: 3.2.0-18.0.dev
8484
vm:
8585
git:
8686
url: https://github.com/dart-lang/sdk.git
8787
path: pkg/vm
88-
ref: 3.1.0-327.0.dev
88+
ref: 3.2.0-18.0.dev

0 commit comments

Comments
 (0)