author | darcy |
Tue, 19 Feb 2013 00:31:45 -0800 | |
changeset 16303 | b5dca0b42963 |
parent 14952 | d0022ae20516 |
child 17273 | d7ec6654aac9 |
permissions | -rw-r--r-- |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
1 |
/* |
16303
b5dca0b42963
8008267: Add @Supported annotation to com.sun.source types
darcy
parents:
14952
diff
changeset
|
2 |
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
4 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
10 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
16 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
20 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
23 |
* questions. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
24 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
25 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
26 |
package com.sun.source.util; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
27 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
28 |
import javax.annotation.processing.ProcessingEnvironment; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
29 |
import javax.lang.model.element.Element; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
30 |
import javax.tools.JavaCompiler.CompilationTask; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
31 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
32 |
import com.sun.source.doctree.DocCommentTree; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
33 |
import com.sun.source.doctree.ReferenceTree; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
34 |
import javax.tools.Diagnostic; |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
35 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
36 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
37 |
* Provides access to syntax trees for doc comments. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
38 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
39 |
* @since 1.8 |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
40 |
*/ |
16303
b5dca0b42963
8008267: Add @Supported annotation to com.sun.source types
darcy
parents:
14952
diff
changeset
|
41 |
@jdk.Supported |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
42 |
public abstract class DocTrees extends Trees { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
43 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
44 |
* Gets a DocTrees object for a given CompilationTask. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
45 |
* @param task the compilation task for which to get the Trees object |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
46 |
* @throws IllegalArgumentException if the task does not support the Trees API. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
47 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
48 |
public static DocTrees instance(CompilationTask task) { |
14952 | 49 |
return (DocTrees) Trees.instance(task); |
14541
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
50 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
51 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
52 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
53 |
* Gets a DocTrees object for a given ProcessingEnvironment. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
54 |
* @param env the processing environment for which to get the Trees object |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
55 |
* @throws IllegalArgumentException if the env does not support the Trees API. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
56 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
57 |
public static DocTrees instance(ProcessingEnvironment env) { |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
58 |
if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
59 |
throw new IllegalArgumentException(); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
60 |
return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
61 |
} |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
62 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
63 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
64 |
* Gets the doc comment tree, if any, for the Tree node identified by a given TreePath. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
65 |
* Returns null if no doc comment was found. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
66 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
67 |
public abstract DocCommentTree getDocCommentTree(TreePath path); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
68 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
69 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
70 |
* Gets the language model element referred to by a ReferenceTree that |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
71 |
* appears on the declaration identified by the given path. |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
72 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
73 |
public abstract Element getElement(TreePath path, ReferenceTree reference); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
74 |
|
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
75 |
/** |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
76 |
* Prints a message of the specified kind at the location of the |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
77 |
* tree within the provided compilation unit |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
78 |
* |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
79 |
* @param kind the kind of message |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
80 |
* @param msg the message, or an empty string if none |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
81 |
* @param t the tree to use as a position hint |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
82 |
* @param root the compilation unit that contains tree |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
83 |
*/ |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
84 |
public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
85 |
com.sun.source.doctree.DocTree t, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
86 |
com.sun.source.doctree.DocCommentTree c, |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
87 |
com.sun.source.tree.CompilationUnitTree root); |
36f9d11fc9aa
7021614: extend com.sun.source API to support parsing javadoc comments
jjg
parents:
diff
changeset
|
88 |
} |