- 所有父级接口:
SourcePositions
提供获取 DocTree 在 javadoc 注释中的位置的方法。位置定义为从 CompilationUnit 开始的简单字符偏移量,其中第一个字符位于偏移量 0。
- 自从:
- 1.8
-
方法总结
修饰符和类型方法描述longgetEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) 返回文件中注释中树的结束位置。longgetStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) 返回文件中注释中树的起始位置。在接口 com.sun.source.util.SourcePositions 中声明的方法
getEndPosition, getStartPosition
-
方法详情
-
getStartPosition
返回文件中注释中树的起始位置。如果在文件中找不到树,或者起始位置不可用,则返回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
返回文件中注释中树的结束位置。如果在文件中找不到树,或者结束位置不可用,则返回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) == NOPOSgetStartPosition(file, comment, tree) <= getEndPosition(file, comment, tree)或getStartPosition(file, comment, tree) == NOPOS或getEndPosition(file, comment, tree) == NOPOS- 参数:
file- 在其中查找树的编译单元comment- 包含正在为其寻找位置的树的评论树tree- 寻找位置的树- 返回:
- 树的结束位置
-