Describe the bug
@Builder on a class while having a javadoc comment on a field, the resulting builder method does not show the javadoc of the field. (Delombok generates a javadoc comment in this case.)@Builder on a constructor while having a javadoc comment on a constructor parameter, the resulting builder method does not show the javadoc of the parameter. (Neither Delombok not the Eclipse agent generate a javadoc comment in this case.)To Reproduce
@Builder on class:@lombok.Builder
public class Test1 {
/** Comment on Field */
private int number;
/** @param number Comment on Constructor */
public Test1(final int number) {
this.number = number;
}
private void bla() {
Test1.builder()
.number(1) // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
.build();
}
}
@Builder on constructor:public class Test2 {
/** Comment on Field */
private int number;
/** @param number Comment on Constructor */
@lombok.Builder
public Test2(final int number) {
this.number = number;
}
private void bla() {
Test2.builder()
.number(1) // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
.build();
}
}
Expected behavior
@Builder on a class while having a javadoc comment on a field, the resulting builder method should have a javadoc comment which contains the javadoc of the field. This should be consistent with the delombok behaviour (which generates a javadoc comment from the field's javadoc).@Builder on a constructor while having a javadoc comment on a constructor parameter, the resulting builder method should have a javadoc comment which contains the javadoc of the parameter. This seems to be completely missing - neither delombok nor the Eclipse agent generate javadoc in this case.@Builder on the constructor, so the information should come from there.)Version info (please complete the following information):
Additional context
I know that #2008 should have addressed this issue and was baffled when I learned that it doesn't work - at least for me. I also read through #1033 and #1445 but didn't find out how I may have failed, but I'm not a Lombok expert, so please tell me if I missed something!
The PR you mentioned added support for delombok/javac and doesn't change anything eclipse related. I can confirm that it doesn't work in eclipse. I also tried to find a feature that successfully copies javadoc but it seems to be broken or I did something wrong. I will check if I can figure out how this stuff works.
I just tested using delombok, and it works for the first described situation (@Builder on class). But when using @Builder on a constructor, nothing is copied into the javadoc of the builder method - neither from the field nor from the constructor's @param entry.
I updated the issue accordingly.
Seems like you are right.
If @Builder gets added to the constructor we can not identify the field because it might be named different or be part of the parent class. That means that it is not possible to copy the field javadoc. Nevertheless it should be possible to copy the parameter javadoc to the builder method, that might look like this one:
/**
* @param number Comment on Constructor
* @return {@code this}.
*/
public Test2.Test2Builder number(final int number) {
this.number = number;
return this;
}
Is that the behaviour you would expect?
Yes, that is exactly what I expect.
Working on it right now, should be done soon
Most helpful comment
Working on it right now, should be done soon