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

Support macros when analyzer is used as a library #56102

Closed
davidmorgan opened this issue Jun 28, 2024 · 5 comments
Closed

Support macros when analyzer is used as a library #56102

davidmorgan opened this issue Jun 28, 2024 · 5 comments
Assignees
Labels
analyzer-api Issues that impact the public API of the analyzer package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P3 A lower priority bug or feature request

Comments

@davidmorgan
Copy link
Contributor

I noticed that ContextBuilder currently passes through null macroSupport by default, with no way to provide one. (Unless you cast to ContextBuilderImpl).

So people using the analyzer as a library and using ContextBuilder will currently get no macros.

As discussed we probably want macros to work with some reasonable default settings "out of the box".

So, here is an issue for that :)

@davidmorgan davidmorgan added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature labels Jun 28, 2024
@davidmorgan
Copy link
Contributor Author

A hint for anyone else who's trying this: make sure you pass in KernelMacroSupport() and not MacroSupport() :)

Which is a good reminder that we'll have to think about different ways the code could be running.

@keertip keertip added the analyzer-api Issues that impact the public API of the analyzer package label Jul 8, 2024
@keertip
Copy link
Contributor

keertip commented Jul 8, 2024

@bwilkerson , @scheglov

@keertip keertip added the P3 A lower priority bug or feature request label Jul 8, 2024
@bwilkerson
Copy link
Member

While I agree that we need this longer term, I think there's work that needs to be done first before we support this kind of usage. Minimally we need to do some API design work.

@scheglov scheglov self-assigned this Jul 8, 2024
@scheglov
Copy link
Contributor

scheglov commented Jul 8, 2024

tl;dr we do support macros

People using package:analyzer/dart/analysis/context_builder.dart should migrate to AnalysisContextCollection, which provides default way to run macros.

macroSupportFactory ??= KernelMacroSupportFactory();

In general, ContextBuilder is an older attempt to API, and should be removed.

@scheglov scheglov closed this as completed Jul 8, 2024
@davidmorgan
Copy link
Contributor Author

Thanks @scheglov, it did occur to me that there are probably multiple ways to set up the analyzer as a library, which might handle macros differently today. That's fine.

For the macros launch do you think it should be / will be the case that all ways to set up the analyzer support macros by default? e.g. do you think ContextBuilder will be removed by then? Thanks.

copybara-service bot pushed a commit that referenced this issue Jul 15, 2024
Bug: #56102
Change-Id: I06a53805514655fa01e962bbc98255b5e70f3ed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
copybara-service bot pushed a commit that referenced this issue Jul 15, 2024
Bug: #56102
Change-Id: Ia55b978571e412ea7b6b7c4b6cc482f731ecdc1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375760
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-api Issues that impact the public API of the analyzer package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-macros Implementation of the macros feature P3 A lower priority bug or feature request
Projects
Development

No branches or pull requests

4 participants