author | jjg |
Tue, 19 Mar 2013 15:13:44 -0700 | |
changeset 16559 | e927a4e65b0c |
parent 16303 | b5dca0b42963 |
child 17273 | d7ec6654aac9 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
16303
b5dca0b42963
8008267: Add @Supported annotation to com.sun.source types
darcy
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.source.util; |
|
27 |
||
28 |
import com.sun.source.tree.*; |
|
29 |
||
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 |
*/ |
|
16303
b5dca0b42963
8008267: Add @Supported annotation to com.sun.source types
darcy
parents:
5520
diff
changeset
|
38 |
@jdk.Supported |
10 | 39 |
public interface SourcePositions { |
40 |
||
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); |
|
59 |
||
60 |
/** |
|
61 |
* Gets the ending position of tree within file. If tree is not found within |
|
62 |
* file, or if the starting 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); |
|
86 |
||
87 |
} |