Bug 385901 - [formatter] Indentation: align fields in columns looks awful for class/interface implementations like BroadcastReciever
Summary: [formatter] Indentation: align fields in columns looks awful for class/interf...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-24 19:56 EDT by J.T. Gilkeson CLA
Modified: 2019-12-10 15:56 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J.T. Gilkeson CLA 2012-07-24 19:56:21 EDT
Build Identifier: M20120208-0800

Align fields in columns is great for lining up simple variables; however, it looks awful for variables that have class/interface implementations like BroadcastReciever.  

The class/interface body definition should not be indented by default, or a setting to allow this exception should be provided.  When align fields in columns is off, the class/interface definition that appears on the next line is not indented.  

Here's an example:
private static final String     TAG          = "MyTag";
private SharedPreferences       preferences;
private BroadcastReceiver	myReciever   = new BroadcastReceiver()
                                             {
						@Override
						public void onReceive(Context context, Intent intent)
...
                                             };
Would prefer it to look like:

private static final String     TAG          = "MyTag";
private SharedPreferences       preferences;
private BroadcastReceiver	myReciever   = new BroadcastReceiver()
{
    @Override
    public void onReceive(Context context, Intent intent)
    ...
};




Reproducible: Always

Steps to Reproduce:
1. Create code as above
2. Format Source
3. Observe
Comment 1 Tomasz Zarna CLA 2012-07-31 04:47:54 EDT
Have you tried editing the active formatter profile under Java > Code Style > Formatter ? The number of options there is enormous, so you should be able to create a profile fitting your needs.
Comment 2 J.T. Gilkeson CLA 2012-07-31 05:29:19 EDT
(In reply to comment #1)
> Have you tried editing the active formatter profile under Java > Code Style
> > Formatter ? The number of options there is enormous, so you should be able
> to create a profile fitting your needs.

Yes, this issue concerns one of those options not working as one would expect.
Comment 3 Julian Wright CLA 2015-05-06 00:35:03 EDT
I've had the same problem - my formatting style is also set to align fields in columns, which I'd love to keep for the most part, but it does cause the above problem when I assign a new anonymous version of an Action to a field.

I noticed the formatter now has @formatter:off and @formatter:on tags, which may help in a pinch (and need to be enabled, first), however this isn't the best solution as I do want the anonymous class definition to be formatted - just not indented out to beyond the '='.
Comment 4 Taro Kyo CLA 2019-12-10 15:56:45 EST
This bug title should be changed to:

[formatter] Indentation: Align fields in columns" would format anonymous inner class/interface implementations incorrectly