Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 435241

Summary: [1.8][lambda][formatter] if/else within lambda is incorrectly formatted
Product: [Eclipse Project] JDT Reporter: Brandon Pedersen <bpedman>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, manju656, manoj.palat, noufaln26
Version: 4.4   
Target Milestone: 4.6 M2   
Hardware: PC   
OS: Mac OS X   
Whiteboard: To be verified for 4.6 M4

Description Brandon Pedersen CLA 2014-05-19 23:02:36 EDT
Overview: 
If I have an if/else statement inside a lambda it gets incorrectly formatted with certain formatter settings

Steps To Reproduce:
- Open formatter settings
  - On braces tab select "next line" for blocks
  - On control statements check "Insert new line before 'else' in an 'if' statement
- Create a simple test that uses an if/else inside a lambda, like so:

Executors.newSingleThreadExecutor().execute(() -> {
      if (true)
      {
        System.err.println("foo");
      }
        else
        {
          System.err.println("bar");
        }
      });

Actual results:
Not sure if bugzilla will format this correctly but the above example is what I see. The entire else block is shifted over to the right when it shouldn't be.

Expected results:
The else block should be lined up with the if statement

Build:
Has been happening on Kepler with java 8 patches as well as the 4.4 nightly/integration builds with java 8 added (on a Mac)
Comment 1 Mateusz Matela CLA 2015-09-02 17:49:48 EDT
This issue has been resolved by the formatter redesign bug 303519.

Test case committed via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=f5f144eaadfc3b2a6a242fa2d3bde9667704484e

*** This bug has been marked as a duplicate of bug 303519 ***