annotations - 如何访问 Dart 注释元数据

标签 annotations dart metadata

了解了这里发生的事情背后的大部分逻辑: 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:reflectablepackage: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/

相关文章:

schema - 如何为 DSpace 创建新的、可搜索的元数据模式?

python - 鹈鹕博客为类别索引页面定义元数据

java - 在方法之前和之后执行代码?

java - 参数 JAXBElement 字符串

dart - 从utf8到latin1

unit-testing - Flutter/Dart 在单元测试中等待几秒钟

grails - Grails如何使用注释来过滤 Controller Action

java - 如何使用PDFBox删除PDF文件中的注释

dart - 正确使用 Dart 变压器

php - PHP自动生成META标签