src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -21,20 +21,27 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-package com.sun.tools.doclets.formats.html;
+package jdk.javadoc.internal.doclets.formats.html;
import java.io.*;
import java.util.*;
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.formats.html.markup.*;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import com.sun.source.doctree.DocTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
+
/**
* This abstract class exists to provide functionality needed in the
* the formatting of member information. Since AbstractSubWriter and its
* subclasses control this, they would be the logical place to put this.
* However, because each member type has its own subclass, subclassing
@@ -67,29 +74,29 @@
/**
* Add the summary header.
*
* @param mw the writer for the member being documented
- * @param cd the classdoc to be documented
+ * @param typeElement the te to be documented
* @param memberTree the content tree to which the summary header will be added
*/
- public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
+ public void addSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
Content memberTree) {
- mw.addSummaryAnchor(cd, memberTree);
+ mw.addSummaryAnchor(typeElement, memberTree);
mw.addSummaryLabel(memberTree);
}
/**
* Get the summary table.
*
* @param mw the writer for the member being documented
- * @param cd the classdoc to be documented
+ * @param typeElement the te to be documented
* @param tableContents list of summary table contents
* @param showTabs true if the table needs to show tabs
* @return the content tree for the summary table
*/
- public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd,
+ public Content getSummaryTableTree(AbstractMemberWriter mw, TypeElement typeElement,
List<Content> tableContents, boolean showTabs) {
Content caption;
if (showTabs) {
caption = getTableCaption(mw.methodTypes);
generateMethodTypesScript(mw.typeMap, mw.methodTypes);
@@ -98,11 +105,11 @@
caption = getTableCaption(mw.getCaption());
}
Content table = (configuration.isOutputHtml5())
? HtmlTree.TABLE(HtmlStyle.memberSummary, caption)
: HtmlTree.TABLE(HtmlStyle.memberSummary, mw.getTableSummary(), caption);
- table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
+ table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(typeElement), "col"));
for (Content tableContent : tableContents) {
table.addContent(tableContent);
}
return table;
}
@@ -148,52 +155,53 @@
/**
* Add the inherited summary header.
*
* @param mw the writer for the member being documented
- * @param cd the classdoc to be documented
+ * @param typeElement the te to be documented
* @param inheritedTree the content tree to which the inherited summary header will be added
*/
- public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
+ public void addInheritedSummaryHeader(AbstractMemberWriter mw, TypeElement typeElement,
Content inheritedTree) {
- mw.addInheritedSummaryAnchor(cd, inheritedTree);
- mw.addInheritedSummaryLabel(cd, inheritedTree);
+ mw.addInheritedSummaryAnchor(typeElement, inheritedTree);
+ mw.addInheritedSummaryLabel(typeElement, inheritedTree);
}
/**
* Add the index comment.
*
* @param member the member being documented
* @param contentTree the content tree to which the comment will be added
*/
- protected void addIndexComment(Doc member, Content contentTree) {
- addIndexComment(member, member.firstSentenceTags(), contentTree);
+ protected void addIndexComment(Element member, Content contentTree) {
+ List<? extends DocTree> tags = utils.getFirstSentenceTrees(member);
+ addIndexComment(member, tags, contentTree);
}
/**
* Add the index comment.
*
* @param member the member being documented
* @param firstSentenceTags the first sentence tags for the member to be documented
* @param tdSummary the content tree to which the comment will be added
*/
- protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
+ protected void addIndexComment(Element member, List<? extends DocTree> firstSentenceTags,
Content tdSummary) {
- Tag[] deprs = member.tags("deprecated");
+ List<? extends DocTree> deprs = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
Content div;
- if (utils.isDeprecated((ProgramElementDoc) member)) {
+ if (utils.isDeprecated(member)) {
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
div.addContent(getSpace());
- if (deprs.length > 0) {
- addInlineDeprecatedComment(member, deprs[0], div);
+ if (!deprs.isEmpty()) {
+ addInlineDeprecatedComment(member, deprs.get(0), div);
}
tdSummary.addContent(div);
return;
} else {
- ClassDoc cd = ((ProgramElementDoc)member).containingClass();
- if (cd != null && utils.isDeprecated(cd)) {
+ Element te = member.getEnclosingElement();
+ if (te != null && utils.isTypeElement(te) && utils.isDeprecated(te)) {
Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
div.addContent(getSpace());
tdSummary.addContent(div);
}
@@ -206,12 +214,11 @@
*
* @param mw the writer for the member being documented
* @param member the member to be documented
* @param tdSummaryType the content tree to which the type will be added
*/
- public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
- Content tdSummaryType) {
+ public void addSummaryType(AbstractMemberWriter mw, Element member, Content tdSummaryType) {
mw.addSummaryType(member, tdSummaryType);
}
/**
* Add the summary link for the member.
@@ -218,13 +225,13 @@
*
* @param mw the writer for the member being documented
* @param member the member to be documented
* @param contentTree the content tree to which the link will be added
*/
- public void addSummaryLinkComment(AbstractMemberWriter mw,
- ProgramElementDoc member, Content contentTree) {
- addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
+ public void addSummaryLinkComment(AbstractMemberWriter mw, Element member, Content contentTree) {
+ List<? extends DocTree> tags = utils.getFirstSentenceTrees(member);
+ addSummaryLinkComment(mw, member, tags, contentTree);
}
/**
* Add the summary link comment.
*
@@ -232,29 +239,29 @@
* @param member the member being documented
* @param firstSentenceTags the first sentence tags for the member to be documented
* @param tdSummary the content tree to which the comment will be added
*/
public void addSummaryLinkComment(AbstractMemberWriter mw,
- ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
+ Element member, List<? extends DocTree> firstSentenceTags, Content tdSummary) {
addIndexComment(member, firstSentenceTags, tdSummary);
}
/**
* Add the inherited member summary.
*
* @param mw the writer for the member being documented
- * @param cd the class being documented
+ * @param typeElement the class being documented
* @param member the member being documented
* @param isFirst true if its the first link being documented
* @param linksTree the content tree to which the summary will be added
*/
- public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
- ProgramElementDoc member, boolean isFirst, Content linksTree) {
+ public void addInheritedMemberSummary(AbstractMemberWriter mw, TypeElement typeElement,
+ Element member, boolean isFirst, Content linksTree) {
if (! isFirst) {
linksTree.addContent(", ");
}
- mw.addInheritedSummaryLink(cd, member, linksTree);
+ mw.addInheritedSummaryLink(typeElement, member, linksTree);
}
/**
* Get the document content header tree
*