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

Bug 485462

Summary: [formatter] Extra white space after a full lambda body when in a method invocation argument
Product: [Eclipse Project] JDT Reporter: Petr Dolezal <petr.dolezal>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: dusisarath, mateusz.matela
Version: 4.5.1   
Target Milestone: 4.5.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Petr Dolezal CLA 2016-01-08 15:27:34 EST
When a lambda body with braces appears as an argument in a method invocation and other parameter follows, the formatter puts an extra white space between the closing brace of the lambda body and the comma separating it from the next argument. Tested with Eclipse Mars 4.5.1, "Eclipse [built-in]" formatter.


Consider function declaration like this:

void foo(Consumer<Object> s, int dummy);


Invocation like:

foo(o -> { }, 0);

is formatted as:

foo(o -> { } , 0);

Curiously, this does not happen with an anonymous class:

foo(new Consumer<Object>() {
	public void accept(Object o) {
	}
}, 1);

It seems that enabling "white space after block closing brace" overrides disabling "white space before a comma". Guessing that either white space settings for method parameters should have higher precedence, or a special setting(s) for lambda body formatting are needed.
Comment 1 Mateusz Matela CLA 2016-01-08 16:00:01 EST

*** This bug has been marked as a duplicate of bug 475793 ***
Comment 2 Dusi Sarath Chandra CLA 2016-01-18 07:34:44 EST
Verified for Eclipse Mars 4.5.2 Build id: M20160113-1000