src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,18 +21,23 @@
* 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.internal.toolkit.builders;
+package jdk.javadoc.internal.doclets.toolkit.builders;
import java.util.*;
-import com.sun.javadoc.*;
-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 jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+
+
/**
* Builds documentation for required annotation type members.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@@ -46,11 +51,11 @@
public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
/**
* The annotation type whose members are being documented.
*/
- protected ClassDoc classDoc;
+ protected TypeElement typeElement;
/**
* The visible members for the given class.
*/
protected VisibleMemberMap visibleMemberMap;
@@ -61,73 +66,70 @@
protected AnnotationTypeRequiredMemberWriter writer;
/**
* The list of members being documented.
*/
- protected List<ProgramElementDoc> members;
+ protected SortedSet<Element> members;
/**
* The index of the current member that is being documented at this point
* in time.
*/
- protected int currentMemberIndex;
+ protected Element currentMember;
/**
* Construct a new AnnotationTypeRequiredMemberBuilder.
*
* @param context the build context.
- * @param classDoc the class whose members are being documented.
+ * @param typeElement the class whose members are being documented.
* @param writer the doclet specific writer.
*/
protected AnnotationTypeRequiredMemberBuilder(Context context,
- ClassDoc classDoc,
+ TypeElement typeElement,
AnnotationTypeRequiredMemberWriter writer,
- int memberType) {
+ VisibleMemberMap.Kind memberType) {
super(context);
- this.classDoc = classDoc;
+ this.typeElement = typeElement;
this.writer = writer;
- this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
- configuration);
- this.members = new ArrayList<>(this.visibleMemberMap.getMembersFor(classDoc));
- if (configuration.getMemberComparator() != null) {
- Collections.sort(this.members, configuration.getMemberComparator());
+ this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
+ this.members = this.visibleMemberMap.getMembersFor(typeElement);
}
- }
/**
* Construct a new AnnotationTypeMemberBuilder.
*
* @param context the build context.
- * @param classDoc the class whose members are being documented.
+ * @param typeElement the class whose members are being documented.
* @param writer the doclet specific writer.
*/
public static AnnotationTypeRequiredMemberBuilder getInstance(
- Context context, ClassDoc classDoc,
+ Context context, TypeElement typeElement,
AnnotationTypeRequiredMemberWriter writer) {
- return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
+ return new AnnotationTypeRequiredMemberBuilder(context, typeElement,
writer,
- VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
+ VisibleMemberMap.Kind.ANNOTATION_TYPE_MEMBER_REQUIRED);
}
/**
* {@inheritDoc}
*/
+ @Override
public String getName() {
return "AnnotationTypeRequiredMemberDetails";
}
/**
* Returns a list of members that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
- * @param classDoc the {@link ClassDoc} we want to check.
+ * @param typeElement the {@link TypeElement} we want to check.
* @return a list of members that will be documented.
*/
- public List<ProgramElementDoc> members(ClassDoc classDoc) {
- return visibleMemberMap.getMembersFor(classDoc);
+ public SortedSet<Element> members(TypeElement typeElement) {
+ return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the members of this class.
*
@@ -138,10 +140,11 @@
}
/**
* summaryOrder.size()
*/
+ @Override
public boolean hasMembersToDocument() {
return members.size() > 0;
}
/**
@@ -165,19 +168,19 @@
return;
}
int size = members.size();
if (size > 0) {
writer.addAnnotationDetailsMarker(memberDetailsTree);
- for (currentMemberIndex = 0; currentMemberIndex < size;
- currentMemberIndex++) {
+ for (Element element : members) {
+ currentMember = element;
Content detailsTree = writer.getMemberTreeHeader();
- writer.addAnnotationDetailsTreeHeader(classDoc, detailsTree);
+ writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree);
Content annotationDocTree = writer.getAnnotationDocTreeHeader(
- (MemberDoc) members.get(currentMemberIndex), detailsTree);
+ element, detailsTree);
buildChildren(node, annotationDocTree);
detailsTree.addContent(writer.getAnnotationDoc(
- annotationDocTree, (currentMemberIndex == size - 1)));
+ annotationDocTree, currentMember == members.last()));
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
}
}
}
@@ -186,23 +189,21 @@
*
* @param node the XML element that specifies which components to document
* @param annotationDocTree the content tree to which the documentation will be added
*/
public void buildSignature(XMLNode node, Content annotationDocTree) {
- annotationDocTree.addContent(
- writer.getSignature((MemberDoc) members.get(currentMemberIndex)));
+ annotationDocTree.addContent(writer.getSignature(currentMember));
}
/**
* Build the deprecation information.
*
* @param node the XML element that specifies which components to document
* @param annotationDocTree the content tree to which the documentation will be added
*/
public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) {
- writer.addDeprecated((MemberDoc) members.get(currentMemberIndex),
- annotationDocTree);
+ writer.addDeprecated(currentMember, annotationDocTree);
}
/**
* Build the comments for the member. Do nothing if
* {@link Configuration#nocomment} is set to true.
@@ -209,13 +210,12 @@
*
* @param node the XML element that specifies which components to document
* @param annotationDocTree the content tree to which the documentation will be added
*/
public void buildMemberComments(XMLNode node, Content annotationDocTree) {
- if(! configuration.nocomment){
- writer.addComments((MemberDoc) members.get(currentMemberIndex),
- annotationDocTree);
+ if(! configuration.nocomment) {
+ writer.addComments(currentMember, annotationDocTree);
}
}
/**
* Build the tag information.
@@ -222,12 +222,11 @@
*
* @param node the XML element that specifies which components to document
* @param annotationDocTree the content tree to which the documentation will be added
*/
public void buildTagInfo(XMLNode node, Content annotationDocTree) {
- writer.addTags((MemberDoc) members.get(currentMemberIndex),
- annotationDocTree);
+ writer.addTags(currentMember, annotationDocTree);
}
/**
* Return the annotation type required member writer for this builder.
*