langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
author jjg
Thu, 15 Nov 2012 09:18:36 -0800
changeset 14542 7062120649c2
parent 14263 473b1eaede64
child 15385 ee1eebe7e210
permissions -rw-r--r--
8000800: javadoc uses static non-final fields Reviewed-by: bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 7681
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1787
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    29
import com.sun.tools.doclets.formats.html.markup.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    30
import com.sun.tools.doclets.internal.toolkit.*;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.util.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Print method and constructor info.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    36
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    37
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    38
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    39
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14259
diff changeset
    40
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Atul M Dambalkar
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    43
 * @author Bhavesh Patel (Modified)
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    public AbstractExecutableMemberWriter(SubWriterHolderWriter writer,
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
    48
            ClassDoc classdoc) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        super(writer, classdoc);
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    public AbstractExecutableMemberWriter(SubWriterHolderWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        super(writer);
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    57
     * Add the type parameters for the executable member.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * @param member the member to write type parameters for.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    60
     * @param htmltree the content tree to which the parameters will be added.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * @return the display length required to write this information.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    63
    protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
    64
        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        String typeParameters = writer.getTypeParameterLinks(linkInfo);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        if (linkInfo.displayLength > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    68
            Content linkContent = new RawHtml(typeParameters);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    69
            htmltree.addContent(linkContent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    70
            htmltree.addContent(writer.getSpace());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
            writer.displayLength += linkInfo.displayLength + 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        return linkInfo.displayLength;
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    76
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    77
     * {@inheritDoc}
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    78
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    79
    protected Content getDeprecatedLink(ProgramElementDoc member) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    80
        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    81
        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    82
                emd.qualifiedName() + emd.flatSignature());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    85
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    86
     * Add the summary link for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    87
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    88
     * @param context the id of the context where the link will be printed
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 7681
diff changeset
    89
     * @param cd the classDoc that we should link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    90
     * @param member the member being linked to
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    91
     * @param tdSummary the content tree to which the link will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    92
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    93
    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    94
            Content tdSummary) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    96
        String name = emd.name();
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    97
        Content strong = HtmlTree.STRONG(new RawHtml(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    98
                writer.getDocLink(context, cd, (MemberDoc) emd,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
    99
                name, false)));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   100
        Content code = HtmlTree.CODE(strong);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   101
        writer.displayLength = name.length();
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   102
        addParameters(emd, false, code);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   103
        tdSummary.addContent(code);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   106
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   107
     * Add the inherited summary link for the member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   108
     *
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 7681
diff changeset
   109
     * @param cd the classDoc that we should link to
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   110
     * @param member the member being linked to
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   111
     * @param linksTree the content tree to which the link will be added
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   112
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   113
    protected void addInheritedSummaryLink(ClassDoc cd,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   114
            ProgramElementDoc member, Content linksTree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   115
        linksTree.addContent(new RawHtml(
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   116
                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   117
                member.name(), false)));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   120
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   121
     * Add the parameter for the executable member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   122
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   123
     * @param member the member to write parameter for.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   124
     * @param param the parameter that needs to be written.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   125
     * @param isVarArg true if this is a link to var arg.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   126
     * @param tree the content tree to which the parameter information will be added.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   127
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   128
    protected void addParam(ExecutableMemberDoc member, Parameter param,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   129
        boolean isVarArg, Content tree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        if (param.type() != null) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   131
            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   132
                    configuration, LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM,
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   133
                    param.type(), isVarArg)));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   134
            tree.addContent(link);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        if(param.name().length() > 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   137
            tree.addContent(writer.getSpace());
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   138
            tree.addContent(param.name());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   142
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   143
     * Add all the parameters for the executable member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   144
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   145
     * @param member the member to write parameters for.
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 7681
diff changeset
   146
     * @param htmltree the content tree to which the parameters information will be added.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   147
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   148
    protected void addParameters(ExecutableMemberDoc member, Content htmltree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   149
        addParameters(member, true, htmltree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   152
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   153
     * Add all the parameters for the executable member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   154
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   155
     * @param member the member to write parameters for.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   156
     * @param includeAnnotations true if annotation information needs to be added.
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 7681
diff changeset
   157
     * @param htmltree the content tree to which the parameters information will be added.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   158
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   159
    protected void addParameters(ExecutableMemberDoc member,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   160
            boolean includeAnnotations, Content htmltree) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   161
        htmltree.addContent("(");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        Parameter[] params = member.parameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        String indent = makeSpace(writer.displayLength);
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   164
        if (configuration.linksource) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            //add spaces to offset indentation changes caused by link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            indent+= makeSpace(member.name().length());
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        int paramstart;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        for (paramstart = 0; paramstart < params.length; paramstart++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            Parameter param = params[paramstart];
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            if (!param.name().startsWith("this$")) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                if (includeAnnotations) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   173
                    boolean foundAnnotations =
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   174
                            writer.addAnnotationInfo(indent.length(),
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   175
                            member, param, htmltree);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   176
                    if (foundAnnotations) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   177
                        htmltree.addContent(DocletConstants.NL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   178
                        htmltree.addContent(indent);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
                }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   181
                addParam(member, param,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   182
                    (paramstart == params.length - 1) && member.isVarArgs(), htmltree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        for (int i = paramstart + 1; i < params.length; i++) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   188
            htmltree.addContent(",");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   189
            htmltree.addContent(DocletConstants.NL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   190
            htmltree.addContent(indent);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            if (includeAnnotations) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                boolean foundAnnotations =
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   193
                        writer.addAnnotationInfo(indent.length(), member, params[i],
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   194
                        htmltree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
                if (foundAnnotations) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   196
                    htmltree.addContent(DocletConstants.NL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   197
                    htmltree.addContent(indent);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
            }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   200
            addParam(member, params[i], (i == params.length - 1) && member.isVarArgs(),
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   201
                    htmltree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   203
        htmltree.addContent(")");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   206
    /**
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   207
     * Add exceptions for the executable member.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   208
     *
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   209
     * @param member the member to write exceptions for.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   210
     * @param htmltree the content tree to which the exceptions information will be added.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   211
     */
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   212
    protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        Type[] exceptions = member.thrownExceptionTypes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        if(exceptions.length > 0) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   215
            LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   216
                    LinkInfoImpl.CONTEXT_MEMBER, member, false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            int retlen = getReturnTypeLength(member);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            writer.getTypeParameterLinks(memberTypeParam);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            retlen += memberTypeParam.displayLength == 0 ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
                0 : memberTypeParam.displayLength + 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            String indent = makeSpace(modifierString(member).length() +
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   222
                    member.name().length() + retlen - 4);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   223
            htmltree.addContent(DocletConstants.NL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   224
            htmltree.addContent(indent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   225
            htmltree.addContent("throws ");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
            indent += "       ";
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   227
            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(configuration,
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   228
                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   229
            htmltree.addContent(link);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            for(int i = 1; i < exceptions.length; i++) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   231
                htmltree.addContent(",");
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   232
                htmltree.addContent(DocletConstants.NL);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   233
                htmltree.addContent(indent);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   234
                Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   235
                        configuration, LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   236
                htmltree.addContent(exceptionLink);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    protected int getReturnTypeLength(ExecutableMemberDoc member) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        if (member instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            MethodDoc method = (MethodDoc)member;
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            Type rettype = method.returnType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            if (rettype.isPrimitive()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
                return rettype.typeName().length() +
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
                       rettype.dimension().length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
            } else {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14263
diff changeset
   249
                LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
                    LinkInfoImpl.CONTEXT_MEMBER, rettype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
                writer.getLink(linkInfo);
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
                return linkInfo.displayLength;
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        } else {   // it's a constructordoc
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
            return -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    protected ClassDoc implementsMethodInIntfac(MethodDoc method,
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
                                                ClassDoc[] intfacs) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        for (int i = 0; i < intfacs.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
            MethodDoc[] methods = intfacs[i].methods();
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
            if (methods.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
                for (int j = 0; j < methods.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
                    if (methods[j].name().equals(method.name()) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
                          methods[j].signature().equals(method.signature())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
                        return intfacs[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * For backward compatibility, include an anchor using the erasures of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * parameters.  NOTE:  We won't need this method anymore after we fix
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * see tags so that they use the type instead of the erasure.
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     * @param emd the ExecutableMemberDoc to anchor to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
     * @return the 1.4.x style anchor for the ExecutableMemberDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    protected String getErasureAnchor(ExecutableMemberDoc emd) {
14263
473b1eaede64 8000310: Clean up use of StringBuffer in langtools
jjg
parents: 14260
diff changeset
   284
        StringBuilder buf = new StringBuilder(emd.name() + "(");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
        Parameter[] params = emd.parameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        boolean foundTypeVariable = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        for (int i = 0; i < params.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
            if (i > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
                buf.append(",");
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            Type t = params[i].type();
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
            foundTypeVariable = foundTypeVariable || t.asTypeVariable() != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            buf.append(t.isPrimitive() ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
                t.typeName() : t.asClassDoc().qualifiedName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            buf.append(t.dimension());
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        buf.append(")");
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        return foundTypeVariable ? buf.toString() : null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
}