langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
changeset 15385 ee1eebe7e210
parent 15035 d03c311f44e6
child 15725 e0516b913894
equal deleted inserted replaced
15384:5a8d00abf076 15385:ee1eebe7e210
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1728     public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
  1728     public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
  1729         addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
  1729         addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
  1730     }
  1730     }
  1731 
  1731 
  1732     /**
  1732     /**
       
  1733      * Add the annotation types of the executable receiver.
       
  1734      *
       
  1735      * @param method the executable to write the receiver annotations for.
       
  1736      * @param htmltree the documentation tree to which the annotation info will be
       
  1737      *        added
       
  1738      */
       
  1739     public void addReceiverAnnotationInfo(ExecutableMemberDoc method, Content htmltree) {
       
  1740         addAnnotationInfo(method, method.receiverAnnotations(), htmltree);
       
  1741     }
       
  1742 
       
  1743     /**
  1733      * Adds the annotatation types for the given doc.
  1744      * Adds the annotatation types for the given doc.
  1734      *
  1745      *
  1735      * @param doc the package to write annotations for
  1746      * @param doc the package to write annotations for
  1736      * @param htmltree the content tree to which the annotation types will be added
  1747      * @param htmltree the content tree to which the annotation types will be added
  1737      */
  1748      */
  1797      * @param linkBreak if true, add new line between each member value.
  1808      * @param linkBreak if true, add new line between each member value.
  1798      * @return an array of strings representing the annotations being
  1809      * @return an array of strings representing the annotations being
  1799      *         documented.
  1810      *         documented.
  1800      */
  1811      */
  1801     private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
  1812     private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
       
  1813         return getAnnotations(indent, descList, linkBreak, true);
       
  1814     }
       
  1815 
       
  1816     /**
       
  1817      * Return the string representations of the annotation types for
       
  1818      * the given doc.
       
  1819      *
       
  1820      * A {@code null} {@code elementType} indicates that all the
       
  1821      * annotations should be returned without any filtering.
       
  1822      *
       
  1823      * @param indent the number of extra spaces to indent the annotations.
       
  1824      * @param descList the array of {@link AnnotationDesc}.
       
  1825      * @param linkBreak if true, add new line between each member value.
       
  1826      * @param elementType the type of targeted element (used for filtering
       
  1827      *        type annotations from declaration annotations)
       
  1828      * @return an array of strings representing the annotations being
       
  1829      *         documented.
       
  1830      */
       
  1831     public List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
       
  1832             boolean isJava5DeclarationLocation) {
  1802         List<String> results = new ArrayList<String>();
  1833         List<String> results = new ArrayList<String>();
  1803         StringBuilder annotation;
  1834         StringBuilder annotation;
  1804         for (int i = 0; i < descList.length; i++) {
  1835         for (int i = 0; i < descList.length; i++) {
  1805             AnnotationTypeDoc annotationDoc = descList[i].annotationType();
  1836             AnnotationTypeDoc annotationDoc = descList[i].annotationType();
  1806             // If an annotation is not documented, do not add it to the list. If
  1837             // If an annotation is not documented, do not add it to the list. If
  1810             // but its container is documented, it will be added to the list.
  1841             // but its container is documented, it will be added to the list.
  1811             if (! Util.isDocumentedAnnotation(annotationDoc) &&
  1842             if (! Util.isDocumentedAnnotation(annotationDoc) &&
  1812                     (!isAnnotationDocumented && !isContainerDocumented)) {
  1843                     (!isAnnotationDocumented && !isContainerDocumented)) {
  1813                 continue;
  1844                 continue;
  1814             }
  1845             }
       
  1846             /* TODO: check logic here to correctly handle declaration
       
  1847              * and type annotations.
       
  1848             if  (Util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) {
       
  1849                 continue;
       
  1850             }*/
  1815             annotation = new StringBuilder();
  1851             annotation = new StringBuilder();
  1816             isAnnotationDocumented = false;
  1852             isAnnotationDocumented = false;
  1817             LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
  1853             LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
  1818                 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
  1854                 LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
  1819             AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
  1855             AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();