-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect up augmentations from macro output through to host. #21
Conversation
a5287c5
to
81605eb
Compare
2a1e96e
to
5fd74ba
Compare
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.
Sorry apparently I never actually send my review comments from last week, now they are on outdated commits I think due to the force push but lets see if it does anything reasonable...
final augmentRequest = | ||
AugmentRequest.fromJson(json.decode(request) as Map<String, Object?>); | ||
// TODO(davidmorgan): support multiple macros. | ||
final response = await macros.single.augment(host, augmentRequest); |
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.
Related to my comment in the previous PR but I don't think this is the correct API for us to expose, it is too low level. I would like to see macros look more like they do in the current API.
Also, I think this makes merging augmentations from multiple macros together more difficult, which is partly why the augmentation library generation is done by the host right now and not the macro.
pkgs/_macro_host/lib/macro_host.dart
Outdated
@@ -61,18 +66,35 @@ class MacroHost implements MacroService { | |||
return _macroPhases!; | |||
} | |||
|
|||
/// Sends it [request] to the macro with [name]. |
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.
/// Sends it [request] to the macro with [name]. | |
/// Sends [request] to the macro with [name]. |
}); | ||
|
||
/// Augmentation code. | ||
String get code => node['code'] as String; |
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.
It seems wrong that this assumes code
exists, but the constructor does not require it to be non-null. Should this be typed as String?
? Similar question for below.
|
||
@override | ||
SyncJsonProvider get provide => (String path) { | ||
if (path != 'file:///dart_model.schema.json') { |
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.
should we have a custom scheme for this?
@@ -12,7 +12,10 @@ void main() { | |||
for (final package in ['dart_model', 'macro_service']) { | |||
test('$package output is up to date', () { | |||
final expected = dart_model_generator.generate( | |||
File('../../schemas/$package.schema.json').readAsStringSync()); | |||
File('../../schemas/$package.schema.json').readAsStringSync(), | |||
importDartModel: package == 'macro_service', |
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.
It would be good if we could somehow make this a more general thing, similar to how it works in protos where the dependencies live in the schema file. Is there an eventual path towards that?
08f457e
to
7d757a2
Compare
Thanks, PTAL. |
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.
Feel free to leave TODOs for anything outstanding so we can get out of the chained PR state :)
pkgs/_macro_host/lib/macro_host.dart
Outdated
throw StateError('request is already pending'); | ||
} | ||
_responseCompleter = Completer<AugmentResponse>(); | ||
final result = await _responseCompleter!.future; |
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.
Does this local variable here actually do anything? Maybe you are getting type promotion actually since its private so you don't need this (since the completer has a more specific type?).
What I actually had in mind was assigning the completer to a local variable (as well as the field) and returning the future from the local variable since it would have a better type. But if the promotion works here that is better.
Hook up macro augmentation output end to end.
Add the capability to reference the
dart_model
schema from themacro_service
schema, becauseAugmentation
is indart_model
.The wire format still does not carry the actual request type because it's not needed yet, there are few enough request types to always "guess" correctly. It will need the request type very soon :)