Getters and Setters in Eclipse for Hungarian Style Members

被刻印的时光 ゝ 提交于 2019-12-12 16:54:47

问题


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.


回答1:


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.




回答2:


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

That should do it!



来源:https://stackoverflow.com/questions/7784103/getters-and-setters-in-eclipse-for-hungarian-style-members

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!