author | pmuthuswamy |
Mon, 12 Nov 2018 13:31:41 +0530 | |
changeset 52487 | 5d1d07b72f15 |
parent 50240 | b9c483223a91 |
child 54198 | 6ba98ff89499 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
48029
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, 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.*; |
|
29 |
import java.util.*; |
|
30 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
31 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
32 |
import javax.lang.model.element.ExecutableElement; |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
33 |
import javax.lang.model.element.ModuleElement; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
34 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
35 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
36 |
import javax.lang.model.element.VariableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
37 |
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
|
38 |
import javax.tools.JavaFileManager; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
39 |
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
|
40 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
41 |
import com.sun.source.doctree.DocTree; |
44388 | 42 |
import jdk.javadoc.doclet.Doclet; |
43 |
import jdk.javadoc.doclet.DocletEnvironment; |
|
45417 | 44 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
45 |
import jdk.javadoc.internal.doclets.toolkit.DocletElement; |
40303 | 46 |
import jdk.javadoc.internal.doclets.toolkit.Messages; |
47 |
import jdk.javadoc.internal.doclets.toolkit.Resources; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
48 |
|
50240 | 49 |
import jdk.javadoc.internal.doclets.toolkit.taglets.BaseTaglet.Site; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
50 |
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
51 |
import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
52 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
53 |
import static javax.tools.DocumentationTool.Location.*; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
54 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
55 |
import static com.sun.source.doctree.DocTree.Kind.*; |
14258 | 56 |
|
10 | 57 |
/** |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
58 |
* Manages the {@code Taglet}s used by doclets. |
10 | 59 |
* |
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
60 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
61 |
* 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
|
62 |
* 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
|
63 |
* deletion without notice.</b> |
10 | 64 |
* |
65 |
* @author Jamie Ho |
|
66 |
*/ |
|
67 |
||
68 |
public class TagletManager { |
|
69 |
||
70 |
/** |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
71 |
* The default separator for the simple tag option. |
10 | 72 |
*/ |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
73 |
public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':'; |
10 | 74 |
|
75 |
/** |
|
50240 | 76 |
* The map of all taglets. |
10 | 77 |
*/ |
50240 | 78 |
private final LinkedHashMap<String,Taglet> allTaglets; |
10 | 79 |
|
80 |
/** |
|
50240 | 81 |
* Block (non-line) taglets, grouped by Site |
10 | 82 |
*/ |
50240 | 83 |
private Map<Site, List<Taglet>> blockTagletsBySite; |
10 | 84 |
|
85 |
/** |
|
50240 | 86 |
* The taglets that can appear inline in descriptive text. |
10 | 87 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
88 |
private List<Taglet> inlineTags; |
10 | 89 |
|
90 |
/** |
|
50240 | 91 |
* The taglets that can appear in the serialized form. |
10 | 92 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
93 |
private List<Taglet> serializedFormTags; |
10 | 94 |
|
44388 | 95 |
private final DocletEnvironment docEnv; |
96 |
private final Doclet doclet; |
|
97 |
||
50240 | 98 |
private final Utils utils; |
40303 | 99 |
private final Messages messages; |
100 |
private final Resources resources; |
|
10 | 101 |
|
102 |
/** |
|
103 |
* Keep track of standard tags. |
|
104 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
105 |
private final Set<String> standardTags; |
10 | 106 |
|
107 |
/** |
|
108 |
* Keep track of standard tags in lowercase to compare for better |
|
109 |
* error messages when a tag like @docRoot is mistakenly spelled |
|
110 |
* lowercase @docroot. |
|
111 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
112 |
private final Set<String> standardTagsLowercase; |
10 | 113 |
|
114 |
/** |
|
115 |
* Keep track of overriden standard tags. |
|
116 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
117 |
private final Set<String> overridenStandardTags; |
10 | 118 |
|
119 |
/** |
|
120 |
* Keep track of the tags that may conflict |
|
121 |
* with standard tags in the future (any custom tag without |
|
122 |
* a period in its name). |
|
123 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
124 |
private final Set<String> potentiallyConflictingTags; |
10 | 125 |
|
126 |
/** |
|
127 |
* The set of unseen custom tags. |
|
128 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
129 |
private final Set<String> unseenCustomTags; |
10 | 130 |
|
131 |
/** |
|
132 |
* True if we do not want to use @since tags. |
|
133 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
134 |
private final boolean nosince; |
10 | 135 |
|
136 |
/** |
|
137 |
* True if we want to use @version tags. |
|
138 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
139 |
private final boolean showversion; |
10 | 140 |
|
141 |
/** |
|
142 |
* True if we want to use @author tags. |
|
143 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
144 |
private final boolean showauthor; |
10 | 145 |
|
146 |
/** |
|
49879
601277b1d582
8025091: VisibleMemberMap.java possible performance improvements
ksrini
parents:
48029
diff
changeset
|
147 |
* True if we want to use JavaFX-related tags (@defaultValue, @treatAsPrivate). |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
148 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
149 |
private final boolean javafx; |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
150 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
151 |
/** |
50240 | 152 |
* Show the taglets table when it has been initialized. |
153 |
*/ |
|
154 |
private final boolean showTaglets; |
|
155 |
||
156 |
/** |
|
157 |
* Construct a new {@code TagletManager}. |
|
10 | 158 |
* @param nosince true if we do not want to use @since tags. |
159 |
* @param showversion true if we want to use @version tags. |
|
160 |
* @param showauthor true if we want to use @author tags. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
161 |
* @param javafx indicates whether javafx is active. |
44388 | 162 |
* @param configuration the configuration for this taglet manager |
10 | 163 |
*/ |
164 |
public TagletManager(boolean nosince, boolean showversion, |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
165 |
boolean showauthor, boolean javafx, |
45417 | 166 |
BaseConfiguration configuration) { |
22163 | 167 |
overridenStandardTags = new HashSet<>(); |
168 |
potentiallyConflictingTags = new HashSet<>(); |
|
169 |
standardTags = new HashSet<>(); |
|
170 |
standardTagsLowercase = new HashSet<>(); |
|
171 |
unseenCustomTags = new HashSet<>(); |
|
50240 | 172 |
allTaglets = new LinkedHashMap<>(); |
10 | 173 |
this.nosince = nosince; |
174 |
this.showversion = showversion; |
|
175 |
this.showauthor = showauthor; |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
176 |
this.javafx = javafx; |
44388 | 177 |
this.docEnv = configuration.docEnv; |
178 |
this.doclet = configuration.doclet; |
|
40303 | 179 |
this.messages = configuration.getMessages(); |
180 |
this.resources = configuration.getResources(); |
|
50240 | 181 |
this.showTaglets = configuration.showTaglets; |
182 |
this.utils = configuration.utils; |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
183 |
initStandardTaglets(); |
10 | 184 |
} |
185 |
||
186 |
/** |
|
50240 | 187 |
* Add a new {@code Taglet}. This is used to add a Taglet from within |
10 | 188 |
* a Doclet. No message is printed to indicate that the Taglet is properly |
189 |
* registered because these Taglets are typically added for every execution of the |
|
190 |
* Doclet. We don't want to see this type of error message every time. |
|
50240 | 191 |
* @param customTag the new {@code Taglet} to add. |
10 | 192 |
*/ |
193 |
public void addCustomTag(Taglet customTag) { |
|
194 |
if (customTag != null) { |
|
195 |
String name = customTag.getName(); |
|
50240 | 196 |
allTaglets.remove(name); |
197 |
allTaglets.put(name, customTag); |
|
10 | 198 |
checkTagName(name); |
199 |
} |
|
200 |
} |
|
201 |
||
50240 | 202 |
public Set<String> getAllTagletNames() { |
203 |
return allTaglets.keySet(); |
|
21500
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
204 |
} |
475e59d3b40c
8006248: Since addition of -Xdoclint, javadoc ignores unknown tags
bpatel
parents:
18659
diff
changeset
|
205 |
|
10 | 206 |
/** |
50240 | 207 |
* Add a new {@code Taglet}. Print a message to indicate whether or not |
10 | 208 |
* the Taglet was registered properly. |
209 |
* @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
|
210 |
* @param fileManager the filemanager to load classes and resources. |
10 | 211 |
* @param tagletPath the path to the class representing the custom tag. |
212 |
*/ |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14368
diff
changeset
|
213 |
public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) { |
10 | 214 |
try { |
44388 | 215 |
ClassLoader tagClassLoader; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
216 |
if (!fileManager.hasLocation(TAGLET_PATH)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
217 |
List<File> paths = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
218 |
if (tagletPath != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
219 |
for (String pathname : tagletPath.split(File.pathSeparator)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
220 |
paths.add(new File(pathname)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
221 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
222 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
223 |
if (fileManager instanceof StandardJavaFileManager) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
224 |
((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, paths); |
10 | 225 |
} |
226 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
227 |
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH); |
44388 | 228 |
Class<? extends jdk.javadoc.doclet.Taglet> customTagClass = |
229 |
tagClassLoader.loadClass(classname).asSubclass(jdk.javadoc.doclet.Taglet.class); |
|
230 |
jdk.javadoc.doclet.Taglet instance = customTagClass.getConstructor().newInstance(); |
|
231 |
instance.init(docEnv, doclet); |
|
232 |
Taglet newLegacy = new UserTaglet(instance); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
233 |
String tname = newLegacy.getName(); |
50240 | 234 |
Taglet t = allTaglets.get(tname); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
235 |
if (t != null) { |
50240 | 236 |
allTaglets.remove(tname); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
237 |
} |
50240 | 238 |
allTaglets.put(tname, newLegacy); |
40303 | 239 |
messages.notice("doclet.Notice_taglet_registered", classname); |
10 | 240 |
} catch (Exception exc) { |
40303 | 241 |
messages.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname); |
10 | 242 |
} |
243 |
} |
|
244 |
||
245 |
/** |
|
50240 | 246 |
* Add a new {@code SimpleTaglet}. If this tag already exists |
10 | 247 |
* and the header passed as an argument is null, move tag to the back of the |
248 |
* list. If this tag already exists and the header passed as an argument is |
|
249 |
* not null, overwrite previous tag with new one. Otherwise, add new |
|
250 |
* SimpleTaglet to list. |
|
251 |
* @param tagName the name of this tag |
|
252 |
* @param header the header to output. |
|
253 |
* @param locations the possible locations that this tag |
|
254 |
* can appear in. |
|
255 |
*/ |
|
256 |
public void addNewSimpleCustomTag(String tagName, String header, String locations) { |
|
257 |
if (tagName == null || locations == null) { |
|
258 |
return; |
|
259 |
} |
|
50240 | 260 |
Taglet tag = allTaglets.get(tagName); |
10 | 261 |
if (tag == null || header != null) { |
50240 | 262 |
allTaglets.remove(tagName); |
263 |
allTaglets.put(tagName, new SimpleTaglet(tagName, header, locations)); |
|
264 |
if (Utils.toLowerCase(locations).indexOf('x') == -1) { |
|
10 | 265 |
checkTagName(tagName); |
266 |
} |
|
267 |
} else { |
|
268 |
//Move to back |
|
50240 | 269 |
allTaglets.remove(tagName); |
270 |
allTaglets.put(tagName, tag); |
|
10 | 271 |
} |
272 |
} |
|
273 |
||
274 |
/** |
|
275 |
* Given a tag name, add it to the set of tags it belongs to. |
|
276 |
*/ |
|
277 |
private void checkTagName(String name) { |
|
278 |
if (standardTags.contains(name)) { |
|
279 |
overridenStandardTags.add(name); |
|
280 |
} else { |
|
281 |
if (name.indexOf('.') == -1) { |
|
282 |
potentiallyConflictingTags.add(name); |
|
283 |
} |
|
284 |
unseenCustomTags.add(name); |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
/** |
|
289 |
* Given a name of a seen custom tag, remove it from the set of unseen |
|
290 |
* custom tags. |
|
291 |
* @param name the name of the seen custom tag. |
|
292 |
*/ |
|
50240 | 293 |
void seenCustomTag(String name) { |
10 | 294 |
unseenCustomTags.remove(name); |
295 |
} |
|
296 |
||
297 |
/** |
|
50240 | 298 |
* Given a series of {@code DocTree}s, check for spelling mistakes. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
299 |
* @param element the tags holder |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
300 |
* @param trees the trees containing the comments |
10 | 301 |
* @param areInlineTags true if the array of tags are inline and false otherwise. |
302 |
*/ |
|
50240 | 303 |
public void checkTags(Element element, Iterable<? extends DocTree> trees, boolean areInlineTags) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
304 |
if (trees == null) { |
10 | 305 |
return; |
306 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
307 |
CommentHelper ch = utils.getCommentHelper(element); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
308 |
for (DocTree tag : trees) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
309 |
String name = tag.getKind().tagName; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
310 |
if (name == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
311 |
continue; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
312 |
} |
10 | 313 |
if (name.length() > 0 && name.charAt(0) == '@') { |
314 |
name = name.substring(1, name.length()); |
|
315 |
} |
|
50240 | 316 |
if (! (standardTags.contains(name) || allTaglets.containsKey(name))) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
317 |
if (standardTagsLowercase.contains(Utils.toLowerCase(name))) { |
40303 | 318 |
messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag)); |
10 | 319 |
continue; |
320 |
} else { |
|
40303 | 321 |
messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag)); |
10 | 322 |
continue; |
323 |
} |
|
324 |
} |
|
50240 | 325 |
final Taglet taglet = allTaglets.get(name); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
326 |
// Check and verify tag usage |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
327 |
if (taglet != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
328 |
if (areInlineTags && !taglet.isInlineTag()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
329 |
printTagMisuseWarn(ch, taglet, tag, "inline"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
330 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
331 |
// nothing more to do |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
332 |
if (element == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
333 |
return; |
10 | 334 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
335 |
new SimpleElementVisitor9<Void, Void>() { |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
336 |
@Override |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
337 |
public Void visitModule(ModuleElement e, Void p) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
338 |
if (!taglet.inModule()) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
339 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "module"); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
340 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
341 |
return null; |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
342 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
343 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
344 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
345 |
public Void visitPackage(PackageElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
346 |
if (!taglet.inPackage()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
347 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
348 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
349 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
350 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
351 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
352 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
353 |
public Void visitType(TypeElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
354 |
if (!taglet.inType()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
355 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "class"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
356 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
357 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
358 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
359 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
360 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
361 |
public Void visitExecutable(ExecutableElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
362 |
if (utils.isConstructor(e) && !taglet.inConstructor()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
363 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "constructor"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
364 |
} else if (!taglet.inMethod()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
365 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "method"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
366 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
367 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
368 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
369 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
370 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
371 |
public Void visitVariable(VariableElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
372 |
if (utils.isField(e) && !taglet.inField()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
373 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "field"); |
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 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
376 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
377 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
378 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
379 |
public Void visitUnknown(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
380 |
if (utils.isOverviewElement(e) && !taglet.inOverview()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
381 |
printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "overview"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
382 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
383 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
384 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
385 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40303
diff
changeset
|
386 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
387 |
protected Void defaultAction(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
388 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
389 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
390 |
}.visit(element); |
10 | 391 |
} |
392 |
} |
|
393 |
} |
|
394 |
||
395 |
/** |
|
396 |
* Given the taglet, the tag and the type of documentation that the tag |
|
397 |
* was found in, print a tag misuse warning. |
|
398 |
* @param taglet the taglet representing the misused tag. |
|
399 |
* @param tag the misused tag. |
|
400 |
* @param holderType the type of documentation that the misused tag was found in. |
|
401 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
402 |
private void printTagMisuseWarn(CommentHelper ch, Taglet taglet, DocTree tag, String holderType) { |
22163 | 403 |
Set<String> locationsSet = new LinkedHashSet<>(); |
50240 | 404 |
// The following names should be localized |
10 | 405 |
if (taglet.inOverview()) { |
406 |
locationsSet.add("overview"); |
|
407 |
} |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
408 |
if (taglet.inModule()) { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
409 |
locationsSet.add("module"); |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
410 |
} |
10 | 411 |
if (taglet.inPackage()) { |
412 |
locationsSet.add("package"); |
|
413 |
} |
|
414 |
if (taglet.inType()) { |
|
415 |
locationsSet.add("class/interface"); |
|
416 |
} |
|
417 |
if (taglet.inConstructor()) { |
|
418 |
locationsSet.add("constructor"); |
|
419 |
} |
|
420 |
if (taglet.inField()) { |
|
421 |
locationsSet.add("field"); |
|
422 |
} |
|
423 |
if (taglet.inMethod()) { |
|
424 |
locationsSet.add("method"); |
|
425 |
} |
|
426 |
if (taglet.isInlineTag()) { |
|
427 |
locationsSet.add("inline text"); |
|
428 |
} |
|
50240 | 429 |
if (locationsSet.isEmpty()) { |
10 | 430 |
//This known tag is excluded. |
431 |
return; |
|
432 |
} |
|
14263 | 433 |
StringBuilder combined_locations = new StringBuilder(); |
50240 | 434 |
for (String location: locationsSet) { |
435 |
if (combined_locations.length() > 0) { |
|
10 | 436 |
combined_locations.append(", "); |
437 |
} |
|
50240 | 438 |
combined_locations.append(location); |
10 | 439 |
} |
40303 | 440 |
messages.warning(ch.getDocTreePath(tag), "doclet.tag_misuse", |
10 | 441 |
"@" + taglet.getName(), holderType, combined_locations.toString()); |
442 |
} |
|
443 |
||
444 |
/** |
|
50240 | 445 |
* Returns the taglets that can appear inline, in descriptive text. |
446 |
* @return the taglets that can appear inline |
|
10 | 447 |
*/ |
50240 | 448 |
List<Taglet> getInlineTaglets() { |
10 | 449 |
if (inlineTags == null) { |
50240 | 450 |
initBlockTaglets(); |
10 | 451 |
} |
452 |
return inlineTags; |
|
453 |
} |
|
454 |
||
455 |
/** |
|
50240 | 456 |
* Returns the taglets that can appear in the serialized form. |
457 |
* @return the taglet that can appear in the serialized form |
|
10 | 458 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
459 |
public List<Taglet> getSerializedFormTaglets() { |
10 | 460 |
if (serializedFormTags == null) { |
50240 | 461 |
initBlockTaglets(); |
10 | 462 |
} |
463 |
return serializedFormTags; |
|
464 |
} |
|
465 |
||
466 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
467 |
* Returns the custom tags for a given element. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
468 |
* |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
469 |
* @param e the element to get custom tags for |
50240 | 470 |
* @return the array of {@code Taglet}s that can |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
471 |
* appear in the given element. |
10 | 472 |
*/ |
50240 | 473 |
@SuppressWarnings("fallthrough") |
474 |
public List<Taglet> getBlockTaglets(Element e) { |
|
475 |
if (blockTagletsBySite == null) { |
|
476 |
initBlockTaglets(); |
|
477 |
} |
|
478 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
479 |
switch (e.getKind()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
480 |
case CONSTRUCTOR: |
50240 | 481 |
return blockTagletsBySite.get(Site.CONSTRUCTOR); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
482 |
case METHOD: |
50240 | 483 |
return blockTagletsBySite.get(Site.METHOD); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
484 |
case ENUM_CONSTANT: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
485 |
case FIELD: |
50240 | 486 |
return blockTagletsBySite.get(Site.FIELD); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
487 |
case ANNOTATION_TYPE: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
488 |
case INTERFACE: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
489 |
case CLASS: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
490 |
case ENUM: |
50240 | 491 |
return blockTagletsBySite.get(Site.TYPE); |
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
37759
diff
changeset
|
492 |
case MODULE: |
50240 | 493 |
return blockTagletsBySite.get(Site.MODULE); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
494 |
case PACKAGE: |
50240 | 495 |
return blockTagletsBySite.get(Site.PACKAGE); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
496 |
case OTHER: |
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
497 |
if (e instanceof DocletElement) { |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
498 |
DocletElement de = (DocletElement)e; |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
499 |
switch (de.getSubKind()) { |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
500 |
case DOCFILE: |
50240 | 501 |
return blockTagletsBySite.get(Site.PACKAGE); |
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
502 |
case OVERVIEW: |
50240 | 503 |
return blockTagletsBySite.get(Site.OVERVIEW); |
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
504 |
default: |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
505 |
// fall through |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
506 |
} |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47216
diff
changeset
|
507 |
} |
50240 | 508 |
// fall through |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
509 |
default: |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
510 |
throw new AssertionError("unknown element: " + e + " ,kind: " + e.getKind()); |
10 | 511 |
} |
512 |
} |
|
513 |
||
514 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
515 |
* Initialize the custom tag Lists. |
10 | 516 |
*/ |
50240 | 517 |
private void initBlockTaglets() { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
518 |
|
50240 | 519 |
blockTagletsBySite = new EnumMap<>(Site.class); |
520 |
for (Site site : Site.values()) { |
|
521 |
blockTagletsBySite.put(site, new ArrayList<>()); |
|
522 |
} |
|
523 |
||
524 |
inlineTags = new ArrayList<>(); |
|
525 |
||
526 |
for (Taglet current : allTaglets.values()) { |
|
10 | 527 |
if (current.isInlineTag()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
528 |
inlineTags.add(current); |
50240 | 529 |
} else { |
530 |
if (current.inOverview()) { |
|
531 |
blockTagletsBySite.get(Site.OVERVIEW).add(current); |
|
532 |
} |
|
533 |
if (current.inModule()) { |
|
534 |
blockTagletsBySite.get(Site.MODULE).add(current); |
|
535 |
} |
|
536 |
if (current.inPackage()) { |
|
537 |
blockTagletsBySite.get(Site.PACKAGE).add(current); |
|
538 |
} |
|
539 |
if (current.inType()) { |
|
540 |
blockTagletsBySite.get(Site.TYPE).add(current); |
|
541 |
} |
|
542 |
if (current.inConstructor()) { |
|
543 |
blockTagletsBySite.get(Site.CONSTRUCTOR).add(current); |
|
544 |
} |
|
545 |
if (current.inMethod()) { |
|
546 |
blockTagletsBySite.get(Site.METHOD).add(current); |
|
547 |
} |
|
548 |
if (current.inField()) { |
|
549 |
blockTagletsBySite.get(Site.FIELD).add(current); |
|
550 |
} |
|
10 | 551 |
} |
552 |
} |
|
553 |
||
554 |
//Init the serialized form tags |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
555 |
serializedFormTags = new ArrayList<>(); |
50240 | 556 |
serializedFormTags.add(allTaglets.get(SERIAL_DATA.tagName)); |
557 |
serializedFormTags.add(allTaglets.get(THROWS.tagName)); |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
5520
diff
changeset
|
558 |
if (!nosince) |
50240 | 559 |
serializedFormTags.add(allTaglets.get(SINCE.tagName)); |
560 |
serializedFormTags.add(allTaglets.get(SEE.tagName)); |
|
561 |
||
562 |
if (showTaglets) { |
|
563 |
showTaglets(System.out); |
|
564 |
} |
|
10 | 565 |
} |
566 |
||
567 |
/** |
|
568 |
* Initialize standard Javadoc tags for ordering purposes. |
|
569 |
*/ |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
570 |
private void initStandardTaglets() { |
18659
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
571 |
if (javafx) { |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
572 |
initJavaFXTaglets(); |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
573 |
} |
5fe5650da7f9
8015720: since tag isn't copied while generating JavaFX documentation
janvalenta
parents:
17573
diff
changeset
|
574 |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
575 |
addStandardTaglet(new ParamTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
576 |
addStandardTaglet(new ReturnTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
577 |
addStandardTaglet(new ThrowsTaglet()); |
50240 | 578 |
addStandardTaglet( |
579 |
new SimpleTaglet(EXCEPTION.tagName, null, |
|
580 |
EnumSet.of(Site.METHOD, Site.CONSTRUCTOR))); |
|
581 |
addStandardTaglet( |
|
582 |
new SimpleTaglet(SINCE.tagName, resources.getText("doclet.Since"), |
|
583 |
EnumSet.allOf(Site.class), !nosince)); |
|
584 |
addStandardTaglet( |
|
585 |
new SimpleTaglet(VERSION.tagName, resources.getText("doclet.Version"), |
|
586 |
EnumSet.of(Site.OVERVIEW, Site.MODULE, Site.PACKAGE, Site.TYPE), showversion)); |
|
587 |
addStandardTaglet( |
|
588 |
new SimpleTaglet(AUTHOR.tagName, resources.getText("doclet.Author"), |
|
589 |
EnumSet.of(Site.OVERVIEW, Site.MODULE, Site.PACKAGE, Site.TYPE), showauthor)); |
|
590 |
addStandardTaglet( |
|
591 |
new SimpleTaglet(SERIAL_DATA.tagName, resources.getText("doclet.SerialData"), |
|
592 |
EnumSet.noneOf(Site.class))); |
|
593 |
addStandardTaglet( |
|
594 |
new SimpleTaglet(HIDDEN.tagName, null, |
|
595 |
EnumSet.of(Site.TYPE, Site.METHOD, Site.FIELD))); |
|
596 |
||
597 |
// This appears to be a default custom (non-standard) taglet |
|
598 |
Taglet factoryTaglet = new SimpleTaglet("factory", resources.getText("doclet.Factory"), |
|
599 |
EnumSet.of(Site.METHOD)); |
|
600 |
allTaglets.put(factoryTaglet.getName(), factoryTaglet); |
|
601 |
||
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
602 |
addStandardTaglet(new SeeTaglet()); |
50240 | 603 |
|
604 |
// Standard inline tags |
|
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
605 |
addStandardTaglet(new DocRootTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
606 |
addStandardTaglet(new InheritDocTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
607 |
addStandardTaglet(new ValueTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
608 |
addStandardTaglet(new LiteralTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
609 |
addStandardTaglet(new CodeTaglet()); |
33920 | 610 |
addStandardTaglet(new IndexTaglet()); |
46184
f1325703ea85
8173425: Javadoc needs a new tag to specify the summary.
ksrini
parents:
45417
diff
changeset
|
611 |
addStandardTaglet(new SummaryTaglet()); |
52487
5d1d07b72f15
5076751: System properties documentation needed in javadocs
pmuthuswamy
parents:
50240
diff
changeset
|
612 |
addStandardTaglet(new SystemPropertyTaglet()); |
10 | 613 |
|
50240 | 614 |
// Keep track of the names of standard tags for error checking purposes. |
615 |
// The following are not handled above. |
|
616 |
addStandardTaglet(new DeprecatedTaglet()); |
|
617 |
addStandardTaglet(new BaseTaglet(LINK.tagName, true, EnumSet.allOf(Site.class))); |
|
618 |
addStandardTaglet(new BaseTaglet(LINK_PLAIN.tagName, true, EnumSet.allOf(Site.class))); |
|
619 |
addStandardTaglet(new BaseTaglet(USES.tagName, false, EnumSet.of(Site.MODULE))); |
|
620 |
addStandardTaglet(new BaseTaglet(PROVIDES.tagName, false, EnumSet.of(Site.MODULE))); |
|
621 |
addStandardTaglet( |
|
622 |
new SimpleTaglet(SERIAL.tagName, null, |
|
623 |
EnumSet.of(Site.PACKAGE, Site.TYPE, Site.FIELD))); |
|
624 |
addStandardTaglet( |
|
625 |
new SimpleTaglet(SERIAL_FIELD.tagName, null, EnumSet.of(Site.FIELD))); |
|
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
626 |
} |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
627 |
|
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
628 |
/** |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
629 |
* Initialize JavaFX-related tags. |
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14545
diff
changeset
|
630 |
*/ |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
631 |
private void initJavaFXTaglets() { |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
632 |
addStandardTaglet(new PropertyGetterTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
633 |
addStandardTaglet(new PropertySetterTaglet()); |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
634 |
addStandardTaglet(new SimpleTaglet("propertyDescription", |
40303 | 635 |
resources.getText("doclet.PropertyDescription"), |
50240 | 636 |
EnumSet.of(Site.METHOD, Site.FIELD))); |
40303 | 637 |
addStandardTaglet(new SimpleTaglet("defaultValue", resources.getText("doclet.DefaultValue"), |
50240 | 638 |
EnumSet.of(Site.METHOD, Site.FIELD))); |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
639 |
addStandardTaglet(new SimpleTaglet("treatAsPrivate", null, |
50240 | 640 |
EnumSet.of(Site.TYPE, Site.METHOD, Site.FIELD))); |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
641 |
} |
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
642 |
|
50240 | 643 |
private void addStandardTaglet(Taglet taglet) { |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
644 |
String name = taglet.getName(); |
50240 | 645 |
allTaglets.put(name, taglet); |
17573
0e20dec17c87
8012311: Cleanup names and duplicatre code in TagletManager
jjg
parents:
17572
diff
changeset
|
646 |
standardTags.add(name); |
50240 | 647 |
standardTagsLowercase.add(Utils.toLowerCase(name)); |
10 | 648 |
} |
649 |
||
650 |
public boolean isKnownCustomTag(String tagName) { |
|
50240 | 651 |
return allTaglets.containsKey(tagName); |
10 | 652 |
} |
653 |
||
654 |
/** |
|
655 |
* Print a list of {@link Taglet}s that might conflict with |
|
656 |
* standard tags in the future and a list of standard tags |
|
657 |
* that have been overriden. |
|
658 |
*/ |
|
659 |
public void printReport() { |
|
660 |
printReportHelper("doclet.Notice_taglet_conflict_warn", potentiallyConflictingTags); |
|
661 |
printReportHelper("doclet.Notice_taglet_overriden", overridenStandardTags); |
|
662 |
printReportHelper("doclet.Notice_taglet_unseen", unseenCustomTags); |
|
663 |
} |
|
664 |
||
868 | 665 |
private void printReportHelper(String noticeKey, Set<String> names) { |
10 | 666 |
if (names.size() > 0) { |
50240 | 667 |
StringBuilder result = new StringBuilder(); |
668 |
for (String name : names) { |
|
669 |
result.append(result.length() == 0 ? " " : ", "); |
|
670 |
result.append("@").append(name); |
|
10 | 671 |
} |
40303 | 672 |
messages.notice(noticeKey, result); |
10 | 673 |
} |
674 |
} |
|
675 |
||
676 |
/** |
|
677 |
* Given the name of a tag, return the corresponding taglet. |
|
678 |
* Return null if the tag is unknown. |
|
679 |
* |
|
680 |
* @param name the name of the taglet to retrieve. |
|
681 |
* @return return the corresponding taglet. Return null if the tag is |
|
682 |
* unknown. |
|
683 |
*/ |
|
50240 | 684 |
Taglet getTaglet(String name) { |
10 | 685 |
if (name.indexOf("@") == 0) { |
50240 | 686 |
return allTaglets.get(name.substring(1)); |
10 | 687 |
} else { |
50240 | 688 |
return allTaglets.get(name); |
10 | 689 |
} |
690 |
||
691 |
} |
|
50240 | 692 |
|
693 |
/* |
|
694 |
* The output of this method is the basis for a table at the end of the |
|
695 |
* doc comment specification, so any changes in the output may indicate |
|
696 |
* a need for a corresponding update to the spec. |
|
697 |
*/ |
|
698 |
private void showTaglets(PrintStream out) { |
|
699 |
Set<Taglet> taglets = new TreeSet<>((o1, o2) -> o1.getName().compareTo(o2.getName())); |
|
700 |
taglets.addAll(allTaglets.values()); |
|
701 |
||
702 |
for (Taglet t : taglets) { |
|
703 |
String name = t.isInlineTag() ? "{@" + t.getName() + "}" : "@" + t.getName(); |
|
704 |
out.println(String.format("%20s", name) + ": " |
|
705 |
+ format(t.inOverview(), "overview") + " " |
|
706 |
+ format(t.inModule(), "module") + " " |
|
707 |
+ format(t.inPackage(), "package") + " " |
|
708 |
+ format(t.inType(), "type") + " " |
|
709 |
+ format(t.inConstructor(),"constructor") + " " |
|
710 |
+ format(t.inMethod(), "method") + " " |
|
711 |
+ format(t.inField(), "field") + " " |
|
712 |
+ format(t.isInlineTag(), "inline")+ " " |
|
713 |
+ format((t instanceof SimpleTaglet) && !((SimpleTaglet)t).enabled, "disabled")); |
|
714 |
} |
|
715 |
} |
|
716 |
||
717 |
private String format(boolean b, String s) { |
|
718 |
return b ? s : s.replaceAll(".", "."); // replace all with "." |
|
719 |
} |
|
10 | 720 |
} |