author | jjg |
Tue, 09 Aug 2016 13:22:57 -0700 | |
changeset 40303 | 96a1226aca18 |
parent 38911 | 48a00b5ee366 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
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:
25874
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.taglets; |
10 | 27 |
|
14258 | 28 |
import java.util.*; |
29 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
30 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
31 |
import javax.lang.model.element.ExecutableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
32 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
import com.sun.source.doctree.DocTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
35 |
import com.sun.source.doctree.ParamTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40303 | 37 |
import jdk.javadoc.internal.doclets.toolkit.Messages; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
41 |
import jdk.javadoc.internal.doclets.toolkit.util.Utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
42 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
43 |
import static com.sun.source.doctree.DocTree.Kind.*; |
10 | 44 |
|
45 |
/** |
|
46 |
* A taglet that represents the @param tag. |
|
47 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
48 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
49 |
* 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:
14259
diff
changeset
|
50 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
51 |
* deletion without notice.</b> |
10 | 52 |
* |
53 |
* @author Jamie Ho |
|
54 |
*/ |
|
55 |
public class ParamTaglet extends BaseTaglet implements InheritableTaglet { |
|
56 |
||
57 |
/** |
|
58 |
* Construct a ParamTaglet. |
|
59 |
*/ |
|
60 |
public ParamTaglet() { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
61 |
name = PARAM.tagName; |
10 | 62 |
} |
63 |
||
64 |
/** |
|
65 |
* Given an array of <code>Parameter</code>s, return |
|
66 |
* a name/rank number map. If the array is null, then |
|
67 |
* null is returned. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
68 |
* @param params The array of parameters (from type or executable member) to |
10 | 69 |
* check. |
70 |
* @return a name-rank number map. |
|
71 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
72 |
private static Map<String, String> getRankMap(Utils utils, List<? extends Element> params){ |
10 | 73 |
if (params == null) { |
74 |
return null; |
|
75 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
76 |
HashMap<String, String> result = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
77 |
int rank = 0; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
78 |
for (Element e : params) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
79 |
String name = utils.isTypeParameterElement(e) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
80 |
? utils.getTypeName(e.asType(), false) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
81 |
: utils.getSimpleName(e); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
82 |
result.put(name, String.valueOf(rank)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
83 |
rank++; |
10 | 84 |
} |
85 |
return result; |
|
86 |
} |
|
87 |
||
88 |
/** |
|
89 |
* {@inheritDoc} |
|
90 |
*/ |
|
91 |
public void inherit(DocFinder.Input input, DocFinder.Output output) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
92 |
Utils utils = input.utils; |
10 | 93 |
if (input.tagId == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
94 |
input.isTypeVariableParamTag = ((ParamTree)input.docTreeInfo.docTree).isTypeParameter(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
95 |
ExecutableElement ee = (ExecutableElement)input.docTreeInfo.element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
96 |
CommentHelper ch = utils.getCommentHelper(ee); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
97 |
List<? extends Element> parameters = input.isTypeVariableParamTag |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
98 |
? ee.getTypeParameters() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
99 |
: ee.getParameters(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
100 |
String target = ch.getParameterName(input.docTreeInfo.docTree); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
101 |
for (int i = 0 ; i < parameters.size(); i++) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
102 |
Element e = parameters.get(i); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
103 |
String pname = input.isTypeVariableParamTag |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
104 |
? utils.getTypeName(e.asType(), false) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
105 |
: utils.getSimpleName(e); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
106 |
if (pname.equals(target)) { |
10 | 107 |
input.tagId = String.valueOf(i); |
108 |
break; |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
112 |
ExecutableElement md = (ExecutableElement)input.element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
113 |
CommentHelper ch = utils.getCommentHelper(md); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
114 |
List<? extends DocTree> tags = input.isTypeVariableParamTag |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
115 |
? utils.getTypeParamTrees(md) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
116 |
: utils.getParamTrees(md); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
117 |
List<? extends Element> parameters = input.isTypeVariableParamTag |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
118 |
? md.getTypeParameters() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
119 |
: md.getParameters(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
120 |
Map<String, String> rankMap = getRankMap(utils, parameters); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
121 |
for (DocTree tag : tags) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
122 |
String paramName = ch.getParameterName(tag); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
123 |
if (rankMap.containsKey(paramName) && rankMap.get(paramName).equals((input.tagId))) { |
17547
40f2f9a5a445
8008768: Using {@inheritDoc} in simple tag defined via -tag fails
jjg
parents:
14260
diff
changeset
|
124 |
output.holder = input.element; |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
17574
diff
changeset
|
125 |
output.holderTag = tag; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
126 |
output.inlineTags = ch.getBody(utils.configuration, tag); |
10 | 127 |
return; |
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
/** |
|
133 |
* {@inheritDoc} |
|
134 |
*/ |
|
135 |
public boolean inField() { |
|
136 |
return false; |
|
137 |
} |
|
138 |
||
139 |
/** |
|
140 |
* {@inheritDoc} |
|
141 |
*/ |
|
142 |
public boolean inMethod() { |
|
143 |
return true; |
|
144 |
} |
|
145 |
||
146 |
/** |
|
147 |
* {@inheritDoc} |
|
148 |
*/ |
|
149 |
public boolean inOverview() { |
|
150 |
return false; |
|
151 |
} |
|
152 |
||
153 |
/** |
|
154 |
* {@inheritDoc} |
|
155 |
*/ |
|
38911
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
156 |
public boolean inModule() { |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
157 |
return false; |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
158 |
} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
159 |
|
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
160 |
/** |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
161 |
* {@inheritDoc} |
48a00b5ee366
8156077: Support javadoc tags in module documentation
bpatel
parents:
35426
diff
changeset
|
162 |
*/ |
10 | 163 |
public boolean inPackage() { |
164 |
return false; |
|
165 |
} |
|
166 |
||
167 |
/** |
|
168 |
* {@inheritDoc} |
|
169 |
*/ |
|
170 |
public boolean inType() { |
|
171 |
return true; |
|
172 |
} |
|
173 |
||
174 |
/** |
|
175 |
* {@inheritDoc} |
|
176 |
*/ |
|
177 |
public boolean isInlineTag() { |
|
178 |
return false; |
|
179 |
} |
|
180 |
||
181 |
/** |
|
182 |
* Given an array of <code>ParamTag</code>s,return its string representation. |
|
183 |
* @param holder the member that holds the param tags. |
|
184 |
* @param writer the TagletWriter that will write this tag. |
|
185 |
* @return the TagletOutput representation of these <code>ParamTag</code>s. |
|
186 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
187 |
public Content getTagletOutput(Element holder, TagletWriter writer) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
188 |
Utils utils = writer.configuration().utils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
189 |
if (utils.isExecutableElement(holder)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
190 |
ExecutableElement member = (ExecutableElement) holder; |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
191 |
Content output = getTagletOutput(false, member, writer, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
192 |
member.getTypeParameters(), utils.getTypeParamTrees(member)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
193 |
output.addContent(getTagletOutput(true, member, writer, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
194 |
member.getParameters(), utils.getParamTrees(member))); |
10 | 195 |
return output; |
196 |
} else { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
197 |
TypeElement typeElement = (TypeElement) holder; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
198 |
return getTagletOutput(false, typeElement, writer, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
199 |
typeElement.getTypeParameters(), utils.getTypeParamTrees(typeElement)); |
10 | 200 |
} |
201 |
} |
|
202 |
||
203 |
/** |
|
204 |
* Given an array of <code>ParamTag</code>s,return its string representation. |
|
205 |
* Try to inherit the param tags that are missing. |
|
206 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
207 |
* @param holder the element that holds the param tags. |
10 | 208 |
* @param writer the TagletWriter that will write this tag. |
209 |
* @param formalParameters The array of parmeters (from type or executable |
|
210 |
* member) to check. |
|
211 |
* |
|
212 |
* @return the TagletOutput representation of these <code>ParamTag</code>s. |
|
213 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
214 |
private Content getTagletOutput(boolean isParameters, Element holder, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
215 |
TagletWriter writer, List<? extends Element> formalParameters, List<? extends DocTree> paramTags) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
216 |
Content result = writer.getOutputInstance(); |
22163 | 217 |
Set<String> alreadyDocumented = new HashSet<>(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
218 |
if (!paramTags.isEmpty()) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
219 |
result.addContent( |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
220 |
processParamTags(holder, isParameters, paramTags, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
221 |
getRankMap(writer.configuration().utils, formalParameters), writer, alreadyDocumented) |
10 | 222 |
); |
223 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
224 |
if (alreadyDocumented.size() != formalParameters.size()) { |
10 | 225 |
//Some parameters are missing corresponding @param tags. |
226 |
//Try to inherit them. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
227 |
result.addContent(getInheritedTagletOutput(isParameters, holder, |
10 | 228 |
writer, formalParameters, alreadyDocumented)); |
229 |
} |
|
230 |
return result; |
|
231 |
} |
|
232 |
||
233 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
234 |
* Loop through each individual parameter, despite not having a |
10 | 235 |
* corresponding param tag, try to inherit it. |
236 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
237 |
private Content getInheritedTagletOutput(boolean isParameters, Element holder, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
238 |
TagletWriter writer, List<? extends Element> formalParameters, |
868 | 239 |
Set<String> alreadyDocumented) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
240 |
Utils utils = writer.configuration().utils; |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
241 |
Content result = writer.getOutputInstance(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
242 |
if ((!alreadyDocumented.contains(null)) && utils.isExecutableElement(holder)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
243 |
for (int i = 0; i < formalParameters.size(); i++) { |
10 | 244 |
if (alreadyDocumented.contains(String.valueOf(i))) { |
245 |
continue; |
|
246 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
247 |
// This parameter does not have any @param documentation. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
248 |
// Try to inherit it. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
249 |
Input input = new DocFinder.Input(writer.configuration().utils, holder, this, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
250 |
Integer.toString(i), !isParameters); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
251 |
DocFinder.Output inheritedDoc = DocFinder.search(writer.configuration(), input); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
252 |
if (inheritedDoc.inlineTags != null && !inheritedDoc.inlineTags.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
253 |
Element e = formalParameters.get(i); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
254 |
String lname = isParameters |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
255 |
? utils.getSimpleName(e) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
256 |
: utils.getTypeName(e.asType(), false); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
257 |
CommentHelper ch = utils.getCommentHelper(holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
258 |
ch.setOverrideElement(inheritedDoc.holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
259 |
Content content = processParamTag(holder, isParameters, writer, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
260 |
inheritedDoc.holderTag, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
261 |
lname, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
262 |
alreadyDocumented.isEmpty()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
263 |
result.addContent(content); |
10 | 264 |
} |
265 |
alreadyDocumented.add(String.valueOf(i)); |
|
266 |
} |
|
267 |
} |
|
268 |
return result; |
|
269 |
} |
|
270 |
||
271 |
/** |
|
272 |
* Given an array of <code>Tag</code>s representing this custom |
|
273 |
* tag, return its string representation. Print a warning for param |
|
274 |
* tags that do not map to parameters. Print a warning for param |
|
275 |
* tags that are duplicated. |
|
276 |
* |
|
277 |
* @param paramTags the array of <code>ParamTag</code>s to convert. |
|
278 |
* @param writer the TagletWriter that will write this tag. |
|
279 |
* @param alreadyDocumented the set of exceptions that have already |
|
280 |
* been documented. |
|
281 |
* @param rankMap a {@link java.util.Map} which holds ordering |
|
282 |
* information about the parameters. |
|
14259 | 283 |
* @param rankMap a {@link java.util.Map} which holds a mapping |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
284 |
of a rank of a parameter to its name. This is |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
285 |
used to ensure that the right name is used |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
286 |
when parameter documentation is inherited. |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
287 |
* @return the Content representation of this <code>Tag</code>. |
10 | 288 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
289 |
private Content processParamTags(Element e, boolean isParams, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
290 |
List<? extends DocTree> paramTags, Map<String, String> rankMap, TagletWriter writer, |
868 | 291 |
Set<String> alreadyDocumented) { |
40303 | 292 |
Messages messages = writer.configuration().getMessages(); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
293 |
Content result = writer.getOutputInstance(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
294 |
if (!paramTags.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
295 |
CommentHelper ch = writer.configuration().utils.getCommentHelper(e); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
296 |
for (DocTree dt : paramTags) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
297 |
String paramName = isParams |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
298 |
? ch.getParameterName(dt) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
299 |
: "<" + ch.getParameterName(dt) + ">"; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
300 |
if (!rankMap.containsKey(ch.getParameterName(dt))) { |
40303 | 301 |
messages.warning(ch.getDocTreePath(dt), |
302 |
isParams |
|
303 |
? "doclet.Parameters_warn" |
|
304 |
: "doclet.Type_Parameters_warn", |
|
305 |
paramName); |
|
10 | 306 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
307 |
String rank = rankMap.get(ch.getParameterName(dt)); |
10 | 308 |
if (rank != null && alreadyDocumented.contains(rank)) { |
40303 | 309 |
messages.warning(ch.getDocTreePath(dt), |
310 |
isParams |
|
311 |
? "doclet.Parameters_dup_warn" |
|
312 |
: "doclet.Type_Parameters_dup_warn", |
|
313 |
paramName); |
|
10 | 314 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
315 |
result.addContent(processParamTag(e, isParams, writer, dt, |
40303 | 316 |
ch.getParameterName(dt), alreadyDocumented.isEmpty())); |
10 | 317 |
alreadyDocumented.add(rank); |
318 |
} |
|
319 |
} |
|
320 |
return result; |
|
321 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
322 |
|
10 | 323 |
/** |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
324 |
* Convert the individual ParamTag into Content. |
10 | 325 |
* |
326 |
* @param isNonTypeParams true if this is just a regular param tag. False |
|
327 |
* if this is a type param tag. |
|
328 |
* @param writer the taglet writer for output writing. |
|
329 |
* @param paramTag the tag whose inline tags will be printed. |
|
330 |
* @param name the name of the parameter. We can't rely on |
|
331 |
* the name in the param tag because we might be |
|
332 |
* inheriting documentation. |
|
333 |
* @param isFirstParam true if this is the first param tag being printed. |
|
334 |
* |
|
335 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
336 |
private Content processParamTag(Element e, boolean isParams, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
337 |
TagletWriter writer, DocTree paramTag, String name, |
10 | 338 |
boolean isFirstParam) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
339 |
Content result = writer.getOutputInstance(); |
10 | 340 |
String header = writer.configuration().getText( |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
341 |
isParams ? "doclet.Parameters" : "doclet.TypeParameters"); |
10 | 342 |
if (isFirstParam) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17547
diff
changeset
|
343 |
result.addContent(writer.getParamHeader(header)); |
10 | 344 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
345 |
result.addContent(writer.paramTagOutput(e, paramTag, name)); |
10 | 346 |
return result; |
347 |
} |
|
348 |
} |