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 - Inconsistent brace formatting when using lambdas
Summary: Inconsistent brace formatting when using lambdas
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-05 01:02 UTC by _ gtzabari
Modified: 2014-12-05 01:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Code-formatting configuration (59.55 KB, text/xml)
2014-12-05 01:02 UTC, _ gtzabari
Details

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