eclipse 代碼清理 代碼格式化 代碼凝視

來源:互聯網
上載者:User

標籤: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 代碼清理 代碼格式化 代碼凝視

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.