author | darcy |
Mon, 13 Jun 2016 09:12:35 -0700 | |
changeset 38918 | bf1ed1a40f5b |
parent 38911 | 48a00b5ee366 |
child 40303 | 96a1226aca18 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
2 |
* Copyright (c) 2001, 2016, 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 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.taglets; |
10 | 27 |
|
28 |
import java.io.*; |
|
36526 | 29 |
import java.lang.reflect.Method; |
10 | 30 |
import java.util.*; |
31 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
32 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
33 |
import javax.lang.model.element.ExecutableElement; |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
34 |
import javax.lang.model.element.ModuleElement; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
35 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
36 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
37 |
import javax.lang.model.element.VariableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
38 |
import javax.lang.model.util.SimpleElementVisitor9; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
39 |
import javax.tools.JavaFileManager; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
40 |
import javax.tools.StandardJavaFileManager; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
41 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
42 |
import com.sun.source.doctree.DocTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
43 |
import com.sun.tools.javac.util.DefinedBy; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
44 |
import com.sun.tools.javac.util.DefinedBy.Api; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
45 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
46 |
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
47 |
import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
48 |
import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
49 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
50 |
import static javax.tools.DocumentationTool.Location.*; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
51 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
52 |
import static com.sun.source.doctree.DocTree.Kind.*; |
14258 | 53 |
|
10 | 54 |
/** |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
55 |
* Manages the {@code Taglet}s used by doclets. |
10 | 56 |
* |
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
57 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
58 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
59 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
60 |
* deletion without notice.</b> |
10 | 61 |
* |
62 |
* @author Jamie Ho |
|
63 |
*/ |
|
64 |
||
65 |
public class TagletManager { |
|
66 |
||
67 |
/** |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
68 |
* The default separator for the simple tag option. |
10 | 69 |
*/ |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
70 |
public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':'; |
10 | 71 |
|
72 |
/** |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
73 |
* The alternate separator for simple tag options. Use this |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
74 |
* when you want the default separator to be in the name of the |
10 | 75 |
* custom tag. |
76 |
*/ |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
77 |
public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-"; |
10 | 78 |
|
79 |
/** |
|
80 |
* The map of custom tags. |
|
81 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
82 |
private final LinkedHashMap<String,Taglet> customTags; |
10 | 83 |
|
84 |
/** |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
85 |
* The array of custom tags that can appear in modules. |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
86 |
*/ |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
87 |
private List<Taglet> moduleTags; |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
88 |
|
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
89 |
/** |
10 | 90 |
* The array of custom tags that can appear in packages. |
91 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
92 |
private List<Taglet> packageTags; |
10 | 93 |
|
94 |
/** |
|
95 |
* The array of custom tags that can appear in classes or interfaces. |
|
96 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
97 |
private List<Taglet> typeTags; |
10 | 98 |
|
99 |
/** |
|
100 |
* The array of custom tags that can appear in fields. |
|
101 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
102 |
private List<Taglet> fieldTags; |
10 | 103 |
|
104 |
/** |
|
105 |
* The array of custom tags that can appear in constructors. |
|
106 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
107 |
private List<Taglet> constructorTags; |
10 | 108 |
|
109 |
/** |
|
110 |
* The array of custom tags that can appear in methods. |
|
111 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
112 |
private List<Taglet> methodTags; |
10 | 113 |
|
114 |
/** |
|
115 |
* The array of custom tags that can appear in the overview. |
|
116 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
117 |
private List<Taglet> overviewTags; |
10 | 118 |
|
119 |
/** |
|
120 |
* The array of custom tags that can appear in comments. |
|
121 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
122 |
private List<Taglet> inlineTags; |
10 | 123 |
|
124 |
/** |
|
125 |
* The array of custom tags that can appear in the serialized form. |
|
126 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
127 |
private List<Taglet> serializedFormTags; |
10 | 128 |
|
129 |
/** |
|
130 |
* The message retriever that will be used to print error messages. |
|
131 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
132 |
private final MessageRetriever message; |
10 | 133 |
|
134 |
/** |
|
135 |
* Keep track of standard tags. |
|
136 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
137 |
private final Set<String> standardTags; |
10 | 138 |
|
139 |
/** |
|
140 |
* Keep track of standard tags in lowercase to compare for better |
|
141 |
* error messages when a tag like @docRoot is mistakenly spelled |
|
142 |
* lowercase @docroot. |
|
143 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
144 |
private final Set<String> standardTagsLowercase; |
10 | 145 |
|
146 |
/** |
|
147 |
* Keep track of overriden standard tags. |
|
148 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
149 |
private final Set<String> overridenStandardTags; |
10 | 150 |
|
151 |
/** |
|
152 |
* Keep track of the tags that may conflict |
|
153 |
* with standard tags in the future (any custom tag without |
|
154 |
* a period in its name). |
|
155 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
156 |
private final Set<String> potentiallyConflictingTags; |
10 | 157 |
|
158 |
/** |
|
159 |
* The set of unseen custom tags. |
|
160 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
161 |
private final Set<String> unseenCustomTags; |
10 | 162 |
|
163 |
/** |
|
164 |
* True if we do not want to use @since tags. |
|
165 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
166 |
private final boolean nosince; |
10 | 167 |
|
168 |
/** |
|
169 |
* True if we want to use @version tags. |
|
170 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
171 |
private final boolean showversion; |
10 | 172 |
|
173 |
/** |
|
174 |
* True if we want to use @author tags. |
|
175 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
176 |
private final boolean showauthor; |
10 | 177 |
|
178 |
/** |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
179 |
* True if we want to use JavaFX-related tags (@propertyGetter, |
17572 | 180 |
* @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate). |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
181 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
182 |
private final boolean javafx; |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
183 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
184 |
/** |
10 | 185 |
* Construct a new <code>TagletManager</code>. |
186 |
* @param nosince true if we do not want to use @since tags. |
|
187 |
* @param showversion true if we want to use @version tags. |
|
188 |
* @param showauthor true if we want to use @author tags. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
189 |
* @param javafx indicates whether javafx is active. |
10 | 190 |
* @param message the message retriever to print warnings. |
191 |
*/ |
|
192 |
public TagletManager(boolean nosince, boolean showversion, |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
193 |
boolean showauthor, boolean javafx, |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
194 |
MessageRetriever message) { |
22163 | 195 |
overridenStandardTags = new HashSet<>(); |
196 |
potentiallyConflictingTags = new HashSet<>(); |
|
197 |
standardTags = new HashSet<>(); |
|
198 |
standardTagsLowercase = new HashSet<>(); |
|
199 |
unseenCustomTags = new HashSet<>(); |
|
200 |
customTags = new LinkedHashMap<>(); |
|
10 | 201 |
this.nosince = nosince; |
202 |
this.showversion = showversion; |
|
203 |
this.showauthor = showauthor; |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
204 |
this.javafx = javafx; |
10 | 205 |
this.message = message; |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
206 |
initStandardTaglets(); |
10 | 207 |
initStandardTagsLowercase(); |
208 |
} |
|
209 |
||
210 |
/** |
|
211 |
* Add a new <code>CustomTag</code>. This is used to add a Taglet from within |
|
212 |
* a Doclet. No message is printed to indicate that the Taglet is properly |
|
213 |
* registered because these Taglets are typically added for every execution of the |
|
214 |
* Doclet. We don't want to see this type of error message every time. |
|
215 |
* @param customTag the new <code>CustomTag</code> to add. |
|
216 |
*/ |
|
217 |
public void addCustomTag(Taglet customTag) { |
|
218 |
if (customTag != null) { |
|
219 |
String name = customTag.getName(); |
|
220 |
if (customTags.containsKey(name)) { |
|
221 |
customTags.remove(name); |
|
222 |
} |
|
223 |
customTags.put(name, customTag); |
|
224 |
checkTagName(name); |
|
225 |
} |
|
226 |
} |
|
227 |
||
21500
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
228 |
public Set<String> getCustomTagNames() { |
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
229 |
return customTags.keySet(); |
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
230 |
} |
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
231 |
|
10 | 232 |
/** |
233 |
* Add a new <code>Taglet</code>. Print a message to indicate whether or not |
|
234 |
* the Taglet was registered properly. |
|
235 |
* @param classname the name of the class representing the custom tag. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
236 |
* @param fileManager the filemanager to load classes and resources. |
10 | 237 |
* @param tagletPath the path to the class representing the custom tag. |
238 |
*/ |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
239 |
public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) { |
10 | 240 |
try { |
36526 | 241 |
ClassLoader tagClassLoader = null; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
242 |
if (!fileManager.hasLocation(TAGLET_PATH)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
243 |
List<File> paths = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
244 |
if (tagletPath != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
245 |
for (String pathname : tagletPath.split(File.pathSeparator)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
246 |
paths.add(new File(pathname)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
247 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
248 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
249 |
if (fileManager instanceof StandardJavaFileManager) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
250 |
((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, paths); |
10 | 251 |
} |
252 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
253 |
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
254 |
Class<?> customTagClass = tagClassLoader.loadClass(classname); |
38918
bf1ed1a40f5b
8155880: Fix langtools usage of the deprecated Class.newInstance method
darcy
parents:
38911
diff
changeset
|
255 |
Object instance = customTagClass.getConstructor().newInstance(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
256 |
Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
257 |
String tname = newLegacy.getName(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
258 |
Taglet t = customTags.get(tname); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
259 |
if (t != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
260 |
customTags.remove(tname); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
261 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
262 |
customTags.put(tname, newLegacy); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
263 |
message.notice("doclet.Notice_taglet_registered", classname); |
10 | 264 |
} catch (Exception exc) { |
265 |
message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname); |
|
266 |
} |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
* Add a new <code>SimpleTaglet</code>. If this tag already exists |
|
271 |
* and the header passed as an argument is null, move tag to the back of the |
|
272 |
* list. If this tag already exists and the header passed as an argument is |
|
273 |
* not null, overwrite previous tag with new one. Otherwise, add new |
|
274 |
* SimpleTaglet to list. |
|
275 |
* @param tagName the name of this tag |
|
276 |
* @param header the header to output. |
|
277 |
* @param locations the possible locations that this tag |
|
278 |
* can appear in. |
|
279 |
*/ |
|
280 |
public void addNewSimpleCustomTag(String tagName, String header, String locations) { |
|
281 |
if (tagName == null || locations == null) { |
|
282 |
return; |
|
283 |
} |
|
868 | 284 |
Taglet tag = customTags.get(tagName); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
285 |
locations = Utils.toLowerCase(locations); |
10 | 286 |
if (tag == null || header != null) { |
287 |
customTags.remove(tagName); |
|
288 |
customTags.put(tagName, new SimpleTaglet(tagName, header, locations)); |
|
289 |
if (locations != null && locations.indexOf('x') == -1) { |
|
290 |
checkTagName(tagName); |
|
291 |
} |
|
292 |
} else { |
|
293 |
//Move to back |
|
294 |
customTags.remove(tagName); |
|
295 |
customTags.put(tagName, tag); |
|
296 |
} |
|
297 |
} |
|
298 |
||
299 |
/** |
|
300 |
* Given a tag name, add it to the set of tags it belongs to. |
|
301 |
*/ |
|
302 |
private void checkTagName(String name) { |
|
303 |
if (standardTags.contains(name)) { |
|
304 |
overridenStandardTags.add(name); |
|
305 |
} else { |
|
306 |
if (name.indexOf('.') == -1) { |
|
307 |
potentiallyConflictingTags.add(name); |
|
308 |
} |
|
309 |
unseenCustomTags.add(name); |
|
310 |
} |
|
311 |
} |
|
312 |
||
313 |
/** |
|
314 |
* Check the taglet to see if it is a legacy taglet. Also |
|
315 |
* check its name for errors. |
|
316 |
*/ |
|
317 |
private void checkTaglet(Object taglet) { |
|
318 |
if (taglet instanceof Taglet) { |
|
319 |
checkTagName(((Taglet) taglet).getName()); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
320 |
} else if (taglet instanceof jdk.javadoc.doclet.taglet.Taglet) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
321 |
jdk.javadoc.doclet.taglet.Taglet legacyTaglet = (jdk.javadoc.doclet.taglet.Taglet) taglet; |
10 | 322 |
customTags.remove(legacyTaglet.getName()); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
323 |
customTags.put(legacyTaglet.getName(), new UserTaglet(legacyTaglet)); |
10 | 324 |
checkTagName(legacyTaglet.getName()); |
325 |
} else { |
|
326 |
throw new IllegalArgumentException("Given object is not a taglet."); |
|
327 |
} |
|
328 |
} |
|
329 |
||
330 |
/** |
|
331 |
* Given a name of a seen custom tag, remove it from the set of unseen |
|
332 |
* custom tags. |
|
333 |
* @param name the name of the seen custom tag. |
|
334 |
*/ |
|
335 |
public void seenCustomTag(String name) { |
|
336 |
unseenCustomTags.remove(name); |
|
337 |
} |
|
338 |
||
339 |
/** |
|
340 |
* Given an array of <code>Tag</code>s, check for spelling mistakes. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
341 |
* @param utils the utility class to use |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
342 |
* @param element the tags holder |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
343 |
* @param trees the trees containing the comments |
10 | 344 |
* @param areInlineTags true if the array of tags are inline and false otherwise. |
345 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
346 |
public void checkTags(final Utils utils, Element element, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
347 |
Iterable<? extends DocTree> trees, boolean areInlineTags) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
348 |
if (trees == null) { |
10 | 349 |
return; |
350 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
351 |
CommentHelper ch = utils.getCommentHelper(element); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
352 |
for (DocTree tag : trees) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
353 |
String name = tag.getKind().tagName; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
354 |
if (name == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
355 |
continue; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
356 |
} |
10 | 357 |
if (name.length() > 0 && name.charAt(0) == '@') { |
358 |
name = name.substring(1, name.length()); |
|
359 |
} |
|
360 |
if (! (standardTags.contains(name) || customTags.containsKey(name))) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
361 |
if (standardTagsLowercase.contains(Utils.toLowerCase(name))) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
362 |
message.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag)); |
10 | 363 |
continue; |
364 |
} else { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
365 |
message.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag)); |
10 | 366 |
continue; |
367 |
} |
|
368 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
369 |
final Taglet taglet = customTags.get(name); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
370 |
// Check and verify tag usage |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
371 |
if (taglet != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
372 |
if (areInlineTags && !taglet.isInlineTag()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
373 |
printTagMisuseWarn(ch, taglet, tag, "inline"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
374 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
375 |
// nothing more to do |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
376 |
if (element == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
377 |
return; |
10 | 378 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
379 |
new SimpleElementVisitor9<Void, Void>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
380 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
381 |
public Void visitModule(ModuleElement e, Void p) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
382 |
if (!taglet.inModule()) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
383 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "module"); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
384 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
385 |
return null; |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
386 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
387 |
|
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
388 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
389 |
public Void visitPackage(PackageElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
390 |
if (!taglet.inPackage()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
391 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
392 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
393 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
394 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
395 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
396 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
397 |
public Void visitType(TypeElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
398 |
if (!taglet.inType()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
399 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "class"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
400 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
401 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
402 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
403 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
404 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
405 |
public Void visitExecutable(ExecutableElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
406 |
if (utils.isConstructor(e) && !taglet.inConstructor()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
407 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "constructor"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
408 |
} else if (!taglet.inMethod()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
409 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "method"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
410 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
411 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
412 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
413 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
414 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
415 |
public Void visitVariable(VariableElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
416 |
if (utils.isField(e) && !taglet.inField()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
417 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "field"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
418 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
419 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
420 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
421 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
422 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
423 |
public Void visitUnknown(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
424 |
if (utils.isOverviewElement(e) && !taglet.inOverview()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
425 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "overview"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
426 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
427 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
428 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
429 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
430 |
@Override @DefinedBy(Api.LANGUAGE_MODEL) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
431 |
protected Void defaultAction(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
432 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
433 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
434 |
}.visit(element); |
10 | 435 |
} |
436 |
} |
|
437 |
} |
|
438 |
||
439 |
/** |
|
440 |
* Given the taglet, the tag and the type of documentation that the tag |
|
441 |
* was found in, print a tag misuse warning. |
|
442 |
* @param taglet the taglet representing the misused tag. |
|
443 |
* @param tag the misused tag. |
|
444 |
* @param holderType the type of documentation that the misused tag was found in. |
|
445 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
446 |
private void printTagMisuseWarn(CommentHelper ch, Taglet taglet, DocTree tag, String holderType) { |
22163 | 447 |
Set<String> locationsSet = new LinkedHashSet<>(); |
10 | 448 |
if (taglet.inOverview()) { |
449 |
locationsSet.add("overview"); |
|
450 |
} |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
451 |
if (taglet.inModule()) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
452 |
locationsSet.add("module"); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
453 |
} |
10 | 454 |
if (taglet.inPackage()) { |
455 |
locationsSet.add("package"); |
|
456 |
} |
|
457 |
if (taglet.inType()) { |
|
458 |
locationsSet.add("class/interface"); |
|
459 |
} |
|
460 |
if (taglet.inConstructor()) { |
|
461 |
locationsSet.add("constructor"); |
|
462 |
} |
|
463 |
if (taglet.inField()) { |
|
464 |
locationsSet.add("field"); |
|
465 |
} |
|
466 |
if (taglet.inMethod()) { |
|
467 |
locationsSet.add("method"); |
|
468 |
} |
|
469 |
if (taglet.isInlineTag()) { |
|
470 |
locationsSet.add("inline text"); |
|
471 |
} |
|
868 | 472 |
String[] locations = locationsSet.toArray(new String[]{}); |
10 | 473 |
if (locations == null || locations.length == 0) { |
474 |
//This known tag is excluded. |
|
475 |
return; |
|
476 |
} |
|
14263 | 477 |
StringBuilder combined_locations = new StringBuilder(); |
10 | 478 |
for (int i = 0; i < locations.length; i++) { |
479 |
if (i > 0) { |
|
480 |
combined_locations.append(", "); |
|
481 |
} |
|
482 |
combined_locations.append(locations[i]); |
|
483 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
484 |
message.warning(ch.getDocTreePath(tag), "doclet.tag_misuse", |
10 | 485 |
"@" + taglet.getName(), holderType, combined_locations.toString()); |
486 |
} |
|
487 |
||
488 |
/** |
|
489 |
* Return the array of <code>Taglet</code>s that can |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
490 |
* appear in modules. |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
491 |
* @return the array of <code>Taglet</code>s that can |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
492 |
* appear in modules. |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
493 |
*/ |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
494 |
public List<Taglet> getModuleCustomTaglets() { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
495 |
if (moduleTags == null) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
496 |
initCustomTaglets(); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
497 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
498 |
return moduleTags; |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
499 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
500 |
|
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
501 |
/** |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
502 |
* Return the array of <code>Taglet</code>s that can |
10 | 503 |
* appear in packages. |
504 |
* @return the array of <code>Taglet</code>s that can |
|
505 |
* appear in packages. |
|
506 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
507 |
public List<Taglet> getPackageCustomTaglets() { |
10 | 508 |
if (packageTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
509 |
initCustomTaglets(); |
10 | 510 |
} |
511 |
return packageTags; |
|
512 |
} |
|
513 |
||
514 |
/** |
|
515 |
* Return the array of <code>Taglet</code>s that can |
|
516 |
* appear in classes or interfaces. |
|
517 |
* @return the array of <code>Taglet</code>s that can |
|
518 |
* appear in classes or interfaces. |
|
519 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
520 |
public List<Taglet> getTypeCustomTaglets() { |
10 | 521 |
if (typeTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
522 |
initCustomTaglets(); |
10 | 523 |
} |
524 |
return typeTags; |
|
525 |
} |
|
526 |
||
527 |
/** |
|
528 |
* Return the array of inline <code>Taglet</code>s that can |
|
529 |
* appear in comments. |
|
530 |
* @return the array of <code>Taglet</code>s that can |
|
531 |
* appear in comments. |
|
532 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
533 |
public List<Taglet> getInlineCustomTaglets() { |
10 | 534 |
if (inlineTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
535 |
initCustomTaglets(); |
10 | 536 |
} |
537 |
return inlineTags; |
|
538 |
} |
|
539 |
||
540 |
/** |
|
541 |
* Return the array of <code>Taglet</code>s that can |
|
542 |
* appear in fields. |
|
543 |
* @return the array of <code>Taglet</code>s that can |
|
544 |
* appear in field. |
|
545 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
546 |
public List<Taglet> getFieldCustomTaglets() { |
10 | 547 |
if (fieldTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
548 |
initCustomTaglets(); |
10 | 549 |
} |
550 |
return fieldTags; |
|
551 |
} |
|
552 |
||
553 |
/** |
|
554 |
* Return the array of <code>Taglet</code>s that can |
|
555 |
* appear in the serialized form. |
|
556 |
* @return the array of <code>Taglet</code>s that can |
|
557 |
* appear in the serialized form. |
|
558 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
559 |
public List<Taglet> getSerializedFormTaglets() { |
10 | 560 |
if (serializedFormTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
561 |
initCustomTaglets(); |
10 | 562 |
} |
563 |
return serializedFormTags; |
|
564 |
} |
|
565 |
||
566 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
567 |
* Returns the custom tags for a given element. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
568 |
* |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
569 |
* @param e the element to get custom tags for |
10 | 570 |
* @return the array of <code>Taglet</code>s that can |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
571 |
* appear in the given element. |
10 | 572 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
573 |
public List<Taglet> getCustomTaglets(Element e) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
574 |
switch (e.getKind()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
575 |
case CONSTRUCTOR: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
576 |
return getConstructorCustomTaglets(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
577 |
case METHOD: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
578 |
return getMethodCustomTaglets(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
579 |
case ENUM_CONSTANT: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
580 |
case FIELD: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
581 |
return getFieldCustomTaglets(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
582 |
case ANNOTATION_TYPE: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
583 |
case INTERFACE: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
584 |
case CLASS: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
585 |
case ENUM: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
586 |
return getTypeCustomTaglets(); |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
587 |
case MODULE: |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
588 |
return getModuleCustomTaglets(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
589 |
case PACKAGE: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
590 |
return getPackageCustomTaglets(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
591 |
case OTHER: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
592 |
return getOverviewCustomTaglets(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
593 |
default: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
594 |
throw new AssertionError("unknown element: " + e + " ,kind: " + e.getKind()); |
10 | 595 |
} |
596 |
} |
|
597 |
||
598 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
599 |
* Return a List of <code>Taglet</code>s that can |
10 | 600 |
* appear in constructors. |
601 |
* @return the array of <code>Taglet</code>s that can |
|
602 |
* appear in constructors. |
|
603 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
604 |
public List<Taglet> getConstructorCustomTaglets() { |
10 | 605 |
if (constructorTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
606 |
initCustomTaglets(); |
10 | 607 |
} |
608 |
return constructorTags; |
|
609 |
} |
|
610 |
||
611 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
612 |
* Return a List of <code>Taglet</code>s that can |
10 | 613 |
* appear in methods. |
614 |
* @return the array of <code>Taglet</code>s that can |
|
615 |
* appear in methods. |
|
616 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
617 |
public List<Taglet> getMethodCustomTaglets() { |
10 | 618 |
if (methodTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
619 |
initCustomTaglets(); |
10 | 620 |
} |
621 |
return methodTags; |
|
622 |
} |
|
623 |
||
624 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
625 |
* Return a List of <code>Taglet</code>s that can |
10 | 626 |
* appear in an overview. |
627 |
* @return the array of <code>Taglet</code>s that can |
|
628 |
* appear in overview. |
|
629 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
630 |
public List<Taglet> getOverviewCustomTaglets() { |
10 | 631 |
if (overviewTags == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
632 |
initCustomTaglets(); |
10 | 633 |
} |
634 |
return overviewTags; |
|
635 |
} |
|
636 |
||
637 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
638 |
* Initialize the custom tag Lists. |
10 | 639 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
640 |
private void initCustomTaglets() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
641 |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
642 |
moduleTags = new ArrayList<>(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
643 |
packageTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
644 |
typeTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
645 |
fieldTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
646 |
constructorTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
647 |
methodTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
648 |
inlineTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
649 |
overviewTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
650 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
651 |
for (Taglet current : customTags.values()) { |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
652 |
if (current.inModule() && !current.isInlineTag()) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
653 |
moduleTags.add(current); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
654 |
} |
10 | 655 |
if (current.inPackage() && !current.isInlineTag()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
656 |
packageTags.add(current); |
10 | 657 |
} |
658 |
if (current.inType() && !current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
659 |
typeTags.add(current); |
10 | 660 |
} |
661 |
if (current.inField() && !current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
662 |
fieldTags.add(current); |
10 | 663 |
} |
664 |
if (current.inConstructor() && !current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
665 |
constructorTags.add(current); |
10 | 666 |
} |
667 |
if (current.inMethod() && !current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
668 |
methodTags.add(current); |
10 | 669 |
} |
670 |
if (current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
671 |
inlineTags.add(current); |
10 | 672 |
} |
673 |
if (current.inOverview() && !current.isInlineTag()) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
674 |
overviewTags.add(current); |
10 | 675 |
} |
676 |
} |
|
677 |
||
678 |
//Init the serialized form tags |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
679 |
serializedFormTags = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
680 |
serializedFormTags.add(customTags.get(SERIAL_DATA.tagName)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
681 |
serializedFormTags.add(customTags.get(THROWS.tagName)); |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
5520
diff
changeset
|
682 |
if (!nosince) |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
683 |
serializedFormTags.add(customTags.get(SINCE.tagName)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
684 |
serializedFormTags.add(customTags.get(SEE.tagName)); |
10 | 685 |
} |
686 |
||
687 |
/** |
|
688 |
* Initialize standard Javadoc tags for ordering purposes. |
|
689 |
*/ |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
690 |
private void initStandardTaglets() { |
18659
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
691 |
if (javafx) { |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
692 |
initJavaFXTaglets(); |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
693 |
} |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
694 |
|
10 | 695 |
Taglet temp; |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
696 |
addStandardTaglet(new ParamTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
697 |
addStandardTaglet(new ReturnTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
698 |
addStandardTaglet(new ThrowsTaglet()); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
699 |
addStandardTaglet(new SimpleTaglet(EXCEPTION.tagName, null, |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
700 |
SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
701 |
addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, message.getText("doclet.Since"), |
37009
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
36526
diff
changeset
|
702 |
SimpleTaglet.ALL)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
703 |
addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, message.getText("doclet.Version"), |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
704 |
SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
705 |
addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, message.getText("doclet.Author"), |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
706 |
SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
707 |
addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, message.getText("doclet.SerialData"), |
37009
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
36526
diff
changeset
|
708 |
SimpleTaglet.EXCLUDED)); |
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
36526
diff
changeset
|
709 |
addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, message.getText("doclet.Hidden"), |
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
36526
diff
changeset
|
710 |
SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)); |
10 | 711 |
customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"), |
37009
476d8d615222
8073100: [javadoc] Provide an ability to suppress document generation for specific elements.
ksrini
parents:
36526
diff
changeset
|
712 |
SimpleTaglet.METHOD)).getName(), temp); |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
713 |
addStandardTaglet(new SeeTaglet()); |
10 | 714 |
//Standard inline tags |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
715 |
addStandardTaglet(new DocRootTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
716 |
addStandardTaglet(new InheritDocTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
717 |
addStandardTaglet(new ValueTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
718 |
addStandardTaglet(new LiteralTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
719 |
addStandardTaglet(new CodeTaglet()); |
33920 | 720 |
addStandardTaglet(new IndexTaglet()); |
10 | 721 |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
722 |
// Keep track of the names of standard tags for error |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
723 |
// checking purposes. The following are not handled above. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
724 |
standardTags.add(DEPRECATED.tagName); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
725 |
standardTags.add(LINK.tagName); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
726 |
standardTags.add(LINK_PLAIN.tagName); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
727 |
standardTags.add(SERIAL.tagName); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
728 |
standardTags.add(SERIAL_FIELD.tagName); |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
729 |
} |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
730 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
731 |
/** |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
732 |
* Initialize JavaFX-related tags. |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
733 |
*/ |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
734 |
private void initJavaFXTaglets() { |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
735 |
addStandardTaglet(new PropertyGetterTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
736 |
addStandardTaglet(new PropertySetterTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
737 |
addStandardTaglet(new SimpleTaglet("propertyDescription", |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
738 |
message.getText("doclet.PropertyDescription"), |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
739 |
SimpleTaglet.FIELD + SimpleTaglet.METHOD)); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
740 |
addStandardTaglet(new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"), |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
741 |
SimpleTaglet.FIELD + SimpleTaglet.METHOD)); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
742 |
addStandardTaglet(new SimpleTaglet("treatAsPrivate", null, |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
743 |
SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
744 |
} |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
745 |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
746 |
void addStandardTaglet(Taglet taglet) { |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
747 |
String name = taglet.getName(); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
748 |
customTags.put(name, taglet); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
749 |
standardTags.add(name); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
750 |
} |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
751 |
|
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
752 |
void addStandardTaglet(boolean enable, Taglet taglet) { |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
753 |
String name = taglet.getName(); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
754 |
if (enable) |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
755 |
customTags.put(name, taglet); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
756 |
standardTags.add(name); |
10 | 757 |
} |
758 |
||
759 |
/** |
|
760 |
* Initialize lowercase version of standard Javadoc tags. |
|
761 |
*/ |
|
762 |
private void initStandardTagsLowercase() { |
|
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22153
diff
changeset
|
763 |
for (String standardTag : standardTags) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
764 |
standardTagsLowercase.add(Utils.toLowerCase(standardTag)); |
10 | 765 |
} |
766 |
} |
|
767 |
||
768 |
public boolean isKnownCustomTag(String tagName) { |
|
769 |
return customTags.containsKey(tagName); |
|
770 |
} |
|
771 |
||
772 |
/** |
|
773 |
* Print a list of {@link Taglet}s that might conflict with |
|
774 |
* standard tags in the future and a list of standard tags |
|
775 |
* that have been overriden. |
|
776 |
*/ |
|
777 |
public void printReport() { |
|
778 |
printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags); |
|
779 |
printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags); |
|
780 |
printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags); |
|
781 |
} |
|
782 |
||
868 | 783 |
private void printReportHelper(String noticeKey, Set<String> names) { |
10 | 784 |
if (names.size() > 0) { |
868 | 785 |
String[] namesArray = names.toArray(new String[] {}); |
10 | 786 |
String result = " "; |
787 |
for (int i = 0; i < namesArray.length; i++) { |
|
788 |
result += "@" + namesArray[i]; |
|
789 |
if (i + 1 < namesArray.length) { |
|
790 |
result += ", "; |
|
791 |
} |
|
792 |
} |
|
793 |
message.notice(noticeKey, result); |
|
794 |
} |
|
795 |
} |
|
796 |
||
797 |
/** |
|
798 |
* Given the name of a tag, return the corresponding taglet. |
|
799 |
* Return null if the tag is unknown. |
|
800 |
* |
|
801 |
* @param name the name of the taglet to retrieve. |
|
802 |
* @return return the corresponding taglet. Return null if the tag is |
|
803 |
* unknown. |
|
804 |
*/ |
|
805 |
public Taglet getTaglet(String name) { |
|
806 |
if (name.indexOf("@") == 0) { |
|
868 | 807 |
return customTags.get(name.substring(1)); |
10 | 808 |
} else { |
868 | 809 |
return customTags.get(name); |
10 | 810 |
} |
811 |
||
812 |
} |
|
813 |
} |