comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 19284:b339d723a06b

Truffle-DSL: refactor ElementUtils#findAnnotationMirror
author Christian Humer <christian.humer@gmail.com>
date Thu, 29 Jan 2015 19:07:58 +0100
parents 08aa0372dad4
children 62c43fcf5be2
comparison
equal deleted inserted replaced
19283:08aa0372dad4 19284:b339d723a06b
853 return findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), annotationClass); 853 return findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), annotationClass);
854 } 854 }
855 855
856 public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, List<? extends AnnotationMirror> mirrors, Class<?> annotationClass) { 856 public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, List<? extends AnnotationMirror> mirrors, Class<?> annotationClass) {
857 TypeElement expectedAnnotationType = processingEnv.getElementUtils().getTypeElement(annotationClass.getCanonicalName()); 857 TypeElement expectedAnnotationType = processingEnv.getElementUtils().getTypeElement(annotationClass.getCanonicalName());
858 return findAnnotationMirror(mirrors, expectedAnnotationType); 858 return findAnnotationMirror(mirrors, expectedAnnotationType.asType());
859 } 859 }
860 860
861 public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeElement expectedAnnotationType) { 861 public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeElement expectedAnnotationType) {
862 return findAnnotationMirror(mirrors, expectedAnnotationType.asType());
863 }
864
865 public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeMirror expectedAnnotationType) {
862 for (AnnotationMirror mirror : mirrors) { 866 for (AnnotationMirror mirror : mirrors) {
863 DeclaredType annotationType = mirror.getAnnotationType(); 867 if (typeEquals(mirror.getAnnotationType(), expectedAnnotationType)) {
864 TypeElement actualAnnotationType = (TypeElement) annotationType.asElement();
865 if (actualAnnotationType.equals(expectedAnnotationType)) {
866 return mirror; 868 return mirror;
867 } 869 }
868 } 870 }
869 return null; 871 return null;
870 } 872 }