langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.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 1998-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.util;
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 java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * Map all class uses for a given class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * This code is not part of an API.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * It is implementation that is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Do not use it as an API
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @since 1.2
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Robert G. Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public class ClassUseMapper {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    private final ClassTree classtree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * Mapping of ClassDocs to set of PackageDoc used by that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    49
    public Map<String,Set<PackageDoc>> classToPackage = new HashMap<String,Set<PackageDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * Mapping of Annotations to set of PackageDoc that use the annotation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    54
    public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<String,List<PackageDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * Mapping of ClassDocs to set of ClassDoc used by that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    60
    public Map<String,Set<ClassDoc>> classToClass = new HashMap<String,Set<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Mapping of ClassDocs to list of ClassDoc which are direct or
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * indirect subclasses of that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    67
    public Map<String,List<ClassDoc>> classToSubclass = new HashMap<String,List<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * Mapping of ClassDocs to list of ClassDoc which are direct or
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * indirect subinterfaces of that interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    74
    public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<String,List<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * Mapping of ClassDocs to list of ClassDoc which implement
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * this interface.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    81
    public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<String,List<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * Mapping of ClassDocs to list of FieldDoc declared as that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    87
    public Map<String,List<FieldDoc>> classToField = new HashMap<String,List<FieldDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * Mapping of ClassDocs to list of MethodDoc returning that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
    93
    public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<String,List<MethodDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * Mapping of ClassDocs to list of MethodDoc having that class
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * as an arg.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   100
    public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * Mapping of ClassDocs to list of MethodDoc which throws that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   106
    public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * Mapping of ClassDocs to list of ConstructorDoc having that class
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * as an arg.
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   113
    public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * Mapping of ClassDocs to list of ConstructorDoc which throws that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * Entries may be null.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   119
    public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * The mapping of AnnotationTypeDocs to constructors that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   124
    public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<String,List<ConstructorDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * The mapping of AnnotationTypeDocs to Constructor parameters that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   129
    public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * The mapping of ClassDocs to Constructor arguments that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   134
    public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * The mapping of ClassDocs to ClassDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   139
    public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<String,List<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * The mapping of AnnotationTypeDocs to ClassDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   144
    public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<String,List<ClassDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   149
    public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<String,List<MethodDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     * The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   154
    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     * The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   159
    public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<String,List<MethodDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
     * The mapping of ClassDocs to ExecutableMemberDocs that have return type
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
     * with type parameters of that class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   165
    public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<String,List<MethodDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     * The mapping of AnnotationTypeDocs to MethodDoc parameters that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   170
    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     * The mapping of ClassDocs to FieldDocs that use them as type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   175
    public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<String,List<FieldDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     * The mapping of AnnotationTypeDocs to FieldDocs that use them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   180
    public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<String,List<FieldDoc>>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    public ClassUseMapper(RootDoc root, ClassTree classtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        this.classtree = classtree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        // Map subclassing, subinterfacing implementing, ...
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   187
        for (Iterator<ClassDoc> it = classtree.baseclasses().iterator(); it.hasNext();) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   188
            subclasses(it.next());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        }
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   190
        for (Iterator<ClassDoc> it = classtree.baseinterfaces().iterator(); it.hasNext();) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            // does subinterfacing as side-effect
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   192
            implementingClasses(it.next());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        // Map methods, fields, constructors using a class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        ClassDoc[] classes = root.classes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        for (int i = 0; i < classes.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            PackageDoc pkg = classes[i].containingPackage();
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            mapAnnotations(classToPackageAnnotations, pkg, pkg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
            ClassDoc cd = classes[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            mapTypeParameters(classToClassTypeParam, cd, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            mapAnnotations(classToClassAnnotations, cd, cd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
            FieldDoc[] fields = cd.fields();
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
            for (int j = 0; j < fields.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
                FieldDoc fd = fields[j];
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
                mapTypeParameters(classToFieldDocTypeParam, fd, fd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
                mapAnnotations(annotationToFieldDoc, fd, fd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
                if (! fd.type().isPrimitive()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
                    add(classToField, fd.type().asClassDoc(), fd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
            ConstructorDoc[] cons = cd.constructors();
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            for (int j = 0; j < cons.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
                mapAnnotations(classToConstructorAnnotations, cons[j], cons[j]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
                mapExecutable(cons[j]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            MethodDoc[] meths = cd.methods();
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
            for (int j = 0; j < meths.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
                MethodDoc md = meths[j];
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
                mapExecutable(md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
                mapTypeParameters(classToExecMemberDocTypeParam, md, md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
                mapAnnotations(classToExecMemberDocAnnotations, md, md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
                if (! (md.returnType().isPrimitive() || md.returnType() instanceof TypeVariable)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
                    mapTypeParameters(classToExecMemberDocReturnTypeParam,
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
                        md.returnType(), md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
                    add(classToMethodReturn, md.returnType().asClassDoc(), md);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        }
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
     * Return all subclasses of a class AND fill-in classToSubclass map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   234
    private Collection<ClassDoc> subclasses(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   235
        Collection<ClassDoc> ret = classToSubclass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        if (ret == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   237
            ret = new TreeSet<ClassDoc>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   238
            List<ClassDoc> subs = classtree.subclasses(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
            if (subs != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
                ret.addAll(subs);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   241
                for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   242
                    ret.addAll(subclasses(it.next()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            addAll(classToSubclass, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * Return all subinterfaces of an interface AND fill-in classToSubinterface map.
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   253
    private Collection<ClassDoc> subinterfaces(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   254
        Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        if (ret == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   256
            ret = new TreeSet<ClassDoc>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   257
            List<ClassDoc> subs = classtree.subinterfaces(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            if (subs != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                ret.addAll(subs);
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   260
                for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   261
                    ret.addAll(subinterfaces(it.next()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
            addAll(classToSubinterface, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * Return all implementing classes of an interface (including
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     * all subclasses of implementing classes and all classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     * implementing subinterfaces) AND fill-in both classToImplementingClass
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     * and classToSubinterface maps.
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   275
    private Collection<ClassDoc> implementingClasses(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   276
        Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        if (ret == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   278
            ret = new TreeSet<ClassDoc>();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   279
            List<ClassDoc> impl = classtree.implementingclasses(cd);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
            if (impl != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
                ret.addAll(impl);
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   282
                for (Iterator<ClassDoc> it = impl.iterator(); it.hasNext();) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   283
                    ret.addAll(subclasses(it.next()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            }
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   286
            for (Iterator<ClassDoc> it = subinterfaces(cd).iterator(); it.hasNext();) {
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   287
                ret.addAll(implementingClasses(it.next()));
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            addAll(classToImplementingClass, cd, ret);
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        return ret;
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
     * Determine classes used by a method or constructor, so they can be
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     * inverse mapped.
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
    private void mapExecutable(ExecutableMemberDoc em) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        Parameter[] params = em.parameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        boolean isConstructor = em.isConstructor();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   301
        List<Type> classArgs = new ArrayList<Type>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        for (int k = 0; k < params.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            Type pcd = params[k].type();
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            // primitives don't get mapped, also avoid dups
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            if ((! params[k].type().isPrimitive()) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                 ! classArgs.contains(pcd) &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                 ! (pcd instanceof TypeVariable)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
                add(isConstructor? classToConstructorArgs :classToMethodArgs,
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
                        pcd.asClassDoc(), em);
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
                classArgs.add(pcd);
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
                mapTypeParameters(isConstructor?
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
                   classToConstructorDocArgTypeParam : classToExecMemberDocArgTypeParam,
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                   pcd, em);
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
            mapAnnotations(
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                isConstructor ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                    classToConstructorParamAnnotation :
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
                    classToExecMemberDocParamAnnotation,
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
                params[k], em);
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        ClassDoc[] thr = em.thrownExceptions();
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        for (int k = 0; k < thr.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
            add(isConstructor? classToConstructorThrows : classToMethodThrows,
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                    thr[k], em);
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   328
    private <T> List<T> refList(Map<String,List<T>> map, ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   329
        List<T> list = map.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        if (list == null) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   331
            List<T> l = new ArrayList<T>();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   332
            list = l;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
            map.put(cd.qualifiedName(), list);
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        return list;
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   338
    private Set<PackageDoc> packageSet(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   339
        Set<PackageDoc> pkgSet = classToPackage.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        if (pkgSet == null) {
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   341
            pkgSet = new TreeSet<PackageDoc>();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
            classToPackage.put(cd.qualifiedName(), pkgSet);
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        return pkgSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   347
    private Set<ClassDoc> classSet(ClassDoc cd) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   348
        Set<ClassDoc> clsSet = classToClass.get(cd.qualifiedName());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        if (clsSet == null) {
1789
7ac8c0815000 6765045: Remove rawtypes warnings from langtools
mcimadamore
parents: 1264
diff changeset
   350
            Set<ClassDoc> s = new TreeSet<ClassDoc>();
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   351
            clsSet = s;
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
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   379
        for (Iterator<ClassDoc> it = refs.iterator(); it.hasNext();) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   380
            ClassDoc cls = it.next();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   381
            pkgSet.add(cls.containingPackage());
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   382
            clsSet.add(cls);
10
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
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
     * Map the ClassDocs to the ProgramElementDocs that use them as
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
     * type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * @param map the map the insert the information into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     * @param doc the doc whose type parameters are being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     * @param holder the holder that owns the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   395
    private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   396
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
        TypeVariable[] typeVariables;
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
        if (doc instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
            typeVariables = ((ClassDoc) doc).typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        } else if (doc instanceof WildcardType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
            Type[] extendsBounds = ((WildcardType) doc).extendsBounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
            for (int k = 0; k < extendsBounds.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
                addTypeParameterToMap(map, extendsBounds[k], holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            Type[] superBounds = ((WildcardType) doc).superBounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            for (int k = 0; k < superBounds.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
                addTypeParameterToMap(map, superBounds[k], holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        } else if (doc instanceof ParameterizedType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
            Type[] typeArguments = ((ParameterizedType) doc).typeArguments();
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
            for (int k = 0; k < typeArguments.length; k++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
                addTypeParameterToMap(map, typeArguments[k], holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        } else if (doc instanceof ExecutableMemberDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
            typeVariables = ((ExecutableMemberDoc) doc).typeParameters();
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        } else if (doc instanceof FieldDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
            Type fieldType = ((FieldDoc) doc).type();
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
            mapTypeParameters(map, fieldType, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
        for (int i = 0; i < typeVariables.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
            Type[] bounds = typeVariables[i].bounds();
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
            for (int j = 0; j < bounds.length; j++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
                addTypeParameterToMap(map, bounds[j], holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
     * Map the AnnotationType to the ProgramElementDocs that use them as
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
     * type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
     * @param map the map the insert the information into.
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
     * @param doc the doc whose type parameters are being checked.
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
     * @param holder the holder that owns the type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
     */
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   441
    private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   442
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
        AnnotationDesc[] annotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        boolean isPackage = false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        if (doc instanceof ProgramElementDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
            annotations = ((ProgramElementDoc) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        } else if (doc instanceof PackageDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
            annotations = ((PackageDoc) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
            isPackage = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
        } else if (doc instanceof Parameter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
            annotations = ((Parameter) doc).annotations();
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
        for (int i = 0; i < annotations.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
            AnnotationTypeDoc annotationDoc = annotations[i].annotationType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
            if (isPackage)
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
                refList(map, annotationDoc).add(holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
            else
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   460
                add(map, annotationDoc, holder);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
868
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   464
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   465
    /**
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   466
     * Map the AnnotationType to the ProgramElementDocs that use them as
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   467
     * type parameters.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   468
     *
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   469
     * @param map the map the insert the information into.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   470
     * @param doc the doc whose type parameters are being checked.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   471
     * @param holder the holder that owns the type parameters.
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   472
     */
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   473
    private <T extends PackageDoc> void mapAnnotations(Map<String,List<T>> map, PackageDoc doc,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   474
            T holder) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   475
        AnnotationDesc[] annotations;
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   476
        annotations = doc.annotations();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   477
        for (int i = 0; i < annotations.length; i++) {
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   478
            AnnotationTypeDoc annotationDoc = annotations[i].annotationType();
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   479
            refList(map, annotationDoc).add(holder);
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   480
        }
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   481
    }
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   482
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   483
    private <T extends ProgramElementDoc> void addTypeParameterToMap(Map<String,List<T>> map, Type type,
d0f233085cbb 6657907: javadoc has unchecked warnings
jjg
parents: 10
diff changeset
   484
            T holder) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
        if (type instanceof ClassDoc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
            add(map, (ClassDoc) type, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
        } else if (type instanceof ParameterizedType) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
            add(map, ((ParameterizedType) type).asClassDoc(), holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
        mapTypeParameters(map, type, holder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
}