src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java

Tue, 14 May 2013 10:14:52 -0700

author
jjg
date
Tue, 14 May 2013 10:14:52 -0700
changeset 1737
7a9ef837e57f
parent 1736
74cd21f2c2fe
child 1741
4c43e51433ba
permissions
-rw-r--r--

8011650: reduce use of RawHtml nodes in doclet
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 */
bpatel@766 94 public abstract String 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 /**
bpatel@766 196 * Add the member name to the content tree and modifies the display length.
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 writer.displayLength += name.length();
bpatel@766 204 }
bpatel@766 205
bpatel@766 206 /**
duke@1 207 * Return a string describing the access modifier flags.
duke@1 208 * Don't include native or synchronized.
duke@1 209 *
duke@1 210 * The modifier names are returned in canonical order, as
duke@1 211 * specified by <em>The Java Language Specification</em>.
duke@1 212 */
duke@1 213 protected String modifierString(MemberDoc member) {
duke@1 214 int ms = member.modifierSpecifier();
duke@1 215 int no = Modifier.NATIVE | Modifier.SYNCHRONIZED;
duke@1 216 return Modifier.toString(ms & ~no);
duke@1 217 }
duke@1 218
duke@1 219 protected String typeString(MemberDoc member) {
duke@1 220 String type = "";
duke@1 221 if (member instanceof MethodDoc) {
duke@1 222 type = ((MethodDoc)member).returnType().toString();
duke@1 223 } else if (member instanceof FieldDoc) {
duke@1 224 type = ((FieldDoc)member).type().toString();
duke@1 225 }
duke@1 226 return type;
duke@1 227 }
duke@1 228
bpatel@766 229 /**
bpatel@766 230 * Add the modifier for the member.
bpatel@766 231 *
bpatel@766 232 * @param member the member for which teh modifier will be added.
bpatel@766 233 * @param htmltree the content tree to which the modifier information will be added.
bpatel@766 234 */
bpatel@766 235 protected void addModifiers(MemberDoc member, Content htmltree) {
duke@1 236 String mod = modifierString(member);
duke@1 237 // According to JLS, we should not be showing public modifier for
duke@1 238 // interface methods.
duke@1 239 if ((member.isField() || member.isMethod()) &&
duke@1 240 writer instanceof ClassWriterImpl &&
bpatel@766 241 ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
bpatel@1468 242 // This check for isDefault() and the default modifier needs to be
bpatel@1468 243 // added for it to appear on the method details section. Once the
bpatel@1468 244 // default modifier is added to the Modifier list on DocEnv and once
bpatel@1468 245 // it is updated to use the javax.lang.model.element.Modifier, we
bpatel@1468 246 // will need to remove this.
bpatel@1468 247 mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ?
bpatel@1468 248 Util.replaceText(mod, "public", "default").trim() :
bpatel@1468 249 Util.replaceText(mod, "public", "").trim();
duke@1 250 }
duke@1 251 if(mod.length() > 0) {
bpatel@766 252 htmltree.addContent(mod);
bpatel@766 253 htmltree.addContent(writer.getSpace());
duke@1 254 }
duke@1 255 }
duke@1 256
duke@1 257 protected String makeSpace(int len) {
duke@1 258 if (len <= 0) {
duke@1 259 return "";
duke@1 260 }
jjg@1362 261 StringBuilder sb = new StringBuilder(len);
duke@1 262 for(int i = 0; i < len; i++) {
duke@1 263 sb.append(' ');
duke@1 264 }
duke@1 265 return sb.toString();
duke@1 266 }
duke@1 267
duke@1 268 /**
bpatel@766 269 * Add the modifier and type for the member in the member summary.
bpatel@766 270 *
bpatel@766 271 * @param member the member to add the type for
bpatel@766 272 * @param type the type to add
bpatel@766 273 * @param tdSummaryType the content tree to which the modified and type will be added
duke@1 274 */
bpatel@766 275 protected void addModifierAndType(ProgramElementDoc member, Type type,
bpatel@766 276 Content tdSummaryType) {
bpatel@766 277 HtmlTree code = new HtmlTree(HtmlTag.CODE);
bpatel@766 278 addModifier(member, code);
duke@1 279 if (type == null) {
duke@1 280 if (member.isClass()) {
bpatel@766 281 code.addContent("class");
duke@1 282 } else {
bpatel@766 283 code.addContent("interface");
duke@1 284 }
bpatel@766 285 code.addContent(writer.getSpace());
duke@1 286 } else {
duke@1 287 if (member instanceof ExecutableMemberDoc &&
duke@1 288 ((ExecutableMemberDoc) member).typeParameters().length > 0) {
duke@1 289 //Code to avoid ugly wrapping in member summary table.
bpatel@766 290 int displayLength = ((AbstractExecutableMemberWriter) this).addTypeParameters(
bpatel@766 291 (ExecutableMemberDoc) member, code);
duke@1 292 if (displayLength > 10) {
bpatel@766 293 code.addContent(new HtmlTree(HtmlTag.BR));
duke@1 294 }
jjg@1736 295 code.addContent(
jjg@1410 296 writer.getLink(new LinkInfoImpl(configuration,
jjg@1736 297 LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
duke@1 298 } else {
jjg@1736 299 code.addContent(
jjg@1410 300 writer.getLink(new LinkInfoImpl(configuration,
jjg@1736 301 LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
duke@1 302 }
duke@1 303
duke@1 304 }
bpatel@766 305 tdSummaryType.addContent(code);
duke@1 306 }
duke@1 307
bpatel@233 308 /**
bpatel@766 309 * Add the modifier for the member.
bpatel@766 310 *
bpatel@766 311 * @param member the member to add the type for
bpatel@766 312 * @param code the content tree to which the modified will be added
bpatel@766 313 */
bpatel@766 314 private void addModifier(ProgramElementDoc member, Content code) {
bpatel@766 315 if (member.isProtected()) {
bpatel@766 316 code.addContent("protected ");
bpatel@766 317 } else if (member.isPrivate()) {
bpatel@766 318 code.addContent("private ");
bpatel@766 319 } else if (!member.isPublic()) { // Package private
jjg@1410 320 code.addContent(configuration.getText("doclet.Package_private"));
bpatel@766 321 code.addContent(" ");
bpatel@766 322 }
bpatel@1468 323 if (member.isMethod()) {
bpatel@1476 324 if (!(member.containingClass().isInterface()) &&
bpatel@1476 325 ((MethodDoc)member).isAbstract()) {
bpatel@1468 326 code.addContent("abstract ");
bpatel@1468 327 }
bpatel@1468 328 // This check for isDefault() and the default modifier needs to be
bpatel@1468 329 // added for it to appear on the "Modifier and Type" column in the
bpatel@1468 330 // method summary section. Once the default modifier is added
bpatel@1468 331 // to the Modifier list on DocEnv and once it is updated to use the
bpatel@1468 332 // javax.lang.model.element.Modifier, we will need to remove this.
bpatel@1476 333 if (((MethodDoc)member).isDefault()) {
bpatel@1468 334 code.addContent("default ");
bpatel@1468 335 }
bpatel@766 336 }
bpatel@766 337 if (member.isStatic()) {
bpatel@766 338 code.addContent("static ");
bpatel@766 339 }
bpatel@766 340 }
bpatel@766 341
bpatel@766 342 /**
bpatel@766 343 * Add the deprecated information for the given member.
bpatel@233 344 *
bpatel@233 345 * @param member the member being documented.
bpatel@766 346 * @param contentTree the content tree to which the deprecated information will be added.
bpatel@233 347 */
bpatel@766 348 protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
bpatel@233 349 String output = (new DeprecatedTaglet()).getTagletOutput(member,
bpatel@233 350 writer.getTagletWriterInstance(false)).toString().trim();
bpatel@233 351 if (!output.isEmpty()) {
bpatel@766 352 Content deprecatedContent = new RawHtml(output);
bpatel@766 353 Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
bpatel@766 354 contentTree.addContent(div);
bpatel@233 355 }
bpatel@233 356 }
bpatel@233 357
bpatel@766 358 /**
bpatel@766 359 * Add the comment for the given member.
bpatel@766 360 *
bpatel@766 361 * @param member the member being documented.
jjg@1358 362 * @param htmltree the content tree to which the comment will be added.
bpatel@766 363 */
bpatel@766 364 protected void addComment(ProgramElementDoc member, Content htmltree) {
duke@1 365 if (member.inlineTags().length > 0) {
bpatel@766 366 writer.addInlineComment(member, htmltree);
duke@1 367 }
duke@1 368 }
duke@1 369
duke@1 370 protected String name(ProgramElementDoc member) {
duke@1 371 return member.name();
duke@1 372 }
duke@1 373
bpatel@766 374 /**
bpatel@766 375 * Get the header for the section.
bpatel@766 376 *
bpatel@766 377 * @param member the member being documented.
bpatel@766 378 * @return a header content for the section.
bpatel@766 379 */
bpatel@766 380 protected Content getHead(MemberDoc member) {
jjg@1737 381 Content memberContent = new StringContent(member.name());
bpatel@766 382 Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
bpatel@766 383 return heading;
duke@1 384 }
duke@1 385
duke@1 386 /**
duke@1 387 * Return true if the given <code>ProgramElement</code> is inherited
duke@1 388 * by the class that is being documented.
duke@1 389 *
duke@1 390 * @param ped The <code>ProgramElement</code> being checked.
duke@1 391 * return true if the <code>ProgramElement</code> is being inherited and
duke@1 392 * false otherwise.
duke@1 393 */
duke@1 394 protected boolean isInherited(ProgramElementDoc ped){
duke@1 395 if(ped.isPrivate() || (ped.isPackagePrivate() &&
duke@1 396 ! ped.containingPackage().equals(classdoc.containingPackage()))){
duke@1 397 return false;
duke@1 398 }
duke@1 399 return true;
duke@1 400 }
duke@1 401
duke@1 402 /**
bpatel@766 403 * Add deprecated information to the documentation tree
bpatel@766 404 *
bpatel@766 405 * @param deprmembers list of deprecated members
bpatel@766 406 * @param headingKey the caption for the deprecated members table
bpatel@766 407 * @param tableSummary the summary for the deprecated members table
bpatel@766 408 * @param tableHeader table headers for the deprecated members table
bpatel@766 409 * @param contentTree the content tree to which the deprecated members table will be added
duke@1 410 */
bpatel@766 411 protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey,
bpatel@766 412 String tableSummary, String[] tableHeader, Content contentTree) {
duke@1 413 if (deprmembers.size() > 0) {
bpatel@766 414 Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
jjg@1410 415 writer.getTableCaption(configuration.getText(headingKey)));
bpatel@766 416 table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
bpatel@766 417 Content tbody = new HtmlTree(HtmlTag.TBODY);
duke@1 418 for (int i = 0; i < deprmembers.size(); i++) {
duke@1 419 ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
bpatel@766 420 HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
duke@1 421 if (member.tags("deprecated").length > 0)
bpatel@766 422 writer.addInlineDeprecatedComment(member,
bpatel@766 423 member.tags("deprecated")[0], td);
bpatel@766 424 HtmlTree tr = HtmlTree.TR(td);
bpatel@766 425 if (i%2 == 0)
bpatel@766 426 tr.addStyle(HtmlStyle.altColor);
bpatel@766 427 else
bpatel@766 428 tr.addStyle(HtmlStyle.rowColor);
bpatel@766 429 tbody.addContent(tr);
duke@1 430 }
bpatel@766 431 table.addContent(tbody);
bpatel@766 432 Content li = HtmlTree.LI(HtmlStyle.blockList, table);
bpatel@766 433 Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
bpatel@766 434 contentTree.addContent(ul);
duke@1 435 }
duke@1 436 }
duke@1 437
duke@1 438 /**
bpatel@766 439 * Add use information to the documentation tree.
bpatel@766 440 *
bpatel@766 441 * @param mems list of program elements for which the use information will be added
bpatel@766 442 * @param heading the section heading
bpatel@766 443 * @param tableSummary the summary for the use table
bpatel@766 444 * @param contentTree the content tree to which the use information will be added
duke@1 445 */
bpatel@766 446 protected void addUseInfo(List<? extends ProgramElementDoc> mems,
bpatel@766 447 String heading, String tableSummary, Content contentTree) {
duke@1 448 if (mems == null) {
duke@1 449 return;
duke@1 450 }
jjg@74 451 List<? extends ProgramElementDoc> members = mems;
bpatel@243 452 boolean printedUseTableHeader = false;
duke@1 453 if (members.size() > 0) {
bpatel@766 454 Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
bpatel@766 455 writer.getTableCaption(heading));
bpatel@766 456 Content tbody = new HtmlTree(HtmlTag.TBODY);
bpatel@766 457 Iterator<? extends ProgramElementDoc> it = members.iterator();
bpatel@766 458 for (int i = 0; it.hasNext(); i++) {
jjg@74 459 ProgramElementDoc pgmdoc = it.next();
duke@1 460 ClassDoc cd = pgmdoc.containingClass();
bpatel@243 461 if (!printedUseTableHeader) {
bpatel@766 462 table.addContent(writer.getSummaryTableHeader(
bpatel@766 463 this.getSummaryTableHeader(pgmdoc), "col"));
bpatel@243 464 printedUseTableHeader = true;
bpatel@243 465 }
bpatel@766 466 HtmlTree tr = new HtmlTree(HtmlTag.TR);
bpatel@766 467 if (i % 2 == 0) {
bpatel@766 468 tr.addStyle(HtmlStyle.altColor);
bpatel@766 469 } else {
bpatel@766 470 tr.addStyle(HtmlStyle.rowColor);
bpatel@766 471 }
bpatel@766 472 HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
bpatel@766 473 tdFirst.addStyle(HtmlStyle.colFirst);
bpatel@766 474 writer.addSummaryType(this, pgmdoc, tdFirst);
bpatel@766 475 tr.addContent(tdFirst);
bpatel@766 476 HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
bpatel@766 477 tdLast.addStyle(HtmlStyle.colLast);
duke@1 478 if (cd != null && !(pgmdoc instanceof ConstructorDoc)
bpatel@766 479 && !(pgmdoc instanceof ClassDoc)) {
bpatel@766 480 HtmlTree name = new HtmlTree(HtmlTag.SPAN);
bpatel@766 481 name.addStyle(HtmlStyle.strong);
bpatel@766 482 name.addContent(cd.name() + ".");
bpatel@766 483 tdLast.addContent(name);
duke@1 484 }
bpatel@766 485 addSummaryLink(pgmdoc instanceof ClassDoc ?
jjg@1735 486 LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER,
bpatel@766 487 cd, pgmdoc, tdLast);
bpatel@766 488 writer.addSummaryLinkComment(this, pgmdoc, tdLast);
bpatel@766 489 tr.addContent(tdLast);
bpatel@766 490 tbody.addContent(tr);
duke@1 491 }
bpatel@766 492 table.addContent(tbody);
bpatel@766 493 contentTree.addContent(table);
duke@1 494 }
duke@1 495 }
duke@1 496
bpatel@766 497 /**
bpatel@766 498 * Add the navigation detail link.
bpatel@766 499 *
bpatel@766 500 * @param members the members to be linked
bpatel@766 501 * @param liNav the content tree to which the navigation detail link will be added
bpatel@766 502 */
bpatel@766 503 protected void addNavDetailLink(List<?> members, Content liNav) {
bpatel@766 504 addNavDetailLink(members.size() > 0 ? true : false, liNav);
duke@1 505 }
duke@1 506
bpatel@766 507 /**
bpatel@766 508 * Add the navigation summary link.
bpatel@766 509 *
bpatel@766 510 * @param members members to be linked
bpatel@766 511 * @param visibleMemberMap the visible inherited members map
bpatel@766 512 * @param liNav the content tree to which the navigation summary link will be added
bpatel@766 513 */
bpatel@766 514 protected void addNavSummaryLink(List<?> members,
bpatel@766 515 VisibleMemberMap visibleMemberMap, Content liNav) {
duke@1 516 if (members.size() > 0) {
bpatel@766 517 liNav.addContent(getNavSummaryLink(null, true));
duke@1 518 return;
bpatel@766 519 }
bpatel@766 520 ClassDoc icd = classdoc.superclass();
bpatel@766 521 while (icd != null) {
bpatel@766 522 List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
bpatel@766 523 if (inhmembers.size() > 0) {
bpatel@766 524 liNav.addContent(getNavSummaryLink(icd, true));
bpatel@766 525 return;
duke@1 526 }
bpatel@766 527 icd = icd.superclass();
duke@1 528 }
bpatel@766 529 liNav.addContent(getNavSummaryLink(null, false));
duke@1 530 }
duke@1 531
duke@1 532 protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
jjg@1410 533 if (configuration.serialwarn) {
jjg@1410 534 configuration.getDocletSpecificMsg().warning(pos, key, a1, a2);
duke@1 535 }
duke@1 536 }
duke@1 537
duke@1 538 public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) {
duke@1 539 return nodepr? Util.excludeDeprecatedMembers(members): members;
duke@1 540 }
duke@1 541
duke@1 542 /**
bpatel@766 543 * Add the member summary for the given class.
bpatel@766 544 *
bpatel@766 545 * @param classDoc the class that is being documented
bpatel@766 546 * @param member the member being documented
bpatel@766 547 * @param firstSentenceTags the first sentence tags to be added to the summary
bpatel@1417 548 * @param tableContents the list of contents to which the documentation will be added
bpatel@1417 549 * @param counter the counter for determining id and style for the table row
duke@1 550 */
bpatel@766 551 public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
bpatel@1417 552 Tag[] firstSentenceTags, List<Content> tableContents, int counter) {
bpatel@766 553 HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
bpatel@766 554 tdSummaryType.addStyle(HtmlStyle.colFirst);
bpatel@766 555 writer.addSummaryType(this, member, tdSummaryType);
bpatel@766 556 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
bpatel@766 557 setSummaryColumnStyle(tdSummary);
bpatel@766 558 addSummaryLink(classDoc, member, tdSummary);
bpatel@766 559 writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
bpatel@766 560 HtmlTree tr = HtmlTree.TR(tdSummaryType);
bpatel@766 561 tr.addContent(tdSummary);
bpatel@1417 562 if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
bpatel@1417 563 int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
bpatel@1417 564 MethodTypes.INSTANCE.value();
bpatel@1476 565 if (member.containingClass().isInterface()) {
bpatel@1476 566 methodType = (((MethodDoc) member).isAbstract())
bpatel@1476 567 ? methodType | MethodTypes.ABSTRACT.value()
bpatel@1476 568 : methodType | MethodTypes.DEFAULT.value();
bpatel@1476 569 } else {
bpatel@1476 570 methodType = (((MethodDoc) member).isAbstract())
bpatel@1476 571 ? methodType | MethodTypes.ABSTRACT.value()
bpatel@1476 572 : methodType | MethodTypes.CONCRETE.value();
bpatel@1468 573 }
bpatel@1417 574 if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
bpatel@1417 575 methodType = methodType | MethodTypes.DEPRECATED.value();
bpatel@1417 576 }
bpatel@1417 577 methodTypesOr = methodTypesOr | methodType;
bpatel@1417 578 String tableId = "i" + counter;
bpatel@1417 579 typeMap.put(tableId, methodType);
bpatel@1417 580 tr.addAttr(HtmlAttr.ID, tableId);
bpatel@1417 581 }
bpatel@766 582 if (counter%2 == 0)
bpatel@766 583 tr.addStyle(HtmlStyle.altColor);
bpatel@766 584 else
bpatel@766 585 tr.addStyle(HtmlStyle.rowColor);
bpatel@1417 586 tableContents.add(tr);
bpatel@1417 587 }
bpatel@1417 588
bpatel@1417 589 /**
bpatel@1417 590 * Generate the method types set and return true if the method summary table
bpatel@1417 591 * needs to show tabs.
bpatel@1417 592 *
bpatel@1417 593 * @return true if the table should show tabs
bpatel@1417 594 */
bpatel@1417 595 public boolean showTabs() {
bpatel@1417 596 int value;
bpatel@1417 597 for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
bpatel@1417 598 value = type.value();
bpatel@1417 599 if ((value & methodTypesOr) == value) {
bpatel@1417 600 methodTypes.add(type);
bpatel@1417 601 }
bpatel@1417 602 }
bpatel@1417 603 boolean showTabs = methodTypes.size() > 1;
bpatel@1417 604 if (showTabs) {
bpatel@1417 605 methodTypes.add(MethodTypes.ALL);
bpatel@1417 606 }
bpatel@1417 607 return showTabs;
bpatel@766 608 }
bpatel@766 609
bpatel@766 610 /**
bpatel@766 611 * Set the style for the summary column.
bpatel@766 612 *
bpatel@766 613 * @param tdTree the column for which the style will be set
bpatel@766 614 */
bpatel@766 615 public void setSummaryColumnStyle(HtmlTree tdTree) {
bpatel@766 616 tdTree.addStyle(HtmlStyle.colLast);
bpatel@766 617 }
bpatel@766 618
bpatel@766 619 /**
bpatel@766 620 * Add inherited member summary for the given class and member.
bpatel@766 621 *
bpatel@766 622 * @param classDoc the class the inherited member belongs to
bpatel@766 623 * @param nestedClass the inherited member that is summarized
bpatel@766 624 * @param isFirst true if this is the first member in the list
bpatel@766 625 * @param isLast true if this is the last member in the list
bpatel@766 626 * @param linksTree the content tree to which the summary will be added
bpatel@766 627 */
bpatel@766 628 public void addInheritedMemberSummary(ClassDoc classDoc,
bpatel@766 629 ProgramElementDoc nestedClass, boolean isFirst, boolean isLast,
bpatel@766 630 Content linksTree) {
bpatel@766 631 writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst,
bpatel@766 632 linksTree);
bpatel@766 633 }
bpatel@766 634
bpatel@766 635 /**
bpatel@766 636 * Get the inherited summary header for the given class.
bpatel@766 637 *
bpatel@766 638 * @param classDoc the class the inherited member belongs to
bpatel@766 639 * @return a content tree for the inherited summary header
bpatel@766 640 */
bpatel@766 641 public Content getInheritedSummaryHeader(ClassDoc classDoc) {
bpatel@766 642 Content inheritedTree = writer.getMemberTreeHeader();
bpatel@766 643 writer.addInheritedSummaryHeader(this, classDoc, inheritedTree);
bpatel@766 644 return inheritedTree;
bpatel@766 645 }
bpatel@766 646
bpatel@766 647 /**
bpatel@766 648 * Get the inherited summary links tree.
bpatel@766 649 *
bpatel@766 650 * @return a content tree for the inherited summary links
bpatel@766 651 */
bpatel@766 652 public Content getInheritedSummaryLinksTree() {
bpatel@766 653 return new HtmlTree(HtmlTag.CODE);
bpatel@766 654 }
bpatel@766 655
bpatel@766 656 /**
bpatel@766 657 * Get the summary table tree for the given class.
bpatel@766 658 *
bpatel@766 659 * @param classDoc the class for which the summary table is generated
bpatel@1417 660 * @param tableContents list of contents to be displayed in the summary table
bpatel@766 661 * @return a content tree for the summary table
bpatel@766 662 */
bpatel@1417 663 public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) {
bpatel@1417 664 return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
bpatel@766 665 }
bpatel@766 666
bpatel@766 667 /**
bpatel@766 668 * Get the member tree to be documented.
bpatel@766 669 *
bpatel@766 670 * @param memberTree the content tree of member to be documented
bpatel@766 671 * @return a content tree that will be added to the class documentation
bpatel@766 672 */
bpatel@766 673 public Content getMemberTree(Content memberTree) {
bpatel@766 674 return writer.getMemberTree(memberTree);
bpatel@766 675 }
bpatel@766 676
bpatel@766 677 /**
bpatel@766 678 * Get the member tree to be documented.
bpatel@766 679 *
bpatel@766 680 * @param memberTree the content tree of member to be documented
bpatel@766 681 * @param isLastContent true if the content to be added is the last content
bpatel@766 682 * @return a content tree that will be added to the class documentation
bpatel@766 683 */
bpatel@766 684 public Content getMemberTree(Content memberTree, boolean isLastContent) {
bpatel@766 685 if (isLastContent)
bpatel@766 686 return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
bpatel@766 687 else
bpatel@766 688 return HtmlTree.UL(HtmlStyle.blockList, memberTree);
duke@1 689 }
duke@1 690 }

mercurial