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

How to access metadata of Named Fields in a RecordType using Dart Analyzer? #59817

Open
jodinathan opened this issue Dec 28, 2024 · 1 comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-question A question about expected behavior or functionality

Comments

@jodinathan
Copy link

I asked at SO before coming here.

I am working on a Dart builder and need to inspect the metadata (annotations) applied to the named fields of a RecordType. However, while I can successfully access RecordType.namedFields, the resulting RecordTypeNamedField objects do not appear to expose any metadata-related members.

Here is an example of the code I am trying to analyze:

Future<({@SomeAnnotation() String foo, int bar})?> someFunction() async {
  return null;
}

In this case, I need to determine programmatically that the foo field is annotated with @SomeAnnotation.

My Setup:
Dart SDK: 3.6.0
Analyzer version: 6.11.0

Question:
How can I access the metadata (annotations) of a named field in a RecordType using Dart's analyzer package in the context of a builder? Is there a specific API or workaround to achieve this?

@dart-github-bot
Copy link
Collaborator

Summary: User needs to access metadata (annotations) on named fields within a Dart RecordType using the analyzer package for a Dart builder. Currently, RecordTypeNamedField lacks necessary metadata access.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-question A question about expected behavior or functionality labels Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

2 participants