Bug 303107 - [formatter] "Never Join Lines" causes Formatter to over-indent braces in Anonymous Inner Classes
Summary: [formatter] "Never Join Lines" causes Formatter to over-indent braces in Anon...
Status: VERIFIED DUPLICATE of bug 286601
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-17 14:17 EST by aaron.clark CLA
Modified: 2010-03-09 06:48 EST (History)
3 users (show)

See Also:


Attachments
Sample file before running formatter (4.39 KB, text/java)
2010-02-17 14:20 EST, aaron.clark CLA
no flags Details
Formatter configuration that demonstrates the bug (28.23 KB, text/xml)
2010-02-17 14:22 EST, aaron.clark CLA
no flags Details

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