Is there an infrastructure similar and/or with the same functionality as the Java Annotation Processing Tool (APT) in the Dart Language?

StackOverflow https://stackoverflow.com/questions/22745837

The Java APT includes a set of reflective APIs and supporting infrastructure to process program annotations, and I want to know if there is something similar in Dart.

有帮助吗?

解决方案

You can do something similar with the analyzer package. This package allows you to get the AST or Resolved AST (with types) from sources and navigate inside it.

So yes, you can process source codes like with apt.

其他提示

I have never uses Java APT and did just a very brief Google search
but of what I understand this is already used in several Dart packages.
There are source mirrors, you can reflect on Dart source code without actually running it.
This is usually used in transformers which are executed during the build process.
You can add custom transformers in the the pubspec.yaml configuration file.

This package may be worth a look: http://pub.dartlang.org/packages/smoke
source repository: https://github.com/dart-lang/bleeding_edge/tree/master/dart/pkg/smoke

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top