0N/A/*
553N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.source.util;
0N/A
0N/Aimport com.sun.source.tree.*;
0N/A
0N/A/**
0N/A * Provides methods to obtain the position of a Tree within a CompilationUnit.
0N/A * A position is defined as a simple character offset from the start of a
0N/A * CompilationUnit where the first character is at offset 0.
0N/A *
0N/A * @author Peter von der Ahé
0N/A * @since 1.6
0N/A */
0N/Apublic interface SourcePositions {
0N/A
0N/A /**
0N/A * Gets the starting position of tree within file. If tree is not found within
0N/A * file, or if the starting position is not available,
0N/A * return {@link javax.tools.Diagnostic#NOPOS}.
0N/A * The returned position must be at the start of the yield of this tree, that
0N/A * is for any sub-tree of this tree, the following must hold:
0N/A *
0N/A * <p>
0N/A * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
0N/A * {@code tree.getStartPosition() == NOPOS} or <br>
0N/A * {@code subtree.getStartPosition() == NOPOS}
0N/A * </p>
0N/A *
0N/A * @param file CompilationUnit in which to find tree.
0N/A * @param tree tree for which a position is sought.
0N/A * @return the start position of tree.
0N/A */
0N/A long getStartPosition(CompilationUnitTree file, Tree tree);
0N/A
0N/A /**
0N/A * Gets the ending position of tree within file. If tree is not found within
0N/A * file, or if the starting position is not available,
0N/A * return {@link javax.tools.Diagnostic#NOPOS}.
0N/A * The returned position must be at the end of the yield of this tree,
0N/A * that is for any sub-tree of this tree, the following must hold:
0N/A *
0N/A * <p>
0N/A * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
0N/A * {@code tree.getEndPosition() == NOPOS} or <br>
0N/A * {@code subtree.getEndPosition() == NOPOS}
0N/A * </p>
0N/A *
0N/A * In addition, the following must hold:
0N/A *
0N/A * <p>
0N/A * {@code tree.getStartPosition() <= tree.getEndPosition()} or <br>
0N/A * {@code tree.getStartPosition() == NOPOS} or <br>
0N/A * {@code tree.getEndPosition() == NOPOS}
0N/A * </p>
0N/A *
0N/A * @param file CompilationUnit in which to find tree.
0N/A * @param tree tree for which a position is sought.
0N/A * @return the end position of tree.
0N/A */
0N/A long getEndPosition(CompilationUnitTree file, Tree tree);
0N/A
0N/A}