Mercurial > hg > openjdk > icedtea > jdk7 > langtools
changeset 1244:ce88d36be582
Merge jdk7u6-b13
author | andrew |
---|---|
date | Fri, 08 Jun 2012 17:12:36 +0100 |
parents | 93e9eae30c44 (current diff) fcebf337f5c1 (diff) |
children | e899fe9f5be5 |
files | .hgtags |
diffstat | 39 files changed, 1962 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Wed May 23 20:37:49 2012 +0100 +++ b/.hgtags Fri Jun 08 17:12:36 2012 +0100 @@ -180,3 +180,6 @@ 870ec15296f34e973bc256b7a14a4ce7eaa1af7e jdk7u6-b07 ed00f61a5de82f63449ea6ad0a17c0ad7177aaf9 jdk7u6-b08 3e268ea565efb2fd1df1d1b733512c202d83cf4f jdk7u6-b09 +21d2313dfeac8c52a04b837d13958c86346a4b12 jdk7u6-b10 +13d3c624291615593b4299a273085441b1dd2f03 jdk7u6-b11 +f0be10a26af08c33d9afe8fe51df29572d431bac jdk7u6-b12
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -703,7 +703,8 @@ } HtmlTree navList = new HtmlTree(HtmlTag.UL); navList.addStyle(HtmlStyle.navList); - navList.addAttr(HtmlAttr.TITLE, "Navigation"); + navList.addAttr(HtmlAttr.TITLE, + configuration.getText("doclet.Navigation")); if (configuration.createoverview) { navList.addContent(getNavLinkContents()); } @@ -1986,7 +1987,24 @@ */ public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc, String label, boolean strong) { - print(getDocLink(context, classDoc, doc, label, strong)); + printDocLink(context, classDoc, doc, label, strong, false); + } + + /** + * Print the link for the given member. + * + * @param context the id of the context where the link will be printed. + * @param classDoc the classDoc that we should link to. This is not + * necessarily equal to doc.containingClass(). We may be + * inheriting comments. + * @param doc the member being linked to. + * @param label the label for the link. + * @param strong true if the link should be strong. + * @param isProperty true if the doc parameter is a JavaFX property. + */ + public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc, + String label, boolean strong, boolean isProperty) { + print(getDocLink(context, classDoc, doc, label, strong, isProperty)); } /** @@ -2017,13 +2035,31 @@ */ public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc, String label, boolean strong) { + return getDocLink(context, classDoc, doc, label, strong, false); + } + + /** + * Return the link for the given member. + * + * @param context the id of the context where the link will be printed. + * @param classDoc the classDoc that we should link to. This is not + * necessarily equal to doc.containingClass(). We may be + * inheriting comments. + * @param doc the member being linked to. + * @param label the label for the link. + * @param strong true if the link should be strong. + * @param isProperty true if the doc parameter is a JavaFX property. + * @return the link for the given member. + */ + public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc, + String label, boolean strong, boolean isProperty) { if (! (doc.isIncluded() || Util.isLinkable(classDoc, configuration()))) { return label; } else if (doc instanceof ExecutableMemberDoc) { ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; return getLink(new LinkInfoImpl(context, classDoc, - getAnchor(emd), label, strong)); + getAnchor(emd, isProperty), label, strong)); } else if (doc instanceof MemberDoc) { return getLink(new LinkInfoImpl(context, classDoc, doc.name(), label, strong)); @@ -2065,6 +2101,13 @@ } public String getAnchor(ExecutableMemberDoc emd) { + return getAnchor(emd, false); + } + + public String getAnchor(ExecutableMemberDoc emd, boolean isProperty) { + if (isProperty) { + return emd.name(); + } StringBuilder signature = new StringBuilder(emd.signature()); StringBuilder signatureParsed = new StringBuilder(); int counter = 0; @@ -2177,6 +2220,13 @@ refMemName += ((ExecutableMemberDoc)refMem).signature(); } } + if (Configuration.getJavafxJavadoc()) { + int index; + if ((index = refMemName.indexOf("<")) != -1 ) { + refMemName = refMemName.substring(0, index) + ")"; + } + } + text = (isplaintext) ? refMemName : getCode() + Util.escapeHtmlChars(refMemName) + getCodeEnd();
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -31,6 +31,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.formats.html.markup.*; +import com.sun.tools.doclets.internal.toolkit.builders.PackageSummaryBuilder; /** * Class to generate file for each package contents in the left-hand bottom @@ -160,6 +161,7 @@ */ protected void addClassKindListing(ClassDoc[] arr, Content labelContent, Content contentTree) { + arr = PackageSummaryBuilder.filterOutPrivateClasses(arr); if(arr.length > 0) { Arrays.sort(arr); boolean printedHeader = false;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,303 @@ +/* + * Copyright (c) 1997, 2012, 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 com.sun.tools.doclets.formats.html; + +import java.io.*; + +import com.sun.javadoc.*; +import com.sun.tools.doclets.formats.html.markup.*; +import com.sun.tools.doclets.internal.toolkit.*; +import com.sun.tools.doclets.internal.toolkit.util.*; + +/** + * Writes property documentation in HTML format. + * + * @author Robert Field + * @author Atul M Dambalkar + * @author Jamie Ho (rewrite) + * @author Bhavesh Patel (Modified) + */ +public class PropertyWriterImpl extends AbstractMemberWriter + implements PropertyWriter, MemberSummaryWriter { + + public PropertyWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) { + super(writer, classdoc); + } + + /** + * {@inheritDoc} + */ + public Content getMemberSummaryHeader(ClassDoc classDoc, + Content memberSummaryTree) { + memberSummaryTree.addContent(HtmlConstants.START_OF_PROPERTY_SUMMARY); + Content memberTree = writer.getMemberTreeHeader(); + writer.addSummaryHeader(this, classDoc, memberTree); + return memberTree; + } + + /** + * {@inheritDoc} + */ + public Content getFieldDetailsTreeHeader(ClassDoc classDoc, + Content memberDetailsTree) { + memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS); + Content fieldDetailsTree = writer.getMemberTreeHeader(); + fieldDetailsTree.addContent(writer.getMarkerAnchor("property_detail")); + Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, + writer.propertyDetailsLabel); + fieldDetailsTree.addContent(heading); + return fieldDetailsTree; + } + + /** + * {@inheritDoc} + */ + public Content getFieldDocTreeHeader(MethodDoc field, + Content fieldDetailsTree) { + fieldDetailsTree.addContent( + writer.getMarkerAnchor(field.name())); + Content fieldDocTree = writer.getMemberTreeHeader(); + Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); + heading.addContent(field.name().substring(0, field.name().lastIndexOf("Property"))); + fieldDocTree.addContent(heading); + return fieldDocTree; + } + + /** + * {@inheritDoc} + */ + public Content getSignature(MethodDoc field) { + return new Comment("property signature"); + } + + /** + * {@inheritDoc} + */ + public void addDeprecated(MethodDoc field, Content fieldDocTree) { + } + + /** + * {@inheritDoc} + */ + public void addComments(MethodDoc field, Content fieldDocTree) { + ClassDoc holder = field.containingClass(); + if (field.inlineTags().length > 0) { + if (holder.equals(classdoc) || + (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) { + writer.addInlineComment(field, fieldDocTree); + } else { + Content link = new RawHtml( + writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY, + holder, field, + holder.isIncluded() ? + holder.typeName() : holder.qualifiedTypeName(), + false)); + Content codeLink = HtmlTree.CODE(link); + Content strong = HtmlTree.STRONG(holder.isClass()? + writer.descfrmClassLabel : writer.descfrmInterfaceLabel); + strong.addContent(writer.getSpace()); + strong.addContent(codeLink); + fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong)); + writer.addInlineComment(field, fieldDocTree); + } + } + } + + /** + * {@inheritDoc} + */ + public void addTags(MethodDoc field, Content fieldDocTree) { + writer.addTagsInfo(field, fieldDocTree); + } + + /** + * {@inheritDoc} + */ + public Content getFieldDetails(Content fieldDetailsTree) { + return getMemberTree(fieldDetailsTree); + } + + /** + * {@inheritDoc} + */ + public Content getFieldDoc(Content fieldDocTree, + boolean isLastContent) { + return getMemberTree(fieldDocTree, isLastContent); + } + + /** + * Close the writer. + */ + public void close() throws IOException { + writer.close(); + } + + public int getMemberKind() { + return VisibleMemberMap.PROPERTIES; + } + + /** + * {@inheritDoc} + */ + public void addSummaryLabel(Content memberTree) { + Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, + writer.getResource("doclet.Property_Summary")); + memberTree.addContent(label); + } + + /** + * {@inheritDoc} + */ + public String getTableSummary() { + return configuration().getText("doclet.Member_Table_Summary", + configuration().getText("doclet.Property_Summary"), + configuration().getText("doclet.properties")); + } + + /** + * {@inheritDoc} + */ + public String getCaption() { + return configuration().getText("doclet.Properties"); + } + + /** + * {@inheritDoc} + */ + public String[] getSummaryTableHeader(ProgramElementDoc member) { + String[] header = new String[] { + configuration().getText("doclet.Type"), + configuration().getText("doclet.0_and_1", + configuration().getText("doclet.Property"), + configuration().getText("doclet.Description")) + }; + return header; + } + + /** + * {@inheritDoc} + */ + public void addSummaryAnchor(ClassDoc cd, Content memberTree) { + memberTree.addContent(writer.getMarkerAnchor("property_summary")); + } + + /** + * {@inheritDoc} + */ + public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) { + inheritedTree.addContent(writer.getMarkerAnchor( + "properties_inherited_from_class_" + configuration().getClassName(cd))); + } + + /** + * {@inheritDoc} + */ + public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) { + Content classLink = new RawHtml(writer.getPreQualifiedClassLink( + LinkInfoImpl.CONTEXT_MEMBER, cd, false)); + Content label = new StringContent(cd.isClass() ? + configuration().getText("doclet.Properties_Inherited_From_Class") : + configuration().getText("doclet.Properties_Inherited_From_Interface")); + Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING, + label); + labelHeading.addContent(writer.getSpace()); + labelHeading.addContent(classLink); + inheritedTree.addContent(labelHeading); + } + + /** + * {@inheritDoc} + */ + protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member, + Content tdSummary) { + Content strong = HtmlTree.STRONG(new RawHtml( + writer.getDocLink(context, + cd, + (MemberDoc) member, + member.name().substring(0, member.name().lastIndexOf("Property")), + false, + true))); + + Content code = HtmlTree.CODE(strong); + tdSummary.addContent(code); + } + + /** + * {@inheritDoc} + */ + protected void addInheritedSummaryLink(ClassDoc cd, + ProgramElementDoc member, Content linksTree) { + linksTree.addContent(new RawHtml( + writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member, + ((member.name().lastIndexOf("Property") != -1) && Configuration.getJavafxJavadoc()) + ? member.name().substring(0, member.name().length() - "Property".length()) + : member.name(), + false, true))); + } + + /** + * {@inheritDoc} + */ + protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) { + MethodDoc method = (MethodDoc)member; + addModifierAndType(method, method.returnType(), tdSummaryType); + } + + /** + * {@inheritDoc} + */ + protected Content getDeprecatedLink(ProgramElementDoc member) { + return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, + (MemberDoc) member, ((MethodDoc)member).qualifiedName()); + } + + /** + * {@inheritDoc} + */ + protected Content getNavSummaryLink(ClassDoc cd, boolean link) { + if (link) { + return writer.getHyperLink("", (cd == null)? + "property_summary": + "properties_inherited_from_class_" + + configuration().getClassName(cd), + writer.getResource("doclet.navProperty")); + } else { + return writer.getResource("doclet.navProperty"); + } + } + + /** + * {@inheritDoc} + */ + protected void addNavDetailLink(boolean link, Content liNav) { + if (link) { + liNav.addContent(writer.getHyperLink("", "property_detail", + writer.getResource("doclet.navProperty"))); + } else { + liNav.addContent(writer.getResource("doclet.navProperty")); + } + } +}
--- a/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -119,6 +119,15 @@ /** * {@inheritDoc} */ + public PropertyWriter getPropertyWriter(ClassWriter classWriter) + throws Exception { + return new PropertyWriterImpl((SubWriterHolderWriter) classWriter, + classWriter.getClassDoc()); + } + + /** + * {@inheritDoc} + */ public MethodWriter getMethodWriter(ClassWriter classWriter) throws Exception { return new MethodWriterImpl((SubWriterHolderWriter) classWriter, @@ -147,6 +156,8 @@ return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter); case VisibleMemberMap.FIELDS: return (FieldWriterImpl) getFieldWriter(classWriter); + case VisibleMemberMap.PROPERTIES: + return (PropertyWriterImpl) getPropertyWriter(classWriter); case VisibleMemberMap.INNERCLASSES: return new NestedClassWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getClassDoc());
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2012, 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 @@ -107,6 +107,12 @@ new Comment("=========== FIELD SUMMARY ==========="); /** + * Marker to identify start of properties summary. + */ + public static final Content START_OF_PROPERTY_SUMMARY = + new Comment("=========== PROPERTY SUMMARY ==========="); + + /** * Marker to identify start of method summary. */ public static final Content START_OF_METHOD_SUMMARY = @@ -131,6 +137,12 @@ new Comment("============ FIELD DETAIL ==========="); /** + * Marker to identify start of property details. + */ + public static final Content START_OF_PROPERTY_DETAILS = + new Comment("============ PROPERTY DETAIL ==========="); + + /** * Marker to identify start of constructor details. */ public static final Content START_OF_CONSTRUCTOR_DETAILS =
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -136,6 +136,8 @@ public final Content fieldDetailsLabel; + public final Content propertyDetailsLabel; + public final Content constructorDetailsLabel; public final Content enumConstantsDetailsLabel; @@ -205,6 +207,7 @@ methodDetailsLabel = getResource("doclet.Method_Detail"); annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail"); fieldDetailsLabel = getResource("doclet.Field_Detail"); + propertyDetailsLabel = getResource("doclet.Property_Detail"); constructorDetailsLabel = getResource("doclet.Constructor_Detail"); enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail"); specifiedByLabel = getResource("doclet.Specified_By");
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties Fri Jun 08 17:12:36 2012 +0100 @@ -32,6 +32,7 @@ doclet.navAnnotationTypeRequiredMember=Required doclet.navAnnotationTypeMember=Element doclet.navField=Field +doclet.navProperty=Property doclet.navEnum=Enum Constants doclet.navConstructor=Constr doclet.navMethod=Method @@ -40,6 +41,7 @@ doclet.Window_Split_Index={0}-Index doclet.Help=Help doclet.Skip_navigation_links=Skip navigation links +doclet.Navigation=Navigation doclet.New_Page=NewPage doclet.None=None doclet.Factory_Method_Detail=Static Factory Method Detail @@ -189,7 +191,9 @@ doclet.ClassUse_TypeParameter=Classes in {1} with type parameters of type {0} doclet.ClassUse_MethodTypeParameter=Methods in {1} with type parameters of type {0} doclet.ClassUse_FieldTypeParameter=Fields in {1} with type parameters of type {0} +doclet.ClassUse_PropertyTypeParameter=Properties in {1} with type parameters of type {0} doclet.ClassUse_FieldAnnotations=Fields in {1} with annotations of type {0} +doclet.ClassUse_PropertyAnnotations=Properties in {1} with annotations of type {0} doclet.ClassUse_MethodAnnotations=Methods in {1} with annotations of type {0} doclet.ClassUse_MethodParameterAnnotations=Method parameters in {1} with annotations of type {0} doclet.ClassUse_MethodReturnTypeParameter=Methods in {1} that return types with arguments of type {0}
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, 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 @@ -221,6 +221,19 @@ public final Extern extern = new Extern(this); /** + * Returns true if the user wants to generate JavaFX documentation. + */ + public static boolean getJavafxJavadoc() { + return Boolean.getBoolean("javafx.javadoc"); + } + + /** + * Location of doclet properties file. + */ + public static final String DOCLETS_RESOURCE + = "com.sun.tools.doclets.internal.toolkit.resources.doclets"; + + /** * Return the build date for the doclet. */ public abstract String getDocletSpecificBuildDate(); @@ -253,8 +266,7 @@ */ public Configuration() { message = - new MessageRetriever(this, - "com.sun.tools.doclets.internal.toolkit.resources.doclets"); + new MessageRetriever(this, DOCLETS_RESOURCE); excludedDocFileDirs = new HashSet<String>(); excludedQualifiers = new HashSet<String>(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2003, 2012, 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 com.sun.tools.doclets.internal.toolkit; + +import java.io.*; +import com.sun.javadoc.*; + +/** + * The interface for writing field output. + * + * This code is not part of an API. + * It is implementation that is subject to change. + * Do not use it as an API + * + * @author Jamie Ho + * @author Bhavesh Patel (Modified) + * @since 1.5 + */ + +public interface PropertyWriter { + + /** + * Get the field details tree header. + * + * @param classDoc the class being documented + * @param memberDetailsTree the content tree representing member details + * @return content tree for the field details header + */ + public Content getFieldDetailsTreeHeader(ClassDoc classDoc, + Content memberDetailsTree); + + /** + * Get the field documentation tree header. + * + * @param field the constructor being documented + * @param fieldDetailsTree the content tree representing field details + * @return content tree for the field documentation header + */ + public Content getFieldDocTreeHeader(MethodDoc field, + Content fieldDetailsTree); + + /** + * Get the signature for the given field. + * + * @param field the field being documented + * @return content tree for the field signature + */ + public Content getSignature(MethodDoc field); + + /** + * Add the deprecated output for the given field. + * + * @param field the field being documented + * @param fieldDocTree content tree to which the deprecated information will be added + */ + public void addDeprecated(MethodDoc field, Content fieldDocTree); + + /** + * Add the comments for the given field. + * + * @param field the field being documented + * @param fieldDocTree the content tree to which the comments will be added + */ + public void addComments(MethodDoc field, Content fieldDocTree); + + /** + * Add the tags for the given field. + * + * @param field the field being documented + * @param fieldDocTree the content tree to which the tags will be added + */ + public void addTags(MethodDoc field, Content fieldDocTree); + + /** + * Get the field details tree. + * + * @param memberDetailsTree the content tree representing member details + * @return content tree for the field details + */ + public Content getFieldDetails(Content memberDetailsTree); + + /** + * Get the field documentation. + * + * @param fieldDocTree the content tree representing field documentation + * @param isLastContent true if the content to be added is the last content + * @return content tree for the field documentation + */ + public Content getFieldDoc(Content fieldDocTree, boolean isLastContent); + + /** + * Close the writer. + */ + public void close() throws IOException; +}
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -146,6 +146,16 @@ throws Exception; /** + * Return the property writer for a given class. + * + * @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. + */ + public abstract PropertyWriter getPropertyWriter(ClassWriter classWriter) + throws Exception; + + /** * Return the constructor writer for a given class. * * @param classWriter the writer for the class being documented.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -188,6 +188,19 @@ } /** + * Return an instance of the property builder for the given class. + * + * @return an instance of the field builder for the given class. + */ + public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception { + final PropertyWriter propertyWriter = + writerFactory.getPropertyWriter(classWriter); + return PropertyBuilder.getInstance(configuration, + classWriter.getClassDoc(), + propertyWriter); + } + + /** * Return an instance of the constructor builder for the given class. * * @return an instance of the constructor builder for the given class.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -372,6 +372,17 @@ } /** + * Build the property documentation. + * + * @param elements the XML elements that specify how a field is documented. + */ + public void buildPropertyDetails(XMLNode node, + Content memberDetailsTree) throws Exception { + configuration.getBuilderFactory(). + getPropertyBuilder(writer).buildChildren(node, memberDetailsTree); + } + + /** * Build the constructor documentation. * * @param node the XML element that specifies which components to document
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -29,6 +29,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.javadoc.*; +import java.text.MessageFormat; /** * Builds the member summary. @@ -249,6 +250,17 @@ } /** + * Build the summary for the fields. + */ + public void buildPropertiesSummary(XMLNode node, Content memberSummaryTree) { + MemberSummaryWriter writer = + memberSummaryWriters[VisibleMemberMap.PROPERTIES]; + VisibleMemberMap visibleMemberMap = + visibleMemberMaps[VisibleMemberMap.PROPERTIES]; + addSummary(writer, visibleMemberMap, true, memberSummaryTree); + } + + /** * Build the summary for the nested classes. * * @param node the XML element that specifies which components to document @@ -306,6 +318,11 @@ Content tableTree = writer.getSummaryTableTree(classDoc); for (int i = 0; i < members.size(); i++) { ProgramElementDoc member = members.get(i); + final ProgramElementDoc propertyDoc = + visibleMemberMap.getPropertyMemberDoc(member); + if (propertyDoc != null) { + processProperty(visibleMemberMap, member, propertyDoc); + } Tag[] firstSentenceTags = member.firstSentenceTags(); if (member instanceof MethodDoc && firstSentenceTags.length == 0) { //Inherit comments from overriden or implemented method if @@ -324,6 +341,106 @@ } /** + * Process the property method, property setter and/or property getter + * comment text so that it contains the documentation from + * the property field. The method adds the leading sentence, + * copied documentation including the defaultValue tag and + * the see tags if the appropriate property getter and setter are + * available. + * + * @param visibleMemberMap the members information. + * @param member the member which is to be augmented. + * @param propertyDoc the original property documentation. + */ + private void processProperty(VisibleMemberMap visibleMemberMap, + ProgramElementDoc member, + ProgramElementDoc propertyDoc) { + StringBuilder commentTextBuilder = new StringBuilder(); + final boolean isSetter = isSetter(member); + final boolean isGetter = isGetter(member); + if (isGetter || isSetter) { + //add "[GS]ets the value of the property PROPERTY_NAME." + if (isSetter) { + commentTextBuilder.append( + MessageFormat.format( + Util.RESOURCE_BUNDLE.getString("doclet.PropertySetterWithName"), + Util.propertyNameFromMethodName(member.name()))); + } + if (isGetter) { + commentTextBuilder.append( + MessageFormat.format( + Util.RESOURCE_BUNDLE.getString("doclet.PropertyGetterWithName"), + Util.propertyNameFromMethodName(member.name()))); + } + if (propertyDoc.commentText() != null + && !propertyDoc.commentText().isEmpty()) { + commentTextBuilder.append(" \n @propertyDescription "); + } + } + commentTextBuilder.append(propertyDoc.commentText()); + + Tag[] tags = propertyDoc.tags("@defaultValue"); + if (tags != null) { + for (Tag tag: tags) { + commentTextBuilder.append("\n") + .append(tag.name()) + .append(" ") + .append(tag.text()); + } + } + + //add @see tags + if (!isGetter && !isSetter) { + MethodDoc getter = (MethodDoc) visibleMemberMap.getGetterForProperty(member); + MethodDoc setter = (MethodDoc) visibleMemberMap.getSetterForProperty(member); + + if ((null != getter) + && (commentTextBuilder.indexOf("@see #" + getter.name()) == -1)) { + commentTextBuilder.append("\n @see #") + .append(getter.name()) + .append("() "); + } + + if ((null != setter) + && (commentTextBuilder.indexOf("@see #" + setter.name()) == -1)) { + String typeName = setter.parameters()[0].typeName(); + // Removal of type parameters and package information. + typeName = typeName.split("<")[0]; + if (typeName.contains(".")) { + typeName = typeName.substring(typeName.lastIndexOf(".") + 1); + } + commentTextBuilder.append("\n @see #").append(setter.name()); + + if (setter.parameters()[0].type().asTypeVariable() == null) { + commentTextBuilder.append("(").append(typeName).append(")"); + } + commentTextBuilder.append(" \n"); + } + } + member.setRawCommentText(commentTextBuilder.toString()); + } + /** + * Test whether the method is a getter. + * @param ped property method documentation. Needs to be either property + * method, property getter, or property setter. + * @return true if the given documentation belongs to a getter. + */ + private boolean isGetter(ProgramElementDoc ped) { + final String pedName = ped.name(); + return pedName.startsWith("get") || pedName.startsWith("is"); + } + + /** + * Test whether the method is a setter. + * @param ped property method documentation. Needs to be either property + * method, property getter, or property setter. + * @return true if the given documentation belongs to a setter. + */ + private boolean isSetter(ProgramElementDoc ped) { + return ped.name().startsWith("set"); + } + + /** * Build the inherited member summary for the given methods. * * @param writer the writer for this member summary.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -25,10 +25,13 @@ package com.sun.tools.doclets.internal.toolkit.builders; -import java.io.*; import com.sun.javadoc.*; +import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; -import com.sun.tools.doclets.internal.toolkit.*; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; /** * Builds the summary for a given package. @@ -173,6 +176,7 @@ ? packageDoc.interfaces() : configuration.classDocCatalog.interfaces( Util.getPackageName(packageDoc)); + interfaces = filterOutPrivateClasses(interfaces); if (interfaces.length > 0) { packageWriter.addClassesSummary( interfaces, @@ -202,6 +206,7 @@ ? packageDoc.ordinaryClasses() : configuration.classDocCatalog.ordinaryClasses( Util.getPackageName(packageDoc)); + classes = filterOutPrivateClasses(classes); if (classes.length > 0) { packageWriter.addClassesSummary( classes, @@ -231,6 +236,7 @@ ? packageDoc.enums() : configuration.classDocCatalog.enums( Util.getPackageName(packageDoc)); + enums = filterOutPrivateClasses(enums); if (enums.length > 0) { packageWriter.addClassesSummary( enums, @@ -260,6 +266,7 @@ ? packageDoc.exceptions() : configuration.classDocCatalog.exceptions( Util.getPackageName(packageDoc)); + exceptions = filterOutPrivateClasses(exceptions); if (exceptions.length > 0) { packageWriter.addClassesSummary( exceptions, @@ -289,6 +296,7 @@ ? packageDoc.errors() : configuration.classDocCatalog.errors( Util.getPackageName(packageDoc)); + errors = filterOutPrivateClasses(errors); if (errors.length > 0) { packageWriter.addClassesSummary( errors, @@ -318,6 +326,7 @@ ? packageDoc.annotationTypes() : configuration.classDocCatalog.annotationTypes( Util.getPackageName(packageDoc)); + annotationTypes = filterOutPrivateClasses(annotationTypes); if (annotationTypes.length > 0) { packageWriter.addClassesSummary( annotationTypes, @@ -353,4 +362,25 @@ } packageWriter.addPackageTags(packageContentTree); } + + static public ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes) { + if (!Configuration.getJavafxJavadoc()) { + return classes; + } + final List<ClassDoc> filteredOutClasses = + new ArrayList<ClassDoc>(classes.length); + for (ClassDoc classDoc : classes) { + if (classDoc.isPrivate() || classDoc.isPackagePrivate()) { + continue; + } + Tag[] aspTags = classDoc.tags("treatAsPrivate"); + if (aspTags != null && aspTags.length > 0) { + continue; + } + filteredOutClasses.add(classDoc); + } + + return filteredOutClasses.toArray(new ClassDoc[0]); + } + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2003, 2012, 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 com.sun.tools.doclets.internal.toolkit.builders; + +import java.util.*; +import com.sun.tools.doclets.internal.toolkit.util.*; +import com.sun.tools.doclets.internal.toolkit.*; +import com.sun.javadoc.*; + +/** + * Builds documentation for a field. + * + * This code is not part of an API. + * It is implementation that is subject to change. + * Do not use it as an API + * + * @author Jamie Ho + * @author Bhavesh Patel (Modified) + * @since 1.5 + */ +public class PropertyBuilder extends AbstractMemberBuilder { + + /** + * The class whose fields are being documented. + */ + private ClassDoc classDoc; + + /** + * The visible fields for the given class. + */ + private VisibleMemberMap visibleMemberMap; + + /** + * The writer to output the field documentation. + */ + private PropertyWriter writer; + + /** + * The list of fields being documented. + */ + private List<ProgramElementDoc> fields; + + /** + * The index of the current field that is being documented at this point + * in time. + */ + private int currentFieldIndex; + + /** + * Construct a new FieldBuilder. + * + * @param configuration the current configuration of the + * doclet. + */ + private PropertyBuilder(Configuration configuration) { + super(configuration); + } + + /** + * Construct a new FieldBuilder. + * + * @param configuration the current configuration of the doclet. + * @param classDoc the class whoses members are being documented. + * @param writer the doclet specific writer. + */ + public static PropertyBuilder getInstance( + Configuration configuration, + ClassDoc classDoc, + PropertyWriter writer) { + PropertyBuilder builder = new PropertyBuilder(configuration); + builder.classDoc = classDoc; + builder.writer = writer; + builder.visibleMemberMap = + new VisibleMemberMap( + classDoc, + VisibleMemberMap.PROPERTIES, + configuration.nodeprecated); + builder.fields = new ArrayList<ProgramElementDoc>( + builder.visibleMemberMap.getMembersFor(classDoc)); + if (configuration.getMemberComparator() != null) { + Collections.sort( + builder.fields, + configuration.getMemberComparator()); + } + return builder; + } + + /** + * {@inheritDoc} + */ + public String getName() { + return "PropertyDetails"; + } + + /** + * Returns a list of fields 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. + * @return a list of fields that will be documented. + */ + public List<ProgramElementDoc> members(ClassDoc classDoc) { + return visibleMemberMap.getMembersFor(classDoc); + } + + /** + * 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; + } + + /** + * summaryOrder.size() + */ + public boolean hasMembersToDocument() { + return fields.size() > 0; + } + + /** + * Build the field documentation. + * + * @param node the XML element that specifies which components to document + * @param memberDetailsTree the content tree to which the documentation will be added + */ + public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) { + if (writer == null) { + return; + } + int size = fields.size(); + if (size > 0) { + Content fieldDetailsTree = writer.getFieldDetailsTreeHeader( + classDoc, memberDetailsTree); + for (currentFieldIndex = 0; currentFieldIndex < size; + currentFieldIndex++) { + Content fieldDocTree = writer.getFieldDocTreeHeader( + (MethodDoc) fields.get(currentFieldIndex), + fieldDetailsTree); + buildChildren(node, fieldDocTree); + fieldDetailsTree.addContent(writer.getFieldDoc( + fieldDocTree, (currentFieldIndex == size - 1))); + } + memberDetailsTree.addContent( + writer.getFieldDetails(fieldDetailsTree)); + } + } + + /** + * Build the signature. + * + * @param node the XML element that specifies which components to document + * @param fieldDocTree the content tree to which the documentation will be added + */ + public void buildSignature(XMLNode node, Content fieldDocTree) { + fieldDocTree.addContent( + writer.getSignature((MethodDoc) fields.get(currentFieldIndex))); + } + + /** + * Build the deprecation information. + * + * @param node the XML element that specifies which components to document + * @param fieldDocTree the content tree to which the documentation will be added + */ + public void buildDeprecationInfo(XMLNode node, Content fieldDocTree) { + writer.addDeprecated( + (MethodDoc) fields.get(currentFieldIndex), fieldDocTree); + } + + /** + * Build the comments for the field. Do nothing if + * {@link Configuration#nocomment} is set to true. + * + * @param node the XML element that specifies which components to document + * @param fieldDocTree the content tree to which the documentation will be added + */ + public void buildPropertyComments(XMLNode node, Content fieldDocTree) { + if (!configuration.nocomment) { + writer.addComments((MethodDoc) fields.get(currentFieldIndex), fieldDocTree); + } + } + + /** + * Build the tag information. + * + * @param node the XML element that specifies which components to document + * @param fieldDocTree the content tree to which the documentation will be added + */ + public void buildTagInfo(XMLNode node, Content fieldDocTree) { + writer.addTags((MethodDoc) fields.get(currentFieldIndex), fieldDocTree); + } + + /** + * Return the field writer for this builder. + * + * @return the field writer for this builder. + */ + public PropertyWriter getWriter() { + return writer; + } +}
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml Fri Jun 08 17:12:36 2012 +0100 @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='utf-8'?> <!-- - Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2003, 2012, 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 @@ -91,6 +91,7 @@ <ClassTagInfo/> </ClassInfo> <MemberSummary> + <PropertiesSummary/> <NestedClassesSummary/> <EnumConstantsSummary/> <FieldsSummary/> @@ -106,6 +107,12 @@ <TagInfo/> </EnumConstant> </EnumConstantsDetails> + <PropertyDetails> + <PropertyDoc> + <PropertyComments/> + <TagInfo/> + </PropertyDoc> + </PropertyDetails> <FieldDetails> <FieldDoc> <Signature/>
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties Fri Jun 08 17:12:36 2012 +0100 @@ -6,6 +6,7 @@ doclet.Serialized_Form=Serialized Form doclet.Serialized_Form_methods=Serialization Methods doclet.Serialized_Form_fields=Serialized Fields +doclet.Serialized_Form_properties=Serialized Properties doclet.Serialized_Form_class=Serialization Overview doclet.Class_0_implements_serializable=Class {0} implements Serializable doclet.Class_0_extends_implements_serializable=Class {0} extends {1} implements Serializable @@ -39,6 +40,12 @@ doclet.Error_taglet_not_registered=Error - Exception {0} thrown while trying to register Taglet {1}... doclet.Error_invalid_custom_tag_argument=Error - {0} is an invalid argument to the -tag option... doclet.Author=Author: +doclet.DefaultValue=Default value: +doclet.PropertyDescription=Property description: +doclet.PropertyGetter=Gets the value of the property +doclet.PropertySetter=Sets the value of the property +doclet.PropertyGetterWithName=Gets the value of the property {0}. +doclet.PropertySetterWithName=Sets the value of the property {0}. doclet.Default=Default: doclet.Parameters=Parameters: doclet.TypeParameters=Type Parameters: @@ -60,6 +67,7 @@ doclet.noInheritedDoc=@inheritDoc used but {0} does not override or implement any method. doclet.malformed_html_link_tag=<a> tag is malformed:\n"{0}" doclet.tag_misuse=Tag {0} cannot be used in {1} documentation. It can only be used in the following types of documentation: {2}. +doclet.javafx_tag_misuse=Tags @propertyGetter, @propertySetter and @propertyDescription can only be used in JavaFX properties getters and setters. doclet.Package_Summary=Package Summary doclet.Interface_Summary=Interface Summary doclet.Annotation_Types_Summary=Annotation Types Summary @@ -71,6 +79,7 @@ doclet.Annotation_Type_Optional_Member_Summary=Optional Element Summary doclet.Annotation_Type_Required_Member_Summary=Required Element Summary doclet.Field_Summary=Field Summary +doclet.Property_Summary=Property Summary doclet.Enum_Constant_Summary=Enum Constant Summary doclet.Constructor_Summary=Constructor Summary doclet.Method_Summary=Method Summary @@ -117,12 +126,15 @@ doclet.Methods_Inherited_From_Interface=Methods inherited from interface doclet.Fields_Inherited_From_Class=Fields inherited from class doclet.Fields_Inherited_From_Interface=Fields inherited from interface +doclet.Properties_Inherited_From_Class=Properties inherited from class +doclet.Properties_Inherited_From_Interface=Properties inherited from interface doclet.Serializable=Serializable doclet.Externalizable=Externalizable doclet.Annotation_Type_Member_Detail=Element Detail doclet.Enum_Constant_Detail=Enum Constant Detail doclet.Constants_Summary=Constant Field Values doclet.Field_Detail=Field Detail +doclet.Property_Detail=Property Detail doclet.Method_Detail=Method Detail doclet.Constructor_Detail=Constructor Detail doclet.Deprecated=Deprecated. @@ -137,6 +149,8 @@ doclet.Member_Table_Summary={0} table, listing {1}, and an explanation doclet.fields=fields doclet.Fields=Fields +doclet.properties=properties +doclet.Properties=Properties doclet.constructors=constructors doclet.Constructors=Constructors doclet.methods=methods @@ -154,6 +168,7 @@ doclet.Modifier=Modifier doclet.Type=Type doclet.Field=Field +doclet.Property=Property doclet.Constructor=Constructor doclet.Method=Method doclet.Annotation_Type_Optional_Member=Optional Element
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2001, 2012, 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 com.sun.tools.doclets.internal.toolkit.taglets; + +import com.sun.javadoc.Tag; + +/** + * An abstract class that implements the {@link Taglet} interface and + * serves as a base for JavaFX property getter and setter taglets. + * + * This code is not part of an API. + * It is implementation that is subject to change. + * Do not use it as an API + * + */ +public abstract class BasePropertyTaglet extends BaseTaglet { + + public BasePropertyTaglet() { + } + + /** + * This method returns the text to be put in the resulting javadoc before + * the property name. + * + * @param tagletWriter the taglet writer for output + * @return the string to be put in the resulting javadoc. + */ + abstract String getText(TagletWriter tagletWriter); + + /** + * Given the <code>Tag</code> representation of this custom + * tag, return its string representation, which is output + * to the generated page. + * @param tag the <code>Tag</code> representation of this custom tag. + * @param tagletWriter the taglet writer for output. + * @return the TagletOutput representation of this <code>Tag</code>. + */ + public TagletOutput getTagletOutput(Tag tag, TagletWriter tagletWriter) { + TagletOutput tagletOutput = tagletWriter.getOutputInstance(); + StringBuilder output = new StringBuilder("<P>"); + output.append(getText(tagletWriter)); + output.append(" <CODE>"); + output.append(tag.text()); + output.append("</CODE>.</P>"); + tagletOutput.setOutput(output.toString()); + return tagletOutput; + } + + /** + * Will return false because this tag may + * only appear in Methods. + * @return false since this is not a method. + */ + public boolean inConstructor() { + return false; + } + + /** + * Will return false because this tag may + * only appear in Methods. + * @return false since this is not a method. + */ + public boolean inOverview() { + return false; + } + + /** + * Will return false because this tag may + * only appear in Methods. + * @return false since this is not a method. + */ + public boolean inPackage() { + return false; + } + + /** + * Will return false because this tag may + * only appear in Methods. + * @return false since this is not a method. + */ + public boolean inType() { + return false; + } + + /** + * Will return false because this tag is not inline. + * @return false since this is not an inline tag. + */ + public boolean isInlineTag() { + return false; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2006, 2012 Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.sun.tools.doclets.internal.toolkit.taglets; + +import java.util.Map; +import com.sun.tools.doclets.Taglet; +import com.sun.javadoc.Tag; + +public class ExpertTaglet implements Taglet { + + private static final String NAME = "expert"; + private static final String START_TAG = "<sub id=\"expert\">"; + private static final String END_TAG = "</sub>"; + + public boolean inField() { + return true; + } + + public boolean inConstructor() { + return true; + } + + public boolean inMethod() { + return true; + } + + public boolean inOverview() { + return true; + } + + public boolean inPackage() { + return true; + } + + public boolean inType() { + return true; + } + + public boolean isInlineTag() { + return false; + } + + public String getName() { + return NAME; + } + + public static void register(Map<String, Taglet> map) { + map.remove(NAME); + map.put(NAME, new ExpertTaglet()); + } + + public String toString(Tag tag) { + return (tag.text() == null || tag.text().length() == 0) ? null : + START_TAG + LiteralTaglet.textToString(tag.text()) + END_TAG; + } + + + public String toString(Tag[] tags) { + if (tags == null || tags.length == 0) return null; + + StringBuffer sb = new StringBuffer(START_TAG); + + for(Tag t:tags) { + sb.append(LiteralTaglet.textToString(t.text())); + } + sb.append(END_TAG); + return sb.toString(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2001, 2012, 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 com.sun.tools.doclets.internal.toolkit.taglets; + +/** + * A taglet that adds the initial line of documentation to the JavaFX + * property getters. + * + * This code is not part of an API. + * It is implementation that is subject to change. + * Do not use it as an API + */ +public class PropertyGetterTaglet extends BasePropertyTaglet { + + /** + * Construct a new PropertyGetterTaglet. + */ + public PropertyGetterTaglet () { + name = "propertyGetter"; + } + + @Override + String getText(TagletWriter tagletWriter) { + return tagletWriter.configuration().getText("doclet.PropertyGetter"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2001, 2012, 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 com.sun.tools.doclets.internal.toolkit.taglets; + +import com.sun.javadoc.*; + +/** + * A taglet that adds the initial line of documentation to the JavaFX + * property setters. + * + * This code is not part of an API. + * It is implementation that is subject to change. + * Do not use it as an API + */ +public class PropertySetterTaglet extends BasePropertyTaglet { + + /** + * Construct a new PropertyGetterTaglet. + */ + public PropertySetterTaglet () { + name = "propertySetter"; + } + + @Override + String getText(TagletWriter tagletWriter) { + return tagletWriter.configuration().getText("doclet.PropertySetter"); + } +}
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2012, 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 @@ -663,7 +663,16 @@ customTags.put((temp = new SimpleTaglet("author", message.getText("doclet.Author"), SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW)).getName(), temp); } - customTags.put((temp = new SimpleTaglet("serialData", message.getText("doclet.SerialData"), + customTags.put((temp = new PropertyGetterTaglet()).getName(), temp); + customTags.put((temp = new PropertySetterTaglet()).getName(), temp); + customTags.put((temp = new SimpleTaglet("propertyDescription", + message.getText("doclet.PropertyDescription"), + SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp); + customTags.put((temp = new SimpleTaglet("defaultValue", + message.getText("doclet.DefaultValue"), + SimpleTaglet.FIELD + SimpleTaglet.METHOD)).getName(), temp); + customTags.put((temp = new SimpleTaglet("serialData", + message.getText("doclet.SerialData"), SimpleTaglet.EXCLUDED)).getName(), temp); customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"), SimpleTaglet.METHOD)).getName(), temp); @@ -676,6 +685,9 @@ temp); customTags.put((temp = new LegacyTaglet(new CodeTaglet())).getName(), temp); + customTags.put((temp = new SimpleTaglet("treatAsPrivate", null , + SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp); + customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp); //Keep track of the names of standard tags for error //checking purposes. @@ -686,6 +698,10 @@ standardTags.add("since"); standardTags.add("version"); standardTags.add("author"); + standardTags.add("propertyGetter"); + standardTags.add("propertySetter"); + standardTags.add("propertyDescription"); + standardTags.add("defaultValue"); standardTags.add("see"); standardTags.add("deprecated"); standardTags.add("link"); @@ -699,6 +715,8 @@ standardTags.add("Text"); standardTags.add("literal"); standardTags.add("code"); + standardTags.add("treatAsPrivate"); + standardTags.add("expert"); } /**
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -171,6 +171,7 @@ tagletManager.checkTags(doc, doc.inlineTags(), true); TagletOutput currentOutput = null; for (int i = 0; i < taglets.length; i++) { + currentOutput = null; if (doc instanceof ClassDoc && taglets[i] instanceof ParamTaglet) { //The type parameters are documented in a special section away //from the tag info, so skip here.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -130,6 +130,16 @@ Util.isDeprecated(classes[i].containingPackage()))) { continue; } + + if (classes[i].tags("treatAsPrivate").length > 0) { + continue; + } + + if (Configuration.getJavafxJavadoc() + && (classes[i].isPackagePrivate() || classes[i].isPrivate())) { + continue; + } + if (classes[i].isEnum()) { processType(classes[i], configuration, baseEnums, subEnums); } else if (classes[i].isClass()) {
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -207,6 +207,25 @@ * Should this doc element be added to the index map? */ protected boolean shouldAddToIndexMap(Doc element) { + if (Configuration.getJavafxJavadoc()) { + if (element.tags("treatAsPrivate").length > 0) { + return false; + } + if (element instanceof ProgramElementDoc) { + ProgramElementDoc elementCasted = (ProgramElementDoc) element; + if (elementCasted.isPackagePrivate() || elementCasted.isPrivate()) { + return false; + } + } + + if (element instanceof ClassDoc) { + ClassDoc elementCasted = (ClassDoc) element; + if (elementCasted.isPackagePrivate() || elementCasted.isPrivate()) { + return false; + } + } + } + if (element instanceof PackageDoc) // Do not add to index map if -nodeprecated option is set and the // package is marked as deprecated.
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, 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 @@ -56,6 +56,12 @@ public static final String RESOURCESDIR = "resources"; /** + * Resource bundle corresponding to the doclets.properties file. + */ + public static final ResourceBundle RESOURCE_BUNDLE = + ResourceBundle.getBundle(Configuration.DOCLETS_RESOURCE); + + /** * Return array of class members whose documentation is to be generated. * If the member is deprecated do not include such a member in the * returned array. @@ -878,4 +884,24 @@ } return false; } + + /** + * A convenience method to get property name from the name of the + * getter or setter method. + * @param name name of the getter or setter method. + * @return the name of the property of the given setter of getter. + */ + public static String propertyNameFromMethodName(String name) { + String propertyName = null; + if (name.startsWith("get") || name.startsWith("set")) { + propertyName = name.substring(3); + } else if (name.startsWith("is")) { + propertyName = name.substring(2); + } + if ((propertyName == null) || propertyName.isEmpty()){ + return ""; + } + return propertyName.substring(0, 1).toLowerCase() + + propertyName.substring(1); + } }
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java Fri Jun 08 17:12:36 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2012, 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 @@ -28,6 +28,7 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; import java.util.*; +import java.util.regex.Pattern; /** * A data structure that encapsulates the visible members of a particular @@ -54,11 +55,12 @@ public static final int METHODS = 4; public static final int ANNOTATION_TYPE_MEMBER_OPTIONAL = 5; public static final int ANNOTATION_TYPE_MEMBER_REQUIRED = 6; + public static final int PROPERTIES = 7; /** * The total number of member types is {@value}. */ - public static final int NUM_MEMBER_TYPES = 7; + public static final int NUM_MEMBER_TYPES = 8; public static final String STARTLEVEL = "start"; @@ -95,6 +97,13 @@ */ private final boolean nodepr; + private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache = + new HashMap<ClassDoc, ProgramElementDoc[]>(); + private static final Map<ProgramElementDoc, ProgramElementDoc> classPropertiesMap = + new HashMap<ProgramElementDoc, ProgramElementDoc>(); + private static final Map<ProgramElementDoc, GetterSetter> getterSetterMap = + new HashMap<ProgramElementDoc, GetterSetter>(); + /** * Construct a VisibleMemberMap of the given type for the given * class. If nodepr is true, exclude the deprecated members from @@ -122,6 +131,33 @@ } /** + * Returns the property field documentation belonging to the given member. + * @param ped the member for which the property documentation is needed. + * @return the property field documentation, null if there is none. + */ + public ProgramElementDoc getPropertyMemberDoc(ProgramElementDoc ped) { + return classPropertiesMap.get(ped); + } + + /** + * Returns the getter documentation belonging to the given property method. + * @param propertyMethod the method for which the getter is needed. + * @return the getter documentation, null if there is none. + */ + public ProgramElementDoc getGetterForProperty(ProgramElementDoc propertyMethod) { + return getterSetterMap.get(propertyMethod).getGetter(); + } + + /** + * Returns the setter documentation belonging to the given property method. + * @param propertyMethod the method for which the setter is needed. + * @return the setter documentation, null if there is none. + */ + public ProgramElementDoc getSetterForProperty(ProgramElementDoc propertyMethod) { + return getterSetterMap.get(propertyMethod).getSetter(); + } + + /** * Return the package private members inherited by the class. Only return * if parent is package private and not documented. * @@ -330,10 +366,11 @@ List<ProgramElementDoc> incllist = new ArrayList<ProgramElementDoc>(); for (int i = 0; i < cdmembers.size(); i++) { ProgramElementDoc pgmelem = cdmembers.get(i); - if (!found(members, pgmelem) && - memberIsVisible(pgmelem) && - !isOverridden(pgmelem, level)) { - incllist.add(pgmelem); + if (!found(members, pgmelem) + && memberIsVisible(pgmelem) + && !isOverridden(pgmelem, level) + && !isTreatedAsPrivate(pgmelem)) { + incllist.add(pgmelem); } } if (incllist.size() > 0) { @@ -343,6 +380,20 @@ fillMemberLevelMap(getClassMembers(fromClass, false), level); } + private boolean isTreatedAsPrivate(ProgramElementDoc pgmelem) { + if (!Configuration.getJavafxJavadoc()) { + return false; + } + + if (pgmelem.isPrivate() || pgmelem.isPackagePrivate()) { + return true; + } + + Tag[] aspTags = pgmelem.tags("@treatAsPrivate"); + boolean result = (aspTags != null) && (aspTags.length > 0); + return result; + } + /** * Is given doc item visible in given classdoc in terms fo inheritance? * The given doc item is visible in the given classdoc if it is public @@ -404,6 +455,10 @@ break; case METHODS: members = cd.methods(filter); + checkOnPropertiesTags((MethodDoc[])members); + break; + case PROPERTIES: + members = properties(cd, filter); break; default: members = new ProgramElementDoc[0]; @@ -470,6 +525,198 @@ } return false; } + + private ProgramElementDoc[] properties(final ClassDoc cd, final boolean filter) { + final MethodDoc[] allMethods = cd.methods(filter); + final FieldDoc[] allFields = cd.fields(); + + if (propertiesCache.containsKey(cd)) { + return propertiesCache.get(cd); + } + + final List<MethodDoc> result = new ArrayList<MethodDoc>(); + + for (final MethodDoc propertyMethod : allMethods) { + + if (!isPropertyMethod(propertyMethod)) { + continue; + } + + final MethodDoc getter = getterForField(allMethods, propertyMethod); + final MethodDoc setter = setterForField(allMethods, propertyMethod); + final FieldDoc field = fieldForProperty(allFields, propertyMethod); + + addToPropertiesMap(setter, getter, propertyMethod, field); + getterSetterMap.put(propertyMethod, new GetterSetter(getter, setter)); + result.add(propertyMethod); + } + final ProgramElementDoc[] resultAray = + result.toArray(new ProgramElementDoc[result.size()]); + propertiesCache.put(cd, resultAray); + return resultAray; + } + + private void addToPropertiesMap(MethodDoc setter, + MethodDoc getter, + MethodDoc propertyMethod, + FieldDoc field) { + if ((field == null) + || (field.getRawCommentText() == null) + || field.getRawCommentText().length() == 0) { + addToPropertiesMap(setter, propertyMethod); + addToPropertiesMap(getter, propertyMethod); + } else { + addToPropertiesMap(getter, field); + addToPropertiesMap(setter, field); + addToPropertiesMap(propertyMethod, field); + } + } + + private void addToPropertiesMap(ProgramElementDoc propertyMethod, + ProgramElementDoc commentSource) { + if (null == propertyMethod || null == commentSource) { + return; + } + final String methodRawCommentText = propertyMethod.getRawCommentText(); + if (null == methodRawCommentText || 0 == methodRawCommentText.length()) { + classPropertiesMap.put(propertyMethod, commentSource); + } + } + + private MethodDoc getterForField(MethodDoc[] methods, + MethodDoc propertyMethod) { + final String propertyMethodName = propertyMethod.name(); + final String fieldName = + propertyMethodName.substring(0, + propertyMethodName.lastIndexOf("Property")); + final String fieldNameUppercased = + "" + Character.toUpperCase(fieldName.charAt(0)) + + fieldName.substring(1); + final String getterName; + final String fieldTypeName = propertyMethod.returnType().toString(); + if ("boolean".equals(fieldTypeName) + || fieldTypeName.endsWith("BooleanProperty")) { + getterName = "is" + fieldNameUppercased; + } else { + getterName = "get" + fieldNameUppercased; + } + + for (MethodDoc methodDoc : methods) { + if (getterName.equals(methodDoc.name())) { + if (0 == methodDoc.parameters().length + && (methodDoc.isPublic() || methodDoc.isProtected())) { + return methodDoc; + } + } + } + return null; + } + + private MethodDoc setterForField(MethodDoc[] methods, + MethodDoc propertyMethod) { + final String propertyMethodName = propertyMethod.name(); + final String fieldName = + propertyMethodName.substring(0, + propertyMethodName.lastIndexOf("Property")); + final String fieldNameUppercased = + "" + Character.toUpperCase(fieldName.charAt(0)) + + fieldName.substring(1); + final String setter = "set" + fieldNameUppercased; + + for (MethodDoc methodDoc : methods) { + if (setter.equals(methodDoc.name())) { + if (1 == methodDoc.parameters().length + && "void".equals(methodDoc.returnType().simpleTypeName()) + && (methodDoc.isPublic() || methodDoc.isProtected())) { + return methodDoc; + } + } + } + return null; + } + + private FieldDoc fieldForProperty(FieldDoc[] fields, MethodDoc property) { + + for (FieldDoc field : fields) { + final String fieldName = field.name(); + final String propertyName = fieldName + "Property"; + if (propertyName.equals(property.name())) { + return field; + } + } + return null; + } + + // properties aren't named setA* or getA* + private final Pattern pattern = Pattern.compile("[sg]et\\p{Upper}.*"); + private boolean isPropertyMethod(MethodDoc method) { + if (!method.name().endsWith("Property")) { + return false; + } + + if (! memberIsVisible(method)) { + return false; + } + + if (pattern.matcher(method.name()).matches()) { + return false; + } + + return 0 == method.parameters().length + && !"void".equals(method.returnType().simpleTypeName()); + } + + private void checkOnPropertiesTags(MethodDoc[] members) { + for (MethodDoc methodDoc: members) { + for (Tag tag: methodDoc.tags()) { + String tagName = tag.name(); + if (tagName.equals("@propertySetter") + || tagName.equals("@propertyGetter") + || tagName.equals("@propertyDescription")) { + if (!isPropertyGetterOrSetter(members, methodDoc)) { + System.out.println(methodDoc.containingClass().qualifiedName() + + ": " + + Util.RESOURCE_BUNDLE.getString("doclet.javafx_tag_misuse")); + } + break; + } + } + } + } + + private boolean isPropertyGetterOrSetter(MethodDoc[] members, + MethodDoc methodDoc) { + boolean found = false; + String propertyName = Util.propertyNameFromMethodName(methodDoc.name()); + if (!propertyName.isEmpty()) { + String propertyMethodName = propertyName + "Property"; + for (MethodDoc member: members) { + if (member.name().equals(propertyMethodName)) { + found = true; + break; + } + } + } + return found; + } + } + + private class GetterSetter { + private final ProgramElementDoc getter; + private final ProgramElementDoc setter; + + public GetterSetter(ProgramElementDoc getter, ProgramElementDoc setter) { + this.getter = getter; + this.setter = setter; + } + + public ProgramElementDoc getGetter() { + return getter; + } + + public ProgramElementDoc getSetter() { + return setter; + } } /** @@ -478,7 +725,11 @@ * @return true if this map has no visible members. */ public boolean noVisibleMembers() { - return noVisibleMembers; + if (Configuration.getJavafxJavadoc()) { + return false; + } else { + return noVisibleMembers; + } } private ClassMember getClassMember(MethodDoc member) {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Jun 08 17:12:36 2012 +0100 @@ -1235,7 +1235,7 @@ // if origin is derived from a raw type, we might have missed // an implementation because we do not know enough about instantiations. // in this case continue with the supertype as origin. - if (types.isDerivedRaw(origin.type)) + if (types.isDerivedRaw(origin.type) && !origin.isInterface()) return implementation(types.supertype(origin.type).tsym, types, checkResult); else return null;
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jun 08 17:12:36 2012 +0100 @@ -522,16 +522,16 @@ * @param a The type that should be bounded by bs. * @param bs The bound. */ - private boolean checkExtends(Type a, TypeVar bs) { + private boolean checkExtends(Type a, Type bound) { if (a.isUnbound()) { return true; } else if (a.tag != WILDCARD) { a = types.upperBound(a); - return types.isSubtype(a, bs.bound); + return types.isSubtype(a, bound); } else if (a.isExtendsBound()) { - return types.isCastable(bs.getUpperBound(), types.upperBound(a), Warner.noWarnings); + return types.isCastable(bound, types.upperBound(a), Warner.noWarnings); } else if (a.isSuperBound()) { - return !types.notSoftSubtype(types.lowerBound(a), bs.getUpperBound()); + return !types.notSoftSubtype(types.lowerBound(a), bound); } return true; } @@ -773,18 +773,16 @@ List<Type> actuals = type.allparams(); List<Type> args = type.getTypeArguments(); List<Type> forms = type.tsym.type.getTypeArguments(); - ListBuffer<Type> tvars_buf = new ListBuffer<Type>(); + ListBuffer<Type> bounds_buf = new ListBuffer<Type>(); // For matching pairs of actual argument types `a' and // formal type parameters with declared bound `b' ... while (args.nonEmpty() && forms.nonEmpty()) { // exact type arguments needs to know their // bounds (for upper and lower bound - // calculations). So we create new TypeVars with - // bounds substed with actuals. - tvars_buf.append(types.substBound(((TypeVar)forms.head), - formals, - actuals)); + // calculations). So we create new bounds where + // type-parameters are replaced with actuals argument types. + bounds_buf.append(types.subst(forms.head.getUpperBound(), formals, actuals)); args = args.tail; forms = forms.tail; } @@ -801,32 +799,30 @@ } args = type.getTypeArguments(); - List<Type> tvars = tvars_buf.toList(); + List<Type> bounds = bounds_buf.toList(); - while (args.nonEmpty() && tvars.nonEmpty()) { - Type actual = types.subst(args.head, - type.tsym.type.getTypeArguments(), - tvars_buf.toList()); + while (args.nonEmpty() && bounds.nonEmpty()) { + Type actual = args.head; if (!isTypeArgErroneous(actual) && - !tvars.head.getUpperBound().isErroneous() && - !checkExtends(actual, (TypeVar)tvars.head)) { + !bounds.head.isErroneous() && + !checkExtends(actual, bounds.head)) { return args.head; } args = args.tail; - tvars = tvars.tail; + bounds = bounds.tail; } args = type.getTypeArguments(); - tvars = tvars_buf.toList(); + bounds = bounds_buf.toList(); for (Type arg : types.capture(type).getTypeArguments()) { if (arg.tag == TYPEVAR && arg.getUpperBound().isErroneous() && - !tvars.head.getUpperBound().isErroneous() && + !bounds.head.isErroneous() && !isTypeArgErroneous(args.head)) { return args.head; } - tvars = tvars.tail; + bounds = bounds.tail; args = args.tail; }
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jun 08 17:12:36 2012 +0100 @@ -1807,9 +1807,10 @@ * ResolveError classes, indicating error situations when accessing symbols ****************************************************************************/ - public void logAccessError(Env<AttrContext> env, JCTree tree, Type type) { - AccessError error = new AccessError(env, type.getEnclosingType(), type.tsym); - logResolveError(error, tree.pos(), type.getEnclosingType().tsym, type.getEnclosingType(), null, null, null); + //used by TransTypes when checking target type of synthetic cast + public void logAccessErrorInternal(Env<AttrContext> env, JCTree tree, Type type) { + AccessError error = new AccessError(env, env.enclClass.type, type.tsym); + logResolveError(error, tree.pos(), env.enclClass.sym, env.enclClass.type, null, null, null); } //where private void logResolveError(ResolveError error,
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed May 23 20:37:49 2012 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Jun 08 17:12:36 2012 +0100 @@ -107,7 +107,7 @@ make.at(tree.pos); if (!types.isSameType(tree.type, target)) { if (!resolve.isAccessible(env, target.tsym)) - resolve.logAccessError(env, tree, target); + resolve.logAccessErrorInternal(env, tree, target); tree = make.TypeCast(make.Type(target), tree).setType(target); } make.pos = oldpos;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testJavaFX/C.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, 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. + */ + +/** + * @expert Expert tag text + */ + +public class C { + + /** + * @propertySetter Property + * @propertyDescription PropertyDescription + */ + public void CC() {} + + /** + * @propertyGetter Property + * @expert Expert tag text + * + */ + public void B() {} + + /** + * Method A documentation + * @treatAsPrivate + */ + public void A() {} + + /** + * Field i + * @defaultValue 1.0 + */ + public int i; + + + /** + * Defines the direction/speed at which the {@code Timeline} is expected to + * be played. + * @defaultValue 11 + */ + private DoubleProperty rate; + + public final void setRate(double value) {} + + public final double getRate() {} + + public final DoubleProperty rateProperty() {} + + private BooleanProperty paused; + + public final void setPaused(boolean value) {} + + public final double isPaused() {} + + /** + * Defines if paused + * @defaultValue false + */ + public final BooleanProperty pausedProperty() {} + + class DoubleProperty {} + + class BooleanProperty {} + + public final BooleanProperty setTestMethodProperty() {} + + private class Inner { + private BooleanProperty testMethodProperty() {} + + /** + * Defines the direction/speed at which the {@code Timeline} is expected to + * be played. + * @defaultValue 11 + */ + private DoubleProperty rate; + + public final void setRate(double value) {} + + public final double getRate() {} + + public final DoubleProperty rateProperty() {} + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testJavaFX/D.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2012, 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. + */ + +/** + * @expert Expert tag text + */ + +public class D extends C {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/com/sun/javadoc/testJavaFX/TestJavaFX.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2012, 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. + */ + +/* + * @test + * @bug 7112427 + * @summary Test of the JavaFX doclet features. + * @author jvalenta + * @library ../lib/ + * @build JavadocTester TestJavaFX + * @run main TestJavaFX + */ + +public class TestJavaFX extends JavadocTester { + + private static final String BUG_ID = "7112427"; + + private static final String[][] TEST = + new String[][] { + {"./" + BUG_ID + "/C.html", + "<dt><span class=\"strong\">See Also:</span></dt><dd><a href=\"C.html#getRate()\"><code>getRate()</code></a>, " + NL + + "<a href=\"C.html#setRate(double)\"><code>setRate(double)</code></a></dd>"}, + {"./" + BUG_ID + "/C.html", + "<pre>public final void setRate(double value)</pre>" + NL + + "<div class=\"block\">Sets the value of the property rate.</div>" + NL + + "<dl><dt><span class=\"strong\">Property description:</span></dt>" }, + {"./" + BUG_ID + "/C.html", + "<pre>public final double getRate()</pre>" + NL + + "<div class=\"block\">Gets the value of the property rate.</div>" + NL + + "<dl><dt><span class=\"strong\">Property description:</span></dt>" }, + {"./" + BUG_ID + "/C.html", + "<td class=\"colLast\"><code><strong><a href=\"C.html#rateProperty\">rate</a></strong></code>" + NL + + "<div class=\"block\">Defines the direction/speed at which the <code>Timeline</code> is expected to"}, + {"./" + BUG_ID + "/C.html", + "<sub id=\"expert\">Expert tag text</sub>"}, + {"./" + BUG_ID + "/C.html", + "<span class=\"strong\">Default value:</span>"}, + {"./" + BUG_ID + "/C.html", + "<P>Sets the value of the property <CODE>Property</CODE>"}, + {"./" + BUG_ID + "/C.html", + "<P>Gets the value of the property <CODE>Property</CODE>"}, + {"./" + BUG_ID + "/C.html", + "<span class=\"strong\">Property description:</span>"}, + {"./" + BUG_ID + "/C.html", + "<td class=\"colLast\"><code><strong><a href=\"C.html#setTestMethodProperty()\">setTestMethodProperty</a></strong>()</code> </td>" }, + {"./" + BUG_ID + "/C.html", + "<h4>isPaused</h4>" + NL + + "<pre>public final double isPaused()</pre>" + NL + + "<div class=\"block\">Gets the value of the property paused.</div>" }, + {"./" + BUG_ID + "/D.html", + "<h3>Properties inherited from class <a href=\"C.html\" title=\"class in <Unnamed>\">C</a></h3>" + NL + + "<code><a href=\"C.html#pausedProperty\">paused</a>, <a href=\"C.html#rateProperty\">rate</a></code></li>" }, + }; + private static final String[][] NO_TEST = + new String[][] { + {"./" + BUG_ID + "/C.html", + "A()"}, + }; + + + private static final String[] ARGS = new String[] { + "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", + SRC_DIR + FS + "C.java", SRC_DIR + FS + "D.java" + }; + + /** + * The entry point of the test. + * @param args the array of command line arguments. + */ + public static void main(String[] args) { + System.setProperty("javafx.javadoc", "true"); + TestJavaFX tester = new TestJavaFX(); + run(tester, ARGS, TEST, NO_TEST); + tester.printSummary(); + } + + /** + * {@inheritDoc} + */ + public String getBugId() { + return BUG_ID; + } + + /** + * {@inheritDoc} + */ + public String getBugName() { + return getClass().getName(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151070/T7151070.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,25 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7151070 + * @summary NullPointerException in Resolve.isAccessible + * @compile/fail/ref=T7151070.out -XDrawDiagnostics T7151070.java + */ + +class T7151070a { + private static class PrivateCls { } + public static class PublicCls extends PrivateCls { } + + public void m(PrivateCls p) { } +} + +class T7151070b { + public void test(Test<T7151070a.PublicCls> obj, T7151070a outer) { + outer.m(obj.get()); + } + + public static class Test<T> { + public T get() { + return null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/7151070/T7151070.out Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,2 @@ +T7151070.java:17:24: compiler.err.report.access: T7151070a.PrivateCls, private, T7151070a +1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/rawOverride/T7148556.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, 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. + */ + +/* + * @test + * @bug 7148556 + * @summary Implementing a generic interface causes a public clone() to become inaccessible + * @compile T7148556.java + */ + +class T7148556 { + + interface A extends Cloneable { + public Object clone(); + } + + interface B extends A, java.util.List { } + + void test(B b) { + b.clone(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/generics/typevars/T7148242.java Fri Jun 08 17:12:36 2012 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2009, 2012, 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. + */ + +/* + * @test + * @bug 7148242 + * @summary Regression: valid code rejected during generic type well-formedness check + * @compile T7148242.java + */ +class T7148242 { + static abstract class A<K, V, I extends Pair<K, V>, I2 extends Pair<V, K>> { + abstract A<V, K, I2, I> test(); + } + static class Pair<K, V> { } +}