Member variable prefix wrongly added to method name
Asked Answered
C

1

11

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?

Closeup answered 11/7, 2009 at 16:11 Comment(1)
You should report this as a bug if still not working in windows : bugs.eclipse.org. Otherwise accapt the answer by Rich !Corkscrew
G
21

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.

Gaillard answered 11/7, 2009 at 16:19 Comment(5)
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?Closeup
It works fine on my box(tm), what platform/version/JVM are you using? (shouldn't make any difference but you never know)Gaillard
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.Closeup
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.Closeup
For what it is worth this works fine for me and I would guess most cases.Saguenay

© 2022 - 2024 — McMap. All rights reserved.