Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@798 | 2 | * Copyright (c) 1997, 2010, 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 | |
bpatel@766 | 28 | import java.io.*; |
duke@1 | 29 | import com.sun.javadoc.*; |
bpatel@766 | 30 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 31 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@766 | 32 | import com.sun.tools.doclets.formats.html.markup.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * This abstract class exists to provide functionality needed in the |
duke@1 | 36 | * the formatting of member information. Since AbstractSubWriter and its |
duke@1 | 37 | * subclasses control this, they would be the logical place to put this. |
duke@1 | 38 | * However, because each member type has its own subclass, subclassing |
duke@1 | 39 | * can not be used effectively to change formatting. The concrete |
duke@1 | 40 | * class subclass of this class can be subclassed to change formatting. |
duke@1 | 41 | * |
duke@1 | 42 | * @see AbstractMemberWriter |
duke@1 | 43 | * @see ClassWriterImpl |
duke@1 | 44 | * |
duke@1 | 45 | * @author Robert Field |
duke@1 | 46 | * @author Atul M Dambalkar |
bpatel@243 | 47 | * @author Bhavesh Patel (Modified) |
duke@1 | 48 | */ |
duke@1 | 49 | public abstract class SubWriterHolderWriter extends HtmlDocletWriter { |
duke@1 | 50 | |
duke@1 | 51 | public SubWriterHolderWriter(ConfigurationImpl configuration, |
duke@1 | 52 | String filename) throws IOException { |
duke@1 | 53 | super(configuration, filename); |
duke@1 | 54 | } |
duke@1 | 55 | |
duke@1 | 56 | |
duke@1 | 57 | public SubWriterHolderWriter(ConfigurationImpl configuration, |
duke@1 | 58 | String path, String filename, String relpath) |
duke@1 | 59 | throws IOException { |
duke@1 | 60 | super(configuration, path, filename, relpath); |
duke@1 | 61 | } |
duke@1 | 62 | |
duke@1 | 63 | public void printTypeSummaryHeader() { |
duke@1 | 64 | tdIndex(); |
duke@1 | 65 | font("-1"); |
duke@1 | 66 | code(); |
duke@1 | 67 | } |
duke@1 | 68 | |
duke@1 | 69 | public void printTypeSummaryFooter() { |
duke@1 | 70 | codeEnd(); |
duke@1 | 71 | fontEnd(); |
duke@1 | 72 | tdEnd(); |
duke@1 | 73 | } |
duke@1 | 74 | |
bpatel@766 | 75 | /** |
bpatel@766 | 76 | * Add the summary header. |
bpatel@766 | 77 | * |
bpatel@766 | 78 | * @param mw the writer for the member being documented |
bpatel@766 | 79 | * @param cd the classdoc to be documented |
bpatel@766 | 80 | * @param memberTree the content tree to which the summary header will be added |
bpatel@766 | 81 | */ |
bpatel@766 | 82 | public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, |
bpatel@766 | 83 | Content memberTree) { |
bpatel@766 | 84 | mw.addSummaryAnchor(cd, memberTree); |
bpatel@766 | 85 | mw.addSummaryLabel(memberTree); |
bpatel@766 | 86 | } |
bpatel@766 | 87 | |
bpatel@766 | 88 | /** |
bpatel@766 | 89 | * Get the summary table. |
bpatel@766 | 90 | * |
bpatel@766 | 91 | * @param mw the writer for the member being documented |
bpatel@766 | 92 | * @param cd the classdoc to be documented |
bpatel@766 | 93 | * @return the content tree for the summary table |
bpatel@766 | 94 | */ |
bpatel@766 | 95 | public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) { |
bpatel@766 | 96 | Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, |
bpatel@766 | 97 | mw.getTableSummary(), getTableCaption(mw.getCaption())); |
bpatel@766 | 98 | table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col")); |
bpatel@766 | 99 | return table; |
duke@1 | 100 | } |
duke@1 | 101 | |
duke@1 | 102 | public void printTableHeadingBackground(String str) { |
duke@1 | 103 | tableIndexDetail(); |
duke@1 | 104 | tableHeaderStart("#CCCCFF", 1); |
bpatel@182 | 105 | strong(str); |
duke@1 | 106 | tableHeaderEnd(); |
duke@1 | 107 | tableEnd(); |
duke@1 | 108 | } |
duke@1 | 109 | |
bpatel@766 | 110 | /** |
bpatel@766 | 111 | * Add the inherited summary header. |
bpatel@766 | 112 | * |
bpatel@766 | 113 | * @param mw the writer for the member being documented |
bpatel@766 | 114 | * @param cd the classdoc to be documented |
bpatel@766 | 115 | * @param inheritedTree the content tree to which the inherited summary header will be added |
bpatel@766 | 116 | */ |
bpatel@766 | 117 | public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd, |
bpatel@766 | 118 | Content inheritedTree) { |
bpatel@766 | 119 | mw.addInheritedSummaryAnchor(cd, inheritedTree); |
bpatel@766 | 120 | mw.addInheritedSummaryLabel(cd, inheritedTree); |
duke@1 | 121 | } |
duke@1 | 122 | |
duke@1 | 123 | public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { |
duke@1 | 124 | tableEnd(); |
duke@1 | 125 | space(); |
duke@1 | 126 | } |
duke@1 | 127 | |
duke@1 | 128 | public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) { |
duke@1 | 129 | codeEnd(); |
duke@1 | 130 | summaryRowEnd(); |
duke@1 | 131 | trEnd(); |
duke@1 | 132 | tableEnd(); |
duke@1 | 133 | space(); |
duke@1 | 134 | } |
duke@1 | 135 | |
bpatel@766 | 136 | /** |
bpatel@766 | 137 | * Add the index comment. |
bpatel@766 | 138 | * |
bpatel@766 | 139 | * @param member the member being documented |
bpatel@766 | 140 | * @param contentTree the content tree to which the comment will be added |
bpatel@766 | 141 | */ |
bpatel@766 | 142 | protected void addIndexComment(Doc member, Content contentTree) { |
bpatel@766 | 143 | addIndexComment(member, member.firstSentenceTags(), contentTree); |
duke@1 | 144 | } |
duke@1 | 145 | |
duke@1 | 146 | protected void printIndexComment(Doc member, Tag[] firstSentenceTags) { |
duke@1 | 147 | Tag[] deprs = member.tags("deprecated"); |
duke@1 | 148 | if (Util.isDeprecated((ProgramElementDoc) member)) { |
bpatel@182 | 149 | strongText("doclet.Deprecated"); |
duke@1 | 150 | space(); |
duke@1 | 151 | if (deprs.length > 0) { |
duke@1 | 152 | printInlineDeprecatedComment(member, deprs[0]); |
duke@1 | 153 | } |
duke@1 | 154 | return; |
duke@1 | 155 | } else { |
duke@1 | 156 | ClassDoc cd = ((ProgramElementDoc)member).containingClass(); |
duke@1 | 157 | if (cd != null && Util.isDeprecated(cd)) { |
bpatel@182 | 158 | strongText("doclet.Deprecated"); space(); |
duke@1 | 159 | } |
duke@1 | 160 | } |
duke@1 | 161 | printSummaryComment(member, firstSentenceTags); |
duke@1 | 162 | } |
duke@1 | 163 | |
bpatel@766 | 164 | /** |
bpatel@766 | 165 | * Add the index comment. |
bpatel@766 | 166 | * |
bpatel@766 | 167 | * @param member the member being documented |
bpatel@766 | 168 | * @param firstSentenceTags the first sentence tags for the member to be documented |
bpatel@766 | 169 | * @param tdSummary the content tree to which the comment will be added |
bpatel@766 | 170 | */ |
bpatel@766 | 171 | protected void addIndexComment(Doc member, Tag[] firstSentenceTags, |
bpatel@766 | 172 | Content tdSummary) { |
bpatel@766 | 173 | Tag[] deprs = member.tags("deprecated"); |
bpatel@766 | 174 | Content div; |
bpatel@766 | 175 | if (Util.isDeprecated((ProgramElementDoc) member)) { |
bpatel@766 | 176 | Content strong = HtmlTree.STRONG(deprecatedPhrase); |
bpatel@766 | 177 | div = HtmlTree.DIV(HtmlStyle.block, strong); |
bpatel@766 | 178 | div.addContent(getSpace()); |
bpatel@766 | 179 | if (deprs.length > 0) { |
bpatel@766 | 180 | addInlineDeprecatedComment(member, deprs[0], div); |
bpatel@766 | 181 | } |
bpatel@766 | 182 | tdSummary.addContent(div); |
bpatel@766 | 183 | return; |
bpatel@766 | 184 | } else { |
bpatel@766 | 185 | ClassDoc cd = ((ProgramElementDoc)member).containingClass(); |
bpatel@766 | 186 | if (cd != null && Util.isDeprecated(cd)) { |
bpatel@766 | 187 | Content strong = HtmlTree.STRONG(deprecatedPhrase); |
bpatel@766 | 188 | div = HtmlTree.DIV(HtmlStyle.block, strong); |
bpatel@766 | 189 | div.addContent(getSpace()); |
bpatel@766 | 190 | tdSummary.addContent(div); |
bpatel@766 | 191 | } |
bpatel@766 | 192 | } |
bpatel@766 | 193 | addSummaryComment(member, firstSentenceTags, tdSummary); |
duke@1 | 194 | } |
duke@1 | 195 | |
bpatel@766 | 196 | /** |
bpatel@766 | 197 | * Add the summary type for the member. |
bpatel@766 | 198 | * |
bpatel@766 | 199 | * @param mw the writer for the member being documented |
bpatel@766 | 200 | * @param member the member to be documented |
bpatel@766 | 201 | * @param tdSummaryType the content tree to which the type will be added |
bpatel@766 | 202 | */ |
bpatel@766 | 203 | public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member, |
bpatel@766 | 204 | Content tdSummaryType) { |
bpatel@766 | 205 | mw.addSummaryType(member, tdSummaryType); |
bpatel@766 | 206 | } |
bpatel@766 | 207 | |
bpatel@766 | 208 | /** |
bpatel@766 | 209 | * Add the summary link for the member. |
bpatel@766 | 210 | * |
bpatel@766 | 211 | * @param mw the writer for the member being documented |
bpatel@766 | 212 | * @param member the member to be documented |
bpatel@766 | 213 | * @param contentTree the content tree to which the link will be added |
bpatel@766 | 214 | */ |
bpatel@766 | 215 | public void addSummaryLinkComment(AbstractMemberWriter mw, |
bpatel@766 | 216 | ProgramElementDoc member, Content contentTree) { |
bpatel@766 | 217 | addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree); |
duke@1 | 218 | } |
duke@1 | 219 | |
duke@1 | 220 | public void printSummaryLinkComment(AbstractMemberWriter mw, |
duke@1 | 221 | ProgramElementDoc member, |
duke@1 | 222 | Tag[] firstSentenceTags) { |
duke@1 | 223 | codeEnd(); |
duke@1 | 224 | println(); |
duke@1 | 225 | br(); |
duke@1 | 226 | printNbsps(); |
duke@1 | 227 | printIndexComment(member, firstSentenceTags); |
duke@1 | 228 | summaryRowEnd(); |
duke@1 | 229 | trEnd(); |
duke@1 | 230 | } |
duke@1 | 231 | |
bpatel@766 | 232 | /** |
bpatel@766 | 233 | * Add the summary link comment. |
bpatel@766 | 234 | * |
bpatel@766 | 235 | * @param mw the writer for the member being documented |
bpatel@766 | 236 | * @param member the member being documented |
bpatel@766 | 237 | * @param firstSentenceTags the first sentence tags for the member to be documented |
bpatel@766 | 238 | * @param tdSummary the content tree to which the comment will be added |
bpatel@766 | 239 | */ |
bpatel@766 | 240 | public void addSummaryLinkComment(AbstractMemberWriter mw, |
bpatel@766 | 241 | ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) { |
bpatel@766 | 242 | addIndexComment(member, firstSentenceTags, tdSummary); |
bpatel@766 | 243 | } |
bpatel@766 | 244 | |
bpatel@766 | 245 | /** |
bpatel@766 | 246 | * Add the inherited member summary. |
bpatel@766 | 247 | * |
bpatel@766 | 248 | * @param mw the writer for the member being documented |
bpatel@766 | 249 | * @param cd the class being documented |
bpatel@766 | 250 | * @param member the member being documented |
bpatel@766 | 251 | * @param isFirst true if its the first link being documented |
bpatel@766 | 252 | * @param linksTree the content tree to which the summary will be added |
bpatel@766 | 253 | */ |
bpatel@766 | 254 | public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd, |
bpatel@766 | 255 | ProgramElementDoc member, boolean isFirst, Content linksTree) { |
duke@1 | 256 | if (! isFirst) { |
bpatel@766 | 257 | linksTree.addContent(", "); |
duke@1 | 258 | } |
bpatel@766 | 259 | mw.addInheritedSummaryLink(cd, member, linksTree); |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | public void printMemberHeader() { |
duke@1 | 263 | hr(); |
duke@1 | 264 | } |
duke@1 | 265 | |
duke@1 | 266 | public void printMemberFooter() { |
duke@1 | 267 | } |
duke@1 | 268 | |
bpatel@766 | 269 | /** |
bpatel@766 | 270 | * Get the document content header tree |
bpatel@766 | 271 | * |
bpatel@766 | 272 | * @return a content tree the document content header |
bpatel@766 | 273 | */ |
bpatel@766 | 274 | public Content getContentHeader() { |
bpatel@766 | 275 | HtmlTree div = new HtmlTree(HtmlTag.DIV); |
bpatel@766 | 276 | div.addStyle(HtmlStyle.contentContainer); |
bpatel@766 | 277 | return div; |
bpatel@766 | 278 | } |
bpatel@766 | 279 | |
bpatel@766 | 280 | /** |
bpatel@766 | 281 | * Get the member header tree |
bpatel@766 | 282 | * |
bpatel@766 | 283 | * @return a content tree the member header |
bpatel@766 | 284 | */ |
bpatel@766 | 285 | public Content getMemberTreeHeader() { |
bpatel@766 | 286 | HtmlTree li = new HtmlTree(HtmlTag.LI); |
bpatel@766 | 287 | li.addStyle(HtmlStyle.blockList); |
bpatel@766 | 288 | return li; |
bpatel@766 | 289 | } |
bpatel@766 | 290 | |
bpatel@766 | 291 | /** |
bpatel@766 | 292 | * Get the member tree |
bpatel@766 | 293 | * |
bpatel@766 | 294 | * @param contentTree the tree used to generate the complete member tree |
bpatel@766 | 295 | * @return a content tree for the member |
bpatel@766 | 296 | */ |
bpatel@766 | 297 | public Content getMemberTree(Content contentTree) { |
bpatel@766 | 298 | Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree); |
bpatel@766 | 299 | return ul; |
bpatel@766 | 300 | } |
bpatel@766 | 301 | |
bpatel@766 | 302 | /** |
bpatel@766 | 303 | * Get the member summary tree |
bpatel@766 | 304 | * |
bpatel@766 | 305 | * @param contentTree the tree used to generate the member summary tree |
bpatel@766 | 306 | * @return a content tree for the member summary |
bpatel@766 | 307 | */ |
bpatel@766 | 308 | public Content getMemberSummaryTree(Content contentTree) { |
bpatel@766 | 309 | return getMemberTree(HtmlStyle.summary, contentTree); |
bpatel@766 | 310 | } |
bpatel@766 | 311 | |
bpatel@766 | 312 | /** |
bpatel@766 | 313 | * Get the member details tree |
bpatel@766 | 314 | * |
bpatel@766 | 315 | * @param contentTree the tree used to generate the member details tree |
bpatel@766 | 316 | * @return a content tree for the member details |
bpatel@766 | 317 | */ |
bpatel@766 | 318 | public Content getMemberDetailsTree(Content contentTree) { |
bpatel@766 | 319 | return getMemberTree(HtmlStyle.details, contentTree); |
bpatel@766 | 320 | } |
bpatel@766 | 321 | |
bpatel@766 | 322 | /** |
bpatel@766 | 323 | * Get the member tree |
bpatel@766 | 324 | * |
bpatel@766 | 325 | * @param style the style class to be added to the content tree |
bpatel@766 | 326 | * @param contentTree the tree used to generate the complete member tree |
bpatel@766 | 327 | */ |
bpatel@766 | 328 | public Content getMemberTree(HtmlStyle style, Content contentTree) { |
bpatel@766 | 329 | Content div = HtmlTree.DIV(style, getMemberTree(contentTree)); |
bpatel@766 | 330 | return div; |
bpatel@766 | 331 | } |
duke@1 | 332 | } |