langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
author jjg
Fri, 27 May 2016 13:06:58 -0700
changeset 38617 d93a7f64e231
parent 26270 a3635e6d3d78
permissions -rw-r--r--
8157606: deprecate com.sun.javadoc API Reviewed-by: ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
     2
 * Copyright (c) 1998, 2014, 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: 1789
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: 1789
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: 1789
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1789
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;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    28
import java.util.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 5520
diff changeset
    29
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.javadoc.*;
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
    31
import com.sun.tools.doclets.formats.html.ConfigurationImpl;
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
 * Map all class uses for a given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    36
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
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: 14258
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: 14258
diff changeset
    39
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Robert G. Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 */
38617
d93a7f64e231 8157606: deprecate com.sun.javadoc API
jjg
parents: 26270
diff changeset
    44
@Deprecated
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
public class ClassUseMapper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private final ClassTree classtree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * Mapping of ClassDocs to set of PackageDoc used by that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    53
    public Map<String,Set<PackageDoc>> classToPackage = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * Mapping of Annotations to set of PackageDoc that use the annotation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    58
    public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Mapping of ClassDocs to set of ClassDoc used by that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    64
    public Map<String,Set<ClassDoc>> classToClass = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * Mapping of ClassDocs to list of ClassDoc which are direct or
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * indirect subclasses of that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    71
    public Map<String,List<ClassDoc>> classToSubclass = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * Mapping of ClassDocs to list of ClassDoc which are direct or
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * indirect subinterfaces of that interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    78
    public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * Mapping of ClassDocs to list of ClassDoc which implement
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * this interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    85
    public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Mapping of ClassDocs to list of FieldDoc declared as that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    91
    public Map<String,List<FieldDoc>> classToField = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * Mapping of ClassDocs to list of MethodDoc returning that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
    97
    public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * Mapping of ClassDocs to list of MethodDoc having that class
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * as an arg.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   104
    public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * Mapping of ClassDocs to list of MethodDoc which throws that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   110
    public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     * Mapping of ClassDocs to list of ConstructorDoc having that class
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * as an arg.
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   117
    public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * Mapping of ClassDocs to list of ConstructorDoc which throws that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   123
    public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * The mapping of AnnotationTypeDocs to constructors that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   128
    public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * The mapping of AnnotationTypeDocs to Constructor parameters that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   133
    public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * The mapping of ClassDocs to Constructor arguments that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   138
    public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<>();
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
     * The mapping of ClassDocs to ClassDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   143
    public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * The mapping of AnnotationTypeDocs to ClassDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   148
    public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     * The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   153
    public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     * The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   158
    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     * The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   163
    public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     * The mapping of ClassDocs to ExecutableMemberDocs that have return type
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * with type parameters of that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   169
    public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * The mapping of AnnotationTypeDocs to MethodDoc parameters that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   174
    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     * The mapping of ClassDocs to FieldDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   179
    public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     * The mapping of AnnotationTypeDocs to FieldDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     */
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   184
    public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   186
    private final Utils utils;
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   187
    public ClassUseMapper(ConfigurationImpl configuration, ClassTree classtree) {
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   188
        RootDoc root = configuration.root;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        this.classtree = classtree;
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   190
        utils = configuration.utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        // Map subclassing, subinterfacing implementing, ...
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   192
        for (ClassDoc doc : classtree.baseclasses()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   193
            subclasses(doc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   195
        for (ClassDoc doc : classtree.baseinterfaces()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
            // does subinterfacing as side-effect
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   197
            implementingClasses(doc);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        // Map methods, fields, constructors using a class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        ClassDoc[] classes = root.classes();
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   201
        for (ClassDoc aClass : classes) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   202
            PackageDoc pkg = aClass.containingPackage();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
            mapAnnotations(classToPackageAnnotations, pkg, pkg);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   204
            ClassDoc cd = aClass;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
            mapTypeParameters(classToClassTypeParam, cd, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            mapAnnotations(classToClassAnnotations, cd, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
            FieldDoc[] fields = cd.fields();
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   208
            for (FieldDoc fd : fields) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                mapTypeParameters(classToFieldDocTypeParam, fd, fd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
                mapAnnotations(annotationToFieldDoc, fd, fd);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   211
                if (!fd.type().isPrimitive()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
                    add(classToField, fd.type().asClassDoc(), fd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            ConstructorDoc[] cons = cd.constructors();
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   216
            for (ConstructorDoc con : cons) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   217
                mapAnnotations(classToConstructorAnnotations, con, con);
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   218
                mapExecutable(con);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            MethodDoc[] meths = cd.methods();
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   221
            for (MethodDoc md : meths) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
                mapExecutable(md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
                mapTypeParameters(classToExecMemberDocTypeParam, md, md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                mapAnnotations(classToExecMemberDocAnnotations, md, md);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   225
                if (!(md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                    mapTypeParameters(classToExecMemberDocReturnTypeParam,
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   227
                                      md.returnType(), md);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
                    add(classToMethodReturn, md.returnType().asClassDoc(), md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     * Return all subclasses of a class AND fill-in classToSubclass map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   237
    private Collection<ClassDoc> subclasses(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   238
        Collection<ClassDoc> ret = classToSubclass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        if (ret == null) {
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   240
            ret = new TreeSet<>(utils.makeComparatorForClassUse());
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   241
            SortedSet<ClassDoc> subs = classtree.subclasses(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            if (subs != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                ret.addAll(subs);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   244
                for (ClassDoc sub : subs) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   245
                    ret.addAll(subclasses(sub));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
            addAll(classToSubclass, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * Return all subinterfaces of an interface AND fill-in classToSubinterface map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   256
    private Collection<ClassDoc> subinterfaces(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   257
        Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        if (ret == null) {
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   259
            ret = new TreeSet<>(utils.makeComparatorForClassUse());
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   260
            SortedSet<ClassDoc> subs = classtree.subinterfaces(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
            if (subs != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                ret.addAll(subs);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   263
                for (ClassDoc sub : subs) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   264
                    ret.addAll(subinterfaces(sub));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
            addAll(classToSubinterface, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * Return all implementing classes of an interface (including
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * all subclasses of implementing classes and all classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * implementing subinterfaces) AND fill-in both classToImplementingClass
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * and classToSubinterface maps.
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   278
    private Collection<ClassDoc> implementingClasses(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   279
        Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        if (ret == null) {
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   281
            ret = new TreeSet<>(utils.makeComparatorForClassUse());
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   282
            SortedSet<ClassDoc> impl = classtree.implementingclasses(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
            if (impl != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
                ret.addAll(impl);
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   285
                for (ClassDoc anImpl : impl) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   286
                    ret.addAll(subclasses(anImpl));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
            }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   289
            for (ClassDoc doc : subinterfaces(cd)) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   290
                ret.addAll(implementingClasses(doc));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
            addAll(classToImplementingClass, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     * Determine classes used by a method or constructor, so they can be
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
     * inverse mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    private void mapExecutable(ExecutableMemberDoc em) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        boolean isConstructor = em.isConstructor();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   303
        Set<Type> classArgs = new TreeSet<>(utils.makeTypeComparator());
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   304
        for (Parameter param : em.parameters()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   305
            Type pcd = param.type();
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   306
            // ignore primitives and typevars, typevars are handled elsewhere
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   307
            if ((!param.type().isPrimitive()) && !(pcd instanceof TypeVariable)) {
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   308
                 // avoid dups
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   309
                if (classArgs.add(pcd)) {
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   310
                    add(isConstructor ? classToConstructorArgs : classToMethodArgs,
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   311
                            pcd.asClassDoc(), em);
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   312
                    mapTypeParameters(isConstructor
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   313
                                ? classToConstructorDocArgTypeParam
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   314
                                : classToExecMemberDocArgTypeParam,
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   315
                            pcd, em);
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   316
                }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
            }
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   318
            mapAnnotations(isConstructor
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   319
                        ? classToConstructorParamAnnotation
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   320
                        : classToExecMemberDocParamAnnotation,
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   321
                    param, em);
26270
a3635e6d3d78 8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents: 25874
diff changeset
   322
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   324
        for (ClassDoc anException : em.thrownExceptions()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   325
            add(isConstructor ? classToConstructorThrows : classToMethodThrows,
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   326
                anException, em);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   330
    private <T> List<T> refList(Map<String,List<T>> map, ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   331
        List<T> list = map.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        if (list == null) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   333
            list = new ArrayList<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
            map.put(cd.qualifiedName(), list);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        return list;
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   339
    private Set<PackageDoc> packageSet(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   340
        Set<PackageDoc> pkgSet = classToPackage.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        if (pkgSet == null) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   342
            pkgSet = new TreeSet<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            classToPackage.put(cd.qualifiedName(), pkgSet);
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        return pkgSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   348
    private Set<ClassDoc> classSet(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   349
        Set<ClassDoc> clsSet = classToClass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
        if (clsSet == null) {
22163
3651128c74eb 8030244: Update langtools to use Diamond
briangoetz
parents: 22159
diff changeset
   351
            clsSet = new TreeSet<>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
            classToClass.put(cd.qualifiedName(), clsSet);
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
        return clsSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   357
    private <T extends ProgramElementDoc> void add(Map<String,List<T>> map, ClassDoc cd, T ref) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        // add to specified map
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
        refList(map, cd).add(ref);
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        // add ref's package to package map and class map
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        packageSet(cd).add(ref.containingPackage());
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
        classSet(cd).add(ref instanceof MemberDoc?
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
                ((MemberDoc)ref).containingClass() :
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   366
                    (ClassDoc)ref);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   369
    private void addAll(Map<String,List<ClassDoc>> map, ClassDoc cd, Collection<ClassDoc> refs) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
        if (refs == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
        // add to specified map
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
        refList(map, cd).addAll(refs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   376
        Set<PackageDoc> pkgSet = packageSet(cd);
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   377
        Set<ClassDoc> clsSet = classSet(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        // add ref's package to package map and class map
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   379
        for (ClassDoc cls : refs) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   380
            pkgSet.add(cls.containingPackage());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   381
            clsSet.add(cls);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
     * Map the ClassDocs to the ProgramElementDocs that use them as
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
     * type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
     * @param map the map the insert the information into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * @param doc the doc whose type parameters are being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     * @param holder the holder that owns the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   394
    private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   395
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
        TypeVariable[] typeVariables;
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
        if (doc instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
            typeVariables = ((ClassDoc) doc).typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        } else if (doc instanceof WildcardType) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   400
            for (Type extendsBound : ((WildcardType) doc).extendsBounds()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   401
                addTypeParameterToMap(map, extendsBound, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
            }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   403
            for (Type superBound : ((WildcardType) doc).superBounds()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   404
                addTypeParameterToMap(map, superBound, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
        } else if (doc instanceof ParameterizedType) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   408
            for (Type typeArgument : ((ParameterizedType) doc).typeArguments()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   409
                addTypeParameterToMap(map, typeArgument, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
        } else if (doc instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
            typeVariables = ((ExecutableMemberDoc) doc).typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
        } else if (doc instanceof FieldDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            Type fieldType = ((FieldDoc) doc).type();
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
            mapTypeParameters(map, fieldType, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
        }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   421
        for (TypeVariable typeVariable : typeVariables) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   422
            for (Type bound : typeVariable.bounds()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   423
                addTypeParameterToMap(map, bound, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
     * Map the AnnotationType to the ProgramElementDocs that use them as
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
     * type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
     * @param map the map the insert the information into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
     * @param doc the doc whose type parameters are being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
     * @param holder the holder that owns the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   436
    private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   437
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
        AnnotationDesc[] annotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        boolean isPackage = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        if (doc instanceof ProgramElementDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
            annotations = ((ProgramElementDoc) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
        } else if (doc instanceof PackageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
            annotations = ((PackageDoc) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
            isPackage = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        } else if (doc instanceof Parameter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
            annotations = ((Parameter) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        } else {
19667
fdfce85627a9 8001669: javadoc internal DocletAbortException should set cause when appropriate
jjg
parents: 14260
diff changeset
   448
            throw new DocletAbortException("should not happen");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        }
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   450
        for (AnnotationDesc annotation : annotations) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   451
            AnnotationTypeDoc annotationDoc = annotation.annotationType();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
            if (isPackage)
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
                refList(map, annotationDoc).add(holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
            else
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   455
                add(map, annotationDoc, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   459
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   460
    /**
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   461
     * Map the AnnotationType to the ProgramElementDocs that use them as
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   462
     * type parameters.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   463
     *
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   464
     * @param map the map the insert the information into.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   465
     * @param doc the doc whose type parameters are being checked.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   466
     * @param holder the holder that owns the type parameters.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   467
     */
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   468
    private <T extends PackageDoc> void mapAnnotations(Map<String,List<T>> map, PackageDoc doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   469
            T holder) {
22159
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   470
        for (AnnotationDesc annotation : doc.annotations()) {
682da512ec17 8030253: Update langtools to use strings-in-switch
briangoetz
parents: 19667
diff changeset
   471
            AnnotationTypeDoc annotationDoc = annotation.annotationType();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   472
            refList(map, annotationDoc).add(holder);
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   473
        }
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   474
    }
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   475
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   476
    private <T extends ProgramElementDoc> void addTypeParameterToMap(Map<String,List<T>> map, Type type,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   477
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
        if (type instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
            add(map, (ClassDoc) type, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
        } else if (type instanceof ParameterizedType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
            add(map, ((ParameterizedType) type).asClassDoc(), holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
        mapTypeParameters(map, type, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
}