homberghp opened a new issue, #7043:
URL: https://github.com/apache/netbeans/issues/7043

   ### Apache NetBeans version
   
   Apache NetBeans 20
   
   ### 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.
   
   
![image](https://github.com/apache/netbeans/assets/4232630/fe049bea-cf0a-4c58-8968-dc35b05ffef9)
   
   
   ### 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 <alt-shift-F> on my machine.
   
   
![image](https://github.com/apache/netbeans/assets/4232630/c9fb168f-9b57-461b-b22b-da189944e71c)
   
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Linux Ubunto 22.04 LTS
   
   ### JDK
   
   all since 14
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   The problem is always, 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to