views:

276

answers:

1

Hi there,

I am using Eclipse to write some Java code and the naming convention that I am following uses an 'm' as a prefix to any member variables for a class. As soon as I write the member variables I like to go to Source -> Generate Getters and Setters. This generates the methods that I require. However, the method and parameter names all include this 'm' prefix too. I would like Eclipse to ignore the prefix when naming my methods and their parameters. How can I achieve this?

UPDATE: I have already tried Rich's suggestion below without any success. Currently the option is set and I have entered 'm' in the fields section. But Eclipse doesn't seem to take this into account. Clicking on the help icon on the same window brings up a notification saying that this will be taken into account when using 'code assist' and 'refactoring'. Does the 'generate getters/setters' come under code assist?

+2  A: 

If you go to Window->Preferences->Java->Code Style and select Fields, then Edit... and add m to the prefix list, your generated accessor methods will take the prefix into account.

Rich Seller
Hi Rich, thanks for the reply. Apologies upfront as I probably should have mentioned that I tried this already. Currently this option is set and I have entered 'm' in the fields section. But Eclipse doesn't seem to take this into account. Clicking on the help icon on the same window brings up a notification saying that this will be taken into account when using 'code assist' and 'refactoring'. Does the 'generate getters/setters' come under code assist?
JBug
It works fine on my box(tm), what platform/version/JVM are you using? (shouldn't make any difference but you never know)
Rich Seller
I am using Eclipse Galileo on Windows Vista Home Premium SP1. JVM is JDK 1.6.0_12. I have Eclipse installed on my Mac too, I'll try the same thing on that to make sure it's not my setup. Will report back in a few hours as I'm headed out for now.
JBug
Hi Rich, I can confirm that it did indeed work on my mac... I think I will try resetting my workspace settings on my Vista box and try again.
JBug