langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java
author mcimadamore
Tue, 13 Jan 2009 13:27:14 +0000
changeset 1789 7ac8c0815000
parent 1264 076a3cde30d5
child 5520 86e4b9a9da40
permissions -rw-r--r--
6765045: Remove rawtypes warnings from langtools Summary: Removed all occurrences of rawtypes warnings from langtools Reviewed-by: jjg, bpatel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
1264
076a3cde30d5 6754988: Update copyright year
xdono
parents: 868
diff changeset
     2
 * Copyright 2001-2008 Sun Microsystems, Inc.  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
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.internal.toolkit.taglets;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * A taglet that represents the @param tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * This code is not part of an API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * It is implementation that is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * Do not use it as an API
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @since 1.4
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     * Construct a ParamTaglet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    public ParamTaglet() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        name = "param";
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * Given an array of <code>Parameter</code>s, return
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * a name/rank number map.  If the array is null, then
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * null is returned.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * @param params The array of parmeters (from type or executable member) to
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     *               check.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * @return a name-rank number map.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    59
    private static Map<String,String> getRankMap(Object[] params){
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        if (params == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        }
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    63
        HashMap<String,String> result = new HashMap<String,String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        for (int i = 0; i < params.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            String name = params[i] instanceof Parameter ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                ((Parameter) params[i]).name() :
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                ((TypeVariable) params[i]).typeName();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
            result.put(name, String.valueOf(i));
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    public void inherit(DocFinder.Input input, DocFinder.Output output) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        if (input.tagId == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            input.isTypeVariableParamTag = ((ParamTag) input.tag).isTypeParameter();
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            Object[] parameters = input.isTypeVariableParamTag ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
                (Object[]) ((MethodDoc) input.tag.holder()).typeParameters() :
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                (Object[]) ((MethodDoc) input.tag.holder()).parameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            String target = ((ParamTag) input.tag).parameterName();
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
            int i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
            for (i = 0; i < parameters.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
                String name = parameters[i] instanceof Parameter ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
                    ((Parameter) parameters[i]).name() :
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
                    ((TypeVariable) parameters[i]).typeName();
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
                if (name.equals(target)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
                    input.tagId = String.valueOf(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            if (i == parameters.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                //Someone used {@inheritDoc} on an invalid @param tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                //We don't know where to inherit from.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                //XXX: in the future when Configuration is available here,
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                //print a warning for this mistake.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                return;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        ParamTag[] tags = input.isTypeVariableParamTag ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            input.method.typeParamTags() : input.method.paramTags();
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   103
        Map<String, String> rankMap = getRankMap(input.isTypeVariableParamTag ?
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            (Object[]) input.method.typeParameters() :
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            (Object[]) input.method.parameters());
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        for (int i = 0; i < tags.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            if (rankMap.containsKey(tags[i].parameterName()) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                    rankMap.get(tags[i].parameterName()).equals((input.tagId))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                output.holder = input.method;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                output.holderTag = tags[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                output.inlineTags = input.isFirstSentence ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                    tags[i].firstSentenceTags() : tags[i].inlineTags();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
                return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    public boolean inField() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    public boolean inMethod() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public boolean inOverview() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public boolean inPackage() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    public boolean inType() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    public boolean isInlineTag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * Given an array of <code>ParamTag</code>s,return its string representation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * @param holder the member that holds the param tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * @param writer the TagletWriter that will write this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     * @return the TagletOutput representation of these <code>ParamTag</code>s.
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        if (holder instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            ExecutableMemberDoc member = (ExecutableMemberDoc) holder;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            TagletOutput output = getTagletOutput(false, member, writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
                member.typeParameters(), member.typeParamTags());
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            output.appendOutput(getTagletOutput(true, member, writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                member.parameters(), member.paramTags()));
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
            return output;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            ClassDoc classDoc = (ClassDoc) holder;
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            return getTagletOutput(false, classDoc, writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                classDoc.typeParameters(), classDoc.typeParamTags());
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * Given an array of <code>ParamTag</code>s,return its string representation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     * Try to inherit the param tags that are missing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     * @param doc               the doc that holds the param tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     * @param writer            the TagletWriter that will write this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     * @param formalParameters  The array of parmeters (from type or executable
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     *                          member) to check.
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * @return the TagletOutput representation of these <code>ParamTag</code>s.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    private TagletOutput getTagletOutput(boolean isNonTypeParams, Doc holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
            TagletWriter writer, Object[] formalParameters, ParamTag[] paramTags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        TagletOutput result = writer.getOutputInstance();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   195
        Set<String> alreadyDocumented = new HashSet<String>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        if (paramTags.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            result.appendOutput(
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
                processParamTags(isNonTypeParams, paramTags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
                getRankMap(formalParameters), writer, alreadyDocumented)
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            );
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        if (alreadyDocumented.size() != formalParameters.length) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
            //Some parameters are missing corresponding @param tags.
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
            //Try to inherit them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            result.appendOutput(getInheritedTagletOutput (isNonTypeParams, holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                writer, formalParameters, alreadyDocumented));
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * Loop through each indivitual parameter.  It it does not have a
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     * corresponding param tag, try to inherit it.
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    private TagletOutput getInheritedTagletOutput(boolean isNonTypeParams, Doc holder,
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            TagletWriter writer, Object[] formalParameters,
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   217
            Set<String> alreadyDocumented) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        TagletOutput result = writer.getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        if ((! alreadyDocumented.contains(null)) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
                holder instanceof MethodDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
            for (int i = 0; i < formalParameters.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
                if (alreadyDocumented.contains(String.valueOf(i))) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
                    continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                //This parameter does not have any @param documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                //Try to inherit it.
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                DocFinder.Output inheritedDoc =
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                    DocFinder.search(new DocFinder.Input((MethodDoc) holder, this,
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                        String.valueOf(i), ! isNonTypeParams));
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                if (inheritedDoc.inlineTags != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
                        inheritedDoc.inlineTags.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
                    result.appendOutput(
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
                        processParamTag(isNonTypeParams, writer,
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
                            (ParamTag) inheritedDoc.holderTag,
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
                            isNonTypeParams ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
                                ((Parameter) formalParameters[i]).name():
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
                                ((TypeVariable) formalParameters[i]).typeName(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
                            alreadyDocumented.size() == 0));
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
                alreadyDocumented.add(String.valueOf(i));
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * Given an array of <code>Tag</code>s representing this custom
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     * tag, return its string representation.  Print a warning for param
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     * tags that do not map to parameters.  Print a warning for param
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * tags that are duplicated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * @param paramTags the array of <code>ParamTag</code>s to convert.
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * @param writer the TagletWriter that will write this tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * @param alreadyDocumented the set of exceptions that have already
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     *        been documented.
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     * @param rankMap a {@link java.util.Map} which holds ordering
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     *                    information about the parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * @param nameMap a {@link java.util.Map} which holds a mapping
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     *                of a rank of a parameter to its name.  This is
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     *                used to ensure that the right name is used
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     *                when parameter documentation is inherited.
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     * @return the TagletOutput representation of this <code>Tag</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    private TagletOutput processParamTags(boolean isNonTypeParams,
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   265
            ParamTag[] paramTags, Map<String, String> rankMap, TagletWriter writer,
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   266
            Set<String> alreadyDocumented) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        TagletOutput result = writer.getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        if (paramTags.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
            for (int i = 0; i < paramTags.length; ++i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                ParamTag pt = paramTags[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
                String paramName = isNonTypeParams ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
                    pt.parameterName() : "<" + pt.parameterName() + ">";
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
                if (! rankMap.containsKey(pt.parameterName())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
                    writer.getMsgRetriever().warning(pt.position(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
                        isNonTypeParams ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
                            "doclet.Parameters_warn" :
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
                            "doclet.Type_Parameters_warn",
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
                        paramName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                }
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   280
                String rank = rankMap.get(pt.parameterName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
                if (rank != null && alreadyDocumented.contains(rank)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
                    writer.getMsgRetriever().warning(pt.position(),
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
                       isNonTypeParams ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
                           "doclet.Parameters_dup_warn" :
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
                           "doclet.Type_Parameters_dup_warn",
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
                       paramName);
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
                result.appendOutput(processParamTag(isNonTypeParams, writer, pt,
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
                     pt.parameterName(), alreadyDocumented.size() == 0));
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
                alreadyDocumented.add(rank);
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     * Convert the individual ParamTag into TagletOutput.
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * @param isNonTypeParams true if this is just a regular param tag.  False
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     *                        if this is a type param tag.
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     * @param writer          the taglet writer for output writing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
     * @param paramTag        the tag whose inline tags will be printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     * @param name            the name of the parameter.  We can't rely on
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     *                        the name in the param tag because we might be
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     *                        inheriting documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * @param isFirstParam    true if this is the first param tag being printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    private TagletOutput processParamTag(boolean isNonTypeParams,
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
            TagletWriter writer, ParamTag paramTag, String name,
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
            boolean isFirstParam) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        TagletOutput result = writer.getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        String header = writer.configuration().getText(
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
            isNonTypeParams ? "doclet.Parameters" : "doclet.TypeParameters");
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
        if (isFirstParam) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
            result.appendOutput(writer.getParamHeader(header));
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        result.appendOutput(writer.paramTagOutput(paramTag,
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
            name));
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
}