質問

I'm new to the Dart language, and I'm trying to find out a way to parse Dart programs.

What I would like to accomplish with this is to implement a tool that would rewrite a program with fields that have metadata annotations, and replace all direct annotated field accesses and modifications with getter and setter methods, respectively. For that, I need to be able to parse Dart programs.

I've been looking in the Dart documentation and online, but was unable to find anything useful, as all of my search results for "dart parse programs" and other similar queries have returned results about the parse() methods for Numbers and URIs, and other unrelated stuff. Maybe I'm not using the right keywords for this searching. Any help would be really appreciated.

Thanks for all the help in advance.

役に立ちましたか?

解決

You can use the analyzer package.

See also Code generator for dart .

他のヒント

Several transformers already do something similar (for example generating code to replace reflection/mirrors usage). Maybe you can find some useful information in one of them (I didn't find the source very educational but didn't take a close look yet)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top