src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java

Mon, 10 Dec 2012 16:21:26 +0000

author
vromero
date
Mon, 10 Dec 2012 16:21:26 +0000
changeset 1442
fcf89720ae71
parent 1359
25e14ad23cef
child 1985
0e6577980181
permissions
-rw-r--r--

8003967: detect and remove all mutable implicit static enum fields in langtools
Reviewed-by: jjg

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

mercurial