mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#297 check presence of @Mapper annotation
This commit is contained in:
parent
33abe5faaf
commit
2ca4ce5fd5
@ -42,6 +42,7 @@ import javax.tools.Diagnostic.Kind;
|
||||
import org.mapstruct.ap.model.Mapper;
|
||||
import org.mapstruct.ap.option.Options;
|
||||
import org.mapstruct.ap.option.ReportingPolicy;
|
||||
import org.mapstruct.ap.prism.MapperPrism;
|
||||
import org.mapstruct.ap.processor.DefaultModelElementProcessorContext;
|
||||
import org.mapstruct.ap.processor.ModelElementProcessor;
|
||||
import org.mapstruct.ap.processor.ModelElementProcessor.ProcessorContext;
|
||||
@ -134,6 +135,12 @@ public class MappingProcessor extends AbstractProcessor {
|
||||
for ( Element mapperElement : roundEnvironment.getElementsAnnotatedWith( annotation ) ) {
|
||||
TypeElement mapperTypeElement = asTypeElement( mapperElement );
|
||||
|
||||
// on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with
|
||||
// annotations unknown to the compiler, even though they are not declared Mappers
|
||||
if ( MapperPrism.getInstanceOn( mapperTypeElement ) == null ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// create a new context for each generated mapper in order to have imports of referenced types
|
||||
// correctly managed;
|
||||
// note that this assumes that a new source file is created for each mapper which must not
|
||||
|
Loading…
x
Reference in New Issue
Block a user