author | jlahoda |
Mon, 01 Apr 2019 14:46:17 +0200 | |
branch | jlahoda-tree-builder |
changeset 57298 | 72d5f7163f12 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
1 |
/* |
25287 | 2 |
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
4 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
10 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
15 |
* accompanied this code). |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
16 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
20 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
23 |
* questions. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
24 |
*/ |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
25 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
26 |
package com.sun.source.util; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
27 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
28 |
import com.sun.source.doctree.DocCommentTree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
29 |
import com.sun.source.doctree.DocTree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
30 |
import com.sun.source.tree.CompilationUnitTree; |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
31 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
32 |
/** |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
33 |
* Provides methods to obtain the position of a DocTree within a javadoc comment. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
34 |
* A position is defined as a simple character offset from the start of a |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
35 |
* CompilationUnit where the first character is at offset 0. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
36 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
37 |
* @since 1.8 |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
38 |
*/ |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
39 |
public interface DocSourcePositions extends SourcePositions { |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
40 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
41 |
/** |
25287 | 42 |
* Returns the starting position of the tree within the comment within the file. If tree is not found within |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
43 |
* file, or if the starting position is not available, |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
44 |
* return {@link javax.tools.Diagnostic#NOPOS}. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
45 |
* The given tree should be under the given comment tree, and the given documentation |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
46 |
* comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) } |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
47 |
* for a tree under the given file. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
48 |
* The returned position must be at the start of the yield of this tree, that |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
49 |
* is for any sub-tree of this tree, the following must hold: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
50 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
51 |
* <p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
52 |
* {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
53 |
* {@code tree.getStartPosition() == NOPOS} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
54 |
* {@code subtree.getStartPosition() == NOPOS} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
55 |
* </p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
56 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
57 |
* @param file CompilationUnit in which to find tree. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
58 |
* @param comment the comment tree that encloses the tree for which the |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
59 |
* position is being sought |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
60 |
* @param tree tree for which a position is sought. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
61 |
* @return the start position of tree. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
62 |
*/ |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
63 |
long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
64 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
65 |
/** |
25287 | 66 |
* Returns the ending position of the tree within the comment within the file. If tree is not found within |
17273
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
67 |
* file, or if the ending position is not available, |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
68 |
* return {@link javax.tools.Diagnostic#NOPOS}. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
69 |
* The given tree should be under the given comment tree, and the given documentation |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
70 |
* comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) } |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
71 |
* for a tree under the given file. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
72 |
* The returned position must be at the end of the yield of this tree, |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
73 |
* that is for any sub-tree of this tree, the following must hold: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
74 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
75 |
* <p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
76 |
* {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
77 |
* {@code tree.getEndPosition() == NOPOS} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
78 |
* {@code subtree.getEndPosition() == NOPOS} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
79 |
* </p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
80 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
81 |
* In addition, the following must hold: |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
82 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
83 |
* <p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
84 |
* {@code tree.getStartPosition() <= tree.getEndPosition()} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
85 |
* {@code tree.getStartPosition() == NOPOS} or <br> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
86 |
* {@code tree.getEndPosition() == NOPOS} |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
87 |
* </p> |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
88 |
* |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
89 |
* @param file CompilationUnit in which to find tree. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
90 |
* @param comment the comment tree that encloses the tree for which the |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
91 |
* position is being sought |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
92 |
* @param tree tree for which a position is sought. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
93 |
* @return the start position of tree. |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
94 |
*/ |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
95 |
long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree); |
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
96 |
|
d7ec6654aac9
8008174: DocTree API should provide start and end positions for tree nodes
jlahoda
parents:
diff
changeset
|
97 |
} |