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

Bug 303107

Summary: [formatter] "Never Join Lines" causes Formatter to over-indent braces in Anonymous Inner Classes
Product: [Eclipse Project] JDT Reporter: aaron.clark
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jarthana, Olivier_Thomann
Version: 3.5.1   
Target Milestone: 3.6 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Sample file before running formatter
none
Formatter configuration that demonstrates the bug none

Description aaron.clark CLA 2010-02-17 14:17:18 EST
Build Identifier: 20090920-1017

I have the 'never joins lines' option enabled in the formatter preferences with it set to put braces on the next method.  It mangles the opening brace for all blocks inside the anonymous class (specifically class declaration, method declaration, while loops).

Notably, if the opening brace for a method is put on the same line as the method declaration then the first invocation of the formatter correctly drops the bracket to the next line.  A second invocation of the formatter on the already formatted file, indents the bracket by 16 spaces (4 indents).

Example Before Formatting:
        List l = new List()
        {

            @Override
            public boolean add(Object arg0)
            {
                // TODO Auto-generated method stub
                return false;
            }
            ....
        }

Example After Formatting:

       List l = new List()
                        {

            @Override
            public boolean add(Object arg0)
                            {
                // TODO Auto-generated method stub
                return false;
            }
            ....
        }

Reproducible: Always

Steps to Reproduce:
1. Use the attached formatter settings.
2. Open the attached java file in Eclipse
3. From the menu select Source->Format (ctrl+shift+f)

Expected:
The formatter should not change anything.

Actual:
See details.
Comment 1 aaron.clark CLA 2010-02-17 14:20:31 EST
Created attachment 159359 [details]
Sample file before running formatter
Comment 2 aaron.clark CLA 2010-02-17 14:22:35 EST
Created attachment 159361 [details]
Formatter configuration that demonstrates the bug
Comment 3 Olivier Thomann CLA 2010-02-17 17:18:02 EST
I believe this is a duplicate of bug 286601.

*** This bug has been marked as a duplicate of bug 286601 ***
Comment 4 aaron.clark CLA 2010-02-18 08:45:19 EST
(In reply to comment #3)
> I believe this is a duplicate of bug 286601.
> 
> *** This bug has been marked as a duplicate of bug 286601 ***

I believe you are correct.  My apologies for not searching resolved bugs as well as open ones.
Comment 5 Ayushman Jain CLA 2010-03-09 06:23:40 EST
verified for 3.6M6 using build I20100305-1011.
Comment 6 Jay Arthanareeswaran CLA 2010-03-09 06:48:07 EST
Verified