Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java
38899 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.source.util;2627import com.sun.source.doctree.DocCommentTree;28import com.sun.source.doctree.DocTree;29import com.sun.source.tree.CompilationUnitTree;3031/**32* Provides methods to obtain the position of a DocTree within a javadoc comment.33* A position is defined as a simple character offset from the start of a34* CompilationUnit where the first character is at offset 0.35*36* @since 1.837*/38@jdk.Exported39public interface DocSourcePositions extends SourcePositions {4041/**42* Gets the starting position of the tree within the comment within the file. If tree is not found within43* file, or if the starting position is not available,44* return {@link javax.tools.Diagnostic#NOPOS}.45* The given tree should be under the given comment tree, and the given documentation46* comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }47* for a tree under the given file.48* The returned position must be at the start of the yield of this tree, that49* is for any sub-tree of this tree, the following must hold:50*51* <p>52* {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>53* {@code tree.getStartPosition() == NOPOS} or <br>54* {@code subtree.getStartPosition() == NOPOS}55* </p>56*57* @param file CompilationUnit in which to find tree.58* @param comment the comment tree that encloses the tree for which the59* position is being sought60* @param tree tree for which a position is sought.61* @return the start position of tree.62*/63long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);6465/**66* Gets the ending position of the tree within the comment within the file. If tree is not found within67* file, or if the ending position is not available,68* return {@link javax.tools.Diagnostic#NOPOS}.69* The given tree should be under the given comment tree, and the given documentation70* comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }71* for a tree under the given file.72* The returned position must be at the end of the yield of this tree,73* that is for any sub-tree of this tree, the following must hold:74*75* <p>76* {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>77* {@code tree.getEndPosition() == NOPOS} or <br>78* {@code subtree.getEndPosition() == NOPOS}79* </p>80*81* In addition, the following must hold:82*83* <p>84* {@code tree.getStartPosition() <= tree.getEndPosition()} or <br>85* {@code tree.getStartPosition() == NOPOS} or <br>86* {@code tree.getEndPosition() == NOPOS}87* </p>88*89* @param file CompilationUnit in which to find tree.90* @param comment the comment tree that encloses the tree for which the91* position is being sought92* @param tree tree for which a position is sought.93* @return the start position of tree.94*/95long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);9697}9899100