了解了这里发生的事情背后的大部分逻辑: How to create our own metadata in Dart?
除了一件事。注释@column
放在属性String name
之上,但我没有捕获这个关系是如何获得的,String Person.name的信息在哪里
定位/访问过?
Dart-polymer 0.x 使用这种密集型。属性被标记为与 @property
绑定(bind)。
https://github.com/dart-lang/polymer-dart/blob/master/lib/src/common/property.dart#L29
https://github.com/dart-lang/polymer-dart/wiki/properties
所以它有效,研究 Dart 聚合物来源并没有给我太多线索。
最佳答案
通常,package:analyzer
用来。您最终将为涉及静态分析 Dart 代码的大多数函数编写自定义访问者。如果你看Polymer transformer source ,你会看到它使用 package:reflectable和 package:web_components
,两个使用静态分析的变压器。
https://github.com/dart-lang/web-components/blob/master/lib/transformer.dart
https://github.com/dart-lang/reflectable/blob/master/reflectable/lib/transformer.dart
关于annotations - 如何访问 Dart 注释元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42959207/