Fri, 04 Oct 2013 10:00:28 -0700
8025913: Rename jdk.Supported to jdk.Exported
Reviewed-by: psandoz, forax, lancea, alanb, mchung, jjg
1 /*
2 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.source.util;
28 import com.sun.source.tree.*;
30 /**
31 * Provides methods to obtain the position of a Tree within a CompilationUnit.
32 * A position is defined as a simple character offset from the start of a
33 * CompilationUnit where the first character is at offset 0.
34 *
35 * @author Peter von der Ahé
36 * @since 1.6
37 */
38 @jdk.Exported
39 public interface SourcePositions {
41 /**
42 * Gets the starting position of tree within file. If tree is not found within
43 * file, or if the starting position is not available,
44 * return {@link javax.tools.Diagnostic#NOPOS}.
45 * The returned position must be at the start of the yield of this tree, that
46 * is for any sub-tree of this tree, the following must hold:
47 *
48 * <p>
49 * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
50 * {@code tree.getStartPosition() == NOPOS} or <br>
51 * {@code subtree.getStartPosition() == NOPOS}
52 * </p>
53 *
54 * @param file CompilationUnit in which to find tree.
55 * @param tree tree for which a position is sought.
56 * @return the start position of tree.
57 */
58 long getStartPosition(CompilationUnitTree file, Tree tree);
60 /**
61 * Gets the ending position of tree within file. If tree is not found within
62 * file, or if the ending position is not available,
63 * return {@link javax.tools.Diagnostic#NOPOS}.
64 * The returned position must be at the end of the yield of this tree,
65 * that is for any sub-tree of this tree, the following must hold:
66 *
67 * <p>
68 * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
69 * {@code tree.getEndPosition() == NOPOS} or <br>
70 * {@code subtree.getEndPosition() == NOPOS}
71 * </p>
72 *
73 * In addition, the following must hold:
74 *
75 * <p>
76 * {@code tree.getStartPosition() <= tree.getEndPosition()} or <br>
77 * {@code tree.getStartPosition() == NOPOS} or <br>
78 * {@code tree.getEndPosition() == NOPOS}
79 * </p>
80 *
81 * @param file CompilationUnit in which to find tree.
82 * @param tree tree for which a position is sought.
83 * @return the end position of tree.
84 */
85 long getEndPosition(CompilationUnitTree file, Tree tree);
87 }