Skip to content

Commit

Permalink
Adjust WrongAnnotationUsageProcessor to recognize interceptor binding…
Browse files Browse the repository at this point in the history
…s on nested classes
  • Loading branch information
manovotn committed Jan 3, 2023
1 parent bd66b86 commit 3f06069
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class WrongAnnotationUsageProcessor {

@BuildStep
void detect(ArcConfig config, ApplicationIndexBuildItem applicationIndex, CustomScopeAnnotationsBuildItem scopeAnnotations,
TransformedAnnotationsBuildItem transformedAnnotations, BuildProducer<ValidationErrorBuildItem> validationErrors) {
TransformedAnnotationsBuildItem transformedAnnotations, BuildProducer<ValidationErrorBuildItem> validationErrors,
InterceptorResolverBuildItem interceptorResolverBuildItem) {

if (!config.detectWrongAnnotations) {
return;
Expand Down Expand Up @@ -90,6 +91,16 @@ public String apply(AnnotationInstance annotationInstance) {
new IllegalStateException(String.format(
"The %s class %s declares a producer but it must be ignored per the CDI rules",
clazz.nestingType().toString(), clazz.name().toString()))));
} else {
// detect interceptor bindings on nested classes
for (DotName interceptorBinding : interceptorResolverBuildItem.getInterceptorBindings()) {
if (clazz.annotationsMap().containsKey(interceptorBinding)) {
validationErrors.produce(new ValidationErrorBuildItem(
new IllegalStateException(String.format(
"The %s class %s declares an interceptor binding %s but it must be ignored per CDI rules",
clazz.nestingType().toString(), clazz.name().toString(), interceptorBinding))));
}
}
}
}
}
Expand Down

0 comments on commit 3f06069

Please sign in to comment.