Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/source/util/SourcePositions.java
38899 views
/*1* Copyright (c) 2005, 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.tree.*;2829/**30* Provides methods to obtain the position of a Tree within a CompilationUnit.31* A position is defined as a simple character offset from the start of a32* CompilationUnit where the first character is at offset 0.33*34* @author Peter von der Ahé35* @since 1.636*/37@jdk.Exported38public interface SourcePositions {3940/**41* Gets the starting position of tree within file. If tree is not found within42* file, or if the starting position is not available,43* return {@link javax.tools.Diagnostic#NOPOS}.44* The returned position must be at the start of the yield of this tree, that45* is for any sub-tree of this tree, the following must hold:46*47* <p>48* {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>49* {@code tree.getStartPosition() == NOPOS} or <br>50* {@code subtree.getStartPosition() == NOPOS}51* </p>52*53* @param file CompilationUnit in which to find tree.54* @param tree tree for which a position is sought.55* @return the start position of tree.56*/57long getStartPosition(CompilationUnitTree file, Tree tree);5859/**60* Gets the ending position of tree within file. If tree is not found within61* file, or if the ending position is not available,62* return {@link javax.tools.Diagnostic#NOPOS}.63* The returned position must be at the end of the yield of this tree,64* that is for any sub-tree of this tree, the following must hold:65*66* <p>67* {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>68* {@code tree.getEndPosition() == NOPOS} or <br>69* {@code subtree.getEndPosition() == NOPOS}70* </p>71*72* In addition, the following must hold:73*74* <p>75* {@code tree.getStartPosition() <= tree.getEndPosition()} or <br>76* {@code tree.getStartPosition() == NOPOS} or <br>77* {@code tree.getEndPosition() == NOPOS}78* </p>79*80* @param file CompilationUnit in which to find tree.81* @param tree tree for which a position is sought.82* @return the end position of tree.83*/84long getEndPosition(CompilationUnitTree file, Tree tree);8586}878889