Skip to content
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

@Builder methods do not copy javadoc in last @param comment and @Singular and Sub Class #2934

Open
JaesungAhn opened this issue Aug 19, 2021 · 5 comments
Assignees

Comments

@JaesungAhn
Copy link

JaesungAhn commented Aug 19, 2021

related #2481

  1. last @param case
    do not generate last @param field comment
public class Test {
    private String firstField;
    private String secondField;
    private String lastField;

    /**
     * @param firstField Comment First
     * @param secondField Comment Second
     * @param lastField Comment Last
    */
    @Builder
    public Test(final String firstField, final String secondField, final String lastField) {
        this.firstField= firstField;
        this.secondField= secondField;
        this.lastField= lastField;
    }

    private void bla() {
        Test.builder()
            .firstField("a") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .secondField("b") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .lastField("c") // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .build();
    }
}
public class Test {
    private String firstField;
    private String secondField;
    private String lastField;

    /**
     * @param firstField Comment First
     * @param secondField Comment Second
     * @param lastField Comment Last
     * @author user <--- Add any comments at the end. generate javadoc last @param field
    */
    @Builder
    public Test(final String firstField, final String secondField, final String lastField) {
        this.firstField= firstField;
        this.secondField= secondField;
        this.lastField= lastField;
    }

    private void bla() {
        Test.builder()
            .firstField("a") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .secondField("b") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .lastField("c") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .build();
    }
}
  1. @Singular case
    do not generate @Singular field and singular name of this field comment
public class Test {
    private String firstField;
    private List<String> secondField;
    private List<String> lastField;

    /**
     * @param firstField Comment First
     * @param secondField Comment Second
     * @param lastField Comment Last
     * @author user
    */
    @Builder
    public Test(final String firstField, final List<String> secondField, @Singular("addLast") final List<String> lastField) {
        this.firstField= firstField;
        this.secondField= secondField;
        this.lastField= lastField;
    }

    private void bla() {
        Test.builder()
            .firstField("a") // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .secondField(null) // <--- no Javadoc displayed in tooltip without delombok, but delombok would generate Javadoc
            .lastField(null) // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .addLast("c") // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .build();
    }
}
  1. Sub Class case
    do not generate all field comment
public class Test {
    ...~~...

    public static class Sub {
        /** 
         * @param firstField Comment First
         * @param secondField Comment Second
         * @param lastField Comment Last
        */
        @Builder
        public Sub(final String firstField, final String secondField, final String lastField) {
            this.firstField= firstField;
            this.secondField= secondField;
            this.lastField= lastField;
        }
    }
    private void bla() {
        Test.Sub.builder()
            .firstField("a") // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .secondField("b") // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .lastField("c") // <--- no Javadoc displayed in tooltip without delombok, and delombok won't generate Javadoc
            .build();
    }
}
@JaesungAhn JaesungAhn changed the title @Builder methods do not copy javadoc in last @param comment and @Singular @Builder methods do not copy javadoc in last @param comment and @Singular and Sub Class Aug 19, 2021
@Rawi01
Copy link
Collaborator

Rawi01 commented Aug 25, 2021

Can confirm 1 and 2 but was unable to reproduce 3.

@Rawi01 Rawi01 self-assigned this Aug 25, 2021
@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 6, 2021

The singular methods are a bit more complex because we generate multiple methods for the same field/parameter and only have one source comment. I think there are three possible solutions:

  1. Add some special syntax to support multiple comments (most likely hard to understand)
  2. Copy the same comment to both builder methods (might be confusing if the comment is about a collection)
  3. Ignore the singular case and copy the comment only to the regular builder method (no comment at all)

WDYT?

Rawi01 added a commit to Rawi01/lombok that referenced this issue Sep 6, 2021
@JaesungAhn
Copy link
Author

oh.. it's complex...
how about add parameter to @Singular annotation like 'description' or 'javadocComment'?

for example :
@Singular(value="addSome", description="add some to list") final List someList

I think that the solution can be applied to both the constructor parameter and the class field.

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 11, 2021

This should work but it somehow feels wrong to add the javadoc to an annotation. This also means that there are two different locations for comments and that you have to use multiple concatenated strings for longer multiline comments.

@JaesungAhn
Copy link
Author

I agree with you
How about applying the second solution as a base and applying the first solution additionally?
Thanks for your hard work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants