mapstruct-idea
mapstruct-idea copied to clipboard
Bug: smart completion doesn't work for "target" with Lombok @SuperBuilder
Hi, Thank you for great plugin! 👍👍👍 It's really helpful during daily development.
I noticed that Mapstruct IDEA plugin
doesn't support auto-completion for target
attribute in @Mapping
for latest mapstruct
library.
However, auto-completion perfectly works for source
attribute.
I have following setup and dependencies:
- IntelliJ IDEA 2019.2.4
- MapStruct Support IDEA plugin v. 1.1.1
-
org.mapstruct:mapstruct:1.3.1.Final
-
org.projectlombok:lombok:1.18.12
I noticed that Mapstruct Support
stopped suggesting auto-completion after I upgraded mapstruct 1.2.0.Final -> 1.3.1.Final
.
Hey, thanks for the nice words, it is really appreciated.
Are you by any chance using Lombok builders? This might be related to #12.
To rule out Lombok, can you please delombok your class and check whether it is working properly?
Btw, which version of the Lombok plugin are you using? Can you also provide an example classes which are not working so I can try them out?
There is also #39 which seems related as well.
Good questions! I checked these tickets and they are not really related to this issue.
I investigated a bit and discovered that it's directly related to usage of @SuperBuilder
which is experimental lombok feature:
https://projectlombok.org/features/experimental/SuperBuilder
Example that can reproduce this bug:
@Mapper(componentModel = "spring")
public abstract class ExampleMapper {
@Mapping(target = "", source = "fullName")
public abstract ExampleDto toDto(Example source);
//@SuperBuilder
@NoArgsConstructor
static class SuperExampleDto {
}
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
static class ExampleDto extends SuperExampleDto {
private String name;
}
@Getter
@SuperBuilder
static class Example {
private String fullName;
}
}
Also, I checked that if @SuperBuilder
is used on source
object, auto-completion works fine :)
So, the problem only with auto-completion for target
attribute.
Thanks a lot. I'll give it a go with this example. It helps a lot having something that is easily reproducible.
We are using @SuperBuilder
for over a year now in different projects and never had any issues like that.
Seems that something between the plugin version 1.2.0 and 1.4.0 fixed that problem, since the reproducible example cannot be reproduced anymore.
@filiphr I think the ticket can be closed. Should i provide a regression test for this? I've seen no lombok tests, is this out of scope?
Thanks for the information @thunderhook. We don't really have tests with the lombok annotations and this is also a bit out of scope for this project.
I don't remember whether I checked the delomboked sources or not. Most likely it worked correctly. The most likely reason for this not being a problem anymore is that something was fixed in the Lombok IntelliJ plugin or in IntelliJ itself.
In any case, I am going to go ahead and close this issue now.