author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 45417 | langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java@f7479ee8de69 |
child 47395 | 2ea4edfdef8e |
permissions | -rw-r--r-- |
10 | 1 |
/* |
45417 | 2 |
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
25 |
package jdk.javadoc.internal.doclets.toolkit.util; |
10 | 26 |
|
14258 | 27 |
import java.util.*; |
28 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
29 |
import javax.lang.model.element.AnnotationMirror; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
30 |
import javax.lang.model.element.Element; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
31 |
import javax.lang.model.element.ExecutableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
32 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
33 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
34 |
import javax.lang.model.element.TypeParameterElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
35 |
import javax.lang.model.element.VariableElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
36 |
import javax.lang.model.type.ArrayType; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
37 |
import javax.lang.model.type.DeclaredType; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
38 |
import javax.lang.model.type.ErrorType; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
39 |
import javax.lang.model.type.TypeMirror; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
40 |
import javax.lang.model.type.TypeVariable; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
41 |
import javax.lang.model.type.WildcardType; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
42 |
import javax.lang.model.util.Elements; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
43 |
import javax.lang.model.util.SimpleElementVisitor9; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
44 |
import javax.lang.model.util.SimpleTypeVisitor9; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
45 |
import javax.lang.model.util.Types; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
46 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
47 |
import jdk.javadoc.doclet.DocletEnvironment; |
45417 | 48 |
import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration; |
10 | 49 |
|
50 |
/** |
|
51 |
* Map all class uses for a given class. |
|
52 |
* |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
53 |
* <p> |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
54 |
* <b>This is NOT part of any supported API. If you write code that depends on this, you do so at |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
55 |
* your own risk. This code and its internal interfaces are subject to change or deletion without |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
56 |
* notice.</b> |
10 | 57 |
* |
58 |
* @author Robert G. Field |
|
59 |
*/ |
|
60 |
public class ClassUseMapper { |
|
61 |
||
62 |
private final ClassTree classtree; |
|
63 |
||
64 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
65 |
* Mapping of TypeElements to set of PackageElements used by that class. |
10 | 66 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
67 |
public final Map<TypeElement, Set<PackageElement>> classToPackage; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
68 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
69 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
70 |
* Mapping of TypeElements representing annotations to a set of PackageElements that use the annotation. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
71 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
72 |
public final Map<TypeElement, List<PackageElement>> classToPackageAnnotations = new HashMap<>(); |
10 | 73 |
|
74 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
75 |
* Mapping of TypeElements to a set of TypeElements used by that class. |
10 | 76 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
77 |
public final Map<TypeElement, Set<TypeElement>> classToClass = new HashMap<>(); |
10 | 78 |
|
79 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
80 |
* Mapping of TypeElements to a list of TypeElements which are direct or indirect subClasses of |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
81 |
* that class. |
10 | 82 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
83 |
public final Map<TypeElement, List<TypeElement>> classToSubclass = new HashMap<>(); |
10 | 84 |
|
85 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
86 |
* Mapping of TypeElements to list of TypeElements which are direct or indirect subInterfaces of |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
87 |
* that interface. |
10 | 88 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
89 |
public final Map<TypeElement, List<TypeElement>> classToSubinterface = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
90 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
91 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
92 |
* Mapping of TypeElements to list of TypeElements which implement this interface. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
93 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
94 |
public Map<TypeElement, List<TypeElement>> classToImplementingClass = new HashMap<>(); |
10 | 95 |
|
96 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
97 |
* Mapping of TypeElements to list of VariableElements declared as that class. |
10 | 98 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
99 |
public final Map<TypeElement, List<VariableElement>> classToField = new HashMap<>(); |
10 | 100 |
|
101 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
102 |
* Mapping of TypeElements to list of ExecutableElements returning that class. |
10 | 103 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
104 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodReturn = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
105 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
106 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
107 |
* Mapping of TypeElements to list of ExecutableElements having that class as an arg. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
108 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
109 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodArgs = new HashMap<>(); |
10 | 110 |
|
111 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
112 |
* Mapping of TypeElements to list of ExecutableElements which throws that class. |
10 | 113 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
114 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodThrows = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
115 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
116 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
117 |
* Mapping of TypeElements to list of ExecutableElements (constructors) having that |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
118 |
* class as an arg. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
119 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
120 |
public final Map<TypeElement, List<ExecutableElement>> classToConstructorArgs = new HashMap<>(); |
10 | 121 |
|
122 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
123 |
* Mapping of TypeElements to list of constructors which throws that class. |
10 | 124 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
125 |
public final Map<TypeElement, List<ExecutableElement>> classToConstructorThrows = new HashMap<>(); |
10 | 126 |
|
127 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
128 |
* The mapping of TypeElements representing annotations to constructors that use them. |
10 | 129 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
130 |
public final Map<TypeElement, List<ExecutableElement>> classToConstructorAnnotations = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
131 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
132 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
133 |
* The mapping of TypeElement representing annotations to constructor parameters that use them. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
134 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
135 |
public final Map<TypeElement, List<ExecutableElement>> classToConstructorParamAnnotation = new HashMap<>(); |
10 | 136 |
|
137 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
138 |
* The mapping of TypeElements to constructor arguments that use them as type parameters. |
10 | 139 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
140 |
public final Map<TypeElement, List<ExecutableElement>> classToConstructorArgTypeParam = new HashMap<>(); |
10 | 141 |
|
142 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
143 |
* The mapping of TypeElement to TypeElement that use them as type parameters. |
10 | 144 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
145 |
public final Map<TypeElement, List<TypeElement>> classToClassTypeParam = new HashMap<>(); |
10 | 146 |
|
147 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
148 |
* The mapping of TypeElement representing annotation to TypeElements that use them. |
10 | 149 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
150 |
public final Map<TypeElement, List<TypeElement>> classToClassAnnotations = new HashMap<>(); |
10 | 151 |
|
152 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
153 |
* The mapping of TypeElement to methods that use them as type parameters. |
10 | 154 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
155 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodTypeParam = new HashMap<>(); |
10 | 156 |
|
157 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
158 |
* The mapping of TypeElement to method arguments that use them as type parameters. |
10 | 159 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
160 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodArgTypeParam = new HashMap<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
161 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
162 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
163 |
* The mapping of TypeElement representing annotation to methods that use them. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
164 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
165 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodAnnotations = new HashMap<>(); |
10 | 166 |
|
167 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
168 |
* The mapping of TypeElements to methods that have return type with type parameters |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
169 |
* of that class. |
10 | 170 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
171 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodReturnTypeParam = new HashMap<>(); |
10 | 172 |
|
173 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
174 |
* The mapping of TypeElements representing annotations to method parameters that use them. |
10 | 175 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
176 |
public final Map<TypeElement, List<ExecutableElement>> classToMethodParamAnnotation = new HashMap<>(); |
10 | 177 |
|
178 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
179 |
* The mapping of TypeElements to fields that use them as type parameters. |
10 | 180 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
181 |
public final Map<TypeElement, List<VariableElement>> classToFieldTypeParam = new HashMap<>(); |
10 | 182 |
|
183 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
184 |
* The mapping of TypeElements representing annotation to fields that use them. |
10 | 185 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
186 |
public final Map<TypeElement, List<VariableElement>> annotationToField = new HashMap<>(); |
10 | 187 |
|
39364
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
35426
diff
changeset
|
188 |
private final DocletEnvironment docEnv; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
189 |
private final Elements elementUtils; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
190 |
private final Types typeUtils; |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
191 |
private final Utils utils; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
192 |
|
45417 | 193 |
public ClassUseMapper(HtmlConfiguration configuration, ClassTree classtree) { |
39364
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
35426
diff
changeset
|
194 |
docEnv = configuration.docEnv; |
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
35426
diff
changeset
|
195 |
elementUtils = docEnv.getElementUtils(); |
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
35426
diff
changeset
|
196 |
typeUtils = docEnv.getTypeUtils(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
197 |
utils = configuration.utils; |
10 | 198 |
this.classtree = classtree; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
199 |
classToPackage = new TreeMap<>(utils.makeClassUseComparator()); |
10 | 200 |
// Map subclassing, subinterfacing implementing, ... |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
201 |
for (TypeElement te : classtree.baseClasses()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
202 |
subclasses(te); |
10 | 203 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
204 |
for (TypeElement intfc : classtree.baseInterfaces()) { |
10 | 205 |
// does subinterfacing as side-effect |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
206 |
implementingClasses(intfc); |
10 | 207 |
} |
208 |
// Map methods, fields, constructors using a class. |
|
42277 | 209 |
Set<TypeElement> classes = configuration.getIncludedTypeElements(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
210 |
for (TypeElement aClass : classes) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
211 |
PackageElement pkg = elementUtils.getPackageOf(aClass); |
10 | 212 |
mapAnnotations(classToPackageAnnotations, pkg, pkg); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
213 |
mapTypeParameters(classToClassTypeParam, aClass, aClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
214 |
mapAnnotations(classToClassAnnotations, aClass, aClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
215 |
List<VariableElement> fields = utils.getFields(aClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
216 |
for (VariableElement fd : fields) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
217 |
mapTypeParameters(classToFieldTypeParam, fd, fd); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
218 |
mapAnnotations(annotationToField, fd, fd); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
219 |
SimpleTypeVisitor9<Void, VariableElement> stv = new SimpleTypeVisitor9<Void, VariableElement>() { |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
220 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
221 |
public Void visitArray(ArrayType t, VariableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
222 |
return visit(t.getComponentType(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
223 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
224 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
225 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
226 |
public Void visitDeclared(DeclaredType t, VariableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
227 |
add(classToField, (TypeElement) t.asElement(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
228 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
229 |
} |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
230 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
231 |
public Void visitTypeVariable(TypeVariable t, VariableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
232 |
return visit(typeUtils.erasure(t), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
233 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
234 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
235 |
stv.visit(fd.asType(), fd); |
10 | 236 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
237 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
238 |
List<ExecutableElement> ctors = utils.getConstructors(aClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
239 |
for (ExecutableElement ctor : ctors) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
240 |
mapAnnotations(classToConstructorAnnotations, ctor, ctor); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
241 |
mapExecutable(ctor); |
10 | 242 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
243 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
244 |
List<ExecutableElement> methods = utils.getMethods(aClass); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
245 |
for (ExecutableElement method : methods) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
246 |
mapExecutable(method); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
247 |
mapTypeParameters(classToMethodTypeParam, method, method); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
248 |
mapAnnotations(classToMethodAnnotations, method, method); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
249 |
SimpleTypeVisitor9<Void, ExecutableElement> stv = new SimpleTypeVisitor9<Void, ExecutableElement>() { |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
250 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
251 |
public Void visitArray(ArrayType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
252 |
TypeMirror componentType = t.getComponentType(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
253 |
return visit(utils.isTypeVariable(componentType) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
254 |
? typeUtils.erasure(componentType) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
255 |
: componentType, p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
256 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
257 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
258 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
259 |
public Void visitDeclared(DeclaredType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
260 |
mapTypeParameters(classToMethodReturnTypeParam, t, p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
261 |
add(classToMethodReturn, (TypeElement) t.asElement(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
262 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
263 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
264 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
265 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
266 |
protected Void defaultAction(TypeMirror e, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
267 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
268 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
269 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
270 |
stv.visit(method.getReturnType(), method); |
10 | 271 |
} |
272 |
} |
|
273 |
} |
|
274 |
||
275 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
276 |
* Return all subClasses of a class AND fill-in classToSubclass map. |
10 | 277 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
278 |
private Collection<TypeElement> subclasses(TypeElement te) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
279 |
Collection<TypeElement> ret = classToSubclass.get(te); |
10 | 280 |
if (ret == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
281 |
ret = new TreeSet<>(utils.makeClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
282 |
Set<TypeElement> subs = classtree.subClasses(te); |
10 | 283 |
if (subs != null) { |
284 |
ret.addAll(subs); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
285 |
for (TypeElement sub : subs) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
19667
diff
changeset
|
286 |
ret.addAll(subclasses(sub)); |
10 | 287 |
} |
288 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
289 |
addAll(classToSubclass, te, ret); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
290 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
291 |
return ret; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
292 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
293 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
294 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
295 |
* Return all subInterfaces of an interface AND fill-in classToSubinterface map. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
296 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
297 |
private Collection<TypeElement> subinterfaces(TypeElement te) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
298 |
Collection<TypeElement> ret = classToSubinterface.get(te); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
299 |
if (ret == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
300 |
ret = new TreeSet<>(utils.makeClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
301 |
Set<TypeElement> subs = classtree.subInterfaces(te); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
302 |
if (subs != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
303 |
ret.addAll(subs); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
304 |
for (TypeElement sub : subs) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
305 |
ret.addAll(subinterfaces(sub)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
306 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
307 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
308 |
addAll(classToSubinterface, te, ret); |
10 | 309 |
} |
310 |
return ret; |
|
311 |
} |
|
312 |
||
313 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
314 |
* Return all implementing classes of an interface (including all subClasses of implementing |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
315 |
* classes and all classes implementing subInterfaces) AND fill-in both classToImplementingClass |
10 | 316 |
* and classToSubinterface maps. |
317 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
318 |
private Collection<TypeElement> implementingClasses(TypeElement te) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
319 |
Collection<TypeElement> ret = classToImplementingClass.get(te); |
10 | 320 |
if (ret == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
321 |
ret = new TreeSet<>(utils.makeClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
322 |
Set<TypeElement> impl = classtree.implementingClasses(te); |
10 | 323 |
if (impl != null) { |
324 |
ret.addAll(impl); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
325 |
for (TypeElement anImpl : impl) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
19667
diff
changeset
|
326 |
ret.addAll(subclasses(anImpl)); |
10 | 327 |
} |
328 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
329 |
for (TypeElement intfc : subinterfaces(te)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
330 |
ret.addAll(implementingClasses(intfc)); |
10 | 331 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
332 |
addAll(classToImplementingClass, te, ret); |
10 | 333 |
} |
334 |
return ret; |
|
335 |
} |
|
336 |
||
337 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
338 |
* Determine classes used by a method or constructor, so they can be inverse mapped. |
10 | 339 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
340 |
private void mapExecutable(ExecutableElement ee) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
341 |
final boolean isConstructor = utils.isConstructor(ee); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
342 |
Set<TypeMirror> classArgs = new TreeSet<>(utils.makeTypeMirrorClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
343 |
for (VariableElement param : ee.getParameters()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
344 |
TypeMirror pType = param.asType(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
345 |
// primitives don't get mapped and type variables are mapped elsewhere |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
346 |
if (!pType.getKind().isPrimitive() && !utils.isTypeVariable(pType)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
347 |
// no duplicates please |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
348 |
if (classArgs.add(pType)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
349 |
new SimpleTypeVisitor9<Void, ExecutableElement>() { |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
350 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
351 |
public Void visitArray(ArrayType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
352 |
return visit(t.getComponentType(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
353 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
354 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
355 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
356 |
public Void visitDeclared(DeclaredType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
357 |
add(isConstructor |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
358 |
? classToConstructorArgs |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
359 |
: classToMethodArgs, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
360 |
(TypeElement) t.asElement(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
361 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
362 |
} |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
363 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
364 |
public Void visitTypeVariable(TypeVariable t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
365 |
visit(typeUtils.erasure(t), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
366 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
367 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
368 |
}.visit(pType, ee); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
369 |
mapTypeParameters(isConstructor |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
370 |
? classToConstructorArgTypeParam |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
371 |
: classToMethodArgTypeParam, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
372 |
pType, ee); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
373 |
} |
10 | 374 |
} |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
375 |
mapAnnotations(isConstructor |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
376 |
? classToConstructorParamAnnotation |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
377 |
: classToMethodParamAnnotation, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
378 |
param, ee); |
26270
a3635e6d3d78
8050031: [javadoc] class-use pages have duplicates and missing entries
ksrini
parents:
25874
diff
changeset
|
379 |
|
10 | 380 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
381 |
for (TypeMirror anException : ee.getThrownTypes()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
382 |
SimpleTypeVisitor9<Void, ExecutableElement> stv = new SimpleTypeVisitor9<Void, ExecutableElement>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
383 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
384 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
385 |
public Void visitArray(ArrayType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
386 |
super.visit(t.getComponentType(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
387 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
388 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
389 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
390 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
391 |
public Void visitDeclared(DeclaredType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
392 |
add(isConstructor ? classToConstructorThrows : classToMethodThrows, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
393 |
(TypeElement) t.asElement(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
394 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
395 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
396 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
397 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
398 |
public Void visitError(ErrorType t, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
399 |
add(isConstructor ? classToConstructorThrows : classToMethodThrows, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
400 |
(TypeElement) t.asElement(), p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
401 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
402 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
403 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
404 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
405 |
protected Void defaultAction(TypeMirror e, ExecutableElement p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
406 |
throw new AssertionError("this should not happen"); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
407 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
408 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
409 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
410 |
stv.visit(typeUtils.erasure(anException), ee); |
10 | 411 |
} |
412 |
} |
|
413 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
414 |
private <T> List<T> refList(Map<TypeElement, List<T>> map, Element element) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
415 |
List<T> list = map.get(element); |
10 | 416 |
if (list == null) { |
22163 | 417 |
list = new ArrayList<>(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
418 |
map.put((TypeElement) element, list); |
10 | 419 |
} |
420 |
return list; |
|
421 |
} |
|
422 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
423 |
private Set<PackageElement> packageSet(TypeElement te) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
424 |
Set<PackageElement> pkgSet = classToPackage.get(te); |
10 | 425 |
if (pkgSet == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
426 |
pkgSet = new TreeSet<>(utils.makeClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
427 |
classToPackage.put(te, pkgSet); |
10 | 428 |
} |
429 |
return pkgSet; |
|
430 |
} |
|
431 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
432 |
private Set<TypeElement> classSet(TypeElement te) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
433 |
Set<TypeElement> clsSet = classToClass.get(te); |
10 | 434 |
if (clsSet == null) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
435 |
clsSet = new TreeSet<>(utils.makeClassUseComparator()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
436 |
classToClass.put(te, clsSet); |
10 | 437 |
} |
438 |
return clsSet; |
|
439 |
} |
|
440 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
441 |
private <T extends Element> void add(Map<TypeElement, List<T>> map, TypeElement te, T ref) { |
10 | 442 |
// add to specified map |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
443 |
refList(map, te).add(ref); |
10 | 444 |
// add ref's package to package map and class map |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
445 |
packageSet(te).add(elementUtils.getPackageOf(ref)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
446 |
TypeElement entry = (utils.isField((Element) ref) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
447 |
|| utils.isConstructor((Element) ref) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
448 |
|| utils.isMethod((Element) ref)) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
449 |
? (TypeElement) ref.getEnclosingElement() |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
450 |
: (TypeElement) ref; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
451 |
classSet(te).add(entry); |
10 | 452 |
} |
453 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
454 |
private void addAll(Map<TypeElement, List<TypeElement>> map, TypeElement te, Collection<TypeElement> refs) { |
10 | 455 |
if (refs == null) { |
456 |
return; |
|
457 |
} |
|
458 |
// add to specified map |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
459 |
refList(map, te).addAll(refs); |
10 | 460 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
461 |
Set<PackageElement> pkgSet = packageSet(te); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
462 |
Set<TypeElement> clsSet = classSet(te); |
10 | 463 |
// add ref's package to package map and class map |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
464 |
for (TypeElement cls : refs) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
465 |
pkgSet.add(utils.containingPackage(cls)); |
868 | 466 |
clsSet.add(cls); |
10 | 467 |
} |
468 |
} |
|
469 |
||
470 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
471 |
* Map the TypeElements to the members that use them as type parameters. |
10 | 472 |
* |
473 |
* @param map the map the insert the information into. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
474 |
* @param element the te whose type parameters are being checked. |
10 | 475 |
* @param holder the holder that owns the type parameters. |
476 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
477 |
private <T extends Element> void mapTypeParameters(final Map<TypeElement, List<T>> map, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
478 |
Element element, final T holder) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
479 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
480 |
SimpleElementVisitor9<Void, Void> elementVisitor |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
481 |
= new SimpleElementVisitor9<Void, Void>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
482 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
483 |
private void addParameters(TypeParameterElement e) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
484 |
for (TypeMirror type : utils.getBounds(e)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
485 |
addTypeParameterToMap(map, type, holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
486 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
487 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
488 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
489 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
490 |
public Void visitType(TypeElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
491 |
for (TypeParameterElement param : e.getTypeParameters()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
492 |
addParameters(param); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
493 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
494 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
495 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
496 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
497 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
498 |
public Void visitExecutable(ExecutableElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
499 |
for (TypeParameterElement param : e.getTypeParameters()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
500 |
addParameters(param); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
501 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
502 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
503 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
504 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
505 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
506 |
protected Void defaultAction(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
507 |
mapTypeParameters(map, e.asType(), holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
508 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
509 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
510 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
511 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
512 |
public Void visitTypeParameter(TypeParameterElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
513 |
addParameters(e); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
514 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
515 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
516 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
517 |
elementVisitor.visit(element); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
518 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
519 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
520 |
private <T extends Element> void mapTypeParameters(final Map<TypeElement, List<T>> map, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
521 |
TypeMirror aType, final T holder) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
522 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
523 |
SimpleTypeVisitor9<Void, Void> tv = new SimpleTypeVisitor9<Void, Void>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
524 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
525 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
526 |
public Void visitWildcard(WildcardType t, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
527 |
TypeMirror bound = t.getExtendsBound(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
528 |
if (bound != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
529 |
addTypeParameterToMap(map, bound, holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
530 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
531 |
bound = t.getSuperBound(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
532 |
if (bound != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
533 |
addTypeParameterToMap(map, bound, holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
534 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
535 |
return null; |
10 | 536 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
537 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
538 |
// ParameterizedType |
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
539 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
540 |
public Void visitDeclared(DeclaredType t, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
541 |
for (TypeMirror targ : t.getTypeArguments()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
542 |
addTypeParameterToMap(map, targ, holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
543 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
544 |
return null; |
10 | 545 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
546 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
547 |
tv.visit(aType); |
10 | 548 |
} |
549 |
||
550 |
/** |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
551 |
* Map the AnnotationType to the members that use them as type parameters. |
10 | 552 |
* |
553 |
* @param map the map the insert the information into. |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
554 |
* @param element whose type parameters are being checked. |
10 | 555 |
* @param holder the holder that owns the type parameters. |
556 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
557 |
private <T extends Element> void mapAnnotations(final Map<TypeElement, List<T>> map, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
558 |
Element e, final T holder) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
559 |
new SimpleElementVisitor9<Void, Void>() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
560 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
561 |
void addAnnotations(Element e) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
562 |
for (AnnotationMirror a : e.getAnnotationMirrors()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
563 |
add(map, (TypeElement) a.getAnnotationType().asElement(), holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
564 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
565 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
566 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
567 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
568 |
public Void visitPackage(PackageElement e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
569 |
for (AnnotationMirror a : e.getAnnotationMirrors()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
570 |
refList(map, a.getAnnotationType().asElement()).add(holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
571 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
572 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
573 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
574 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
575 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
576 |
protected Void defaultAction(Element e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
577 |
addAnnotations(e); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
578 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
579 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
580 |
}.visit(e); |
10 | 581 |
} |
582 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
583 |
private <T extends Element> void addTypeParameterToMap(final Map<TypeElement, List<T>> map, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
584 |
TypeMirror type, final T holder) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
585 |
new SimpleTypeVisitor9<Void, Void>() { |
868 | 586 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
587 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
588 |
protected Void defaultAction(TypeMirror e, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
589 |
return super.defaultAction(e, p); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
590 |
} |
868 | 591 |
|
40606
eb2c81860c86
8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java
jlahoda
parents:
40508
diff
changeset
|
592 |
@Override |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
593 |
public Void visitDeclared(DeclaredType t, Void p) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
594 |
add(map, (TypeElement) t.asElement(), holder); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
595 |
return null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
596 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
597 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
26270
diff
changeset
|
598 |
}.visit(type); |
10 | 599 |
mapTypeParameters(map, type, holder); |
600 |
} |
|
601 |
} |