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

[BUG] @Getter/@Setter Javadocs can't handle line breaks properly in @param/@return #2443

Comments

@jmitash
Copy link

jmitash commented Apr 27, 2020

Describe the bug
With #132, the following feature was added:

NEW in lombok v1.12.0: javadoc on the field will now be copied to generated getters and setters. Normally, all text is copied, and @return is moved to the getter, whilst @param lines are moved to the setter. Moved means: Deleted from the field's javadoc.

However, if the @param or @return has multiple lines, only the first line is moved to the getter/setter.

To Reproduce
Using the following ExampleFile.java:

import java.util.List;

import lombok.Getter;
import lombok.Setter;

/**
 * @author Jacob Mitash
 */
@Getter
@Setter
public class ExampleFile {

    /**
     * This is a list of booleans.
     *
     * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
     *        long enough to wrap to multiple lines.
     * @return A list of booleans to set for this object. This is a Javadoc return that is long
     *         enough to wrap to multiple lines.
     */
    private List<Boolean> booleans;
}

Run delombok on the file (I used the Maven plugin). The output file is:

import java.util.List;

/**
 * @author Jacob Mitash
 */
public class ExampleFile {
    /**
     * This is a list of booleans.
     *
     *        long enough to wrap to multiple lines.
     *
     *         enough to wrap to multiple lines.
     */
    private List<Boolean> booleans;

    /**
     * This is a list of booleans.
     *
     *        long enough to wrap to multiple lines.
     * @return A list of booleans to set for this object. This is a Javadoc return that is long
     *         enough to wrap to multiple lines.
     */
    @java.lang.SuppressWarnings("all")
    public List<Boolean> getBooleans() {
        return this.booleans;
    }

    /**
     * This is a list of booleans.
     *
     * @param booleans A list of booleans to set for this object. This is a Javadoc param that is
     *        long enough to wrap to multiple lines.
     *
     *         enough to wrap to multiple lines.
     */
    @java.lang.SuppressWarnings("all")
    public void setBooleans(final List<Boolean> booleans) {
        this.booleans = booleans;
    }
}

Expected behavior

  • The booleans Javadoc should not have the "[long] enough to wrap to multiple lines." lines
  • The getBooleans() Javadoc should not have the "long enough to wrap to multiple lines." line
  • The setBooleans() Javadoc should not have the "enough to wrap to multiple lines." line

Version info

  • Lombok version: 1.18.10
  • Platform:
    • OS: macOS 10.14.3
    • javac -version: javac 1.8.0_181
@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 22, 2020

You are right, the regular expression to remove the tags only removes one line. I have updated it to also remove additional lines and restructured the code a little bit. I will provide a PR as soon as my latest javadoc related changes are merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment