eclipse 代码清理 代码格式化 代码凝视

Code Style包含两个方面:代码清理,代码规范化。代码清理能够參考:

http://www.ibm.com/developerworks/cn/opensource/os-eclipse-clean/

http://jiajun.iteye.com/blog/287803

代码清理过程:

进入eclipse菜单: Window > Preferences > Java > Code Style > Clean Up,点击界面上方的Import,在弹出框中选择位于eclipse安装

路径下的eclipse/cleanup-profile.xml,点击

打开,点击右下角的 Apply 使其生效。

代码格式化过程:

进入eclipse菜单: Window > Preferences > Java > Code Style > Formatter,使用类似上述的方法导入eclipse/formatter-profile.xml,并

使其生效。

设置代码格式化的实现时间,一般为当保存的时候自己主动格式化:

进入eclipse菜单: Window > Preferences > Java > Editor > Save Actions,勾选上Perform the selected actions on save 下的Format 

source code,并选择 Format all lines,勾选上Organize imports,点击右下角的Apply 使其生效。

在eclipse中加入�凝视

(1)在方法上面加入�凝视:

在方法的上面一行输/**,然后回车。

(2)在文件头加入�凝视:

用快捷键 Alt+Shift+J。加入�的凝视格式是能够改动的,通过菜单 Window->Preference 打开參数设置面板,然后选择:Java ->

 Code Style -> Code Templates,在右側选择Comments,选择当中的Types项,然后选右边的"Edit",进入编辑模式。进入编辑模

式后就能够自己定义凝视了。另外能够插入一些变量,如年、日期等等。最后,确保 Code -> New Java files 中

有:"${filecomment}"。


假设没有找到cleanup-profile.xml和formatter-profile.xml,大家能够上网上搜索一下。

一个如今公司的模版:http://download.csdn.net/detail/qilixiang012/7246395

代码清理与格式化配置文件(主要):http://download.csdn.net/detail/qilixiang012/7728385

posted @ 2014-10-19 13:51  hrhguanli  阅读(340)  评论(0编辑  收藏  举报