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