163 * Given an array of <code>ParamTag</code>s,return its string representation. |
164 * Given an array of <code>ParamTag</code>s,return its string representation. |
164 * @param holder the member that holds the param tags. |
165 * @param holder the member that holds the param tags. |
165 * @param writer the TagletWriter that will write this tag. |
166 * @param writer the TagletWriter that will write this tag. |
166 * @return the TagletOutput representation of these <code>ParamTag</code>s. |
167 * @return the TagletOutput representation of these <code>ParamTag</code>s. |
167 */ |
168 */ |
168 public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) { |
169 public Content getTagletOutput(Doc holder, TagletWriter writer) { |
169 if (holder instanceof ExecutableMemberDoc) { |
170 if (holder instanceof ExecutableMemberDoc) { |
170 ExecutableMemberDoc member = (ExecutableMemberDoc) holder; |
171 ExecutableMemberDoc member = (ExecutableMemberDoc) holder; |
171 TagletOutput output = getTagletOutput(false, member, writer, |
172 Content output = getTagletOutput(false, member, writer, |
172 member.typeParameters(), member.typeParamTags()); |
173 member.typeParameters(), member.typeParamTags()); |
173 output.appendOutput(getTagletOutput(true, member, writer, |
174 output.addContent(getTagletOutput(true, member, writer, |
174 member.parameters(), member.paramTags())); |
175 member.parameters(), member.paramTags())); |
175 return output; |
176 return output; |
176 } else { |
177 } else { |
177 ClassDoc classDoc = (ClassDoc) holder; |
178 ClassDoc classDoc = (ClassDoc) holder; |
178 return getTagletOutput(false, classDoc, writer, |
179 return getTagletOutput(false, classDoc, writer, |
189 * @param formalParameters The array of parmeters (from type or executable |
190 * @param formalParameters The array of parmeters (from type or executable |
190 * member) to check. |
191 * member) to check. |
191 * |
192 * |
192 * @return the TagletOutput representation of these <code>ParamTag</code>s. |
193 * @return the TagletOutput representation of these <code>ParamTag</code>s. |
193 */ |
194 */ |
194 private TagletOutput getTagletOutput(boolean isNonTypeParams, Doc holder, |
195 private Content getTagletOutput(boolean isNonTypeParams, Doc holder, |
195 TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) { |
196 TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) { |
196 TagletOutput result = writer.getOutputInstance(); |
197 Content result = writer.getOutputInstance(); |
197 Set<String> alreadyDocumented = new HashSet<String>(); |
198 Set<String> alreadyDocumented = new HashSet<String>(); |
198 if (paramTags.length > 0) { |
199 if (paramTags.length > 0) { |
199 result.appendOutput( |
200 result.addContent( |
200 processParamTags(isNonTypeParams, paramTags, |
201 processParamTags(isNonTypeParams, paramTags, |
201 getRankMap(formalParameters), writer, alreadyDocumented) |
202 getRankMap(formalParameters), writer, alreadyDocumented) |
202 ); |
203 ); |
203 } |
204 } |
204 if (alreadyDocumented.size() != formalParameters.length) { |
205 if (alreadyDocumented.size() != formalParameters.length) { |
205 //Some parameters are missing corresponding @param tags. |
206 //Some parameters are missing corresponding @param tags. |
206 //Try to inherit them. |
207 //Try to inherit them. |
207 result.appendOutput(getInheritedTagletOutput (isNonTypeParams, holder, |
208 result.addContent(getInheritedTagletOutput (isNonTypeParams, holder, |
208 writer, formalParameters, alreadyDocumented)); |
209 writer, formalParameters, alreadyDocumented)); |
209 } |
210 } |
210 return result; |
211 return result; |
211 } |
212 } |
212 |
213 |
213 /** |
214 /** |
214 * Loop through each indivitual parameter. It it does not have a |
215 * Loop through each indivitual parameter. It it does not have a |
215 * corresponding param tag, try to inherit it. |
216 * corresponding param tag, try to inherit it. |
216 */ |
217 */ |
217 private TagletOutput getInheritedTagletOutput(boolean isNonTypeParams, Doc holder, |
218 private Content getInheritedTagletOutput(boolean isNonTypeParams, Doc holder, |
218 TagletWriter writer, Object[] formalParameters, |
219 TagletWriter writer, Object[] formalParameters, |
219 Set<String> alreadyDocumented) { |
220 Set<String> alreadyDocumented) { |
220 TagletOutput result = writer.getOutputInstance(); |
221 Content result = writer.getOutputInstance(); |
221 if ((! alreadyDocumented.contains(null)) && |
222 if ((! alreadyDocumented.contains(null)) && |
222 holder instanceof MethodDoc) { |
223 holder instanceof MethodDoc) { |
223 for (int i = 0; i < formalParameters.length; i++) { |
224 for (int i = 0; i < formalParameters.length; i++) { |
224 if (alreadyDocumented.contains(String.valueOf(i))) { |
225 if (alreadyDocumented.contains(String.valueOf(i))) { |
225 continue; |
226 continue; |
229 DocFinder.Output inheritedDoc = |
230 DocFinder.Output inheritedDoc = |
230 DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, |
231 DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, |
231 String.valueOf(i), ! isNonTypeParams)); |
232 String.valueOf(i), ! isNonTypeParams)); |
232 if (inheritedDoc.inlineTags != null && |
233 if (inheritedDoc.inlineTags != null && |
233 inheritedDoc.inlineTags.length > 0) { |
234 inheritedDoc.inlineTags.length > 0) { |
234 result.appendOutput( |
235 result.addContent( |
235 processParamTag(isNonTypeParams, writer, |
236 processParamTag(isNonTypeParams, writer, |
236 (ParamTag) inheritedDoc.holderTag, |
237 (ParamTag) inheritedDoc.holderTag, |
237 isNonTypeParams ? |
238 isNonTypeParams ? |
238 ((Parameter) formalParameters[i]).name(): |
239 ((Parameter) formalParameters[i]).name(): |
239 ((TypeVariable) formalParameters[i]).typeName(), |
240 ((TypeVariable) formalParameters[i]).typeName(), |
259 * information about the parameters. |
260 * information about the parameters. |
260 * @param rankMap a {@link java.util.Map} which holds a mapping |
261 * @param rankMap a {@link java.util.Map} which holds a mapping |
261 * of a rank of a parameter to its name. This is |
262 * of a rank of a parameter to its name. This is |
262 * used to ensure that the right name is used |
263 * used to ensure that the right name is used |
263 * when parameter documentation is inherited. |
264 * when parameter documentation is inherited. |
264 * @return the TagletOutput representation of this <code>Tag</code>. |
265 * @return the Content representation of this <code>Tag</code>. |
265 */ |
266 */ |
266 private TagletOutput processParamTags(boolean isNonTypeParams, |
267 private Content processParamTags(boolean isNonTypeParams, |
267 ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer, |
268 ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer, |
268 Set<String> alreadyDocumented) { |
269 Set<String> alreadyDocumented) { |
269 TagletOutput result = writer.getOutputInstance(); |
270 Content result = writer.getOutputInstance(); |
270 if (paramTags.length > 0) { |
271 if (paramTags.length > 0) { |
271 for (int i = 0; i < paramTags.length; ++i) { |
272 for (int i = 0; i < paramTags.length; ++i) { |
272 ParamTag pt = paramTags[i]; |
273 ParamTag pt = paramTags[i]; |
273 String paramName = isNonTypeParams ? |
274 String paramName = isNonTypeParams ? |
274 pt.parameterName() : "<" + pt.parameterName() + ">"; |
275 pt.parameterName() : "<" + pt.parameterName() + ">"; |
285 isNonTypeParams ? |
286 isNonTypeParams ? |
286 "doclet.Parameters_dup_warn" : |
287 "doclet.Parameters_dup_warn" : |
287 "doclet.Type_Parameters_dup_warn", |
288 "doclet.Type_Parameters_dup_warn", |
288 paramName); |
289 paramName); |
289 } |
290 } |
290 result.appendOutput(processParamTag(isNonTypeParams, writer, pt, |
291 result.addContent(processParamTag(isNonTypeParams, writer, pt, |
291 pt.parameterName(), alreadyDocumented.size() == 0)); |
292 pt.parameterName(), alreadyDocumented.size() == 0)); |
292 alreadyDocumented.add(rank); |
293 alreadyDocumented.add(rank); |
293 } |
294 } |
294 } |
295 } |
295 return result; |
296 return result; |
296 } |
297 } |
297 /** |
298 /** |
298 * Convert the individual ParamTag into TagletOutput. |
299 * Convert the individual ParamTag into Content. |
299 * |
300 * |
300 * @param isNonTypeParams true if this is just a regular param tag. False |
301 * @param isNonTypeParams true if this is just a regular param tag. False |
301 * if this is a type param tag. |
302 * if this is a type param tag. |
302 * @param writer the taglet writer for output writing. |
303 * @param writer the taglet writer for output writing. |
303 * @param paramTag the tag whose inline tags will be printed. |
304 * @param paramTag the tag whose inline tags will be printed. |
305 * the name in the param tag because we might be |
306 * the name in the param tag because we might be |
306 * inheriting documentation. |
307 * inheriting documentation. |
307 * @param isFirstParam true if this is the first param tag being printed. |
308 * @param isFirstParam true if this is the first param tag being printed. |
308 * |
309 * |
309 */ |
310 */ |
310 private TagletOutput processParamTag(boolean isNonTypeParams, |
311 private Content processParamTag(boolean isNonTypeParams, |
311 TagletWriter writer, ParamTag paramTag, String name, |
312 TagletWriter writer, ParamTag paramTag, String name, |
312 boolean isFirstParam) { |
313 boolean isFirstParam) { |
313 TagletOutput result = writer.getOutputInstance(); |
314 Content result = writer.getOutputInstance(); |
314 String header = writer.configuration().getText( |
315 String header = writer.configuration().getText( |
315 isNonTypeParams ? "doclet.Parameters" : "doclet.TypeParameters"); |
316 isNonTypeParams ? "doclet.Parameters" : "doclet.TypeParameters"); |
316 if (isFirstParam) { |
317 if (isFirstParam) { |
317 result.appendOutput(writer.getParamHeader(header)); |
318 result.addContent(writer.getParamHeader(header)); |
318 } |
319 } |
319 result.appendOutput(writer.paramTagOutput(paramTag, |
320 result.addContent(writer.paramTagOutput(paramTag, |
320 name)); |
321 name)); |
321 return result; |
322 return result; |
322 } |
323 } |
323 } |
324 } |