This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 249132

Summary: Inconsistent brace formatting when using lambdas
Product: editor Reporter: _ gtzabari <gtzabari>
Component: Formatting & IndentationAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:
Attachments: Code-formatting configuration

Description _ gtzabari 2014-12-05 01:02:10 UTC
Created attachment 150900 [details]
Code-formatting configuration

Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\8.0.2
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\8.0.2

Here is the source-code alignment I get after code-format:

public PostGeocode getPostalCode()
{
	return postGeocode.orElseGet(() ->
	{
		GeocodeResource geocode = geocodesResource.getByAddress(address);
		Optional<GeocodeState> theState = geocode.get();
		PostGeocode result = theState.map(state -> new PostGeocode(state.getAddress(),
			state.getPostalCode())).orElseGet(() ->
				{
					return null;
			});
		postGeocode = Optional.of(result);
		return result;
	});
}

Notice how the innermost open/close braces do not line up. On the other hand, if you move "() ->" down one line and code-format you end up with:

public PostGeocode getPostalCode()
{
	return postGeocode.orElseGet(() ->
	{
		GeocodeResource geocode = geocodesResource.getByAddress(address);
		Optional<GeocodeState> theState = geocode.get();
		PostGeocode result = theState.map(state -> new PostGeocode(state.getAddress(),
			state.getPostalCode())).orElseGet(
				() ->
				{
					return null;
				});
		postGeocode = Optional.of(result);
		return result;
	});
}

Notice how now the open/close braces line up for the innermost block.

Expected behavior: open/close braces should line up regardless of where "() ->" occurs.