Skip to content
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

Add an analysis_server binary with dart_model implementation injected #120

Merged
merged 3 commits into from
Oct 29, 2024

Conversation

davidmorgan
Copy link
Contributor

There are definitely some correctness issues, in particular it looks like the cached results from with no macro impl injected prevent macros running, so I had to add some change to trigger macros.

But it does work interactively on e.g. json_codable_test.dart.

/// Only works for one path, see `packageConfig` path hardcoded below.
void main(List<String> args) async {
final home = Platform.environment['HOME']!;
injected.macroImplementation = await AnalyzerMacroImplementation.start(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious how we are going to handle enabling/disabling this in general?

If we are going to attempt to support old and new macros together, then the way we are injecting things right now won't really work, because it is a global setting, and you might have multiple projects open with different macro implementations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure I wrote a reply to this, not sure where it went...

My expectation is that we'll switch from one to the other without supporting both, and possibly with some downtime in between when we support neither.

It would be more work+complexity to support both for external users, e.g. we'd have to do something about package:macros being used in two different ways, or use two different packages.

For our own use for development I guess one or the other is enough, or we can add something more fine-grained if needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An atomic switch will probably be a bit tricky given all the tests which work with the existing API as well as the JSON macro (which lives in the SDK but we could move it out which might help).

It might still be the easiest answer though.

Copy link
Contributor Author

@davidmorgan davidmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, PTAL.

pkgs/_analyzer_macros/bin/server.dart Outdated Show resolved Hide resolved
@davidmorgan davidmorgan merged commit f160360 into dart-lang:main Oct 29, 2024
47 checks passed
@davidmorgan davidmorgan deleted the analyzer-bin branch October 29, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants