【问题标题】:Dart mirrors reflectss Comments?飞镖镜反映评论?
【发布时间】:2018-03-20 22:03:27
【问题描述】:

在 mirrors.dart 源码中,你可以找到这个:

/**
 * Class used for encoding comments as metadata annotations.
 */
class Comment {
  /**
   * The comment text as written in the source text.
   */
  final String text;

  /**
   * The comment text without the start, end, and padding text.
   *
   * For example, if [text] is [: /** Comment text. */ :] then the [trimmedText]
   * is [: Comment text. :].
   */
  final String trimmedText;

  /**
   * Is [:true:] if this comment is a documentation comment.
   *
   * That is, that the comment is either enclosed in [: /** ... */ :] or starts
   * with [: /// :].
   */
  final bool isDocComment;

  const Comment(this.text, this.trimmedText, this.isDocComment);
}

但是,该类未在其他任何地方使用。 我们如何才能使用该功能?我想反映字段的文档。

【问题讨论】:

    标签: dart dart-mirrors


    【解决方案1】:

    Doc cmets 无法通过dart:mirrors 获得。

    不过,您可以使用 package:analyzer 访问它们。

    https://pub.dartlang.org/documentation/analyzer/0.31.1/analyzer.dart.element.element/Element/documentationComment.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-20
      • 1970-01-01
      • 1970-01-01
      • 2019-03-02
      • 1970-01-01
      相关资源
      最近更新 更多