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

Allow comment introspection #59842

Open
Pebkac03 opened this issue Jan 5, 2025 · 0 comments
Open

Allow comment introspection #59842

Pebkac03 opened this issue Jan 5, 2025 · 0 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. feature-macros Implementation of the macros feature pkg-macros The experimental package:_macros library type-enhancement A request for a change that isn't a bug

Comments

@Pebkac03
Copy link

Pebkac03 commented Jan 5, 2025

Allow comment introspection

I propose adding a property for comments to the Declaration class. I imagine it looking somethings like this:

/// This is the doc comment
final String someVar = 'some value';

void main() {
  // field = the declaration for someVar
  final FieldDeclaration field;
  print(field.comments.toString());
}
dart run
This is the doc comment
Exited.

Usecase

The usecase I have is creating a macro to generate a vscode json-schema file for a config service but I believe access to comments would be very useful in any kind of automatic file generation.

Resources

Implementation of similar functionality in code generation package dartgenerate: https://pub.dev/documentation/dartgenerate/latest/dartgenerate/FieldDeclaration-class.html.

@lrhn lrhn transferred this issue from dart-lang/language Jan 5, 2025
@lrhn lrhn added area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. type-enhancement A request for a change that isn't a bug feature-macros Implementation of the macros feature pkg-macros The experimental package:_macros library labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. feature-macros Implementation of the macros feature pkg-macros The experimental package:_macros library type-enhancement A request for a change that isn't a bug
Projects
Development

No branches or pull requests

2 participants