466
467 Set<PackageElement> pkgSet = packageSet(te);
468 Set<TypeElement> clsSet = classSet(te);
469 // add ref's package to package map and class map
470 for (TypeElement cls : refs) {
471 pkgSet.add(utils.containingPackage(cls));
472 clsSet.add(cls);
473 }
474 }
475
476 /**
477 * Map the TypeElements to the members that use them as type parameters.
478 *
479 * @param map the map the insert the information into.
480 * @param element the te whose type parameters are being checked.
481 * @param holder the holder that owns the type parameters.
482 */
483 private <T extends Element> void mapTypeParameters(final Map<TypeElement, List<T>> map,
484 Element element, final T holder) {
485
486 @SuppressWarnings("removal")
487 SimpleElementVisitor14<Void, Void> elementVisitor
488 = new SimpleElementVisitor14<Void, Void>() {
489
490 private void addParameters(TypeParameterElement e) {
491 for (TypeMirror type : utils.getBounds(e)) {
492 addTypeParameterToMap(map, type, holder);
493 }
494 }
495
496 @Override
497 public Void visitType(TypeElement e, Void p) {
498 for (TypeParameterElement param : e.getTypeParameters()) {
499 addParameters(param);
500 }
501 return null;
502 }
503
504 @Override
505 public Void visitExecutable(ExecutableElement e, Void p) {
506 for (TypeParameterElement param : e.getTypeParameters()) {
544
545 // ParameterizedType
546 @Override
547 public Void visitDeclared(DeclaredType t, Void p) {
548 for (TypeMirror targ : t.getTypeArguments()) {
549 addTypeParameterToMap(map, targ, holder);
550 }
551 return null;
552 }
553 };
554 tv.visit(aType);
555 }
556
557 /**
558 * Map the AnnotationType to the members that use them as type parameters.
559 *
560 * @param map the map the insert the information into.
561 * @param e whose type parameters are being checked.
562 * @param holder owning the type parameters.
563 */
564 @SuppressWarnings("removal")
565 private <T extends Element> void mapAnnotations(final Map<TypeElement, List<T>> map,
566 Element e, final T holder) {
567 new SimpleElementVisitor14<Void, Void>() {
568
569 void addAnnotations(Element e) {
570 for (AnnotationMirror a : e.getAnnotationMirrors()) {
571 add(map, (TypeElement) a.getAnnotationType().asElement(), holder);
572 }
573 }
574
575 @Override
576 public Void visitPackage(PackageElement e, Void p) {
577 for (AnnotationMirror a : e.getAnnotationMirrors()) {
578 refList(map, (TypeElement) a.getAnnotationType().asElement()).add(holder);
579 }
580 return null;
581 }
582
583 @Override
584 protected Void defaultAction(Element e, Void p) {
|
466
467 Set<PackageElement> pkgSet = packageSet(te);
468 Set<TypeElement> clsSet = classSet(te);
469 // add ref's package to package map and class map
470 for (TypeElement cls : refs) {
471 pkgSet.add(utils.containingPackage(cls));
472 clsSet.add(cls);
473 }
474 }
475
476 /**
477 * Map the TypeElements to the members that use them as type parameters.
478 *
479 * @param map the map the insert the information into.
480 * @param element the te whose type parameters are being checked.
481 * @param holder the holder that owns the type parameters.
482 */
483 private <T extends Element> void mapTypeParameters(final Map<TypeElement, List<T>> map,
484 Element element, final T holder) {
485
486 @SuppressWarnings("preview")
487 SimpleElementVisitor14<Void, Void> elementVisitor
488 = new SimpleElementVisitor14<Void, Void>() {
489
490 private void addParameters(TypeParameterElement e) {
491 for (TypeMirror type : utils.getBounds(e)) {
492 addTypeParameterToMap(map, type, holder);
493 }
494 }
495
496 @Override
497 public Void visitType(TypeElement e, Void p) {
498 for (TypeParameterElement param : e.getTypeParameters()) {
499 addParameters(param);
500 }
501 return null;
502 }
503
504 @Override
505 public Void visitExecutable(ExecutableElement e, Void p) {
506 for (TypeParameterElement param : e.getTypeParameters()) {
544
545 // ParameterizedType
546 @Override
547 public Void visitDeclared(DeclaredType t, Void p) {
548 for (TypeMirror targ : t.getTypeArguments()) {
549 addTypeParameterToMap(map, targ, holder);
550 }
551 return null;
552 }
553 };
554 tv.visit(aType);
555 }
556
557 /**
558 * Map the AnnotationType to the members that use them as type parameters.
559 *
560 * @param map the map the insert the information into.
561 * @param e whose type parameters are being checked.
562 * @param holder owning the type parameters.
563 */
564 @SuppressWarnings("preview")
565 private <T extends Element> void mapAnnotations(final Map<TypeElement, List<T>> map,
566 Element e, final T holder) {
567 new SimpleElementVisitor14<Void, Void>() {
568
569 void addAnnotations(Element e) {
570 for (AnnotationMirror a : e.getAnnotationMirrors()) {
571 add(map, (TypeElement) a.getAnnotationType().asElement(), holder);
572 }
573 }
574
575 @Override
576 public Void visitPackage(PackageElement e, Void p) {
577 for (AnnotationMirror a : e.getAnnotationMirrors()) {
578 refList(map, (TypeElement) a.getAnnotationType().asElement()).add(holder);
579 }
580 return null;
581 }
582
583 @Override
584 protected Void defaultAction(Element e, Void p) {
|