< 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         MemberSignature sig = new MemberSignature(method);
 143         sig.addTypeParametersAndReturnType(getTypeParameters(method), getReturnType(method));
 144         sig.addName(method);
 145         sig.addParametersAndExceptions(getParameters(method, true), getExceptions(method));
 146         return sig.toContent();












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


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



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