编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

宏引用与宏定义同一文件中的符号。:Macro references to symbols in same file as macro definition d

作者: andra-radu 2022-5-12 16:16:34 显示全部楼层 |阅读模式

Macro references to symbols in same file as macro definition don't get discovered.

某人(在这里开始的不一致对话开始)遇到了达多克的错误:

dartdoc:stdout: Generating docs for library services from package:flutter/services.dart...
dartdoc:stderr:   error: unresolved doc reference [onSelectionChanged]
dartdoc:stderr:     from services.TextSelectionDelegate.cutSelection: (file:///b/s/w/ir/x/w/flutter%20sdk/packages/flutter/lib/src/services/text_input.dart:874:8)
dartdoc:stderr:   error: unresolved doc reference [onSelectionChanged]
dartdoc:stderr:     from services.TextSelectionDelegate.pasteText: (file:///b/s/w/ir/x/w/flutter%20sdk/packages/flutter/lib/src/services/text_input.dart:904:16)
dartdoc:stderr:   error: unresolved doc reference [onSelectionChanged]
dartdoc:stderr:     from services.TextSelectionDelegate.selectAll: (file:///b/s/w/ir/x/w/flutter%20sdk/packages/flutter/lib/src/services/text_input.dart:934:8)
dartdoc:stderr:   error: unresolved doc reference [onSelectionChanged]
dartdoc:stderr:     from services.TextSelectionDelegate.copySelection: (file:///b/s/w/ir/x/w/flutter%20sdk/packages/flutter/lib/src/services/text_input.dart:956:8)

(从此构建日志中,此叉中的此PR)

The error is on a line like the line below, that references a macro in a library that would be a layer violation if it referenced it in code, since the flutter.rendering.RenderEditable.cause macro is defined in editable.dart in the widgets library, and it is what contains the reference to the missing onSelectionChanged symbol, which is also in the widgets library (in the same file as the macro). Dartdoc is expanding the macro, but then not finding the symbol. I imagine that Dartdoc knows nothing about Flutter's library layers, but I would have thought it could find the symbol.

  /// Cut current selection to [Clipboard].
  ///
  /// If and only if [cause] is [SelectionChangedCause.toolbar], the toolbar
  /// will be hidden and the current selection will be scrolled into view.
  ///
  /// {@macro flutter.rendering.RenderEditable.cause}
  void cutSelection(SelectionChangedCause cause) {

cc @jcollins-g

该问题来自:dart-lang/dartdoc/issues/2735 , 试试查看该项目更多issue.

问题解答

Amnon Harel 2022-5-12 16:49:39 显示全部楼层

嗯。宏目前仅充当文本扩展,不保留其定义的任何原始上下文。但是对于用户而言,对于宏中定义的符号来说是合理的,可以意识到这种情况。我们要么不应该允许宏定义在源头上(可悲的是,这艘船很可能已经很久以前航行),要么我们应该以某种方式保留对定义背景的知识。

腾讯云服务器 阿里云服务器
关注微信
^