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