-
Notifications
You must be signed in to change notification settings - Fork 917
Description
Apache NetBeans version
Apache NetBeans > 12 (all that support java 14)
What happened
when you have a record, say
record Student( String id, String lastname, String firstname, LocalDate dob ) implements Serializable, Wither<Student, StudentBuilder> {
@Override
public StudentBuilder with() {
return new StudentBuilder(this);
}
}
and you press reformat, then the resulting code looks like this:
record Student( String id, String lastname, String firstname, LocalDate dob) implements Serializable, Wither<Student, StudentBuilder> {
@Override
public StudentBuilder with() {
return new StudentBuilder( this );
}
} // indented wrongly
with the last brace at the wrong place.
This happens if I set spaces within method declaration in the
Options > editor> formatting> spaces > checkbox "method declarations", see below.
I like my code spacious so both in method declaration and calls, because I consider readability paramount.
Language / Project Type / NetBeans Component
java editor
How to reproduce
turn on within parenthesis> Method Declaration and reformat with the well know shortcut or menu.
Shortcut is on my machine.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux Ubuntu 22.04 LTS
Windows 11 with Java 21, Netbeans 20
JDK
all since 14
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
The problem is always there and repeatably reproducible.
If I had a clue how this reformating is implemented I might be able to write a pull request.
For me the reformat tries to be too smart, and considers the code in the record before the first parenthesis as a method declaration too (which it is more or less) and becomes confused when it finds a method declaration before the opening brace of a class, in this case a record.
I would be fine to put spaces inside all pairs of <>, (), [], {}, but that might not be to everyone's taste.
Are you willing to submit a pull request?
No, missing doc on where to find the problem.

