< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java

Print this page




  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  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.util.SortedSet;
  29 import java.util.TreeSet;
  30 
  31 import javax.lang.model.element.Element;
  32 import javax.lang.model.element.ExecutableElement;
  33 import javax.lang.model.element.TypeElement;
  34 import javax.lang.model.type.TypeMirror;
  35 
  36 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  41 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  42 import jdk.javadoc.internal.doclets.formats.html.markup.Table;
  43 import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
  44 import jdk.javadoc.internal.doclets.toolkit.Content;
  45 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
  46 import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
  47 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  48 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
  49 
  50 /**
  51  * Writes method documentation in HTML format.
  52  *
  53  *  <p><b>This is NOT part of any supported API.
  54  *  If you write code that depends on this, you do so at your own risk.
  55  *  This code and its internal interfaces are subject to change or
  56  *  deletion without notice.</b>
  57  *
  58  * @author Robert Field
  59  * @author Atul M Dambalkar


 123         String erasureAnchor;
 124         Content methodDocTree = new ContentBuilder();
 125         Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
 126         heading.add(name(method));
 127         methodDocTree.add(heading);
 128         if ((erasureAnchor = getErasureAnchor(method)) != null) {
 129             methodDocTree.add(links.createAnchor((erasureAnchor)));
 130         }
 131         methodDocTree.add(links.createAnchor(writer.getAnchor(method)));
 132         return HtmlTree.SECTION(HtmlStyle.detail, methodDocTree);
 133     }
 134 
 135     /**
 136      * Get the signature for the given method.
 137      *
 138      * @param method the method being documented.
 139      * @return a content object for the signature
 140      */
 141     @Override
 142     public Content getSignature(ExecutableElement method) {
 143         HtmlTree pre = new HtmlTree(HtmlTag.PRE);
 144         pre.setStyle(HtmlStyle.methodSignature);
 145         writer.addAnnotationInfo(method, pre);
 146         int annotationLength = pre.charCount();
 147         addModifiers(method, pre);
 148         addTypeParameters(method, pre);
 149         addReturnType(method, pre);
 150         if (configuration.linksource) {
 151             Content methodName = new StringContent(name(method));
 152             writer.addSrcLink(method, methodName, pre);
 153         } else {
 154             addName(name(method), pre);
 155         }
 156         int indent = pre.charCount() - annotationLength;
 157         addParameters(method, pre, indent);
 158         addExceptions(method, pre, indent);
 159         return pre;
 160     }
 161 
 162     /**
 163      * {@inheritDoc}
 164      */
 165     @Override
 166     public void addDeprecated(ExecutableElement method, Content methodDocTree) {
 167         addDeprecatedInfo(method, methodDocTree);
 168     }
 169 
 170     /**
 171      * {@inheritDoc}
 172      */
 173     @Override
 174     public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
 175         TypeElement holder = utils.asTypeElement(holderType);
 176         if (!utils.getFullBody(method).isEmpty()) {
 177             if (holder.equals(typeElement) ||
 178                     !(utils.isPublic(holder) ||
 179                     utils.isLinkable(holder))) {


 382             intfac = utils.getDeclaredType(utils.getEnclosingTypeElement(method), intfac);
 383             Content intfaclink = writer.getLink(new LinkInfoImpl(
 384                     writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
 385             Content codeIntfacLink = HtmlTree.CODE(intfaclink);
 386             Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, contents.specifiedByLabel));
 387             dl.add(dt);
 388             Content methlink = writer.getDocLink(
 389                     LinkInfoImpl.Kind.MEMBER, implementedMeth,
 390                     implementedMeth.getSimpleName(), false);
 391             Content codeMethLink = HtmlTree.CODE(methlink);
 392             Content dd = HtmlTree.DD(codeMethLink);
 393             dd.add(Entity.NO_BREAK_SPACE);
 394             dd.add(contents.inInterface);
 395             dd.add(Entity.NO_BREAK_SPACE);
 396             dd.add(codeIntfacLink);
 397             dl.add(dd);
 398         }
 399     }
 400 
 401     /**
 402      * Add the return type.
 403      *
 404      * @param method the method being documented.
 405      * @param htmltree the content tree to which the return type will be added
 406      */
 407     protected void addReturnType(ExecutableElement method, Content htmltree) {
 408         TypeMirror type = utils.getReturnType(method);
 409         if (type != null) {
 410             Content linkContent = writer.getLink(
 411                     new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
 412             htmltree.add(linkContent);
 413             htmltree.add(Entity.NO_BREAK_SPACE);
 414         }

 415     }
 416 
 417     @Override
 418     public Content getMemberTreeHeader(){
 419         return writer.getMemberTreeHeader();
 420     }
 421 }


  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  */
  25 
  26 package jdk.javadoc.internal.doclets.formats.html;
  27 
  28 import java.util.SortedSet;
  29 import java.util.TreeSet;
  30 
  31 import javax.lang.model.element.Element;
  32 import javax.lang.model.element.ExecutableElement;
  33 import javax.lang.model.element.TypeElement;
  34 import javax.lang.model.type.TypeMirror;
  35 
  36 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.Entity;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;

  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  41 import jdk.javadoc.internal.doclets.formats.html.markup.Table;
  42 import jdk.javadoc.internal.doclets.formats.html.markup.TableHeader;
  43 import jdk.javadoc.internal.doclets.toolkit.Content;
  44 import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter;
  45 import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
  46 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  47 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberTable;
  48 
  49 /**
  50  * Writes method documentation in HTML format.
  51  *
  52  *  <p><b>This is NOT part of any supported API.
  53  *  If you write code that depends on this, you do so at your own risk.
  54  *  This code and its internal interfaces are subject to change or
  55  *  deletion without notice.</b>
  56  *
  57  * @author Robert Field
  58  * @author Atul M Dambalkar


 122         String erasureAnchor;
 123         Content methodDocTree = new ContentBuilder();
 124         Content heading = new HtmlTree(Headings.TypeDeclaration.MEMBER_HEADING);
 125         heading.add(name(method));
 126         methodDocTree.add(heading);
 127         if ((erasureAnchor = getErasureAnchor(method)) != null) {
 128             methodDocTree.add(links.createAnchor((erasureAnchor)));
 129         }
 130         methodDocTree.add(links.createAnchor(writer.getAnchor(method)));
 131         return HtmlTree.SECTION(HtmlStyle.detail, methodDocTree);
 132     }
 133 
 134     /**
 135      * Get the signature for the given method.
 136      *
 137      * @param method the method being documented.
 138      * @return a content object for the signature
 139      */
 140     @Override
 141     public Content getSignature(ExecutableElement method) {
 142         return new MemberSignature(method)
 143                 .addTypeParameters(getTypeParameters(method))
 144                 .addReturnType(getReturnType(method))
 145                 .addParameters(getParameters(method, true))
 146                 .addExceptions(getExceptions(method))
 147                 .toContent();











 148     }
 149 
 150     /**
 151      * {@inheritDoc}
 152      */
 153     @Override
 154     public void addDeprecated(ExecutableElement method, Content methodDocTree) {
 155         addDeprecatedInfo(method, methodDocTree);
 156     }
 157 
 158     /**
 159      * {@inheritDoc}
 160      */
 161     @Override
 162     public void addComments(TypeMirror holderType, ExecutableElement method, Content methodDocTree) {
 163         TypeElement holder = utils.asTypeElement(holderType);
 164         if (!utils.getFullBody(method).isEmpty()) {
 165             if (holder.equals(typeElement) ||
 166                     !(utils.isPublic(holder) ||
 167                     utils.isLinkable(holder))) {


 370             intfac = utils.getDeclaredType(utils.getEnclosingTypeElement(method), intfac);
 371             Content intfaclink = writer.getLink(new LinkInfoImpl(
 372                     writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
 373             Content codeIntfacLink = HtmlTree.CODE(intfaclink);
 374             Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, contents.specifiedByLabel));
 375             dl.add(dt);
 376             Content methlink = writer.getDocLink(
 377                     LinkInfoImpl.Kind.MEMBER, implementedMeth,
 378                     implementedMeth.getSimpleName(), false);
 379             Content codeMethLink = HtmlTree.CODE(methlink);
 380             Content dd = HtmlTree.DD(codeMethLink);
 381             dd.add(Entity.NO_BREAK_SPACE);
 382             dd.add(contents.inInterface);
 383             dd.add(Entity.NO_BREAK_SPACE);
 384             dd.add(codeIntfacLink);
 385             dl.add(dd);
 386         }
 387     }
 388 
 389     /**
 390      * Get the return type for the given method.
 391      *
 392      * @param method the method being documented.
 393      * @return content containing the return type
 394      */
 395     protected Content getReturnType(ExecutableElement method) {
 396         TypeMirror type = utils.getReturnType(method);
 397         if (type != null) {
 398             return writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));



 399         }
 400         return new ContentBuilder();
 401     }
 402 
 403     @Override
 404     public Content getMemberTreeHeader(){
 405         return writer.getMemberTreeHeader();
 406     }
 407 }
< prev index next >