src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeFieldWriterImpl.java

Wed, 18 Sep 2013 17:13:26 -0700

author
bpatel
date
Wed, 18 Sep 2013 17:13:26 -0700
changeset 2035
a2a5ad0853ed
child 2101
933ba3f81a87
permissions
-rw-r--r--

8015249: javadoc fails to document static final fields in annotation types
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    30 import com.sun.javadoc.*;
    31 import com.sun.tools.doclets.formats.html.markup.*;
    32 import com.sun.tools.doclets.internal.toolkit.*;
    34 /**
    35  * Writes annotation type field documentation in HTML format.
    36  *
    37  *  <p><b>This is NOT part of any supported API.
    38  *  If you write code that depends on this, you do so at your own risk.
    39  *  This code and its internal interfaces are subject to change or
    40  *  deletion without notice.</b>
    41  *
    42  * @author Bhavesh Patel
    43  */
    44 public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter
    45     implements AnnotationTypeFieldWriter, MemberSummaryWriter {
    47     /**
    48      * Construct a new AnnotationTypeFieldWriterImpl.
    49      *
    50      * @param writer         the writer that will write the output.
    51      * @param annotationType the AnnotationType that holds this member.
    52      */
    53     public AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer,
    54             AnnotationTypeDoc annotationType) {
    55         super(writer, annotationType);
    56     }
    58     /**
    59      * {@inheritDoc}
    60      */
    61     public Content getMemberSummaryHeader(ClassDoc classDoc,
    62             Content memberSummaryTree) {
    63         memberSummaryTree.addContent(
    64                 HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
    65         Content memberTree = writer.getMemberTreeHeader();
    66         writer.addSummaryHeader(this, classDoc, memberTree);
    67         return memberTree;
    68     }
    70     /**
    71      * {@inheritDoc}
    72      */
    73     public Content getMemberTreeHeader() {
    74         return writer.getMemberTreeHeader();
    75     }
    77     /**
    78      * {@inheritDoc}
    79      */
    80     public void addAnnotationFieldDetailsMarker(Content memberDetails) {
    81         memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_FIELD_DETAILS);
    82     }
    84     /**
    85      * {@inheritDoc}
    86      */
    87     public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
    88             Content memberDetailsTree) {
    89         if (!writer.printedAnnotationFieldHeading) {
    90             memberDetailsTree.addContent(writer.getMarkerAnchor(
    91                     "annotation_type_field_detail"));
    92             Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
    93                     writer.fieldDetailsLabel);
    94             memberDetailsTree.addContent(heading);
    95             writer.printedAnnotationFieldHeading = true;
    96         }
    97     }
    99     /**
   100      * {@inheritDoc}
   101      */
   102     public Content getAnnotationDocTreeHeader(MemberDoc member,
   103             Content annotationDetailsTree) {
   104         annotationDetailsTree.addContent(
   105                 writer.getMarkerAnchor(member.name()));
   106         Content annotationDocTree = writer.getMemberTreeHeader();
   107         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
   108         heading.addContent(member.name());
   109         annotationDocTree.addContent(heading);
   110         return annotationDocTree;
   111     }
   113     /**
   114      * {@inheritDoc}
   115      */
   116     public Content getSignature(MemberDoc member) {
   117         Content pre = new HtmlTree(HtmlTag.PRE);
   118         writer.addAnnotationInfo(member, pre);
   119         addModifiers(member, pre);
   120         Content link =
   121                 writer.getLink(new LinkInfoImpl(configuration,
   122                         LinkInfoImpl.Kind.MEMBER, getType(member)));
   123         pre.addContent(link);
   124         pre.addContent(writer.getSpace());
   125         if (configuration.linksource) {
   126             Content memberName = new StringContent(member.name());
   127             writer.addSrcLink(member, memberName, pre);
   128         } else {
   129             addName(member.name(), pre);
   130         }
   131         return pre;
   132     }
   134     /**
   135      * {@inheritDoc}
   136      */
   137     public void addDeprecated(MemberDoc member, Content annotationDocTree) {
   138         addDeprecatedInfo(member, annotationDocTree);
   139     }
   141     /**
   142      * {@inheritDoc}
   143      */
   144     public void addComments(MemberDoc member, Content annotationDocTree) {
   145         addComment(member, annotationDocTree);
   146     }
   148     /**
   149      * {@inheritDoc}
   150      */
   151     public void addTags(MemberDoc member, Content annotationDocTree) {
   152         writer.addTagsInfo(member, annotationDocTree);
   153     }
   155     /**
   156      * {@inheritDoc}
   157      */
   158     public Content getAnnotationDetails(Content annotationDetailsTree) {
   159         return getMemberTree(annotationDetailsTree);
   160     }
   162     /**
   163      * {@inheritDoc}
   164      */
   165     public Content getAnnotationDoc(Content annotationDocTree,
   166             boolean isLastContent) {
   167         return getMemberTree(annotationDocTree, isLastContent);
   168     }
   170     /**
   171      * Close the writer.
   172      */
   173     public void close() throws IOException {
   174         writer.close();
   175     }
   177     /**
   178      * {@inheritDoc}
   179      */
   180     public void addSummaryLabel(Content memberTree) {
   181         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
   182                 writer.getResource("doclet.Field_Summary"));
   183         memberTree.addContent(label);
   184     }
   186     /**
   187      * {@inheritDoc}
   188      */
   189     public String getTableSummary() {
   190         return configuration.getText("doclet.Member_Table_Summary",
   191                 configuration.getText("doclet.Field_Summary"),
   192                 configuration.getText("doclet.fields"));
   193     }
   195     /**
   196      * {@inheritDoc}
   197      */
   198     public Content getCaption() {
   199         return configuration.getResource("doclet.Fields");
   200     }
   202     /**
   203      * {@inheritDoc}
   204      */
   205     public String[] getSummaryTableHeader(ProgramElementDoc member) {
   206         String[] header = new String[] {
   207             writer.getModifierTypeHeader(),
   208             configuration.getText("doclet.0_and_1",
   209                     configuration.getText("doclet.Fields"),
   210                     configuration.getText("doclet.Description"))
   211         };
   212         return header;
   213     }
   215     /**
   216      * {@inheritDoc}
   217      */
   218     public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
   219         memberTree.addContent(writer.getMarkerAnchor(
   220                 "annotation_type_field_summary"));
   221     }
   223     /**
   224      * {@inheritDoc}
   225      */
   226     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
   227     }
   229     /**
   230      * {@inheritDoc}
   231      */
   232     public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
   233     }
   235     /**
   236      * {@inheritDoc}
   237      */
   238     protected void addSummaryLink(LinkInfoImpl.Kind context, ClassDoc cd, ProgramElementDoc member,
   239             Content tdSummary) {
   240         Content strong = HtmlTree.SPAN(HtmlStyle.strong,
   241                 writer.getDocLink(context, (MemberDoc) member, member.name(), false));
   242         Content code = HtmlTree.CODE(strong);
   243         tdSummary.addContent(code);
   244     }
   246     /**
   247      * {@inheritDoc}
   248      */
   249     protected void addInheritedSummaryLink(ClassDoc cd,
   250             ProgramElementDoc member, Content linksTree) {
   251         //Not applicable.
   252     }
   254     /**
   255      * {@inheritDoc}
   256      */
   257     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
   258         MemberDoc m = (MemberDoc)member;
   259         addModifierAndType(m, getType(m), tdSummaryType);
   260     }
   262     /**
   263      * {@inheritDoc}
   264      */
   265     protected Content getDeprecatedLink(ProgramElementDoc member) {
   266         return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
   267                 (MemberDoc) member, ((MemberDoc)member).qualifiedName());
   268     }
   270     /**
   271      * {@inheritDoc}
   272      */
   273     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
   274         if (link) {
   275             return writer.getHyperLink("annotation_type_field_summary",
   276                     writer.getResource("doclet.navField"));
   277         } else {
   278             return writer.getResource("doclet.navField");
   279         }
   280     }
   282     /**
   283      * {@inheritDoc}
   284      */
   285     protected void addNavDetailLink(boolean link, Content liNav) {
   286         if (link) {
   287             liNav.addContent(writer.getHyperLink("annotation_type_field_detail",
   288                     writer.getResource("doclet.navField")));
   289         } else {
   290             liNav.addContent(writer.getResource("doclet.navField"));
   291         }
   292     }
   294     private Type getType(MemberDoc member) {
   295         if (member instanceof FieldDoc) {
   296             return ((FieldDoc) member).type();
   297         } else {
   298             return ((MethodDoc) member).returnType();
   299         }
   300     }
   301 }

mercurial