@@ -7,34 +7,132 @@ import 'introspection.dart';
7
7
abstract class Macro {}
8
8
9
9
/// The interface for [Macro] s that can be applied to any top level function,
10
- /// instance method, or static method.
11
- abstract class FunctionMacro implements Macro {
12
- /// Invoked for any function that is annotated with this macro.
13
- FutureOr <void > visitFunction (
14
- FunctionDeclaration function, FunctionContext context );
10
+ /// instance method, or static method, and wants to contribute new type
11
+ /// declarations to the program.
12
+ abstract class FunctionTypesMacro implements Macro {
13
+ FutureOr <void > buildTypesForFunction (
14
+ FunctionDeclaration function, TypeBuilder builder );
15
15
}
16
16
17
- /// The interface for [Macro] s that can be applied to classes.
18
- abstract class ClassMacro implements Macro {
19
- /// Invoked for any class that is annotated with this macro.
20
- FutureOr <void > visitClass (ClassDeclaration clazz, ClassContext context);
17
+ /// The interface for [Macro] s that can be applied to any top level function,
18
+ /// instance method, or static method, and wants to contribute new non-type
19
+ /// declarations to the program.
20
+ abstract class FunctionDeclarationsMacro implements Macro {
21
+ FutureOr <void > buildDeclarationsForFunction (
22
+ FunctionDeclaration function, DeclarationBuilder builder);
23
+ }
24
+
25
+ /// The interface for [Macro] s that can be applied to any top level function,
26
+ /// instance method, or static method, and wants to augment the function
27
+ /// definition.
28
+ abstract class FunctionDefinitionMacro implements Macro {
29
+ FutureOr <void > buildDefinitionForFunction (
30
+ FunctionDeclaration function, FunctionDefinitionBuilder builder);
31
+ }
32
+
33
+ /// The interface for [Macro] s that can be applied to any top level variable or
34
+ /// instance field, and wants to contribute new type declarations to the
35
+ /// program.
36
+ abstract class VariableTypesMacro implements Macro {
37
+ FutureOr <void > buildTypesForVariable (
38
+ VariableDeclaration variable, TypeBuilder builder);
39
+ }
40
+
41
+ /// The interface for [Macro] s that can be applied to any top level variable or
42
+ /// instance field and wants to contribute new non-type declarations to the
43
+ /// program.
44
+ abstract class VariableDeclarationsMacro implements Macro {
45
+ FutureOr <void > buildDeclarationsForVariable (
46
+ VariableDeclaration variable, DeclarationBuilder builder);
47
+ }
48
+
49
+ /// The interface for [Macro] s that can be applied to any top level variable
50
+ /// or instance field, and wants to augment the variable definition.
51
+ abstract class VariableDefinitionMacro implements Macro {
52
+ FutureOr <void > buildDefinitionForFunction (
53
+ VariableDeclaration variable, VariableDefinitionBuilder builder);
54
+ }
55
+
56
+ /// The interface for [Macro] s that can be applied to any class, and wants to
57
+ /// contribute new type declarations to the program.
58
+ abstract class ClassTypesMacro implements Macro {
59
+ FutureOr <void > buildTypesForClass (
60
+ ClassDeclaration clazz, TypeBuilder builder);
61
+ }
62
+
63
+ /// The interface for [Macro] s that can be applied to any class, and wants to
64
+ /// contribute new non-type declarations to the program.
65
+ abstract class ClassDeclarationsMacro implements Macro {
66
+ FutureOr <void > buildDeclarationsForClass (
67
+ ClassDeclaration clazz, ClassDeclarationBuilder builder);
68
+ }
69
+
70
+ /// The interface for [Macro] s that can be applied to any class, and wants to
71
+ /// augment the definitions of members on the class.
72
+ abstract class ClassDefinitionMacro implements Macro {
73
+ FutureOr <void > buildDefinitionForClass (
74
+ ClassDeclaration clazz, ClassDefinitionBuilder builder);
75
+ }
76
+
77
+ /// The interface for [Macro] s that can be applied to any field, and wants to
78
+ /// contribute new type declarations to the program.
79
+ abstract class FieldTypesMacro implements Macro {
80
+ FutureOr <void > buildTypesForField (
81
+ FieldDeclaration field, TypeBuilder builder);
82
+ }
83
+
84
+ /// The interface for [Macro] s that can be applied to any field, and wants to
85
+ /// contribute new type declarations to the program.
86
+ abstract class FieldDeclarationsMacro implements Macro {
87
+ FutureOr <void > buildTypesForField (
88
+ FieldDeclaration field, ClassMemberDeclarationBuilder builder);
89
+ }
90
+
91
+ /// The interface for [Macro] s that can be applied to any field, and wants to
92
+ /// augement the field definition.
93
+ abstract class FieldDefinitionsMacro implements Macro {
94
+ FutureOr <void > buildDefinitionForField (
95
+ FieldDeclaration field, VariableDefinitionBuilder builder);
96
+ }
97
+
98
+ /// The interface for [Macro] s that can be applied to any method, and wants to
99
+ /// contribute new type declarations to the program.
100
+ abstract class MethodTypesMacro implements Macro {
101
+ FutureOr <void > buildTypesForMethod (
102
+ MethodDeclaration method, TypeBuilder builder);
103
+ }
104
+
105
+ /// The interface for [Macro] s that can be applied to any method, and wants to
106
+ /// contribute new non-type declarations to the program.
107
+ abstract class MethodDeclarationDeclarationsMacro implements Macro {
108
+ FutureOr <void > buildDeclarationsForMethod (
109
+ MethodDeclaration method, ClassMemberDeclarationBuilder builder);
110
+ }
111
+
112
+ /// The interface for [Macro] s that can be applied to any method, and wants to
113
+ /// augment the function definition.
114
+ abstract class MethodDefinitionMacro implements Macro {
115
+ FutureOr <void > buildDefinitionForMethod (
116
+ MethodDeclaration method, FunctionDefinitionBuilder builder);
21
117
}
22
118
23
- /// The interface for [Macro] s that can be applied to fields.
24
- abstract class FieldMacro implements Macro {
25
- /// Invoked for any field that is annotated with this macro
26
- FutureOr <void > visitField (FieldDeclaration field, FieldContext context);
119
+ /// The interface for [Macro] s that can be applied to any constructor, and wants
120
+ /// to contribute new type declarations to the program.
121
+ abstract class ConstructorTypesMacro implements Macro {
122
+ FutureOr <void > buildTypesForConstructor (
123
+ ConstructorDeclaration method, TypeBuilder builder);
27
124
}
28
125
29
- /// The interface for [Macro] s that can be applied to methods.
30
- abstract class MethodMacro implements Macro {
31
- /// Invoked for any method that is annotated with this macro.
32
- FutureOr <void > visitMethod (MethodDeclaration method, MethodContext context);
126
+ /// The interface for [Macro] s that can be applied to any constructors, and
127
+ /// wants to contribute new non-type declarations to the program.
128
+ abstract class ConstructorDeclarationDeclarationsMacro implements Macro {
129
+ FutureOr <void > buildDeclarationsForConstructor (
130
+ ConstructorDeclaration method, ClassMemberDeclarationBuilder builder);
33
131
}
34
132
35
- /// The interface for [Macro] s that can be applied to constructors.
36
- abstract class ConstructorMacro implements Macro {
37
- /// Invoked for each constructor annotated with this macro.
38
- FutureOr <void > visitConstructor (
39
- ConstructorDeclaration constructor, ConstructorContext context );
133
+ /// The interface for [Macro] s that can be applied to any constructor, and wants
134
+ /// to augment the function definition.
135
+ abstract class ConstructorDefinitionMacro implements Macro {
136
+ FutureOr <void > buildDefinitionForConstructor (
137
+ ConstructorDeclaration method, ConstructorDefinitionBuilder builder );
40
138
}
0 commit comments