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

Bug 474918

Summary: [formatter] doesn't align fields in declarations of annotations, enums and anonymous classes
Product: [Eclipse Project] JDT Reporter: Ferry Huberts <mailings>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, jarthana, manoj.palat
Version: 4.5Flags: daniel_megert: pmc_approved+
manoj.palat: review+
Target Milestone: 4.5.1   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/54538
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=80f1e7c4e4b868f26698d3e483443bcf19375a87
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=R4_5_maintenance&id=3639fd3f62bc92c49e5f646d1aba9cc41d2c3ae0
Whiteboard:

Description Ferry Huberts CLA 2015-08-13 12:03:32 EDT
See summary, should be clear enough.
Comment 1 Jay Arthanareeswaran CLA 2015-08-14 06:03:31 EDT
Hmm.. I don't see any problem with build I20150811-1400.

You have an example where you see this? Also, what build did you use?
Comment 2 Ferry Huberts CLA 2015-08-14 06:13:38 EDT
(In reply to Jay Arthanareeswaran from comment #1)
> Hmm.. I don't see any problem with build I20150811-1400.
> 
> You have an example where you see this? Also, what build did you use?

I used the Eclipse Mars release
Comment 3 Mateusz Matela CLA 2015-08-14 13:22:25 EDT
I can confirm, "Align fields on columns" doesn't work for something like this:

public @interface Anno {
	int    aaaaaaaaa;
	String bbbbbbbbb;
}
Comment 4 Ferry Huberts CLA 2015-08-14 13:29:19 EDT
* actual:

package nl.mindef.ahr.interfaceenable.manager;

public @interface Try {
  int aaaaaa = 1;
  String bbbbbbbbb = "default";
}

* expected:

package nl.mindef.ahr.interfaceenable.manager;

public @interface Try {
  int    aaaaaa    = 1;
  String bbbbbbbbb = "default";
}

(simulated by '@interface' -> 'interface'
Comment 5 Mateusz Matela CLA 2015-08-25 17:29:13 EDT
The same problem exists inside anonymous classes and enum declarations.
Also, if a field is initialized with an anonymous class or a lambda expression, its body is not aligned with its header.
Comment 6 Eclipse Genie CLA 2015-08-25 18:02:55 EDT
New Gerrit change created: https://git.eclipse.org/r/54538
Comment 8 Sasikanth Bharadwaj CLA 2015-08-31 04:39:23 EDT
Verified for 4.6 using N20150830-2000 build
Comment 9 Jay Arthanareeswaran CLA 2015-08-31 06:27:56 EDT
I am requesting for PMC approval for 4.5.1

Field alignment is broken, so it would be nice to include this in SR1.
Comment 11 Sasikanth Bharadwaj CLA 2015-09-03 03:52:52 EDT
Verified for 4.5.1 using M20150902-1200 build
Comment 12 Ferry Huberts CLA 2015-10-06 03:31:46 EDT
With Mars.1 the formatter now does NOT restart the alignment after whitespace.
So now ALL fields in the file are aligned.

This is quite annoying to me since my files are divided in 'functional blocks'.

Please fix this so that the alignment is restarted after whitespace