-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: support copy @Deprecated #2996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your patience @chenzijia12300. This PR now looks really clean 😄. I've left one comment about the error, which I think that we should not be that strict.
In addition to the comment, can you please revert the changes you've done with the imports in the AdditionalAnnotationsBuilder and try to keep the same order as it was before. We do have some IDE specific settings in https://github.com/mapstruct/mapstruct/blob/main/etc that you can use to have the right formatting and import order. If you are using IntelliJ then you can import https://github.com/mapstruct/mapstruct/blob/main/etc/mapstruct.xml as a code style.
| annotationMirror.getAnnotationType().asElement().toString() ) ).findFirst(); | ||
| if (optionalAnnotationMirror.isPresent() && | ||
| annotations.stream().anyMatch( annotation -> annotation.getType().equals( deprecatedType ) ) ) { | ||
| messager.printMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that for this particular case we don't have to add an error. We can have a warning that is saying that the method is already using @AnnotateWith(Deprecated.class) and that doing it twice is obsolete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filiphr , should the warning take into account the situation where the @Deprecation and the @AnnotateWith don't match?
for example:
@Deprecated( since = "1.5" )
@AnnotateWith(
value = Deprecated.class,
elements = {
@Element( name = "forRemoval", boolean = true ),
@Element( name = "since", string = "1.5.0" )
}
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so when there is a duplicate definition, a warning is raised and the type defined in @AnnotateWith(Deprecated.class) is returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so when there is a duplicate definition, a warning is raised and the type defined in @AnnotateWith(Deprecated.class) is returned
|
I'm missing the 2 annotation elements of Using a |
|
Thank you for your guidance😊 |
|
Just looked at the reason the JDK 8 tests failed. |
Thanks for the suggestion, I'm having a problem with how to exclude certain classes from compiling in a particular |
Indeed that prevents the execution of a specific test class or test method. The processors tests are not run with Java 8, they are only run with Java 11 and later.
Spot on @chenzijia12300. That class is the one that can add additional excludes for the full feature integration test. Keep in mind that you most likely will also need to add an mapstruct/integrationtest/src/test/resources/fullFeatureTest/pom.xml Lines 22 to 28 in 68571de
and mapstruct/integrationtest/src/test/resources/fullFeatureTest/pom.xml Lines 33 to 50 in 68571de
|
Thank you for the tip 😊 |
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes @chenzijia12300. Few more tiny changes and we are ready to merge this.
| /** | ||
| * @author orange add | ||
| */ | ||
| public class DeprecatedTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that there is some small misunderstanding of the use of the integration fullFeatureTest.
The full feature integration test does nothing more than compiling all the mappers that are in our processor test module. However, it doesn't run any tests on its own.
In addition to that, our processor tests are currently only running with Java 11 and later. Which means that we can easily move this test to the package above org.mapstruct.ap.test.annotatewith.deprecated and remove the one from org.mapstruct.ap.test.annotatewith.deprecated.older. I would also remove the @EnabledForJreRange from this tests, since it is not needed.
Can we also please change the names of the mappers a bit. e.g. everything from the older package can just be moved to the package above org.mapstruct.ap.test.annotatewith.deprecated and the prefix Older can be removed. Everything in the newer package can be moved to a different package called java11, remove the prefix Newer and do things like DeprecatedWithAttributesMapper, etc.
I am asking for this in order to reduce some of the additional test complexity and to be immediately clear when someone reads the names of the classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patient guidance, I will correct it
| return annotations; | ||
| } | ||
| List<AnnotationElement> annotationElements = new ArrayList<>(); | ||
| for ( Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : deprecatedGem.mirror() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really need to use the mirror and strings for this. The DeprecatedGem should have methods that allow to have access to the values. You can rewrite the loop to:
if ( deprecatedGem.since().hasValue() ) {
annotationElements.add( new AnnotationElement(
AnnotationElementType.STRING,
"since",
Collections.singletonList( deprecatedGem.since().getValue() )
) );
}
if ( deprecatedGem.forRemoval().hasValue() ) {
annotationElements.add( new AnnotationElement(
AnnotationElementType.BOOLEAN,
"forRemoval",
Collections.singletonList( deprecatedGem.forRemoval().getValue() )
) );
}
filiphr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for all the changes @chenzijia12300. @Zegveld do you have anything extra to add or can I merge this?
|
Thanks @chenzijia12300. We've integrated this into main |
Fixes #2773