Skip to content

Commit 5c77a5d

Browse files
committed
stop ignoring some macro examples that work, add const constructors
1 parent 0bd1fed commit 5c77a5d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

working/macros/example/analysis_options.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ analyzer:
66
exclude:
77
# TODO: remove these when the analyzer supports macros enough to run them
88
- bin/checks_main.dart
9-
- bin/injectable_main.dart
10-
- bin/json_serializable_main.dart
11-
- bin/observable_main.dart

working/macros/example/lib/injectable.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ macro class Provides implements MethodDeclarationsMacro {
129129
name: providerIdentifier, typeArguments: [param.type.code]),
130130
' provide${param.identifier.name.capitalize}, ',
131131
],
132-
') => ',
132+
') => () => ',
133133
method.identifier,
134134
'(',
135135
for (final param in method.positionalParameters)

working/macros/example/lib/json_serializable.dart

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ macro class JsonSerializable implements ClassDeclarationsMacro {
5050

5151
/// A macro applied to a fromJson constructor, which fills in the initializer list.
5252
macro class FromJson implements ConstructorDefinitionMacro {
53+
const FromJson();
54+
5355
@override
5456
Future<void> buildDefinitionForConstructor(ConstructorDeclaration constructor,
5557
ConstructorDefinitionBuilder builder) async {
@@ -129,6 +131,8 @@ macro class FromJson implements ConstructorDefinitionMacro {
129131

130132
/// A macro applied to a toJson instance method, which fills in the body.
131133
macro class ToJson implements MethodDefinitionMacro {
134+
const ToJson();
135+
132136
@override
133137
Future<void> buildDefinitionForMethod(
134138
MethodDeclaration method, FunctionDefinitionBuilder builder) async {

0 commit comments

Comments
 (0)