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