langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java
author jjg
Wed, 23 Jan 2013 13:27:24 -0800
changeset 15385 ee1eebe7e210
parent 14260 727a84636f12
child 16969 b58d8a70d921
permissions -rw-r--r--
8006775: JSR 308: Compiler changes in JDK8 Reviewed-by: jjg Contributed-by: mernst@cs.washington.edu, wmdietl@cs.washington.edu, mpapi@csail.mit.edu, mahmood@notnoop.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
     2
 * Copyright (c) 2003, 2013, 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: 1264
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: 1264
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: 1264
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
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.internal.toolkit.util.links;
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
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * A factory that constructs links from given link information.
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 5520
diff changeset
    33
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 5520
diff changeset
    34
 *  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: 5520
diff changeset
    35
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 5520
diff changeset
    36
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 5520
diff changeset
    37
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @since 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public abstract class LinkFactory {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     * Return an empty instance of the link output object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * @return an empty instance of the link output object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    protected abstract LinkOutput getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Constructs a link from the given link information.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * @param linkInfo the information about the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * @return the output of the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    public LinkOutput getLinkOutput(LinkInfo linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        if (linkInfo.type != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
            Type type = linkInfo.type;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            LinkOutput linkOutput = getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
            if (type.isPrimitive()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
                //Just a primitive.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
                linkInfo.displayLength += type.typeName().length();
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
                linkOutput.append(type.typeName());
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    64
            } else if (type.asAnnotatedType() != null) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    65
                linkOutput.append(getTypeAnnotationLinks(linkInfo));
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    66
                linkInfo.type = type.asAnnotatedType().underlyingType();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    67
                linkOutput.append(getLinkOutput(linkInfo));
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    68
                return linkOutput;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
            } else if (type.asWildcardType() != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
                //Wildcard type.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
                linkInfo.isTypeBound = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
                linkInfo.displayLength += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
                linkOutput.append("?");
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
                WildcardType wildcardType = type.asWildcardType();
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
                Type[] extendsBounds = wildcardType.extendsBounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
                for (int i = 0; i < extendsBounds.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
                    linkInfo.displayLength += i > 0 ? 2 : 9;
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                    linkOutput.append(i > 0 ? ", " : " extends ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
                    setBoundsLinkInfo(linkInfo, extendsBounds[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
                    linkOutput.append(getLinkOutput(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
                Type[] superBounds = wildcardType.superBounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                for (int i = 0; i < superBounds.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
                    linkInfo.displayLength += i > 0 ? 2 : 7;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
                    linkOutput.append(i > 0 ? ", " : " super ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
                    setBoundsLinkInfo(linkInfo, superBounds[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
                    linkOutput.append(getLinkOutput(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            } else if (type.asTypeVariable()!= null) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
    90
                linkOutput.append(getTypeAnnotationLinks(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
                linkInfo.isTypeBound = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
                //A type variable.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                Doc owner = type.asTypeVariable().owner();
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                if ((! linkInfo.excludeTypeParameterLinks) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                        owner instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                    linkInfo.classDoc = (ClassDoc) owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                    linkInfo.label = type.typeName();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    98
                    linkOutput.append(getClassLink(linkInfo));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                    //No need to link method type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                    linkInfo.displayLength += type.typeName().length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
                    linkOutput.append(type.typeName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                Type[] bounds = type.asTypeVariable().bounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                if (! linkInfo.excludeTypeBounds) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
                    linkInfo.excludeTypeBounds = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
                    for (int i = 0; i < bounds.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                        linkInfo.displayLength += i > 0 ? 2 : 9;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                        linkOutput.append(i > 0 ? " & " : " extends ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                        setBoundsLinkInfo(linkInfo, bounds[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                        linkOutput.append(getLinkOutput(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
            } else if (type.asClassDoc() != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                //A class type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                if (linkInfo.isTypeBound &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                        linkInfo.excludeTypeBoundsLinks) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                    //Since we are excluding type parameter links, we should not
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
                    //be linking to the type bound.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
                    linkInfo.displayLength += type.typeName().length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                    linkOutput.append(type.typeName());
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
                    linkOutput.append(getTypeParameterLinks(linkInfo));
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
                    return linkOutput;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
                    linkInfo.classDoc = type.asClassDoc();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   127
                    linkOutput = getClassLink(linkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                    if (linkInfo.includeTypeAsSepLink) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                        linkOutput.append(getTypeParameterLinks(linkInfo, false));
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
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            if (linkInfo.isVarArg) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
                if (type.dimension().length() > 2) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
                    //Javadoc returns var args as array.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
                    //Strip out the first [] from the var arg.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
                    linkInfo.displayLength += type.dimension().length()-2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
                    linkOutput.append(type.dimension().substring(2));
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
                linkInfo.displayLength += 3;
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
                linkOutput.append("...");
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
                linkInfo.displayLength += type.dimension().length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                linkOutput.append(type.dimension());
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            return linkOutput;
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        } else if (linkInfo.classDoc != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            //Just a class link
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   150
            LinkOutput linkOutput = getClassLink(linkInfo);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            if (linkInfo.includeTypeAsSepLink) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
                linkOutput.append(getTypeParameterLinks(linkInfo, false));
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
            return linkOutput;
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    private void setBoundsLinkInfo(LinkInfo linkInfo, Type bound) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        linkInfo.classDoc = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        linkInfo.label = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        linkInfo.type = bound;
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * Return the link to the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     * @param linkInfo the information about the link to construct.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     * @return the link for the given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    protected abstract LinkOutput getClassLink(LinkInfo linkInfo);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     * Return the link to the given type parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * @param linkInfo     the information about the link to construct.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     * @param typeParam the type parameter to link to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    protected abstract LinkOutput getTypeParameterLink(LinkInfo linkInfo,
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        Type typeParam);
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   184
    protected abstract LinkOutput getTypeAnnotationLink(LinkInfo linkInfo,
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   185
            AnnotationDesc annotation);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   186
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     * Return the links to the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     * @param linkInfo     the information about the link to construct.
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
     * @return the links to the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    public LinkOutput getTypeParameterLinks(LinkInfo linkInfo) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        return getTypeParameterLinks(linkInfo, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     * Return the links to the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     * @param linkInfo     the information about the link to construct.
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * @param isClassLabel true if this is a class label.  False if it is
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     *                     the type parameters portion of the link.
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     * @return the links to the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    public LinkOutput getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        LinkOutput output = getOutputInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        Type[] vars;
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        if (linkInfo.executableMemberDoc != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
            vars = linkInfo.executableMemberDoc.typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        } else if (linkInfo.type != null &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
                linkInfo.type.asParameterizedType() != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            vars =  linkInfo.type.asParameterizedType().typeArguments();
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        } else if (linkInfo.classDoc != null){
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            vars = linkInfo.classDoc.typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            //Nothing to document.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            return output;
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        if (((linkInfo.includeTypeInClassLinkLabel && isClassLabel) ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
             (linkInfo.includeTypeAsSepLink && ! isClassLabel)
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
              )
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
            && vars.length > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
            linkInfo.displayLength += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            output.append(getLessThanString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
            for (int i = 0; i < vars.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                if (i > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
                    linkInfo.displayLength += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                    output.append(",");
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
                output.append(getTypeParameterLink(linkInfo, vars[i]));
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
            linkInfo.displayLength += 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
            output.append(getGreaterThanString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        return output;
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   238
    public LinkOutput getTypeAnnotationLinks(LinkInfo linkInfo) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   239
        LinkOutput output = getOutputInstance();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   240
        if (linkInfo.type.asAnnotatedType() == null)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   241
            return output;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   242
        AnnotationDesc[] annotations = linkInfo.type.asAnnotatedType().annotations();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   243
        for (int i = 0; i < annotations.length; i++) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   244
            if (i > 0) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   245
                linkInfo.displayLength += 1;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   246
                output.append(" ");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   247
            }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   248
            output.append(getTypeAnnotationLink(linkInfo, annotations[i]));
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   249
        }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   250
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   251
        linkInfo.displayLength += 1;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   252
        output.append(" ");
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   253
        return output;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   254
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14260
diff changeset
   255
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     * Return &amp;lt;, which is used in type parameters.  Override this
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * if your doclet uses something different.
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
     * @return return &amp;lt;, which is used in type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    protected String getLessThanString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        return "&lt;";
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * Return &amp;gt;, which is used in type parameters.  Override this
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * if your doclet uses something different.
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * @return return &amp;gt;, which is used in type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    protected String getGreaterThanString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        return "&gt;";
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
}