Getters and Setters in Eclipse for Hungarian Style

2019-07-18 22:15发布

The project I'm working on dictates hungarian notation for class member variables. Example: String m_foo;

Is it possible to make Eclipse strip the hungarian prefix when generating getters and setters? I'm using Helios and it suggests (not surprisingly) getM_foo and setM_foo, but I want getFoo and setFoo. Code Templates doesn't look helpful.

2条回答
疯言疯语
2楼-- · 2019-07-18 22:41

In the preference page Java>Code Style, in the naming conventions table, select the "Fields" row, press the Edit button, and type "m_" in the Prefix list.

This also helps with Code Assist when generating fields.

You can also specify a prefix for static fields via the same table.

查看更多
The star\"
3楼-- · 2019-07-18 22:51

Go to "Preferences". Find the node "Java" -> "Code Style". Add "m_" to the "Fields" as a prefix.

That should do it!

查看更多
登录 后发表回答