문제

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