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

Bug 260659

Summary: [formatter] No grouping for code formatter option: `align fields in columns'
Product: [Eclipse Project] JDT Reporter: Lenik <lenik>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: lenik, mateusz.matela, Mike_Wilson
Version: 3.5   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Lenik CLA 2009-01-11 22:03:39 EST
Build ID: I20081211-1908

Steps To Reproduce:
Sorry I didn't find where to put feature request, so I put here. 

The java code formatter supports to align fields in columns, and sometimes fields across the method boundary are aligned in separate positions, for example:
    // A
    int aaa = 2; 
    float b = 3; 
    
    void f() {}

    // B
    int c;
    long d = 3; 
    
is formatted to:
    // A
    int   aaa = 2; 
    float b   = 3; 
    
    void f() {}
    
    // B
    int  c;
    long d = 3; 
    
here group B didn't follow the tabstop position as shown in group A. 
But there is no way to manually specify how to divide the fields into groups, sometimes I want the fields be always aligned across a lot of very small sized methods, and more often, in particular if there declared a serialVersionUID field: 

  private static final long serialVersionUID = 123; 

the field has a really long name, and it expands the following fields too much and results in a very ugly code format. 

As a suggest, fields can be divided into groups by:

1, empty line
  many programmers like to write short comments after the end of field declaration, and so an empty line can just separate two groups:

    int   aaa = 2;  // A...
    float b   = 33; // BB...
    
    int  c; 
    long d = 3; // DD

2, special hint in comment

    int   aaa = 2;  // A...
    float b   = 33; // BB...

    //--

    int  c; 
    long d = 3; // DD



More information:
I've went deep into the org.eclipse.jdt source code, but the code relates to the formatter is really hard to read. And there are two versions of the formatter and they look like in two totally different design. So I abandoned to implement this feature by myself.
Comment 1 Lenik CLA 2009-01-11 22:06:04 EST
and

3, group by different field modifiers, so static and non-static, volatile, public/private/protected etc.  
Comment 2 Mike Wilson CLA 2009-05-05 12:40:19 EDT
Changing Version tag to something more believable. Note that this is not a statement about when the enhancement request will be addressed (the Target Milestone field is used for that); the Version tag should be set to the version of Eclipse you were using when you saw the need for the enhancement.
Comment 3 Mateusz Matela CLA 2016-01-14 17:17:14 EST

*** This bug has been marked as a duplicate of bug 479109 ***