-
Notifications
You must be signed in to change notification settings - Fork 7
Add LiteralParams macro. #128
Conversation
9f42d0c to
93e83c0
Compare
93e83c0 to
20694d0
Compare
Fix converter for lists of union types.
20694d0 to
c7e40bf
Compare
| "expression": { | ||
| "type": "IntegerLiteral", | ||
| "value": { | ||
| "text": "23" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've update the BooleanLiteral, IntegerLiteral and DoubleLiteral to hold their primitive value where possible (ints are a bit weird). It might be good to pass that along - in particular since evaluation (coming shortly) will only provide the value and not the text.
| // TODO(davidmorgan): common code for this in `dart_model` so macros don't | ||
| // all have to write expression evaluation code. | ||
| extension ExpressionExtension on Expression { | ||
| Object get evaluate => switch (type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done more extensively in https://dart-review.googlesource.com/c/sdk/+/392440
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I expect we need a higher level discussion soon to figure out where all this is headed. Or one of us could throw some thoughts on an issue/doc.
No rush though, going to push on the other tracks (performance, data model) a bit next. Thanks.
| Future<void> buildDeclarationsForClass( | ||
| ClassDeclarationsBuilder builder) async { | ||
| final annotation = builder | ||
| .target.metadataAnnotations.first.expression.asConstructorInvocation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a TODO for checking the type of the annotation (in practice you will want to search for a specific one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks! Done.
davidmorgan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
| Future<void> buildDeclarationsForClass( | ||
| ClassDeclarationsBuilder builder) async { | ||
| final annotation = builder | ||
| .target.metadataAnnotations.first.expression.asConstructorInvocation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks! Done.
| // TODO(davidmorgan): common code for this in `dart_model` so macros don't | ||
| // all have to write expression evaluation code. | ||
| extension ExpressionExtension on Expression { | ||
| Object get evaluate => switch (type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I expect we need a higher level discussion soon to figure out where all this is headed. Or one of us could throw some thoughts on an issue/doc.
No rush though, going to push on the other tracks (performance, data model) a bit next. Thanks.
Fix converter for lists of union types.
This macro shows the use case where the macro metadata is written entirely in the annotation.
Mostly works already, just missing constructor invocation names.