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

Pergunta

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.

Foi útil?

Solução

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.

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top