標籤:style blog http io os ar 使用 java for
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
eclipse 代碼清理 代碼格式化 代碼凝視