diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java index ae941ec7391..24f5f9b9b04 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java @@ -626,21 +626,16 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter, Membe set.remove(STRICTFP); // According to JLS, we should not be showing public modifier for - // interface methods. - if ((utils.isField(element) || utils.isMethod(element)) - && ((writer instanceof ClassWriterImpl - && utils.isInterface(((ClassWriterImpl) writer).getTypeElement()) || - writer instanceof AnnotationTypeWriterImpl) )) { - // Remove the implicit abstract and public modifiers - if (utils.isMethod(element) && - (utils.isInterface(element.getEnclosingElement()) || - utils.isAnnotationType(element.getEnclosingElement()))) { - set.remove(ABSTRACT); - set.remove(PUBLIC); - } - if (!utils.isMethod(element)) { - set.remove(PUBLIC); - } + // interface methods and fields. + if ((utils.isField(element) || utils.isMethod(element))) { + Element te = element.getEnclosingElement(); + if (utils.isInterface(te) || utils.isAnnotationType(te)) { + // Remove the implicit abstract and public modifiers + if (utils.isMethod(element)) { + set.remove(ABSTRACT); + } + set.remove(PUBLIC); + } } if (!set.isEmpty()) { String mods = set.stream().map(Modifier::toString).collect(Collectors.joining(" ")); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java deleted file mode 100644 index 9432e07d841..00000000000 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2013, 2020, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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 jdk.javadoc.internal.doclets.formats.html; - -import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeMirror; - -import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; -import jdk.javadoc.internal.doclets.formats.html.markup.Table; -import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader; -import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter; -import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter; - -/** - * Writes annotation type field documentation in HTML format. - * - *
This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter - implements AnnotationTypeFieldWriter, MemberSummaryWriter { - - /** - * Construct a new AnnotationTypeFieldWriterImpl. - * - * @param writer the writer that will write the output. - * @param annotationType the AnnotationType that holds this member. - */ - public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer, - TypeElement annotationType) { - super(writer, annotationType); - } - - @Override - public Content getMemberSummaryHeader(TypeElement typeElement, - Content memberSummaryTree) { - memberSummaryTree.add( - MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY); - Content memberTree = new ContentBuilder(); - writer.addSummaryHeader(this, memberTree); - return memberTree; - } - - @Override - public Content getMemberTreeHeader() { - return writer.getMemberTreeHeader(); - } - - @Override - public void addMemberTree(Content memberSummaryTree, Content memberTree) { - writer.addMemberTree(HtmlStyle.fieldSummary, - SectionName.ANNOTATION_TYPE_FIELD_SUMMARY, memberSummaryTree, memberTree); - } - - @Override - public void addAnnotationFieldDetailsMarker(Content memberDetails) { - memberDetails.add(MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_DETAILS); - } - - @Override - public Content getAnnotationDetailsTreeHeader() { - Content memberDetailsTree = new ContentBuilder(); - if (!writer.printedAnnotationFieldHeading) { - Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.DETAILS_HEADING, - contents.fieldDetailsLabel); - memberDetailsTree.add(heading); - writer.printedAnnotationFieldHeading = true; - } - return memberDetailsTree; - } - - @Override - public Content getAnnotationDocTreeHeader(Element member) { - Content annotationDocTree = new ContentBuilder(); - Content heading = HtmlTree.HEADING(Headings.TypeDeclaration.MEMBER_HEADING, - new StringContent(name(member))); - annotationDocTree.add(heading); - return HtmlTree.SECTION(HtmlStyle.detail, annotationDocTree).setId(name(member)); - } - - @Override - public Content getSignature(Element member) { - return new MemberSignature(member) - .addType(getType(member)) - .toContent(); - } - - @Override - public void addDeprecated(Element member, Content annotationDocTree) { - addDeprecatedInfo(member, annotationDocTree); - } - - @Override - public void addComments(Element member, Content annotationDocTree) { - addComment(member, annotationDocTree); - } - - @Override - public void addTags(Element member, Content annotationDocTree) { - writer.addTagsInfo(member, annotationDocTree); - } - - @Override - public Content getAnnotationDetails(Content annotationDetailsTreeHeader, Content annotationDetailsTree) { - Content annotationDetails = new ContentBuilder(); - annotationDetails.add(annotationDetailsTreeHeader); - annotationDetails.add(annotationDetailsTree); - return getMemberTree(HtmlTree.SECTION(HtmlStyle.fieldDetails, annotationDetails) - .setId(SectionName.ANNOTATION_TYPE_FIELD_DETAIL.getName())); - } - - @Override - public void addSummaryLabel(Content memberTree) { - HtmlTree label = HtmlTree.HEADING(Headings.TypeDeclaration.SUMMARY_HEADING, - contents.fieldSummaryLabel); - memberTree.add(label); - } - - @Override - public TableHeader getSummaryTableHeader(Element member) { - return new TableHeader(contents.modifierAndTypeLabel, contents.fields, - contents.descriptionLabel); - } - - @Override - protected Table createSummaryTable() { - Content caption = contents.getContent("doclet.Fields"); - - TableHeader header = new TableHeader(contents.modifierAndTypeLabel, contents.fields, - contents.descriptionLabel); - - return new Table(HtmlStyle.memberSummary) - .setCaption(caption) - .setHeader(header) - .setRowScopeColumn(1) - .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colSecond, HtmlStyle.colLast); - } - - @Override - public void addInheritedSummaryLabel(TypeElement typeElement, Content inheritedTree) { - } - - @Override - protected void addSummaryLink(LinkInfoImpl.Kind context, TypeElement typeElement, Element member, - Content tdSummary) { - Content memberLink = HtmlTree.SPAN(HtmlStyle.memberNameLink, - writer.getDocLink(context, member, name(member), false)); - Content code = HtmlTree.CODE(memberLink); - tdSummary.add(code); - } - - @Override - protected void addInheritedSummaryLink(TypeElement typeElement, - Element member, Content linksTree) { - //Not applicable. - } - - @Override - protected void addSummaryType(Element member, Content tdSummaryType) { - addModifierAndType(member, getType(member), tdSummaryType); - } - - @Override - protected Content getDeprecatedLink(Element member) { - return writer.getDocLink(LinkInfoImpl.Kind.MEMBER, - member, utils.getFullyQualifiedName(member)); - } - - private TypeMirror getType(Element member) { - if (utils.isConstructor(member)) - return null; - if (utils.isExecutableElement(member)) - return utils.getReturnType(typeElement, (ExecutableElement)member); - return member.asType(); - } -} diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java deleted file mode 100644 index edabb1ed4bb..00000000000 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2003, 2020, 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 - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 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 jdk.javadoc.internal.doclets.formats.html; - -import java.util.List; - -import javax.lang.model.element.ModuleElement; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; - -import com.sun.source.doctree.DocTree; -import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; -import jdk.javadoc.internal.doclets.formats.html.markup.Entity; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; -import jdk.javadoc.internal.doclets.formats.html.markup.TagName; -import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; -import jdk.javadoc.internal.doclets.formats.html.Navigation.PageMode; -import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; -import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter; -import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; -import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; -import jdk.javadoc.internal.doclets.toolkit.util.DocPath; - -/** - * Generate the Class Information Page. - * - *
This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- *
- * @see java.util.Collections
- * @see java.util.List
- * @see java.util.ArrayList
- * @see java.util.HashMap
- */
-public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
- implements AnnotationTypeWriter {
-
- protected TypeElement annotationType;
-
- private final Navigation navBar;
-
- /**
- * @param configuration the configuration
- * @param annotationType the annotation type being documented.
- */
- public AnnotationTypeWriterImpl(HtmlConfiguration configuration,
- TypeElement annotationType) {
- super(configuration, configuration.docPaths.forClass(annotationType));
- this.annotationType = annotationType;
- configuration.currentTypeElement = annotationType;
- this.navBar = new Navigation(annotationType, configuration, PageMode.CLASS, path);
- }
-
- @Override
- public Content getHeader(String header) {
- Content headerContent = new ContentBuilder();
- addTop(headerContent);
- Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
- contents.moduleLabel);
- navBar.setNavLinkModule(linkContent);
- navBar.setMemberSummaryBuilder(configuration.getBuilderFactory().getMemberSummaryBuilder(this));
- navBar.setUserHeader(getUserHeaderFooter(true));
- headerContent.add(navBar.getContent(Navigation.Position.TOP));
-
- HtmlTree div = new HtmlTree(TagName.DIV);
- div.setStyle(HtmlStyle.header);
- if (configuration.showModules) {
- ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(annotationType);
- Content typeModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInType, contents.moduleLabel);
- Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, typeModuleLabel);
- moduleNameDiv.add(Entity.NO_BREAK_SPACE);
- moduleNameDiv.add(getModuleLink(mdle, new StringContent(mdle.getQualifiedName())));
- div.add(moduleNameDiv);
- }
- PackageElement pkg = utils.containingPackage(annotationType);
- if (!pkg.isUnnamed()) {
- Content typePackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInType, contents.packageLabel);
- Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, typePackageLabel);
- pkgNameDiv.add(Entity.NO_BREAK_SPACE);
- Content pkgNameContent = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
- pkgNameDiv.add(pkgNameContent);
- div.add(pkgNameDiv);
- }
- LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
- LinkInfoImpl.Kind.CLASS_HEADER, annotationType);
- Content heading = HtmlTree.HEADING_TITLE(Headings.PAGE_TITLE_HEADING,
- HtmlStyle.title, new StringContent(header));
- heading.add(getTypeParameterLinks(linkInfo));
- div.add(heading);
- bodyContents.setHeader(headerContent)
- .addMainContent(MarkerComments.START_OF_CLASS_DATA)
- .addMainContent(div);
- return getBody(getWindowTitle(utils.getSimpleName(annotationType)));
- }
-
- @Override
- public Content getAnnotationContentHeader() {
- return getContentHeader();
- }
-
- @Override
- public void addFooter() {
- Content htmlTree = HtmlTree.FOOTER();
- navBar.setUserFooter(getUserHeaderFooter(false));
- htmlTree.add(navBar.getContent(Navigation.Position.BOTTOM));
- addBottom(htmlTree);
- bodyContents.addMainContent(MarkerComments.END_OF_CLASS_DATA)
- .setFooter(htmlTree);
- }
-
- @Override
- public void printDocument(Content contentTree) throws DocFileIOException {
- String description = getDescription("declaration", annotationType);
- PackageElement pkg = utils.containingPackage(this.annotationType);
- List This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-
-public interface AnnotationTypeFieldWriter extends MemberWriter {
-
- /**
- * Add the annotation type member tree header.
- *
- * @return content tree for the member tree header
- */
- Content getMemberTreeHeader();
-
- /**
- * Add the annotation type field details marker.
- *
- * @param memberDetails the content tree representing field details marker
- */
- void addAnnotationFieldDetailsMarker(Content memberDetails);
-
- /**
- * Add the annotation type details tree header.
- *
- * @return content tree for the annotation details header
- */
- Content getAnnotationDetailsTreeHeader();
-
- /**
- * Get the annotation type documentation tree header.
- *
- * @param member the annotation type being documented
- * @return content tree for the annotation type documentation header
- */
- Content getAnnotationDocTreeHeader(Element member);
-
- /**
- * Get the annotation type details tree.
- *
- * @param annotationDetailsTreeHeader the content tree representing annotation type details header
- * @param annotationDetailsTree the content tree representing annotation type details
- * @return content tree for the annotation type details
- */
- Content getAnnotationDetails(Content annotationDetailsTreeHeader, Content annotationDetailsTree);
-
- /**
- * Get the signature for the given member.
- *
- * @param member the member being documented
- * @return content tree for the annotation type signature
- */
- Content getSignature(Element member);
-
- /**
- * Add the deprecated output for the given member.
- *
- * @param member the member being documented
- * @param annotationDocTree content tree to which the deprecated information will be added
- */
- void addDeprecated(Element member, Content annotationDocTree);
-
- /**
- * Add the comments for the given member.
- *
- * @param member the member being documented
- * @param annotationDocTree the content tree to which the comments will be added
- */
- void addComments(Element member, Content annotationDocTree);
-
- /**
- * Add the tags for the given member.
- *
- * @param member the member being documented
- * @param annotationDocTree the content tree to which the tags will be added
- */
- void addTags(Element member, Content annotationDocTree);
-}
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java
deleted file mode 100644
index bdd4b478aa6..00000000000
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2003, 2019, 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
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * 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 jdk.javadoc.internal.doclets.toolkit;
-
-import javax.lang.model.element.TypeElement;
-
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-
-/**
- * The interface for writing annotation type output.
- *
- * This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-
-public interface AnnotationTypeWriter {
-
- /**
- * Get the header of the page.
- *
- * @param header the header string to write
- * @return a content tree for the header documentation
- */
- Content getHeader(String header);
-
- /**
- * Get the annotation content header.
- *
- * @return annotation content header that needs to be added to the documentation
- */
- Content getAnnotationContentHeader();
-
- /**
- * Get the annotation information tree header.
- *
- * @return annotation information tree header that needs to be added to the documentation
- */
- Content getAnnotationInfoTreeHeader();
-
- /**
- * Get the annotation information.
- *
- * @param annotationInfoTree content tree containing the annotation information
- * @return a content tree for the annotation
- */
- Content getAnnotationInfo(Content annotationInfoTree);
-
- /**
- * Add the signature of the current annotation type.
- *
- * @param modifiers the modifiers for the signature
- * @param annotationInfoTree the annotation content tree to which the signature will be added
- */
- void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree);
-
- /**
- * Build the annotation type description.
- *
- * @param annotationInfoTree content tree to which the description will be added
- */
- void addAnnotationTypeDescription(Content annotationInfoTree);
-
- /**
- * Add the tag information for the current annotation type.
- *
- * @param annotationInfoTree content tree to which the tag information will be added
- */
- void addAnnotationTypeTagInfo(Content annotationInfoTree);
-
- /**
- * If this annotation is deprecated, add the appropriate information.
- *
- * @param annotationInfoTree content tree to which the deprecated information will be added
- */
- void addAnnotationTypeDeprecationInfo(Content annotationInfoTree);
-
- /**
- * Get the member tree header for the annotation type.
- *
- * @return a content tree for the member tree header
- */
- Content getMemberTreeHeader();
-
- /**
- * Add the annotation content tree to the documentation content tree.
- *
- * @param annotationContentTree annotation content tree which will be added to the content tree
- */
- void addAnnotationContentTree(Content annotationContentTree);
-
- /**
- * Get the member tree.
- *
- * @param memberTree the content tree that will be modified and returned
- * @return a content tree for the member
- */
- Content getMemberTree(Content memberTree);
-
- /**
- * Get the member summary tree.
- *
- * @param memberTree the content tree that will be used to build the summary tree
- * @return a content tree for the member summary
- */
- Content getMemberSummaryTree(Content memberTree);
-
- /**
- * Get the member details tree.
- *
- * @param memberTree the content tree that will be used to build the details tree
- * @return a content tree for the member details
- */
- Content getMemberDetailsTree(Content memberTree);
-
- /**
- * Add the footer of the page.
- */
- void addFooter();
-
- /**
- * Print the document.
- *
- * @param contentTree content tree that will be printed as a document
- * @throws DocFileIOException if there is a problem while writing the document
- */
- void printDocument(Content contentTree) throws DocFileIOException;
-
- /**
- * Return the {@link TypeElement} being documented.
- *
- * @return the TypeElement representing the annotation being documented.
- */
- TypeElement getAnnotationTypeElement();
-}
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java
index 1b9d27a13fd..78ae990c650 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java
@@ -71,143 +71,106 @@ public interface WriterFactory {
ModuleSummaryWriter getModuleSummaryWriter(ModuleElement mdle);
/**
- * Return the writer for a class.
+ * Returns the writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
- * @param typeElement the class being documented.
- * @param classTree the class tree.
- * @return the writer for the class. Return null if this
- * writer is not supported by the doclet.
+ * @param typeElement the class being documented
+ * @param classTree the class tree
+ * @return the writer
*/
ClassWriter getClassWriter(TypeElement typeElement, ClassTree classTree);
/**
- * Return the writer for an annotation type.
+ * Return the method writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
- * @param annotationType the type being documented.
- * @return the writer for the annotation type. Return null if this
- * writer is not supported by the doclet.
- */
- AnnotationTypeWriter getAnnotationTypeWriter(TypeElement annotationType);
-
- /**
- * Return the method writer for a given class.
- *
- * @param classWriter the writer for the class being documented.
- * @return the method writer for the give class. Return null if this
- * writer is not supported by the doclet.
+ * @param classWriter the writer for the class being documented
+ * @return the method writer
*/
MethodWriter getMethodWriter(ClassWriter classWriter);
- /**
- * Return the annotation type field writer for a given annotation type.
- *
- * @param annotationTypeWriter the writer for the annotation type
- * being documented.
- * @return the member writer for the given annotation type. Return null if
- * this writer is not supported by the doclet.
- */
- AnnotationTypeFieldWriter getAnnotationTypeFieldWriter(
- AnnotationTypeWriter annotationTypeWriter);
-
/**
* Return the annotation type optional member writer for a given annotation
- * type.
+ * type, or null if this writer is not supported by the doclet.
*
- * @param annotationTypeWriter the writer for the annotation type
- * being documented.
- * @return the member writer for the given annotation type. Return null if
- * this writer is not supported by the doclet.
+ * @param classWriter the writer for the annotation type being documented
+ * @return the member writer
*/
AnnotationTypeOptionalMemberWriter getAnnotationTypeOptionalMemberWriter(
- AnnotationTypeWriter annotationTypeWriter);
+ ClassWriter classWriter);
/**
- * Return the annotation type required member writer for a given annotation type.
+ * Return the annotation type required member writer for a given annotation
+ * type, or null if this writer is not supported by the doclet.
*
- * @param annotationTypeWriter the writer for the annotation type
- * being documented.
- * @return the member writer for the given annotation type. Return null if
- * this writer is not supported by the doclet.
+ * @param classWriter the writer for the annotation type being documented
+ * @return the member writer
*/
AnnotationTypeRequiredMemberWriter getAnnotationTypeRequiredMemberWriter(
- AnnotationTypeWriter annotationTypeWriter);
+ ClassWriter classWriter);
/**
- * Return the enum constant writer for a given class.
+ * Return the enum constant writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
- * @param classWriter the writer for the class being documented.
- * @return the enum constant writer for the give class. Return null if this
- * writer is not supported by the doclet.
+ * @param classWriter the writer for the type element being documented
+ * @return the enum constant writer
*/
EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter);
/**
- * Return the field writer for a given class.
+ * Return the field writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
* @param classWriter the writer for the class being documented.
- * @return the field writer for the give class. Return null if this
+ * @return the field writer for the given class. Return null if this
* writer is not supported by the doclet.
*/
FieldWriter getFieldWriter(ClassWriter classWriter);
/**
- * Return the property writer for a given class.
+ * Return the property writer for a given class,
+ * or null if this writer is not supported by the doclet.
*
- * @param classWriter the writer for the class being documented.
- * @return the property writer for the give class. Return null if this
- * writer is not supported by the doclet.
+ * @param classWriter the writer for the type elemen t being documented.
+ * @return the property writer
*/
PropertyWriter getPropertyWriter(ClassWriter classWriter);
/**
- * Return the constructor writer for a given class.
+ * Return the constructor writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
- * @param classWriter the writer for the class being documented.
- * @return the method writer for the give class. Return null if this
- * writer is not supported by the doclet.
+ * @param classWriter the writer for the type element being documented
+ * @return the constructor writer
*/
ConstructorWriter getConstructorWriter(ClassWriter classWriter);
/**
- * Return the specified member summary writer for a given class.
+ * Return the specified member summary writer for a given type element,
+ * or null if this writer is not supported by the doclet.
*
* @param classWriter the writer for the class being documented.
* @param memberType the {@link VisibleMemberTable} member type indicating
* the type of member summary that should be returned.
- * @return the summary writer for the give class. Return null if this
- * writer is not supported by the doclet.
+ * @return the summary writer
*
* @see VisibleMemberTable
*/
MemberSummaryWriter getMemberSummaryWriter(ClassWriter classWriter,
VisibleMemberTable.Kind memberType);
- /**
- * Return the specified member summary writer for a given annotation type.
- *
- * @param annotationTypeWriter the writer for the annotation type being
- * documented.
- * @param memberType the {@link VisibleMemberTable} member type indicating
- * the type of member summary that should be returned.
- * @return the summary writer for the give class. Return null if this
- * writer is not supported by the doclet.
- *
- * @see VisibleMemberTable
- */
- MemberSummaryWriter getMemberSummaryWriter(AnnotationTypeWriter annotationTypeWriter,
- VisibleMemberTable.Kind memberType);
-
/**
* Return the writer for the serialized form.
*
- * @return the writer for the serialized form.
+ * @return the writer for the serialized form
*/
SerializedFormWriter getSerializedFormWriter();
/**
* Return the handler for doc files.
*
- * @return the handler for the doc files.
+ * @return the handler for the doc files
*/
DocFilesHandler getDocFilesHandler(Element pkg);
}
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java
deleted file mode 100644
index 0de2ceb9d94..00000000000
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2003, 2020, 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
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * 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 jdk.javadoc.internal.doclets.toolkit.builders;
-
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-
-import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.DocFilesHandler;
-import jdk.javadoc.internal.doclets.toolkit.DocletException;
-
-
-/**
- * Builds the summary for a given annotation type.
- *
- * This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-public class AnnotationTypeBuilder extends AbstractBuilder {
-
- /**
- * The annotation type being documented.
- */
- private final TypeElement annotationType;
-
- /**
- * The doclet specific writer.
- */
- private final AnnotationTypeWriter writer;
-
- /**
- * Construct a new ClassBuilder.
- *
- * @param context the build context.
- * @param annotationTypeElement the class being documented.
- * @param writer the doclet specific writer.
- */
- private AnnotationTypeBuilder(Context context,
- TypeElement annotationTypeElement,
- AnnotationTypeWriter writer) {
- super(context);
- this.annotationType = annotationTypeElement;
- this.writer = writer;
- }
-
- /**
- * Construct a new AnnotationTypeBuilder.
- *
- * @param context the build context.
- * @param annotationTypeDoc the class being documented.
- * @param writer the doclet specific writer.
- * @return an AnnotationTypeBuilder
- */
- public static AnnotationTypeBuilder getInstance(Context context,
- TypeElement annotationTypeDoc,
- AnnotationTypeWriter writer) {
- return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
- }
-
- @Override
- public void build() throws DocletException {
- buildAnnotationTypeDoc();
- }
-
- /**
- * Build the annotation type documentation.
- *
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeDoc() throws DocletException {
- Content contentTree = writer.getHeader(resources.getText("doclet.AnnotationType") +
- " " + utils.getSimpleName(annotationType));
- Content annotationContentTree = writer.getAnnotationContentHeader();
-
- buildAnnotationTypeInfo(annotationContentTree);
- buildMemberSummary(annotationContentTree);
- buildAnnotationTypeMemberDetails(annotationContentTree);
-
- writer.addAnnotationContentTree(annotationContentTree);
- writer.addFooter();
- writer.printDocument(contentTree);
- copyDocFiles();
- }
-
- /**
- * Copy the doc files for the current TypeElement if necessary.
- *
- * @throws DocletException if there is a problem building the documentation
- */
- private void copyDocFiles() throws DocletException {
- PackageElement containingPackage = utils.containingPackage(annotationType);
- if ((configuration.packages == null ||
- !configuration.packages.contains(containingPackage) &&
- !containingPackagesSeen.contains(containingPackage))){
- //Only copy doc files dir if the containing package is not
- //documented AND if we have not documented a class from the same
- //package already. Otherwise, we are making duplicate copies.
- DocFilesHandler docFilesHandler = configuration
- .getWriterFactory()
- .getDocFilesHandler(containingPackage);
- docFilesHandler.copyDocFiles();
- containingPackagesSeen.add(containingPackage);
- }
- }
-
- /**
- * Build the annotation information tree documentation.
- *
- * @param annotationContentTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeInfo(Content annotationContentTree)
- throws DocletException {
- Content annotationInfoTree = new ContentBuilder();
- buildAnnotationTypeSignature(annotationInfoTree);
- buildDeprecationInfo(annotationInfoTree);
- buildAnnotationTypeDescription(annotationInfoTree);
- buildAnnotationTypeTagInfo(annotationInfoTree);
-
- annotationContentTree.add(writer.getAnnotationInfo(annotationInfoTree));
- }
-
- /**
- * If this annotation is deprecated, build the appropriate information.
- *
- * @param annotationInfoTree the content tree to which the documentation will be added
- */
- protected void buildDeprecationInfo(Content annotationInfoTree) {
- writer.addAnnotationTypeDeprecationInfo(annotationInfoTree);
- }
-
- /**
- * Build the signature of the current annotation type.
- *
- * @param annotationInfoTree the content tree to which the documentation will be added
- */
- protected void buildAnnotationTypeSignature(Content annotationInfoTree) {
- writer.addAnnotationTypeSignature(utils.modifiersToString(annotationType, true),
- annotationInfoTree);
- }
-
- /**
- * Build the annotation type description.
- *
- * @param annotationInfoTree the content tree to which the documentation will be added
- */
- protected void buildAnnotationTypeDescription(Content annotationInfoTree) {
- writer.addAnnotationTypeDescription(annotationInfoTree);
- }
-
- /**
- * Build the tag information for the current annotation type.
- *
- * @param annotationInfoTree the content tree to which the documentation will be added
- */
- protected void buildAnnotationTypeTagInfo(Content annotationInfoTree) {
- writer.addAnnotationTypeTagInfo(annotationInfoTree);
- }
-
- /**
- * Build the member summary contents of the page.
- *
- * @param annotationContentTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildMemberSummary(Content annotationContentTree) throws DocletException {
- Content memberSummaryTree = writer.getMemberTreeHeader();
- builderFactory.getMemberSummaryBuilder(writer).build(memberSummaryTree);
- annotationContentTree.add(writer.getMemberSummaryTree(memberSummaryTree));
- }
-
- /**
- * Build the member details contents of the page.
- *
- * @param annotationContentTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeMemberDetails(Content annotationContentTree)
- throws DocletException {
- Content memberDetailsTree = writer.getMemberTreeHeader();
-
- buildAnnotationTypeFieldDetails(memberDetailsTree);
- buildAnnotationTypeRequiredMemberDetails(memberDetailsTree);
- buildAnnotationTypeOptionalMemberDetails(memberDetailsTree);
-
- if (memberDetailsTree.isValid()) {
- annotationContentTree.add(writer.getMemberDetailsTree(memberDetailsTree));
- }
- }
-
- /**
- * Build the annotation type field documentation.
- *
- * @param memberDetailsTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeFieldDetails(Content memberDetailsTree)
- throws DocletException {
- builderFactory.getAnnotationTypeFieldsBuilder(writer).build(memberDetailsTree);
- }
-
- /**
- * Build the annotation type optional member documentation.
- *
- * @param memberDetailsTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeOptionalMemberDetails(Content memberDetailsTree)
- throws DocletException {
- builderFactory.getAnnotationTypeOptionalMemberBuilder(writer).build(memberDetailsTree);
- }
-
- /**
- * Build the annotation type required member documentation.
- *
- * @param memberDetailsTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem building the documentation
- */
- protected void buildAnnotationTypeRequiredMemberDetails(Content memberDetailsTree)
- throws DocletException {
- builderFactory.getAnnotationTypeRequiredMemberBuilder(writer).build(memberDetailsTree);
- }
-}
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java
deleted file mode 100644
index 7a7a7b2a93d..00000000000
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2013, 2020, 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
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * 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 jdk.javadoc.internal.doclets.toolkit.builders;
-
-import java.util.*;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-
-import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
-import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.DocletException;
-import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
-
-
-/**
- * Builds documentation for annotation type fields.
- *
- * This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.
- */
-public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
-
- /**
- * The writer to output the member documentation.
- */
- protected AnnotationTypeFieldWriter writer;
-
- /**
- * The list of members being documented.
- */
- protected List extends Element> members;
-
- /**
- * The index of the current member that is being documented at this point
- * in time.
- */
- protected Element currentMember;
-
- /**
- * Construct a new AnnotationTypeFieldsBuilder.
- *
- * @param context the build context.
- * @param typeElement the class whose members are being documented.
- * @param writer the doclet specific writer.
- * @param memberType the type of member that is being documented.
- */
- protected AnnotationTypeFieldBuilder(Context context,
- TypeElement typeElement,
- AnnotationTypeFieldWriter writer,
- VisibleMemberTable.Kind memberType) {
- super(context, typeElement);
- this.writer = writer;
- this.members = getVisibleMembers(memberType);
- }
-
-
- /**
- * Construct a new AnnotationTypeFieldBuilder.
- *
- * @param context the build context.
- * @param typeElement the class whose members are being documented.
- * @param writer the doclet specific writer.
- * @return the new AnnotationTypeFieldBuilder
- */
- public static AnnotationTypeFieldBuilder getInstance(
- Context context, TypeElement typeElement,
- AnnotationTypeFieldWriter writer) {
- return new AnnotationTypeFieldBuilder(context, typeElement,
- writer, VisibleMemberTable.Kind.ANNOTATION_TYPE_FIELDS);
- }
-
- /**
- * Returns whether or not there are members to document.
- * @return whether or not there are members to document
- */
- @Override
- public boolean hasMembersToDocument() {
- return !members.isEmpty();
- }
-
- @Override
- public void build(Content contentTree) throws DocletException {
- buildAnnotationTypeField(contentTree);
- }
-
- /**
- * Build the annotation type field documentation.
- *
- * @param memberDetailsTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem while building the documentation
- */
- protected void buildAnnotationTypeField(Content memberDetailsTree)
- throws DocletException {
- buildAnnotationTypeMember(memberDetailsTree);
- }
-
- /**
- * Build the member documentation.
- *
- * @param memberDetailsTree the content tree to which the documentation will be added
- * @throws DocletException if there is a problem while building the documentation
- */
- protected void buildAnnotationTypeMember(Content memberDetailsTree)
- throws DocletException {
- if (writer == null) {
- return;
- }
- if (hasMembersToDocument()) {
- writer.addAnnotationFieldDetailsMarker(memberDetailsTree);
- Content annotationDetailsTreeHeader = writer.getAnnotationDetailsTreeHeader();
- Content memberList = writer.getMemberList();
-
- for (Element member : members) {
- currentMember = member;
- Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember);
-
- buildSignature(annotationDocTree);
- buildDeprecationInfo(annotationDocTree);
- buildMemberComments(annotationDocTree);
- buildTagInfo(annotationDocTree);
-
- memberList.add(writer.getMemberListItem(annotationDocTree));
- }
- memberDetailsTree.add(writer.getAnnotationDetails(annotationDetailsTreeHeader, memberList));
- }
- }
-
- /**
- * Build the signature.
- *
- * @param annotationDocTree the content tree to which the documentation will be added
- */
- protected void buildSignature(Content annotationDocTree) {
- annotationDocTree.add(
- writer.getSignature(currentMember));
- }
-
- /**
- * Build the deprecation information.
- *
- * @param annotationDocTree the content tree to which the documentation will be added
- */
- protected void buildDeprecationInfo(Content annotationDocTree) {
- writer.addDeprecated(currentMember, annotationDocTree);
- }
-
- /**
- * Build the comments for the member. Do nothing if
- * {@link BaseOptions#noComment()} is set to true.
- *
- * @param annotationDocTree the content tree to which the documentation will be added
- */
- protected void buildMemberComments(Content annotationDocTree) {
- if (!options.noComment()) {
- writer.addComments(currentMember, annotationDocTree);
- }
- }
-
- /**
- * Build the tag information.
- *
- * @param annotationDocTree the content tree to which the documentation will be added
- */
- protected void buildTagInfo(Content annotationDocTree) {
- writer.addTags(currentMember, annotationDocTree);
- }
-
- /**
- * Return the annotation type field writer for this builder.
- *
- * @return the annotation type field writer for this builder.
- */
- public AnnotationTypeFieldWriter getWriter() {
- return writer;
- }
-}
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java
index 5710d1a19d1..adac9885406 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java
@@ -33,7 +33,6 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
-import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
@@ -117,18 +116,6 @@ public class BuilderFactory {
writerFactory.getClassWriter(typeElement, classTree));
}
- /**
- * Return the builder for the annotation type.
- *
- * @param annotationType the annotation type being documented.
- * @return the writer for the annotation type. Return null if this
- * writer is not supported by the doclet.
- */
- public AbstractBuilder getAnnotationTypeBuilder(TypeElement annotationType) {
- return AnnotationTypeBuilder.getInstance(context, annotationType,
- writerFactory.getAnnotationTypeWriter(annotationType));
- }
-
/**
* Return an instance of the method builder for the given class.
*
@@ -140,49 +127,34 @@ public class BuilderFactory {
writerFactory.getMethodWriter(classWriter));
}
- /**
- * Return an instance of the annotation type fields builder for the given
- * class.
- *
- * @param annotationTypeWriter the writer for the enclosing annotation type
- * @return an instance of the annotation type field builder for the given
- * annotation type.
- */
- public AbstractMemberBuilder getAnnotationTypeFieldsBuilder(
- AnnotationTypeWriter annotationTypeWriter) {
- return AnnotationTypeFieldBuilder.getInstance(context,
- annotationTypeWriter.getAnnotationTypeElement(),
- writerFactory.getAnnotationTypeFieldWriter(annotationTypeWriter));
- }
-
/**
* Return an instance of the annotation type member builder for the given
* class.
*
- * @param annotationTypeWriter the writer for the enclosing annotation type
+ * @param classWriter the writer for the enclosing annotation type
* @return an instance of the annotation type member builder for the given
* annotation type.
*/
public AbstractMemberBuilder getAnnotationTypeOptionalMemberBuilder(
- AnnotationTypeWriter annotationTypeWriter) {
+ ClassWriter classWriter) {
return AnnotationTypeOptionalMemberBuilder.getInstance(context,
- annotationTypeWriter.getAnnotationTypeElement(),
- writerFactory.getAnnotationTypeOptionalMemberWriter(annotationTypeWriter));
+ classWriter.getTypeElement(),
+ writerFactory.getAnnotationTypeOptionalMemberWriter(classWriter));
}
/**
* Return an instance of the annotation type member builder for the given
* class.
*
- * @param annotationTypeWriter the writer for the enclosing annotation type
+ * @param classWriter the writer for the enclosing annotation type
* @return an instance of the annotation type member builder for the given
* annotation type.
*/
public AbstractMemberBuilder getAnnotationTypeRequiredMemberBuilder(
- AnnotationTypeWriter annotationTypeWriter) {
+ ClassWriter classWriter) {
return AnnotationTypeRequiredMemberBuilder.getInstance(context,
- annotationTypeWriter.getAnnotationTypeElement(),
- writerFactory.getAnnotationTypeRequiredMemberWriter(annotationTypeWriter));
+ classWriter.getTypeElement(),
+ writerFactory.getAnnotationTypeRequiredMemberWriter(classWriter));
}
/**
@@ -242,18 +214,6 @@ public class BuilderFactory {
return MemberSummaryBuilder.getInstance(classWriter, context);
}
- /**
- * Return an instance of the member summary builder for the given annotation
- * type.
- *
- * @param annotationTypeWriter the writer for the enclosing annotation type
- * @return an instance of the member summary builder for the given
- * annotation type.
- */
- public MemberSummaryBuilder getMemberSummaryBuilder(AnnotationTypeWriter annotationTypeWriter) {
- return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
- }
-
/**
* Return the builder that builds the serialized form.
*
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java
index 45955b10c70..33cc6629937 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java
@@ -66,21 +66,6 @@ public class ClassBuilder extends AbstractBuilder {
*/
private final ClassWriter writer;
- /**
- * Keep track of whether or not this typeElement is an interface.
- */
- private final boolean isInterface;
-
- /**
- * Keep track of whether or not this typeElement is an enum.
- */
- private final boolean isEnum;
-
- /**
- * Keep track of whether or not this typeElement is a record.
- */
- private final boolean isRecord;
-
/**
* The content tree for the class documentation.
*/
@@ -100,24 +85,14 @@ public class ClassBuilder extends AbstractBuilder {
this.typeElement = typeElement;
this.writer = writer;
this.utils = configuration.utils;
- if (utils.isInterface(typeElement)) {
- isInterface = true;
- isEnum = false;
- isRecord = false;
- } else if (utils.isEnum(typeElement)) {
- isInterface = false;
- isEnum = true;
- isRecord = false;
- setEnumDocumentation(typeElement);
- } else if (utils.isRecord(typeElement)) {
- isInterface = false;
- isEnum = false;
- isRecord = true;
- setRecordDocumentation(typeElement);
- } else {
- isInterface = false;
- isEnum = false;
- isRecord = false;
+ switch (typeElement.getKind()) {
+ case ENUM:
+ setEnumDocumentation(typeElement);
+ break;
+
+ case RECORD:
+ setRecordDocumentation(typeElement);
+ break;
}
}
@@ -145,15 +120,25 @@ public class ClassBuilder extends AbstractBuilder {
*/
protected void buildClassDoc() throws DocletException {
String key;
- if (isInterface) {
- key = "doclet.Interface";
- } else if (isEnum) {
- key = "doclet.Enum";
- } else if (isRecord) {
- key = "doclet.Record";
- } else {
- key = "doclet.Class";
- }
+ switch (typeElement.getKind()) {
+ case INTERFACE:
+ key = "doclet.Interface";
+ break;
+ case ENUM:
+ key = "doclet.Enum";
+ break;
+ case RECORD:
+ key = "doclet.Record";
+ break;
+ case ANNOTATION_TYPE:
+ key = "doclet.AnnotationType";
+ break;
+ case CLASS:
+ key = "doclet.Class";
+ break;
+ default:
+ throw new IllegalStateException(typeElement.getKind() + " " + typeElement);
+ }
Content contentTree = writer.getHeader(resources.getText(key) + " "
+ utils.getSimpleName(typeElement));
Content classContentTree = writer.getClassContentHeader();
@@ -356,6 +341,8 @@ public class ClassBuilder extends AbstractBuilder {
buildPropertyDetails(memberDetailsTree);
buildFieldDetails(memberDetailsTree);
buildConstructorDetails(memberDetailsTree);
+ buildAnnotationTypeRequiredMemberDetails(memberDetailsTree);
+ buildAnnotationTypeOptionalMemberDetails(memberDetailsTree);
buildMethodDetails(memberDetailsTree);
classContentTree.add(writer.getMemberDetailsTree(memberDetailsTree));
@@ -411,6 +398,28 @@ public class ClassBuilder extends AbstractBuilder {
builderFactory.getMethodBuilder(writer).build(memberDetailsTree);
}
+ /**
+ * Build the annotation type optional member documentation.
+ *
+ * @param memberDetailsTree the content tree to which the documentation will be added
+ * @throws DocletException if there is a problem building the documentation
+ */
+ protected void buildAnnotationTypeOptionalMemberDetails(Content memberDetailsTree)
+ throws DocletException {
+ builderFactory.getAnnotationTypeOptionalMemberBuilder(writer).build(memberDetailsTree);
+ }
+
+ /**
+ * Build the annotation type required member documentation.
+ *
+ * @param memberDetailsTree the content tree to which the documentation will be added
+ * @throws DocletException if there is a problem building the documentation
+ */
+ protected void buildAnnotationTypeRequiredMemberDetails(Content memberDetailsTree)
+ throws DocletException {
+ builderFactory.getAnnotationTypeRequiredMemberBuilder(writer).build(memberDetailsTree);
+ }
+
/**
* The documentation for values() and valueOf() in Enums are set by the
* doclet only iff the user or overridden methods are missing.
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java
index 6c63fb34fe5..51d5ce297fa 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java
@@ -39,7 +39,6 @@ import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.DocTree.Kind;
import com.sun.source.doctree.UnknownBlockTagTree;
-import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
@@ -105,6 +104,8 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
buildPropertiesSummary(contentTree);
buildNestedClassesSummary(contentTree);
buildEnumConstantsSummary(contentTree);
+ buildAnnotationTypeRequiredMemberSummary(contentTree);
+ buildAnnotationTypeOptionalMemberSummary(contentTree);
buildFieldsSummary(contentTree);
buildConstructorsSummary(contentTree);
buildMethodsSummary(contentTree);
@@ -125,40 +126,6 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
return builder;
}
- /**
- * Construct a new MemberSummaryBuilder for an annotation type.
- *
- * @param annotationTypeWriter the writer for the class whose members are
- * being summarized.
- * @param context the build context.
- * @return the instance
- */
- public static MemberSummaryBuilder getInstance(
- AnnotationTypeWriter annotationTypeWriter, Context context) {
- MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
- annotationTypeWriter.getAnnotationTypeElement()) {
- @Override
- public void build(Content contentTree) {
- buildAnnotationTypeFieldsSummary(contentTree);
- buildAnnotationTypeRequiredMemberSummary(contentTree);
- buildAnnotationTypeOptionalMemberSummary(contentTree);
- }
-
- @Override
- public boolean hasMembersToDocument() {
- return !utils.getAnnotationMembers(typeElement).isEmpty();
- }
- };
- WriterFactory wf = context.configuration.getWriterFactory();
- for (VisibleMemberTable.Kind kind : VisibleMemberTable.Kind.values()) {
- MemberSummaryWriter msw = builder.getVisibleMemberTable().hasVisibleMembers(kind)
- ? wf.getMemberSummaryWriter(annotationTypeWriter, kind)
- : null;
- builder.memberSummaryWriters.put(kind, msw);
- }
- return builder;
- }
-
/**
* Return the specified visible member map.
*
@@ -222,8 +189,8 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
* @param memberSummaryTree the content tree to which the documentation will be added
*/
protected void buildAnnotationTypeFieldsSummary(Content memberSummaryTree) {
- MemberSummaryWriter writer = memberSummaryWriters.get(ANNOTATION_TYPE_FIELDS);
- addSummary(writer, ANNOTATION_TYPE_FIELDS, false, memberSummaryTree);
+ MemberSummaryWriter writer = memberSummaryWriters.get(FIELDS);
+ addSummary(writer, FIELDS, false, memberSummaryTree);
}
/**
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
index 95de95e2101..d9a0807a21e 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
@@ -147,8 +147,9 @@ public class IndexBuilder {
*/
private void indexMembers(TypeElement te) {
VisibleMemberTable vmt = configuration.getVisibleMemberTable(te);
- indexElements(vmt.getMembers(ANNOTATION_TYPE_FIELDS));
indexElements(vmt.getMembers(FIELDS));
+ indexElements(vmt.getMembers(ANNOTATION_TYPE_MEMBER_OPTIONAL));
+ indexElements(vmt.getMembers(ANNOTATION_TYPE_MEMBER_REQUIRED));
indexElements(vmt.getMembers(METHODS));
indexElements(vmt.getMembers(CONSTRUCTORS));
indexElements(vmt.getMembers(ENUM_CONSTANTS));
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
index bb9fa961f60..60184b8dbbd 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
@@ -94,7 +94,6 @@ public class VisibleMemberTable {
FIELDS,
CONSTRUCTORS,
METHODS,
- ANNOTATION_TYPE_FIELDS,
ANNOTATION_TYPE_MEMBER_OPTIONAL,
ANNOTATION_TYPE_MEMBER_REQUIRED,
PROPERTIES;
@@ -352,6 +351,11 @@ public class VisibleMemberTable {
}
private void computeParents() {
+ // suppress parents of annotation types
+ if (utils.isAnnotationType(te)) {
+ return;
+ }
+
for (TypeMirror intfType : te.getInterfaces()) {
TypeElement intfc = utils.asTypeElement(intfType);
if (intfc != null) {
@@ -673,16 +677,16 @@ public class VisibleMemberTable {
break;
case FIELD:
addMember(e, Kind.FIELDS);
- addMember(e, Kind.ANNOTATION_TYPE_FIELDS);
break;
case METHOD:
- ExecutableElement ee = (ExecutableElement)e;
if (utils.isAnnotationType(te)) {
+ ExecutableElement ee = (ExecutableElement) e;
addMember(e, ee.getDefaultValue() == null
? Kind.ANNOTATION_TYPE_MEMBER_REQUIRED
: Kind.ANNOTATION_TYPE_MEMBER_OPTIONAL);
+ } else {
+ addMember(e, Kind.METHODS);
}
- addMember(e, Kind.METHODS);
break;
case CONSTRUCTOR:
addMember(e, Kind.CONSTRUCTORS);
diff --git a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java
index 920ae4d6582..81a4dd9383f 100644
--- a/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java
+++ b/test/langtools/jdk/javadoc/doclet/testAnnotationTypes/TestAnnotationTypes.java
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4973609 8015249 8025633 8026567 6469561 8071982 8162363 8182765 8223364
+ 8242056
* @summary Make sure that annotation types with 0 members does not have
* extra HR tags.
* @library ../../lib
@@ -50,16 +51,14 @@ public class TestAnnotationTypes extends JavadocTester {
checkOutput("pkg/AnnotationTypeField.html", true,
"Field Summary
",
" ",
- "",
+ "",
"DEFAULT_NAME"
+ "
DEFAULT_NAME
\n"
+ "
\n"
+ "@Deprecated(forRemoval=true)\n"
+ "@Documented\n"
- + "public @interface TestAnnotationType
\n"
+ + "public @interface TestAnnotationType\n"
+ "