8167967: javadoc should identify the ordinal value of enum constants

Reviewed-by: jjg
This commit is contained in:
Kumar Srinivasan 2016-11-14 16:33:48 -08:00
parent 95d99302d8
commit 9b43eda24c
26 changed files with 990 additions and 757 deletions

View file

@ -535,7 +535,7 @@ public abstract class AbstractMemberWriter {
TypeElement superClass = utils.getSuperClass(typeElement);
while (superClass != null) {
if (visibleMemberMap.hasMembersFor(superClass)) {
if (visibleMemberMap.hasMembers(superClass)) {
liNav.addContent(getNavSummaryLink(superClass, true));
return;
}

View file

@ -135,8 +135,6 @@ public class ConfigurationImpl extends Configuration {
*/
public String docrootparent = "";
public boolean sortedMethodDetails = false;
/**
* True if command line option "-nohelp" is used. Default value is false.
*/

View file

@ -72,7 +72,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
VisibleMemberMap visibleMemberMap = new VisibleMemberMap(
typeElement,
VisibleMemberMap.Kind.CONSTRUCTORS, configuration);
SortedSet<Element> constructors = visibleMemberMap.getMembersFor(typeElement);
List<Element> constructors = visibleMemberMap.getMembers(typeElement);
for (Element constructor : constructors) {
if (utils.isProtected(constructor) || utils.isPrivate(constructor)) {
setFoundNonPubConstructor(true);

View file

@ -25,6 +25,15 @@
package jdk.javadoc.internal.doclets.toolkit.builders;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.lang.model.element.Element;
import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.DocletException;
@ -42,6 +51,7 @@ import jdk.javadoc.internal.doclets.toolkit.DocletException;
*/
public abstract class AbstractMemberBuilder extends AbstractBuilder {
public final Comparator<Element> comparator;
/**
* Construct a SubBuilder.
* @param context a context object, providing information used in this run
@ -49,6 +59,7 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder {
*/
public AbstractMemberBuilder(Context context) {
super(context);
comparator = utils.makeGeneralPurposeComparator();
}
/**
@ -83,4 +94,10 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder {
* @return true if this subbuilder has anything to document
*/
public abstract boolean hasMembersToDocument();
public SortedSet<Element> asSortedSet(Collection<Element> members) {
SortedSet<Element> out = new TreeSet<>(comparator);
out.addAll(members);
return out;
}
}

View file

@ -67,7 +67,7 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
/**
* The list of members being documented.
*/
protected SortedSet<Element> members;
protected List<Element> members;
/**
* The index of the current member that is being documented at this point
@ -91,7 +91,7 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
this.typeElement = typeElement;
this.writer = writer;
this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
this.members = this.visibleMemberMap.getMembersFor(typeElement);
this.members = this.visibleMemberMap.getMembers(typeElement);
}
@ -118,26 +118,6 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
return "AnnotationTypeFieldDetails";
}
/**
* Returns a list of members that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the TypeElement we want to check.
* @return a list of members that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the members of this class.
*
* @return the visible member map for the members of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* Returns whether or not there are members to document.
@ -145,7 +125,7 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
*/
@Override
public boolean hasMembersToDocument() {
return members.size() > 0;
return !members.isEmpty();
}
/**
@ -172,16 +152,19 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder {
if (writer == null) {
return;
}
if (!members.isEmpty()) {
if (hasMembersToDocument()) {
writer.addAnnotationFieldDetailsMarker(memberDetailsTree);
for (Element element : members) {
currentMember = element;
Element lastElement = members.get(members.size() - 1);
for (Element member : members) {
currentMember = member;
Content detailsTree = writer.getMemberTreeHeader();
writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree);
Content annotationDocTree = writer.getAnnotationDocTreeHeader(element, detailsTree);
Content annotationDocTree = writer.getAnnotationDocTreeHeader(currentMember,
detailsTree);
buildChildren(node, annotationDocTree);
detailsTree.addContent(writer.getAnnotationDoc(
annotationDocTree, currentMember == members.last()));
annotationDocTree, currentMember == lastElement));
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
}
}

View file

@ -68,7 +68,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
/**
* The list of members being documented.
*/
protected SortedSet<Element> members;
protected List<Element> members;
/**
* The index of the current member that is being documented at this point
@ -82,6 +82,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
* @param context the build context.
* @param typeElement the class whose members are being documented.
* @param writer the doclet specific writer.
* @param memberType the kind of member this builder processes.
*/
protected AnnotationTypeRequiredMemberBuilder(Context context,
TypeElement typeElement,
@ -91,7 +92,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
this.typeElement = typeElement;
this.writer = writer;
this.visibleMemberMap = new VisibleMemberMap(typeElement, memberType, configuration);
this.members = this.visibleMemberMap.getMembersFor(typeElement);
this.members = this.visibleMemberMap.getMembers(typeElement);
}
@ -101,6 +102,7 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
* @param context the build context.
* @param typeElement the class whose members are being documented.
* @param writer the doclet specific writer.
* @return an instance of this object
*/
public static AnnotationTypeRequiredMemberBuilder getInstance(
Context context, TypeElement typeElement,
@ -118,34 +120,13 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
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 typeElement the {@link TypeElement} we want to check.
* @return a list of members that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the members of this class.
*
* @return the visible member map for the members of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* Returns whether or not there are members to document.
* @return whether or not there are members to document
*/
@Override
public boolean hasMembersToDocument() {
return members.size() > 0;
return !members.isEmpty();
}
/**
@ -165,24 +146,25 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
*
* @param node the XML element that specifies which components to document
* @param memberDetailsTree the content tree to which the documentation will be added
* @throws DocletException if an error occurs
*/
public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree)
throws DocletException {
if (writer == null) {
return;
}
int size = members.size();
if (size > 0) {
if (hasMembersToDocument()) {
writer.addAnnotationDetailsMarker(memberDetailsTree);
for (Element element : members) {
currentMember = element;
Element lastMember = members.get((members.size() - 1));
for (Element member : members) {
currentMember = member;
Content detailsTree = writer.getMemberTreeHeader();
writer.addAnnotationDetailsTreeHeader(typeElement, detailsTree);
Content annotationDocTree = writer.getAnnotationDocTreeHeader(
element, detailsTree);
currentMember, detailsTree);
buildChildren(node, annotationDocTree);
detailsTree.addContent(writer.getAnnotationDoc(
annotationDocTree, currentMember == members.last()));
annotationDocTree, currentMember == lastMember));
memberDetailsTree.addContent(writer.getAnnotationDetails(detailsTree));
}
}

View file

@ -275,7 +275,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
private boolean hasConstantField (TypeElement typeElement) {
VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(typeElement,
VisibleMemberMap.Kind.FIELDS, configuration);
SortedSet<Element> fields = visibleMemberMapFields.getLeafClassMembers();
List<Element> fields = visibleMemberMapFields.getLeafMembers();
for (Element f : fields) {
VariableElement field = (VariableElement)f;
if (field.getConstantValue() != null) {
@ -350,21 +350,21 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
}
/**
* Return the list of visible constant fields for the given TypeElement.
* @return the list of visible constant fields for the given TypeElement.
* Returns a set of visible constant fields for the given type.
* @return the set of visible constant fields for the given type.
*/
protected SortedSet<VariableElement> members() {
SortedSet<Element> list = visibleMemberMapFields.getLeafClassMembers();
list.addAll(visibleMemberMapEnumConst.getLeafClassMembers());
SortedSet<VariableElement> inclList =
List<Element> members = visibleMemberMapFields.getLeafMembers();
members.addAll(visibleMemberMapEnumConst.getLeafMembers());
SortedSet<VariableElement> includes =
new TreeSet<>(utils.makeGeneralPurposeComparator());
for (Element element : list) {
for (Element element : members) {
VariableElement member = (VariableElement)element;
if (member.getConstantValue() != null) {
inclList.add(member);
includes.add(member);
}
}
return inclList;
return includes;
}
}
}

View file

@ -59,7 +59,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
/**
* The current constructor that is being documented at this point in time.
*/
private ExecutableElement constructor;
private ExecutableElement currentConstructor;
/**
* The class whose constructors are being documented.
@ -79,7 +79,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
/**
* The constructors being documented.
*/
private final SortedSet<Element> constructors;
private final List<Element> constructors;
/**
* Construct a new ConstructorBuilder.
@ -99,7 +99,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
typeElement,
VisibleMemberMap.Kind.CONSTRUCTORS,
configuration);
constructors = visibleMemberMap.getMembersFor(typeElement);
constructors = visibleMemberMap.getMembers(typeElement);
for (Element ctor : constructors) {
if (utils.isProtected(ctor) || utils.isPrivate(ctor)) {
writer.setFoundNonPubConstructor(true);
@ -136,18 +136,6 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
return !constructors.isEmpty();
}
/**
* Returns a list of constructors that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the class
* @return a list of constructors that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Return the constructor writer for this builder.
*
@ -168,17 +156,17 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
if (writer == null) {
return;
}
int size = constructors.size();
if (size > 0) {
if (hasMembersToDocument()) {
Content constructorDetailsTree = writer.getConstructorDetailsTreeHeader(typeElement,
memberDetailsTree);
for (Element ctor : constructors) {
constructor = (ExecutableElement)ctor;
Content constructorDocTree = writer.getConstructorDocTreeHeader(
constructor, constructorDetailsTree);
Element lastElement = constructors.get(constructors.size() - 1);
for (Element contructor : constructors) {
currentConstructor = (ExecutableElement)contructor;
Content constructorDocTree = writer.getConstructorDocTreeHeader(currentConstructor, constructorDetailsTree);
buildChildren(node, constructorDocTree);
constructorDetailsTree.addContent(writer.getConstructorDoc(constructorDocTree,
constructors.last().equals(constructor)));
currentConstructor == lastElement));
}
memberDetailsTree.addContent(
writer.getConstructorDetails(constructorDetailsTree));
@ -192,7 +180,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
* @param constructorDocTree the content tree to which the documentation will be added
*/
public void buildSignature(XMLNode node, Content constructorDocTree) {
constructorDocTree.addContent(writer.getSignature(constructor));
constructorDocTree.addContent(writer.getSignature(currentConstructor));
}
/**
@ -202,7 +190,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
* @param constructorDocTree the content tree to which the documentation will be added
*/
public void buildDeprecationInfo(XMLNode node, Content constructorDocTree) {
writer.addDeprecated(constructor, constructorDocTree);
writer.addDeprecated(currentConstructor, constructorDocTree);
}
/**
@ -214,7 +202,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
*/
public void buildConstructorComments(XMLNode node, Content constructorDocTree) {
if (!configuration.nocomment) {
writer.addComments(constructor, constructorDocTree);
writer.addComments(currentConstructor, constructorDocTree);
}
}
@ -225,6 +213,6 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
* @param constructorDocTree the content tree to which the documentation will be added
*/
public void buildTagInfo(XMLNode node, Content constructorDocTree) {
writer.addTags(constructor, constructorDocTree);
writer.addTags(currentConstructor, constructorDocTree);
}
}

View file

@ -67,9 +67,9 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
private final EnumConstantWriter writer;
/**
* The list of enum constants being documented.
* The set of enum constants being documented.
*/
private final SortedSet<Element> enumConstants;
private final List<Element> enumConstants;
/**
* The current enum constant that is being documented at this point
@ -94,7 +94,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
typeElement,
VisibleMemberMap.Kind.ENUM_CONSTANTS,
configuration);
enumConstants = visibleMemberMap.getMembersFor(typeElement);
enumConstants = visibleMemberMap.getMembers(typeElement);
}
/**
@ -118,27 +118,6 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
return "EnumConstantDetails";
}
/**
* Returns a list of enum constants that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the {@link TypeElement} we want to check.
* @return a list of enum constants that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the enum constants of this class.
*
* @return the visible member map for the enum constants of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* Returns whether or not there are members to document.
*
@ -146,7 +125,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
*/
@Override
public boolean hasMembersToDocument() {
return enumConstants.size() > 0;
return !enumConstants.isEmpty();
}
/**
@ -160,16 +139,17 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
if (writer == null) {
return;
}
if (!enumConstants.isEmpty()) {
if (hasMembersToDocument()) {
Content enumConstantsDetailsTree = writer.getEnumConstantsDetailsTreeHeader(typeElement,
memberDetailsTree);
for (Element element : enumConstants) {
currentElement = (VariableElement)element;
Element lastElement = enumConstants.get(enumConstants.size() - 1);
for (Element enumConstant : enumConstants) {
currentElement = (VariableElement)enumConstant;
Content enumConstantsTree = writer.getEnumConstantsTreeHeader(currentElement,
enumConstantsDetailsTree);
buildChildren(node, enumConstantsTree);
enumConstantsDetailsTree.addContent(writer.getEnumConstants(
enumConstantsTree, currentElement.equals(enumConstants.last())));
enumConstantsTree, currentElement == lastElement));
}
memberDetailsTree.addContent(
writer.getEnumConstantsDetails(enumConstantsDetailsTree));

View file

@ -69,7 +69,7 @@ public class FieldBuilder extends AbstractMemberBuilder {
/**
* The list of fields being documented.
*/
private final SortedSet<Element> fields;
private final List<Element> fields;
/**
* The index of the current field that is being documented at this point
@ -95,7 +95,7 @@ public class FieldBuilder extends AbstractMemberBuilder {
typeElement,
VisibleMemberMap.Kind.FIELDS,
configuration);
fields = visibleMemberMap.getLeafClassMembers();
fields = visibleMemberMap.getLeafMembers();
}
/**
@ -120,27 +120,6 @@ public class FieldBuilder extends AbstractMemberBuilder {
return "FieldDetails";
}
/**
* Returns a list of fields that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the {@link TypeElement} we want to check.
* @return a list of fields that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the fields of this class.
*
* @return the visible member map for the fields of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* Returns whether or not there are members to document.
*
@ -164,12 +143,14 @@ public class FieldBuilder extends AbstractMemberBuilder {
}
if (!fields.isEmpty()) {
Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(typeElement, memberDetailsTree);
Element lastElement = fields.get(fields.size() - 1);
for (Element element : fields) {
currentElement = (VariableElement)element;
Content fieldDocTree = writer.getFieldDocTreeHeader(currentElement, fieldDetailsTree);
buildChildren(node, fieldDocTree);
fieldDetailsTree.addContent(writer.getFieldDoc(
fieldDocTree, currentElement.equals(fields.last())));
fieldDocTree, currentElement == lastElement));
}
memberDetailsTree.addContent(
writer.getFieldDetails(fieldDetailsTree));

View file

@ -182,7 +182,9 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
* @see VisibleMemberMap
*/
public SortedSet<Element> members(VisibleMemberMap.Kind type) {
return visibleMemberMaps.get(type).getLeafClassMembers();
TreeSet<Element> out = new TreeSet<>(comparator);
out.addAll(visibleMemberMaps.get(type).getLeafMembers());
return out;
}
/**
@ -336,7 +338,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
*/
private void buildSummary(MemberSummaryWriter writer,
VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
SortedSet<Element> members = visibleMemberMap.getLeafClassMembers();
SortedSet<Element> members = asSortedSet(visibleMemberMap.getLeafMembers());
if (!members.isEmpty()) {
List<Content> tableContents = new LinkedList<>();
int counter = 0;
@ -492,7 +494,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
if (inhclass == typeElement) {
continue;
}
SortedSet<Element> inhmembers = visibleMemberMap.getMembersFor(inhclass);
SortedSet<Element> inhmembers = asSortedSet(visibleMemberMap.getMembers(inhclass));
if (!inhmembers.isEmpty()) {
Content inheritedTree = writer.getInheritedSummaryHeader(inhclass);
Content linksTree = writer.getInheritedSummaryLinksTree();

View file

@ -78,7 +78,7 @@ public class MethodBuilder extends AbstractMemberBuilder {
/**
* The methods being documented.
*/
private final SortedSet<Element> methods;
private final List<Element> methods;
/**
@ -98,7 +98,7 @@ public class MethodBuilder extends AbstractMemberBuilder {
typeElement,
VisibleMemberMap.Kind.METHODS,
configuration);
methods = visibleMemberMap.getLeafClassMembers();
methods = visibleMemberMap.getLeafMembers();
}
/**
@ -123,27 +123,6 @@ public class MethodBuilder extends AbstractMemberBuilder {
return "MethodDetails";
}
/**
* Returns a list of methods that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the {@link TypeElement} we want to check.
* @return a list of methods that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the methods of this class.
*
* @return the visible member map for the methods of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* {@inheritDoc}
*/
@ -163,18 +142,17 @@ public class MethodBuilder extends AbstractMemberBuilder {
if (writer == null) {
return;
}
if (!methods.isEmpty()) {
if (hasMembersToDocument()) {
Content methodDetailsTree = writer.getMethodDetailsTreeHeader(typeElement,
memberDetailsTree);
Set<Element> methodDetailSet = ((ConfigurationImpl)configuration).sortedMethodDetails
? methods
: visibleMemberMap.getLeafClassMembersSourceOrder();
for (Element e : methodDetailSet) {
currentMethod = (ExecutableElement) e;
Element lastElement = methods.get(methods.size() - 1);
for (Element method : methods) {
currentMethod = (ExecutableElement)method;
Content methodDocTree = writer.getMethodDocTreeHeader(currentMethod, methodDetailsTree);
buildChildren(node, methodDocTree);
methodDetailsTree.addContent(writer.getMethodDoc(
methodDocTree, currentMethod == methods.last()));
methodDocTree, currentMethod == lastElement));
}
memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree));
}

View file

@ -69,7 +69,7 @@ public class PropertyBuilder extends AbstractMemberBuilder {
/**
* The list of properties being documented.
*/
private final SortedSet<Element> properties;
private final List<Element> properties;
/**
* The index of the current property that is being documented at this point
@ -95,7 +95,7 @@ public class PropertyBuilder extends AbstractMemberBuilder {
typeElement,
VisibleMemberMap.Kind.PROPERTIES,
configuration);
properties = visibleMemberMap.getMembersFor(typeElement);
properties = visibleMemberMap.getMembers(typeElement);
}
/**
@ -120,27 +120,6 @@ public class PropertyBuilder extends AbstractMemberBuilder {
return "PropertyDetails";
}
/**
* Returns a list of properties that will be documented for the given class.
* This information can be used for doclet specific documentation
* generation.
*
* @param typeElement the {@link TypeElement} we want to check.
* @return a list of properties that will be documented.
*/
public SortedSet<Element> members(TypeElement typeElement) {
return visibleMemberMap.getMembersFor(typeElement);
}
/**
* Returns the visible member map for the properties of this class.
*
* @return the visible member map for the properties of this class.
*/
public VisibleMemberMap getVisibleMemberMap() {
return visibleMemberMap;
}
/**
* Returns whether or not there are members to document.
*
@ -162,17 +141,17 @@ public class PropertyBuilder extends AbstractMemberBuilder {
if (writer == null) {
return;
}
int size = properties.size();
if (size > 0) {
if (hasMembersToDocument()) {
Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(typeElement,
memberDetailsTree);
for (Element e : properties) {
currentProperty = (ExecutableElement) e;
Element lastElement = properties.get(properties.size() - 1);
for (Element property : properties) {
currentProperty = (ExecutableElement)property;
Content propertyDocTree = writer.getPropertyDocTreeHeader(currentProperty,
propertyDetailsTree);
buildChildren(node, propertyDocTree);
propertyDetailsTree.addContent(writer.getPropertyDoc(
propertyDocTree, currentProperty == properties.last()));
propertyDocTree, currentProperty == lastElement));
}
memberDetailsTree.addContent(
writer.getPropertyDetails(propertyDetailsTree));

View file

@ -25,7 +25,6 @@
package jdk.javadoc.internal.doclets.toolkit.util;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.ref.SoftReference;
import java.text.CollationKey;
@ -77,9 +76,7 @@ import com.sun.source.util.DocTrees;
import com.sun.source.util.TreePath;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
import jdk.javadoc.internal.doclets.toolkit.Configuration;
import jdk.javadoc.internal.doclets.toolkit.DocletException;
import jdk.javadoc.internal.doclets.toolkit.Messages;
import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.WorkArounds;
import static javax.lang.model.element.ElementKind.*;
@ -258,14 +255,6 @@ public class Utils {
return getEnclosingTypeElement(e) == null || isStatic(e);
}
public boolean matches(Element e1, Element e2) {
if (isExecutableElement(e1) && isExecutableElement(e1)) {
return executableMembersEqual((ExecutableElement)e1, (ExecutableElement)e2);
} else {
return e1.getSimpleName().equals(e2.getSimpleName());
}
}
/**
* Copy doc-files directory and its contents from the source
* package directory to the generated documentation directory.
@ -2161,6 +2150,13 @@ public class Utils {
return convertToExecutableElement(getItems(e, false, METHOD));
}
public int getOrdinalValue(VariableElement member) {
if (member == null || member.getKind() != ENUM_CONSTANT) {
throw new IllegalArgumentException("must be an enum constant: " + member);
}
return member.getEnclosingElement().getEnclosedElements().indexOf(member);
}
public long getLineNumber(Element e) {
TreePath path = getTreePath(e);
if (path == null) { // maybe null if synthesized

View file

@ -220,48 +220,36 @@ public class VisibleMemberMap {
}
/**
* Return the visible members of the class being mapped. Also append at the
* end of the list members that are inherited by inaccessible parents. We
* document these members in the child because the parent is not documented.
* Returns a list of visible enclosed members of the type being mapped.
* This list may also contain appended members, inherited by inaccessible
* super types. These members are documented in the subtype when the
* super type is not documented.
*
* @param configuration the current configuration of the doclet.
* @return a list of visible enclosed members
*/
public SortedSet<Element> getLeafClassMembers() {
SortedSet<Element> result = getMembersFor(typeElement);
result.addAll(getInheritedPackagePrivateMethods());
return result;
}
public Set<Element> getLeafClassMembersSourceOrder() {
Set<Element> result = new LinkedHashSet<>(classMap.get(typeElement).members);
public List<Element> getLeafMembers() {
List<Element> result = new ArrayList<>();
result.addAll(classMap.get(typeElement).members);
result.addAll(getInheritedPackagePrivateMethods());
return result;
}
/**
* Retrn the list of members for the given class.
* Returns a list of enclosed members for the given type.
*
* @param typeElement the class to retrieve the list of visible members for.
* @param typeElement the given type
*
* @return the list of members for the given class.
* @return a list of enclosed members
*/
public SortedSet<Element> getMembersFor(TypeElement typeElement) {
return asSortedSet(classMap.get(typeElement).members);
public List<Element> getMembers(TypeElement typeElement) {
return classMap.get(typeElement).members;
}
public boolean hasMembersFor(TypeElement typeElement) {
public boolean hasMembers(TypeElement typeElement) {
return !classMap.get(typeElement).members.isEmpty();
}
private SortedSet<Element> asSortedSet(Collection<Element> in) {
if (in == null) {
return Collections.emptySortedSet();
}
TreeSet<Element> out = new TreeSet<>(comparator);
out.addAll(in);
return out;
}
private void fillMemberLevelMap(List<? extends Element> list, String level) {
for (Element element : list) {
Object key = getMemberKey(element);
@ -318,9 +306,9 @@ public class VisibleMemberMap {
private final TypeElement typeElement;
/**
* List of inherited members from the mapping class.
* List of members from the mapping class.
*/
private Set<Element> members = new LinkedHashSet<>();
private List<Element> members = null;
/**
* Level/Depth of inheritance.
@ -379,23 +367,23 @@ public class VisibleMemberMap {
* Adjust member-level-map, class-map.
*/
private void addMembers(TypeElement fromClass) {
List<? extends Element> classMembers = getClassMembers(fromClass, true);
List<Element> incllist = new ArrayList<>();
for (Element element : classMembers) {
if (!found(members, element)) {
if (memberIsVisible(element)) {
if (!isOverridden(element, level)) {
if (!utils.isHidden(element)) {
incllist.add(element);
}
List<Element> result = new ArrayList<>();
for (Element element : getClassMembers(fromClass, true)) {
if (memberIsVisible(element)) {
if (!isOverridden(element, level)) {
if (!utils.isHidden(element)) {
result.add(element);
}
}
}
}
if (!incllist.isEmpty()) {
if (members != null) {
throw new AssertionError("members should not be null");
}
members = Collections.unmodifiableList(result);
if (!members.isEmpty()) {
noVisibleMembers = false;
}
members.addAll(incllist);
fillMemberLevelMap(getClassMembers(fromClass, false), level);
}
@ -513,16 +501,6 @@ public class VisibleMemberMap {
return targetMembers;
}
private boolean found(Iterable<Element> list, Element elem) {
for (Element pgmelem : list) {
if (utils.matches(pgmelem, elem)) {
return true;
}
}
return false;
}
/**
* Is member overridden? The member is overridden if it is found in the
* same level hierarchy e.g. member at level "11" overrides member at

View file

@ -23,7 +23,7 @@
/*
* @test
* @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363
* @bug 7112427 8012295 8025633 8026567 8061305 8081854 8150130 8162363 8167967
* @summary Test of the JavaFX doclet features.
* @author jvalenta
* @library ../lib
@ -163,10 +163,7 @@ public class TestJavaFX extends JavadocTester {
"pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/Test.html", true,
"<li class=\"blockList\"><a name=\"property.detail\">\n"
+ "<!-- -->\n"
+ "</a>\n"
+ "<h3>Property Detail</h3>\n"
"<h3>Property Detail</h3>\n"
+ "<a name=\"betaProperty\">\n"
+ "<!-- -->\n"
+ "</a>\n"
@ -176,27 +173,27 @@ public class TestJavaFX extends JavadocTester {
+ "<pre>public&nbsp;java.lang.Object betaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
+ "<a name=\"deltaProperty\">\n"
+ "<a name=\"gammaProperty\">\n"
+ "<!-- -->\n"
+ "</a>\n"
+ "<ul class=\"blockList\">\n"
+ "<li class=\"blockList\">\n"
+ "<h4>gamma</h4>\n"
+ "<pre>public final&nbsp;java.util.List&lt;java.lang.String&gt; gammaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
+ "<a name=\"deltaProperty\">\n"
+ "<!-- -->\n"
+ "</a>\n"
+ "<ul class=\"blockListLast\">\n"
+ "<li class=\"blockList\">\n"
+ "<h4>delta</h4>\n"
+ "<pre>public final&nbsp;java.util.List&lt;"
+ "java.util.Set&lt;? super java.lang.Object&gt;&gt; deltaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
+ "<a name=\"gammaProperty\">\n"
+ "<!-- -->\n"
+ "</a>\n"
+ "<ul class=\"blockListLast\">\n"
+ "<li class=\"blockList\">\n"
+ "<h4>gamma</h4>\n"
+ "<pre>public final&nbsp;java.util.List&lt;"
+ "java.lang.String&gt; gammaProperty</pre>\n"
+ "</li>\n"
+ "</ul>\n"
+ "</li>");
+ "</ul>");
}
/*

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 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
@ -21,32 +21,11 @@
* questions.
*/
package order;
package pkg5;
/**
* This class ensures the method detail section contains the methods
* in the order as it appears in the source.
* @author kumasrin
*/
public class MethodOrder {
/**
* Method d.
* Second line.
*/
public void d(){}
/**
* Method b.
* Second line.
*/
public void b() {}
/**
* Method c.
* Second line.
*/
public void c() {}
/**
* Method a.
* Second line.
*/
public void a() {}
public @interface AnnoFieldTest {
public int one = 1;
public int two = 2;
public int three = 3;
public int four = 4;
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public @interface AnnoOptionalTest {
int one() default 1;
int two() default 2;
int three() default 3;
int four() default 4;
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public @interface AnnoRequiredTest {
int one();
int two();
int three();
int four();
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public class CtorTest {
public CtorTest(int one, int two, int three, int four) {}
public CtorTest(int one, int two, int three) {}
public CtorTest(int one, int two) {}
public CtorTest(int one) {}
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public enum EnumTest {
ONE,
TWO,
THREE,
FOUR
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public class FieldTest {
public int one;
public int two;
public int three;
public int four;
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public interface IntfTest {
void one();
void two();
void three();
void four();
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public class MethodTest {
public void one(){}
public void two(){}
public void three(){}
public void four(){}
}

View file

@ -0,0 +1,31 @@
/*
* Copyright (c) 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.
*
* 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 pkg5;
public class PropertyTest {
public int oneProperty() { return 1; }
public int twoProperty() { return 2; }
public int threeProperty() { return 3; }
public int fourProperty() { return 4; }
}