模块 jdk.compiler

接口 DocSourcePositions

所有父级接口:
SourcePositions

public interface DocSourcePositions extends SourcePositions
提供获取 DocTree 在 javadoc 注释中的位置的方法。位置定义为从 CompilationUnit 开始的简单字符偏移量,其中第一个字符位于偏移量 0。
自从:
1.8
  • 方法详情

    • getStartPosition

      long getStartPosition(CompilationUnitTree  file, DocCommentTree  comment, DocTree  tree)
      返回文件中注释中树的起始位置。如果在文件中找不到树,或者起始位置不可用,则返回 Diagnostic.NOPOS 。给定的树应该在给定的评论树下,给定的文档评论树应该从给定文件下的树的 DocTrees.getDocCommentTree(com.sun.source.util.TreePath) 返回。返回的位置必须在这棵树的 yield 开始处,即对于这棵树的任何子树,必须满足以下条件:

      getStartPosition(file, comment, tree) <= getStartPosition(file, comment, subtree)
      getStartPosition(file, comment, tree) == NOPOS
      getStartPosition(file, comment, subtree) == NOPOS

      参数:
      file - 在其中查找树的编译单元
      comment - 包含正在为其寻找位置的树的评论树
      tree - 寻找位置的树
      返回:
      树的起始位置
    • getEndPosition

      long getEndPosition(CompilationUnitTree  file, DocCommentTree  comment, DocTree  tree)
      返回文件中注释中树的结束位置。如果在文件中找不到树,或者结束位置不可用,则返回 Diagnostic.NOPOS 。给定的树应该在给定的评论树下,给定的文档评论树应该从给定文件下的树的 DocTrees.getDocCommentTree(com.sun.source.util.TreePath) 返回。返回的位置必须在这棵树的 yield 的末尾,即对于这棵树的任何子树,必须满足以下条件:

      getEndPosition(file, comment, tree) >= getEndPosition(file, comment, subtree)
      getEndPosition(file, comment, tree) == NOPOS
      getEndPosition(file, comment, subtree) == NOPOS

      此外,必须满足以下条件:

      getStartPosition(file, comment, tree) <= getEndPosition(file, comment, tree)
      getStartPosition(file, comment, tree) == NOPOS
      getEndPosition(file, comment, tree) == NOPOS

      参数:
      file - 在其中查找树的编译单元
      comment - 包含正在为其寻找位置的树的评论树
      tree - 寻找位置的树
      返回:
      树的结束位置