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

Wed, 27 Apr 2016 01:34:52 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:34:52 +0800
changeset 0
959103a6100f
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17

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

mercurial