Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 435241 - [1.8][lambda][formatter] if/else within lambda is incorrectly formatted
Summary: [1.8][lambda][formatter] if/else within lambda is incorrectly formatted
Status: CLOSED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Mac OS X
: P3 normal with 5 votes (vote)
Target Milestone: 4.6 M2   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.6 M4
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-19 23:02 EDT by Brandon Pedersen CLA
Modified: 2015-11-07 18:06 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***