Community
Participate
Working Groups
Build Identifier: 20110916-0149 When using 'Generate Constructor using fields...' on an enum with private field the access modifier is disabled and set to private (which is perfectly ok). Afterwards the access modifier is always set to private, even if you use 'Generate Constructor using fields...' on a class. Eclipse should not remember the private access modifier when it is given and disabled. Reproducible: Always Steps to Reproduce: 1. Create an Enum 2. Create a private field 3. Use 'Generate Constructor using fields...' to create the constructor 4. Create a class 5. Create a private field 6. Use 'Generate Constructor using fields...' to create the constructor -> the access modifier is now set to private regardless of the previous setting
Created attachment 216340 [details] Patch to modify SourceActionDialog Proposing a patch. This patch attempts to not save the constructor visibility modifier in preferences when generating constructor for enum types.
Thanks for the patch Samrat. Moving to JDT/UI.
The patch needs some work: - Code formatting - e.printStackTrace() is a no-go. Use JavaPlugin.log(e) if really necessary - Make sure this behaves right for all subclasses of SourceActionDialog. I'm pretty sure the fix is wrong for other source actions, e.g. "Generate Getters and Setters" on an enum type.
Created attachment 216801 [details] Patch to modify SourceActionDialog Markus thanks for your comments. I changed the formatting and removed the printStackTrace. I did not realize that "SETTINGS_VISIBILITY_MODIFIER" was also being used to drive the visibility of other things in different dialogs. Now the code explicitly checks if the dialog is an instanceof GenerateConstructorUsingFieldsSelectionDialog class. This may be a bit ugly, but I think it works for now. Another way could have been moving the close functionality to each of the individual dialog classes that extend SourceActionDialog so that each class can modify the behavior if it wants to. It will require a bit of refactoring.
Just wanted to send out a gentle reminder to review this patch.
Superclasses should generally not refer to individual subclasses. Fixed in a more generic fashion: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=3f6103cca10d4dcdc9f6da6c91e9226a94a02deb