jhipster / prettier-java

Prettier Java Plugin
http://www.jhipster.tech/prettier-java/
Apache License 2.0
1.06k stars 103 forks source link

Comments in parenthesis code block are wrapped on a single line #581

Closed slemouzy closed 4 months ago

slemouzy commented 1 year ago

Prettier-Java 2.1.0

used via spotless with the following config file

{
  "tabWidth": 4,
  "printWidth": 120,
  "trailingComma": "all"
}

Input:

import java.util.List;
import java.util.stream.Collectors;

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List.of(1, 2, 3).stream().map(
                // a very long comment which explains the beatifullness of multiplication by 2
                // yes this is very important
                v -> v * 2
            ).collect(Collectors.summingInt(v -> v))
        );
    }
}

Output:

import java.util.List;
import java.util.stream.Collectors;

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List
                .of(1, 2, 3)
                .stream()
                .map(v -> v * 2 // yes this is very important // a very long comment which explains the beatifullness of multiplication by 2
                )
                .collect(Collectors.summingInt(v -> v))
        );
    }
}

Expected behavior:

public class Test {

    public static final void main(String[] args) {
        System.out.println(
            List
                .of(1, 2, 3)
                .stream()
                .map(
                    // a very long comment which explains the beatifullness of multiplication by 2
                    // yes this is very important
                    v -> v * 2
                )
                .collect(Collectors.summingInt(v -> v))
        );
    }
}

Comments inside parenthesis blocks should remain unaltered like palantir-java-format seems to do.