private AnnotationMirror findFirstAnnotation(List<? extends Element> elements, Class<? extends Annotation> annotation) { for (Element element : elements) { AnnotationMirror mirror = ElementUtils.findAnnotationMirror(processingEnv, element, annotation); if (mirror != null) { return mirror; } } return null; }
private AnnotationMirror findFirstAnnotation(List<? extends Element> elements, Class<? extends Annotation> annotation) { for (Element element : elements) { AnnotationMirror mirror = ElementUtils.findAnnotationMirror(processingEnv, element, annotation); if (mirror != null) { return mirror; } } return null; }
private boolean containsSpecializations(List<Element> elements) { boolean foundSpecialization = false; for (ExecutableElement method : ElementFilter.methodsIn(elements)) { if (ElementUtils.findAnnotationMirror(processingEnv, method, Specialization.class) != null) { foundSpecialization = true; break; } } return foundSpecialization; }
private boolean containsSpecializations(List<Element> elements) { boolean foundSpecialization = false; for (ExecutableElement method : ElementFilter.methodsIn(elements)) { if (ElementUtils.findAnnotationMirror(processingEnv, method, Specialization.class) != null) { foundSpecialization = true; break; } } return foundSpecialization; }
public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, Element element, Class<?> annotationClass) { return findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), annotationClass); }
public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeElement expectedAnnotationType) { return findAnnotationMirror(mirrors, expectedAnnotationType.asType()); }
public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, Element element, Class<?> annotationClass) { return findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), annotationClass); }
public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeElement expectedAnnotationType) { return findAnnotationMirror(mirrors, expectedAnnotationType.asType()); }
public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, List<? extends AnnotationMirror> mirrors, Class<?> annotationClass) { TypeElement expectedAnnotationType = processingEnv.getElementUtils().getTypeElement(annotationClass.getCanonicalName()); return findAnnotationMirror(mirrors, expectedAnnotationType.asType()); }
public static AnnotationMirror findAnnotationMirror(ProcessingEnvironment processingEnv, List<? extends AnnotationMirror> mirrors, Class<?> annotationClass) { TypeElement expectedAnnotationType = processingEnv.getElementUtils().getTypeElement(annotationClass.getCanonicalName()); return findAnnotationMirror(mirrors, expectedAnnotationType.asType()); }
@Override public boolean matches(VariableElement variable) { if (ElementUtils.findAnnotationMirror(variable.getAnnotationMirrors(), annotationType) != null) { return true; } return false; }
@Override public boolean matches(VariableElement variable) { if (ElementUtils.findAnnotationMirror(variable.getAnnotationMirrors(), annotationType) != null) { return true; } return false; }
public static List<AnnotationMirror> collectAnnotations(ProcessorContext context, AnnotationMirror markerAnnotation, String elementName, Element element, Class<? extends Annotation> annotationClass) { List<AnnotationMirror> result = new ArrayList<>(); if (markerAnnotation != null) { result.addAll(ElementUtils.getAnnotationValueList(AnnotationMirror.class, markerAnnotation, elementName)); } AnnotationMirror explicit = ElementUtils.findAnnotationMirror(context.getEnvironment(), element, annotationClass); if (explicit != null) { result.add(explicit); } return result; }
public static List<AnnotationMirror> collectAnnotations(ProcessorContext context, AnnotationMirror markerAnnotation, String elementName, Element element, Class<? extends Annotation> annotationClass) { List<AnnotationMirror> result = new ArrayList<>(); if (markerAnnotation != null) { result.addAll(ElementUtils.getAnnotationValueList(AnnotationMirror.class, markerAnnotation, elementName)); } AnnotationMirror explicit = ElementUtils.findAnnotationMirror(context.getEnvironment(), element, annotationClass); if (explicit != null) { result.add(explicit); } return result; }
private void verifyExpectedMessages(ProcessorContext context, Log log, List<Message> msgs) { TypeElement expectError = context.getTruffleTypes().getExpectError(); if (expectError != null) { Element element = getMessageElement(); if (element != null) { AnnotationMirror mirror = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), expectError.asType()); if (mirror != null) { List<String> values = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); if (values == null) { values = Collections.emptyList(); } if (values.size() != msgs.size()) { log.message(Kind.ERROR, element, mirror, ElementUtils.getAnnotationValue(mirror, "value"), String.format("Error count expected %s but was %s.", values.size(), msgs.size())); } } } } }
private void verifyExpectedMessages(ProcessorContext context, Log log, List<Message> msgs) { TypeElement expectError = context.getTruffleTypes().getExpectError(); if (expectError != null) { Element element = getMessageElement(); if (element != null) { AnnotationMirror mirror = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), expectError.asType()); if (mirror != null) { List<String> values = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); if (values == null) { values = Collections.emptyList(); } if (values.size() != msgs.size()) { log.message(Kind.ERROR, element, mirror, ElementUtils.getAnnotationValue(mirror, "value"), String.format("Error count expected %s but was %s.", values.size(), msgs.size())); } } } } }
@Override public final boolean isParsable(ExecutableElement method) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; }
@Override public final boolean isParsable(ExecutableElement method) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; }
@Override public boolean isParsable(ExecutableElement method) { if (getAnnotationType() != null) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; } return true; }
@Override public boolean isParsable(ExecutableElement method) { if (getAnnotationType() != null) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; } return true; }