Thu, 29 Aug 2013 11:41:20 -0700
8001669: javadoc internal DocletAbortException should set cause when appropriate
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1735 | 2 | * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
jjg@1357 | 28 | import java.lang.reflect.Modifier; |
bpatel@766 | 29 | import java.util.*; |
jjg@1357 | 30 | |
bpatel@233 | 31 | import com.sun.javadoc.*; |
bpatel@766 | 32 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@766 | 33 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1357 | 34 | import com.sun.tools.doclets.internal.toolkit.taglets.*; |
duke@1 | 35 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 36 | |
duke@1 | 37 | /** |
duke@1 | 38 | * The base class for member writers. |
duke@1 | 39 | * |
jjg@1359 | 40 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 41 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 42 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 43 | * deletion without notice.</b> |
jjg@1359 | 44 | * |
duke@1 | 45 | * @author Robert Field |
duke@1 | 46 | * @author Atul M Dambalkar |
duke@1 | 47 | * @author Jamie Ho (Re-write) |
bpatel@233 | 48 | * @author Bhavesh Patel (Modified) |
duke@1 | 49 | */ |
duke@1 | 50 | public abstract class AbstractMemberWriter { |
duke@1 | 51 | |
jjg@1410 | 52 | protected final ConfigurationImpl configuration; |
duke@1 | 53 | protected final SubWriterHolderWriter writer; |
duke@1 | 54 | protected final ClassDoc classdoc; |
bpatel@1417 | 55 | protected Map<String,Integer> typeMap = new LinkedHashMap<String,Integer>(); |
bpatel@1417 | 56 | protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class); |
bpatel@1417 | 57 | private int methodTypesOr = 0; |
duke@1 | 58 | public final boolean nodepr; |
duke@1 | 59 | |
jjg@1410 | 60 | protected boolean printedSummaryHeader = false; |
jjg@1410 | 61 | |
jjg@1410 | 62 | public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) { |
jjg@1410 | 63 | this.configuration = writer.configuration; |
duke@1 | 64 | this.writer = writer; |
jjg@1410 | 65 | this.nodepr = configuration.nodeprecated; |
duke@1 | 66 | this.classdoc = classdoc; |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | public AbstractMemberWriter(SubWriterHolderWriter writer) { |
duke@1 | 70 | this(writer, null); |
duke@1 | 71 | } |
duke@1 | 72 | |
duke@1 | 73 | /*** abstracts ***/ |
duke@1 | 74 | |
bpatel@766 | 75 | /** |
bpatel@766 | 76 | * Add the summary label for the member. |
bpatel@766 | 77 | * |
bpatel@766 | 78 | * @param memberTree the content tree to which the label will be added |
bpatel@766 | 79 | */ |
bpatel@766 | 80 | public abstract void addSummaryLabel(Content memberTree); |
bpatel@243 | 81 | |
bpatel@766 | 82 | /** |
bpatel@766 | 83 | * Get the summary for the member summary table. |
bpatel@766 | 84 | * |
bpatel@766 | 85 | * @return a string for the table summary |
bpatel@766 | 86 | */ |
bpatel@766 | 87 | public abstract String getTableSummary(); |
bpatel@243 | 88 | |
bpatel@766 | 89 | /** |
bpatel@766 | 90 | * Get the caption for the member summary table. |
bpatel@766 | 91 | * |
bpatel@766 | 92 | * @return a string for the table caption |
bpatel@766 | 93 | */ |
jjg@1747 | 94 | public abstract Content getCaption(); |
duke@1 | 95 | |
bpatel@766 | 96 | /** |
bpatel@766 | 97 | * Get the summary table header for the member. |
bpatel@766 | 98 | * |
bpatel@766 | 99 | * @param member the member to be documented |
bpatel@766 | 100 | * @return the summary table header |
bpatel@766 | 101 | */ |
bpatel@766 | 102 | public abstract String[] getSummaryTableHeader(ProgramElementDoc member); |
duke@1 | 103 | |
bpatel@766 | 104 | /** |
bpatel@766 | 105 | * Add inherited summary lable for the member. |
bpatel@766 | 106 | * |
bpatel@766 | 107 | * @param cd the class doc to which to link to |
bpatel@766 | 108 | * @param inheritedTree the content tree to which the inherited summary label will be added |
bpatel@766 | 109 | */ |
bpatel@766 | 110 | public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree); |
duke@1 | 111 | |
bpatel@766 | 112 | /** |
bpatel@766 | 113 | * Add the anchor for the summary section of the member. |
bpatel@766 | 114 | * |
bpatel@766 | 115 | * @param cd the class doc to be documented |
bpatel@766 | 116 | * @param memberTree the content tree to which the summary anchor will be added |
bpatel@766 | 117 | */ |
bpatel@766 | 118 | public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree); |
duke@1 | 119 | |
bpatel@766 | 120 | /** |
bpatel@766 | 121 | * Add the anchor for the inherited summary section of the member. |
bpatel@766 | 122 | * |
bpatel@766 | 123 | * @param cd the class doc to be documented |
bpatel@766 | 124 | * @param inheritedTree the content tree to which the inherited summary anchor will be added |
bpatel@766 | 125 | */ |
bpatel@766 | 126 | public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree); |
duke@1 | 127 | |
bpatel@766 | 128 | /** |
bpatel@766 | 129 | * Add the summary type for the member. |
bpatel@766 | 130 | * |
bpatel@766 | 131 | * @param member the member to be documented |
bpatel@766 | 132 | * @param tdSummaryType the content tree to which the type will be added |
bpatel@766 | 133 | */ |
bpatel@766 | 134 | protected abstract void addSummaryType(ProgramElementDoc member, |
bpatel@766 | 135 | Content tdSummaryType); |
bpatel@766 | 136 | |
bpatel@766 | 137 | /** |
bpatel@766 | 138 | * Add the summary link for the member. |
bpatel@766 | 139 | * |
bpatel@766 | 140 | * @param cd the class doc to be documented |
bpatel@766 | 141 | * @param member the member to be documented |
bpatel@766 | 142 | * @param tdSummary the content tree to which the link will be added |
bpatel@766 | 143 | */ |
bpatel@766 | 144 | protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member, |
bpatel@766 | 145 | Content tdSummary) { |
jjg@1735 | 146 | addSummaryLink(LinkInfoImpl.Kind.MEMBER, cd, member, tdSummary); |
duke@1 | 147 | } |
duke@1 | 148 | |
bpatel@766 | 149 | /** |
bpatel@766 | 150 | * Add the summary link for the member. |
bpatel@766 | 151 | * |
bpatel@766 | 152 | * @param context the id of the context where the link will be printed |
bpatel@766 | 153 | * @param cd the class doc to be documented |
bpatel@766 | 154 | * @param member the member to be documented |
bpatel@766 | 155 | * @param tdSummary the content tree to which the summary link will be added |
bpatel@766 | 156 | */ |
jjg@1735 | 157 | protected abstract void addSummaryLink(LinkInfoImpl.Kind context, |
bpatel@766 | 158 | ClassDoc cd, ProgramElementDoc member, Content tdSummary); |
duke@1 | 159 | |
bpatel@766 | 160 | /** |
bpatel@766 | 161 | * Add the inherited summary link for the member. |
bpatel@766 | 162 | * |
bpatel@766 | 163 | * @param cd the class doc to be documented |
bpatel@766 | 164 | * @param member the member to be documented |
bpatel@766 | 165 | * @param linksTree the content tree to which the inherited summary link will be added |
bpatel@766 | 166 | */ |
bpatel@766 | 167 | protected abstract void addInheritedSummaryLink(ClassDoc cd, |
bpatel@766 | 168 | ProgramElementDoc member, Content linksTree); |
duke@1 | 169 | |
bpatel@766 | 170 | /** |
bpatel@766 | 171 | * Get the deprecated link. |
bpatel@766 | 172 | * |
bpatel@766 | 173 | * @param member the member being linked to |
bpatel@766 | 174 | * @return a content tree representing the link |
bpatel@766 | 175 | */ |
bpatel@766 | 176 | protected abstract Content getDeprecatedLink(ProgramElementDoc member); |
duke@1 | 177 | |
bpatel@766 | 178 | /** |
bpatel@766 | 179 | * Get the navigation summary link. |
bpatel@766 | 180 | * |
bpatel@766 | 181 | * @param cd the class doc to be documented |
bpatel@766 | 182 | * @param link true if its a link else the label to be printed |
bpatel@766 | 183 | * @return a content tree for the navigation summary link. |
bpatel@766 | 184 | */ |
bpatel@766 | 185 | protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link); |
duke@1 | 186 | |
bpatel@766 | 187 | /** |
bpatel@766 | 188 | * Add the navigation detail link. |
bpatel@766 | 189 | * |
bpatel@766 | 190 | * @param link true if its a link else the label to be printed |
bpatel@766 | 191 | * @param liNav the content tree to which the navigation detail link will be added |
bpatel@766 | 192 | */ |
bpatel@766 | 193 | protected abstract void addNavDetailLink(boolean link, Content liNav); |
duke@1 | 194 | |
duke@1 | 195 | /** |
jjg@1741 | 196 | * Add the member name to the content tree. |
bpatel@766 | 197 | * |
bpatel@766 | 198 | * @param name the member name to be added to the content tree. |
bpatel@766 | 199 | * @param htmltree the content tree to which the name will be added. |
bpatel@766 | 200 | */ |
bpatel@766 | 201 | protected void addName(String name, Content htmltree) { |
bpatel@766 | 202 | htmltree.addContent(name); |
bpatel@766 | 203 | } |
bpatel@766 | 204 | |
bpatel@766 | 205 | /** |
duke@1 | 206 | * Return a string describing the access modifier flags. |
duke@1 | 207 | * Don't include native or synchronized. |
duke@1 | 208 | * |
duke@1 | 209 | * The modifier names are returned in canonical order, as |
duke@1 | 210 | * specified by <em>The Java Language Specification</em>. |
duke@1 | 211 | */ |
duke@1 | 212 | protected String modifierString(MemberDoc member) { |
duke@1 | 213 | int ms = member.modifierSpecifier(); |
duke@1 | 214 | int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; |
duke@1 | 215 | return Modifier.toString(ms & ~no); |
duke@1 | 216 | } |
duke@1 | 217 | |
duke@1 | 218 | protected String typeString(MemberDoc member) { |
duke@1 | 219 | String type = ""; |
duke@1 | 220 | if (member instanceof MethodDoc) { |
duke@1 | 221 | type = ((MethodDoc)member).returnType().toString(); |
duke@1 | 222 | } else if (member instanceof FieldDoc) { |
duke@1 | 223 | type = ((FieldDoc)member).type().toString(); |
duke@1 | 224 | } |
duke@1 | 225 | return type; |
duke@1 | 226 | } |
duke@1 | 227 | |
bpatel@766 | 228 | /** |
bpatel@766 | 229 | * Add the modifier for the member. |
bpatel@766 | 230 | * |
bpatel@766 | 231 | * @param member the member for which teh modifier will be added. |
bpatel@766 | 232 | * @param htmltree the content tree to which the modifier information will be added. |
bpatel@766 | 233 | */ |
bpatel@766 | 234 | protected void addModifiers(MemberDoc member, Content htmltree) { |
duke@1 | 235 | String mod = modifierString(member); |
duke@1 | 236 | // According to JLS, we should not be showing public modifier for |
duke@1 | 237 | // interface methods. |
duke@1 | 238 | if ((member.isField() || member.isMethod()) && |
duke@1 | 239 | writer instanceof ClassWriterImpl && |
bpatel@766 | 240 | ((ClassWriterImpl) writer).getClassDoc().isInterface()) { |
bpatel@1468 | 241 | // This check for isDefault() and the default modifier needs to be |
bpatel@1468 | 242 | // added for it to appear on the method details section. Once the |
bpatel@1468 | 243 | // default modifier is added to the Modifier list on DocEnv and once |
bpatel@1468 | 244 | // it is updated to use the javax.lang.model.element.Modifier, we |
bpatel@1468 | 245 | // will need to remove this. |
bpatel@1468 | 246 | mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ? |
bpatel@1468 | 247 | Util.replaceText(mod, "public", "default").trim() : |
bpatel@1468 | 248 | Util.replaceText(mod, "public", "").trim(); |
duke@1 | 249 | } |
duke@1 | 250 | if(mod.length() > 0) { |
bpatel@766 | 251 | htmltree.addContent(mod); |
bpatel@766 | 252 | htmltree.addContent(writer.getSpace()); |
duke@1 | 253 | } |
duke@1 | 254 | } |
duke@1 | 255 | |
duke@1 | 256 | protected String makeSpace(int len) { |
duke@1 | 257 | if (len <= 0) { |
duke@1 | 258 | return ""; |
duke@1 | 259 | } |
jjg@1362 | 260 | StringBuilder sb = new StringBuilder(len); |
jjg@1741 | 261 | for (int i = 0; i < len; i++) { |
duke@1 | 262 | sb.append(' '); |
duke@1 | 263 | } |
duke@1 | 264 | return sb.toString(); |
duke@1 | 265 | } |
duke@1 | 266 | |
duke@1 | 267 | /** |
bpatel@766 | 268 | * Add the modifier and type for the member in the member summary. |
bpatel@766 | 269 | * |
bpatel@766 | 270 | * @param member the member to add the type for |
bpatel@766 | 271 | * @param type the type to add |
bpatel@766 | 272 | * @param tdSummaryType the content tree to which the modified and type will be added |
duke@1 | 273 | */ |
bpatel@766 | 274 | protected void addModifierAndType(ProgramElementDoc member, Type type, |
bpatel@766 | 275 | Content tdSummaryType) { |
bpatel@766 | 276 | HtmlTree code = new HtmlTree(HtmlTag.CODE); |
bpatel@766 | 277 | addModifier(member, code); |
duke@1 | 278 | if (type == null) { |
duke@1 | 279 | if (member.isClass()) { |
bpatel@766 | 280 | code.addContent("class"); |
duke@1 | 281 | } else { |
bpatel@766 | 282 | code.addContent("interface"); |
duke@1 | 283 | } |
bpatel@766 | 284 | code.addContent(writer.getSpace()); |
duke@1 | 285 | } else { |
duke@1 | 286 | if (member instanceof ExecutableMemberDoc && |
duke@1 | 287 | ((ExecutableMemberDoc) member).typeParameters().length > 0) { |
jjg@1741 | 288 | Content typeParameters = ((AbstractExecutableMemberWriter) this).getTypeParameters( |
jjg@1741 | 289 | (ExecutableMemberDoc) member); |
jjg@1741 | 290 | code.addContent(typeParameters); |
duke@1 | 291 | //Code to avoid ugly wrapping in member summary table. |
jjg@1741 | 292 | if (typeParameters.charCount() > 10) { |
bpatel@766 | 293 | code.addContent(new HtmlTree(HtmlTag.BR)); |
jjg@1741 | 294 | } else { |
jjg@1741 | 295 | code.addContent(writer.getSpace()); |
duke@1 | 296 | } |
jjg@1736 | 297 | code.addContent( |
jjg@1410 | 298 | writer.getLink(new LinkInfoImpl(configuration, |
jjg@1736 | 299 | LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); |
duke@1 | 300 | } else { |
jjg@1736 | 301 | code.addContent( |
jjg@1410 | 302 | writer.getLink(new LinkInfoImpl(configuration, |
jjg@1736 | 303 | LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); |
duke@1 | 304 | } |
duke@1 | 305 | |
duke@1 | 306 | } |
bpatel@766 | 307 | tdSummaryType.addContent(code); |
duke@1 | 308 | } |
duke@1 | 309 | |
bpatel@233 | 310 | /** |
bpatel@766 | 311 | * Add the modifier for the member. |
bpatel@766 | 312 | * |
bpatel@766 | 313 | * @param member the member to add the type for |
bpatel@766 | 314 | * @param code the content tree to which the modified will be added |
bpatel@766 | 315 | */ |
bpatel@766 | 316 | private void addModifier(ProgramElementDoc member, Content code) { |
bpatel@766 | 317 | if (member.isProtected()) { |
bpatel@766 | 318 | code.addContent("protected "); |
bpatel@766 | 319 | } else if (member.isPrivate()) { |
bpatel@766 | 320 | code.addContent("private "); |
bpatel@766 | 321 | } else if (!member.isPublic()) { // Package private |
jjg@1410 | 322 | code.addContent(configuration.getText("doclet.Package_private")); |
bpatel@766 | 323 | code.addContent(" "); |
bpatel@766 | 324 | } |
bpatel@1468 | 325 | if (member.isMethod()) { |
bpatel@1476 | 326 | if (!(member.containingClass().isInterface()) && |
bpatel@1476 | 327 | ((MethodDoc)member).isAbstract()) { |
bpatel@1468 | 328 | code.addContent("abstract "); |
bpatel@1468 | 329 | } |
bpatel@1468 | 330 | // This check for isDefault() and the default modifier needs to be |
bpatel@1468 | 331 | // added for it to appear on the "Modifier and Type" column in the |
bpatel@1468 | 332 | // method summary section. Once the default modifier is added |
bpatel@1468 | 333 | // to the Modifier list on DocEnv and once it is updated to use the |
bpatel@1468 | 334 | // javax.lang.model.element.Modifier, we will need to remove this. |
bpatel@1476 | 335 | if (((MethodDoc)member).isDefault()) { |
bpatel@1468 | 336 | code.addContent("default "); |
bpatel@1468 | 337 | } |
bpatel@766 | 338 | } |
bpatel@766 | 339 | if (member.isStatic()) { |
bpatel@766 | 340 | code.addContent("static "); |
bpatel@766 | 341 | } |
bpatel@766 | 342 | } |
bpatel@766 | 343 | |
bpatel@766 | 344 | /** |
bpatel@766 | 345 | * Add the deprecated information for the given member. |
bpatel@233 | 346 | * |
bpatel@233 | 347 | * @param member the member being documented. |
bpatel@766 | 348 | * @param contentTree the content tree to which the deprecated information will be added. |
bpatel@233 | 349 | */ |
bpatel@766 | 350 | protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) { |
jjg@1751 | 351 | Content output = (new DeprecatedTaglet()).getTagletOutput(member, |
jjg@1744 | 352 | writer.getTagletWriterInstance(false)); |
jjg@1751 | 353 | if (!output.isEmpty()) { |
jjg@1751 | 354 | Content deprecatedContent = output; |
bpatel@766 | 355 | Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent); |
bpatel@766 | 356 | contentTree.addContent(div); |
bpatel@233 | 357 | } |
bpatel@233 | 358 | } |
bpatel@233 | 359 | |
bpatel@766 | 360 | /** |
bpatel@766 | 361 | * Add the comment for the given member. |
bpatel@766 | 362 | * |
bpatel@766 | 363 | * @param member the member being documented. |
jjg@1358 | 364 | * @param htmltree the content tree to which the comment will be added. |
bpatel@766 | 365 | */ |
bpatel@766 | 366 | protected void addComment(ProgramElementDoc member, Content htmltree) { |
duke@1 | 367 | if (member.inlineTags().length > 0) { |
bpatel@766 | 368 | writer.addInlineComment(member, htmltree); |
duke@1 | 369 | } |
duke@1 | 370 | } |
duke@1 | 371 | |
duke@1 | 372 | protected String name(ProgramElementDoc member) { |
duke@1 | 373 | return member.name(); |
duke@1 | 374 | } |
duke@1 | 375 | |
bpatel@766 | 376 | /** |
bpatel@766 | 377 | * Get the header for the section. |
bpatel@766 | 378 | * |
bpatel@766 | 379 | * @param member the member being documented. |
bpatel@766 | 380 | * @return a header content for the section. |
bpatel@766 | 381 | */ |
bpatel@766 | 382 | protected Content getHead(MemberDoc member) { |
jjg@1737 | 383 | Content memberContent = new StringContent(member.name()); |
bpatel@766 | 384 | Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent); |
bpatel@766 | 385 | return heading; |
duke@1 | 386 | } |
duke@1 | 387 | |
duke@1 | 388 | /** |
duke@1 | 389 | * Return true if the given <code>ProgramElement</code> is inherited |
duke@1 | 390 | * by the class that is being documented. |
duke@1 | 391 | * |
duke@1 | 392 | * @param ped The <code>ProgramElement</code> being checked. |
duke@1 | 393 | * return true if the <code>ProgramElement</code> is being inherited and |
duke@1 | 394 | * false otherwise. |
duke@1 | 395 | */ |
duke@1 | 396 | protected boolean isInherited(ProgramElementDoc ped){ |
duke@1 | 397 | if(ped.isPrivate() || (ped.isPackagePrivate() && |
duke@1 | 398 | ! ped.containingPackage().equals(classdoc.containingPackage()))){ |
duke@1 | 399 | return false; |
duke@1 | 400 | } |
duke@1 | 401 | return true; |
duke@1 | 402 | } |
duke@1 | 403 | |
duke@1 | 404 | /** |
bpatel@766 | 405 | * Add deprecated information to the documentation tree |
bpatel@766 | 406 | * |
bpatel@766 | 407 | * @param deprmembers list of deprecated members |
bpatel@766 | 408 | * @param headingKey the caption for the deprecated members table |
bpatel@766 | 409 | * @param tableSummary the summary for the deprecated members table |
bpatel@766 | 410 | * @param tableHeader table headers for the deprecated members table |
bpatel@766 | 411 | * @param contentTree the content tree to which the deprecated members table will be added |
duke@1 | 412 | */ |
bpatel@766 | 413 | protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey, |
bpatel@766 | 414 | String tableSummary, String[] tableHeader, Content contentTree) { |
duke@1 | 415 | if (deprmembers.size() > 0) { |
bpatel@766 | 416 | Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, |
jjg@1747 | 417 | writer.getTableCaption(configuration.getResource(headingKey))); |
bpatel@766 | 418 | table.addContent(writer.getSummaryTableHeader(tableHeader, "col")); |
bpatel@766 | 419 | Content tbody = new HtmlTree(HtmlTag.TBODY); |
duke@1 | 420 | for (int i = 0; i < deprmembers.size(); i++) { |
duke@1 | 421 | ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i); |
bpatel@766 | 422 | HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member)); |
duke@1 | 423 | if (member.tags("deprecated").length > 0) |
bpatel@766 | 424 | writer.addInlineDeprecatedComment(member, |
bpatel@766 | 425 | member.tags("deprecated")[0], td); |
bpatel@766 | 426 | HtmlTree tr = HtmlTree.TR(td); |
bpatel@766 | 427 | if (i%2 == 0) |
bpatel@766 | 428 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 429 | else |
bpatel@766 | 430 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@766 | 431 | tbody.addContent(tr); |
duke@1 | 432 | } |
bpatel@766 | 433 | table.addContent(tbody); |
bpatel@766 | 434 | Content li = HtmlTree.LI(HtmlStyle.blockList, table); |
bpatel@766 | 435 | Content ul = HtmlTree.UL(HtmlStyle.blockList, li); |
bpatel@766 | 436 | contentTree.addContent(ul); |
duke@1 | 437 | } |
duke@1 | 438 | } |
duke@1 | 439 | |
duke@1 | 440 | /** |
bpatel@766 | 441 | * Add use information to the documentation tree. |
bpatel@766 | 442 | * |
bpatel@766 | 443 | * @param mems list of program elements for which the use information will be added |
bpatel@766 | 444 | * @param heading the section heading |
bpatel@766 | 445 | * @param tableSummary the summary for the use table |
bpatel@766 | 446 | * @param contentTree the content tree to which the use information will be added |
duke@1 | 447 | */ |
bpatel@766 | 448 | protected void addUseInfo(List<? extends ProgramElementDoc> mems, |
jjg@1747 | 449 | Content heading, String tableSummary, Content contentTree) { |
duke@1 | 450 | if (mems == null) { |
duke@1 | 451 | return; |
duke@1 | 452 | } |
jjg@74 | 453 | List<? extends ProgramElementDoc> members = mems; |
bpatel@243 | 454 | boolean printedUseTableHeader = false; |
duke@1 | 455 | if (members.size() > 0) { |
bpatel@766 | 456 | Content table = HtmlTree.TABLE(0, 3, 0, tableSummary, |
bpatel@766 | 457 | writer.getTableCaption(heading)); |
bpatel@766 | 458 | Content tbody = new HtmlTree(HtmlTag.TBODY); |
bpatel@766 | 459 | Iterator<? extends ProgramElementDoc> it = members.iterator(); |
bpatel@766 | 460 | for (int i = 0; it.hasNext(); i++) { |
jjg@74 | 461 | ProgramElementDoc pgmdoc = it.next(); |
duke@1 | 462 | ClassDoc cd = pgmdoc.containingClass(); |
bpatel@243 | 463 | if (!printedUseTableHeader) { |
bpatel@766 | 464 | table.addContent(writer.getSummaryTableHeader( |
bpatel@766 | 465 | this.getSummaryTableHeader(pgmdoc), "col")); |
bpatel@243 | 466 | printedUseTableHeader = true; |
bpatel@243 | 467 | } |
bpatel@766 | 468 | HtmlTree tr = new HtmlTree(HtmlTag.TR); |
bpatel@766 | 469 | if (i % 2 == 0) { |
bpatel@766 | 470 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 471 | } else { |
bpatel@766 | 472 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@766 | 473 | } |
bpatel@766 | 474 | HtmlTree tdFirst = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 475 | tdFirst.addStyle(HtmlStyle.colFirst); |
bpatel@766 | 476 | writer.addSummaryType(this, pgmdoc, tdFirst); |
bpatel@766 | 477 | tr.addContent(tdFirst); |
bpatel@766 | 478 | HtmlTree tdLast = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 479 | tdLast.addStyle(HtmlStyle.colLast); |
duke@1 | 480 | if (cd != null && !(pgmdoc instanceof ConstructorDoc) |
bpatel@766 | 481 | && !(pgmdoc instanceof ClassDoc)) { |
bpatel@766 | 482 | HtmlTree name = new HtmlTree(HtmlTag.SPAN); |
bpatel@766 | 483 | name.addStyle(HtmlStyle.strong); |
bpatel@766 | 484 | name.addContent(cd.name() + "."); |
bpatel@766 | 485 | tdLast.addContent(name); |
duke@1 | 486 | } |
bpatel@766 | 487 | addSummaryLink(pgmdoc instanceof ClassDoc ? |
jjg@1735 | 488 | LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER, |
bpatel@766 | 489 | cd, pgmdoc, tdLast); |
bpatel@766 | 490 | writer.addSummaryLinkComment(this, pgmdoc, tdLast); |
bpatel@766 | 491 | tr.addContent(tdLast); |
bpatel@766 | 492 | tbody.addContent(tr); |
duke@1 | 493 | } |
bpatel@766 | 494 | table.addContent(tbody); |
bpatel@766 | 495 | contentTree.addContent(table); |
duke@1 | 496 | } |
duke@1 | 497 | } |
duke@1 | 498 | |
bpatel@766 | 499 | /** |
bpatel@766 | 500 | * Add the navigation detail link. |
bpatel@766 | 501 | * |
bpatel@766 | 502 | * @param members the members to be linked |
bpatel@766 | 503 | * @param liNav the content tree to which the navigation detail link will be added |
bpatel@766 | 504 | */ |
bpatel@766 | 505 | protected void addNavDetailLink(List<?> members, Content liNav) { |
bpatel@766 | 506 | addNavDetailLink(members.size() > 0 ? true : false, liNav); |
duke@1 | 507 | } |
duke@1 | 508 | |
bpatel@766 | 509 | /** |
bpatel@766 | 510 | * Add the navigation summary link. |
bpatel@766 | 511 | * |
bpatel@766 | 512 | * @param members members to be linked |
bpatel@766 | 513 | * @param visibleMemberMap the visible inherited members map |
bpatel@766 | 514 | * @param liNav the content tree to which the navigation summary link will be added |
bpatel@766 | 515 | */ |
bpatel@766 | 516 | protected void addNavSummaryLink(List<?> members, |
bpatel@766 | 517 | VisibleMemberMap visibleMemberMap, Content liNav) { |
duke@1 | 518 | if (members.size() > 0) { |
bpatel@766 | 519 | liNav.addContent(getNavSummaryLink(null, true)); |
duke@1 | 520 | return; |
bpatel@766 | 521 | } |
bpatel@766 | 522 | ClassDoc icd = classdoc.superclass(); |
bpatel@766 | 523 | while (icd != null) { |
bpatel@766 | 524 | List<?> inhmembers = visibleMemberMap.getMembersFor(icd); |
bpatel@766 | 525 | if (inhmembers.size() > 0) { |
bpatel@766 | 526 | liNav.addContent(getNavSummaryLink(icd, true)); |
bpatel@766 | 527 | return; |
duke@1 | 528 | } |
bpatel@766 | 529 | icd = icd.superclass(); |
duke@1 | 530 | } |
bpatel@766 | 531 | liNav.addContent(getNavSummaryLink(null, false)); |
duke@1 | 532 | } |
duke@1 | 533 | |
duke@1 | 534 | protected void serialWarning(SourcePosition pos, String key, String a1, String a2) { |
jjg@1410 | 535 | if (configuration.serialwarn) { |
jjg@1410 | 536 | configuration.getDocletSpecificMsg().warning(pos, key, a1, a2); |
duke@1 | 537 | } |
duke@1 | 538 | } |
duke@1 | 539 | |
duke@1 | 540 | public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) { |
duke@1 | 541 | return nodepr? Util.excludeDeprecatedMembers(members): members; |
duke@1 | 542 | } |
duke@1 | 543 | |
duke@1 | 544 | /** |
bpatel@766 | 545 | * Add the member summary for the given class. |
bpatel@766 | 546 | * |
bpatel@766 | 547 | * @param classDoc the class that is being documented |
bpatel@766 | 548 | * @param member the member being documented |
bpatel@766 | 549 | * @param firstSentenceTags the first sentence tags to be added to the summary |
bpatel@1417 | 550 | * @param tableContents the list of contents to which the documentation will be added |
bpatel@1417 | 551 | * @param counter the counter for determining id and style for the table row |
duke@1 | 552 | */ |
bpatel@766 | 553 | public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member, |
bpatel@1417 | 554 | Tag[] firstSentenceTags, List<Content> tableContents, int counter) { |
bpatel@766 | 555 | HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 556 | tdSummaryType.addStyle(HtmlStyle.colFirst); |
bpatel@766 | 557 | writer.addSummaryType(this, member, tdSummaryType); |
bpatel@766 | 558 | HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); |
bpatel@766 | 559 | setSummaryColumnStyle(tdSummary); |
bpatel@766 | 560 | addSummaryLink(classDoc, member, tdSummary); |
bpatel@766 | 561 | writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary); |
bpatel@766 | 562 | HtmlTree tr = HtmlTree.TR(tdSummaryType); |
bpatel@766 | 563 | tr.addContent(tdSummary); |
bpatel@1417 | 564 | if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) { |
bpatel@1417 | 565 | int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() : |
bpatel@1417 | 566 | MethodTypes.INSTANCE.value(); |
bpatel@1476 | 567 | if (member.containingClass().isInterface()) { |
bpatel@1476 | 568 | methodType = (((MethodDoc) member).isAbstract()) |
bpatel@1476 | 569 | ? methodType | MethodTypes.ABSTRACT.value() |
bpatel@1476 | 570 | : methodType | MethodTypes.DEFAULT.value(); |
bpatel@1476 | 571 | } else { |
bpatel@1476 | 572 | methodType = (((MethodDoc) member).isAbstract()) |
bpatel@1476 | 573 | ? methodType | MethodTypes.ABSTRACT.value() |
bpatel@1476 | 574 | : methodType | MethodTypes.CONCRETE.value(); |
bpatel@1468 | 575 | } |
bpatel@1417 | 576 | if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) { |
bpatel@1417 | 577 | methodType = methodType | MethodTypes.DEPRECATED.value(); |
bpatel@1417 | 578 | } |
bpatel@1417 | 579 | methodTypesOr = methodTypesOr | methodType; |
bpatel@1417 | 580 | String tableId = "i" + counter; |
bpatel@1417 | 581 | typeMap.put(tableId, methodType); |
bpatel@1417 | 582 | tr.addAttr(HtmlAttr.ID, tableId); |
bpatel@1417 | 583 | } |
bpatel@766 | 584 | if (counter%2 == 0) |
bpatel@766 | 585 | tr.addStyle(HtmlStyle.altColor); |
bpatel@766 | 586 | else |
bpatel@766 | 587 | tr.addStyle(HtmlStyle.rowColor); |
bpatel@1417 | 588 | tableContents.add(tr); |
bpatel@1417 | 589 | } |
bpatel@1417 | 590 | |
bpatel@1417 | 591 | /** |
bpatel@1417 | 592 | * Generate the method types set and return true if the method summary table |
bpatel@1417 | 593 | * needs to show tabs. |
bpatel@1417 | 594 | * |
bpatel@1417 | 595 | * @return true if the table should show tabs |
bpatel@1417 | 596 | */ |
bpatel@1417 | 597 | public boolean showTabs() { |
bpatel@1417 | 598 | int value; |
bpatel@1417 | 599 | for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) { |
bpatel@1417 | 600 | value = type.value(); |
bpatel@1417 | 601 | if ((value & methodTypesOr) == value) { |
bpatel@1417 | 602 | methodTypes.add(type); |
bpatel@1417 | 603 | } |
bpatel@1417 | 604 | } |
bpatel@1417 | 605 | boolean showTabs = methodTypes.size() > 1; |
bpatel@1417 | 606 | if (showTabs) { |
bpatel@1417 | 607 | methodTypes.add(MethodTypes.ALL); |
bpatel@1417 | 608 | } |
bpatel@1417 | 609 | return showTabs; |
bpatel@766 | 610 | } |
bpatel@766 | 611 | |
bpatel@766 | 612 | /** |
bpatel@766 | 613 | * Set the style for the summary column. |
bpatel@766 | 614 | * |
bpatel@766 | 615 | * @param tdTree the column for which the style will be set |
bpatel@766 | 616 | */ |
bpatel@766 | 617 | public void setSummaryColumnStyle(HtmlTree tdTree) { |
bpatel@766 | 618 | tdTree.addStyle(HtmlStyle.colLast); |
bpatel@766 | 619 | } |
bpatel@766 | 620 | |
bpatel@766 | 621 | /** |
bpatel@766 | 622 | * Add inherited member summary for the given class and member. |
bpatel@766 | 623 | * |
bpatel@766 | 624 | * @param classDoc the class the inherited member belongs to |
bpatel@766 | 625 | * @param nestedClass the inherited member that is summarized |
bpatel@766 | 626 | * @param isFirst true if this is the first member in the list |
bpatel@766 | 627 | * @param isLast true if this is the last member in the list |
bpatel@766 | 628 | * @param linksTree the content tree to which the summary will be added |
bpatel@766 | 629 | */ |
bpatel@766 | 630 | public void addInheritedMemberSummary(ClassDoc classDoc, |
bpatel@766 | 631 | ProgramElementDoc nestedClass, boolean isFirst, boolean isLast, |
bpatel@766 | 632 | Content linksTree) { |
bpatel@766 | 633 | writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst, |
bpatel@766 | 634 | linksTree); |
bpatel@766 | 635 | } |
bpatel@766 | 636 | |
bpatel@766 | 637 | /** |
bpatel@766 | 638 | * Get the inherited summary header for the given class. |
bpatel@766 | 639 | * |
bpatel@766 | 640 | * @param classDoc the class the inherited member belongs to |
bpatel@766 | 641 | * @return a content tree for the inherited summary header |
bpatel@766 | 642 | */ |
bpatel@766 | 643 | public Content getInheritedSummaryHeader(ClassDoc classDoc) { |
bpatel@766 | 644 | Content inheritedTree = writer.getMemberTreeHeader(); |
bpatel@766 | 645 | writer.addInheritedSummaryHeader(this, classDoc, inheritedTree); |
bpatel@766 | 646 | return inheritedTree; |
bpatel@766 | 647 | } |
bpatel@766 | 648 | |
bpatel@766 | 649 | /** |
bpatel@766 | 650 | * Get the inherited summary links tree. |
bpatel@766 | 651 | * |
bpatel@766 | 652 | * @return a content tree for the inherited summary links |
bpatel@766 | 653 | */ |
bpatel@766 | 654 | public Content getInheritedSummaryLinksTree() { |
bpatel@766 | 655 | return new HtmlTree(HtmlTag.CODE); |
bpatel@766 | 656 | } |
bpatel@766 | 657 | |
bpatel@766 | 658 | /** |
bpatel@766 | 659 | * Get the summary table tree for the given class. |
bpatel@766 | 660 | * |
bpatel@766 | 661 | * @param classDoc the class for which the summary table is generated |
bpatel@1417 | 662 | * @param tableContents list of contents to be displayed in the summary table |
bpatel@766 | 663 | * @return a content tree for the summary table |
bpatel@766 | 664 | */ |
bpatel@1417 | 665 | public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) { |
bpatel@1417 | 666 | return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs()); |
bpatel@766 | 667 | } |
bpatel@766 | 668 | |
bpatel@766 | 669 | /** |
bpatel@766 | 670 | * Get the member tree to be documented. |
bpatel@766 | 671 | * |
bpatel@766 | 672 | * @param memberTree the content tree of member to be documented |
bpatel@766 | 673 | * @return a content tree that will be added to the class documentation |
bpatel@766 | 674 | */ |
bpatel@766 | 675 | public Content getMemberTree(Content memberTree) { |
bpatel@766 | 676 | return writer.getMemberTree(memberTree); |
bpatel@766 | 677 | } |
bpatel@766 | 678 | |
bpatel@766 | 679 | /** |
bpatel@766 | 680 | * Get the member tree to be documented. |
bpatel@766 | 681 | * |
bpatel@766 | 682 | * @param memberTree the content tree of member to be documented |
bpatel@766 | 683 | * @param isLastContent true if the content to be added is the last content |
bpatel@766 | 684 | * @return a content tree that will be added to the class documentation |
bpatel@766 | 685 | */ |
bpatel@766 | 686 | public Content getMemberTree(Content memberTree, boolean isLastContent) { |
bpatel@766 | 687 | if (isLastContent) |
bpatel@766 | 688 | return HtmlTree.UL(HtmlStyle.blockListLast, memberTree); |
bpatel@766 | 689 | else |
bpatel@766 | 690 | return HtmlTree.UL(HtmlStyle.blockList, memberTree); |
duke@1 | 691 | } |
duke@1 | 692 | } |