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 201602

Summary: Add more options to Options > Formatting > Braces Placement
Product: java Reporter: Geertjan Wielenga <geertjan>
Component: SourceAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal CC: jakestay
Priority: P3    
Version: 7.0.1   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: screenshot of 7.3 beta anonymous class layout

Description Geertjan Wielenga 2011-09-04 14:33:47 UTC
Under Options > Formatting > Braces Placement, the only sections are Class Declaration, Method Declaration and Other. What about Array Initializer, Annotations, Try, Catch, Finally, If, Else, etc...? 

I would like to have most of those on a new line, but keep array initializer braces on the same line. 

Or perhaps there should be an option in all cases to respect existing code that has the opening brace on the same line as long as the closing brace is also on that line. 

And I'd like to keep space around the = operator when used for assignment, bbut not when used in annotations.
Comment 1 darkest_fright 2012-05-01 14:44:48 UTC
I find that we need *at least* braces placement for array and anonymous class initializers.  I use the same brace placement for if/for/while/try/catch blocks because semantically, they are more or less the same thing (new scope) but with array and anonymous class initializers the braces mean something different (the interntal definition/state of an instance of an object).
Comment 2 java_dev 2012-12-11 15:16:15 UTC
Created attachment 129212 [details]
screenshot of 7.3 beta anonymous class layout

RFE for anonymous class indentation
Comment 3 java_dev 2012-12-11 15:19:06 UTC
Not sure what happened to my comment that went with that screenshot above. Anyways, what i was adding was an RFE that would permit the anonymous class to be indented such that its defining braces aligned under the "new" keyword. It's pretty self explanatory if you look at the screenshot.
Comment 4 Saucistophe 2015-05-21 22:09:53 UTC
I'd like to see this feature too.
I'm used to braces on the next line, like so:

if (test)
{
   yadda();
}
else
{
   yadda();
}

With the current settings, Array initializations fall in the same category that ifs, fors, whiles, switches... So I can't reasonably choose to keep it on the same line. Thus, my array initializations take 3 ugly lines.

Would it be possible to at least add a separate setting for array and anonymous classes braces, as already requested?

Thanks!
Comment 5 onychomys 2015-09-04 14:12:45 UTC
And here's one more vote for having array initialization treated separately from all the other options!