neilcsmith-net opened a new pull request, #9421:
URL: https://github.com/apache/netbeans/pull/9421

   Fixes for two niggles in the reformatter - empty record bodies and nested 
lambda continuation indents.
   
   ### Empty records
   
   Where a record has an empty body with no whitespace -
   
   ```java
   record Foo(int x) {}
   ```
   
   Stop the reformatter turning this into -
   
   ```java
   record Foo(int x) {
   
   }
   ```
   
   This change keeps the original code intact while reformatting all non-empty 
bodies as before.  The change only affects the default same-line brace 
placement.  The other modes are somewhat broken with records already.
   
   NB. The `classLeftBracePlacement` method is removed and the code added to 
the record handling.  Despite its name, this isn't used for non-record classes 
anyway, and while the intention might have been to allow code reuse, the method 
isn't correct for this.
   
   ### Nested lambda continuations
   
   Where code has nested lambdas, such as -
   
   ```java
   public static void main(String[] args) {
       List<String> lines = Stream.of(args)
               .flatMap(s -> s.lines()
                       .filter(l -> !l.isBlank())
               ).toList();
   }
   ```
   
   Stop the reformatter from flattening the continuation indents -
   
   ```java
   public static void main(String[] args) {
       List<String> lines = Stream.of(args)
               .flatMap(s -> s.lines()
               .filter(l -> !l.isBlank())
               ).toList();
   }
   ```
   
   This behaviour is already correct if `wrapAfterLambdaArrow` is set, but not 
in the default case.


-- 
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