不知道大家在使用eclipse輸入用戶名時(shí)候,有沒有遇到過自動(dòng)補(bǔ)全變量名的問題,前提,設(shè)置了Content Assist,如下:
我每次都是自己刪除補(bǔ)全的變量名的。今天有時(shí)間就搜了下怎么取消eclipse的自動(dòng)補(bǔ)全變量名功能,參考了博客 http://www.cnblogs.com/whunick/p/3632412.html 。
思路:eclipse自動(dòng)補(bǔ)全變量名使用了plugin org.eclipse.jface.text。找到實(shí)際完成此功能的類CompletionProposalPopup,修改后替換plugin。
步驟:
(一)在Eclipse打開Window菜單-->show view -->Others -->Plug-in Development -->Plug-ins。
如下所示:
(二)在plug-ins視圖下找到org.eclipse.jface.text,右鍵import as Source Project ,如下所示。
如何下載插件的源碼呢,可以借助一個(gè)插件來完成,插件名字叫org.freejava.javasourceattacher_1.2.1,可以從 http://svn.codespot.com/a/eclipselabs.org/free-plugins/trunk/site/plugin... 下載,具體介紹可以參考源鏈接: http://www.javaworld.com/article/2075958/open-source-tools/open-source-eclipse-plugin-for-download-library-source-code-automatically.html 。
官方介紹:
Install plugin: - Use Update site URL: http://svn.codespot.com/a/eclipselabs.org/free-plugins/trunk/site/ - Or download offline: download plugin from http://svn.codespot.com/a/eclipselabs.org/free-plugins/trunk/site/plugin... and save it to eclipse/dropins/ folder then restart Eclipse. Usage: Right click on a Java library of a Java-based project and choose the menu item "Attach Java Source" and wait for the source code to be downloaded/attached to the library automatically
下載后把插件放到eclipse的dropins目錄,重啟eclipse,在剛才的項(xiàng)目org.eclipse.jface.text下的org.eclipse.jface.text_3.7.0.v20110505-0800.jar右鍵,選擇Attach Java Source,插件自動(dòng)下載。下載的目錄在C:\Documents and Settings\Administrator\.sourceattacher\下面,可以從eclipse的Error Log看到。
找到源碼位置,解壓,在eclipse新建一個(gè)Java項(xiàng)目,把org文件夾復(fù)制到項(xiàng)目的src下面,其他文件夾復(fù)制到src父文件夾下面,打開org.eclipse.jface.text_3.7.0.v20110505-0800.jar把用META-INF下的文件覆蓋項(xiàng)目的META-INF文件夾。
在項(xiàng)目右擊,選擇build path-->configure build path,在libraries下面點(diǎn)擊add library,選擇plug-in dependencies,點(diǎn)擊finish。如下所示:
(三)找到CompletionProposalPopup類,路徑src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java,找到這樣一行代碼
char[] triggers = t.getTriggerCharacter(); if(contains(triggers,key))
if 里判斷你按下的鍵(key)是否在triggers 中,如果是,就觸發(fā)第一行提示的
代碼。于是,我們只要在這里排除掉空格和=號(hào)即可,如下:
char[] triggers= t.getTriggerCharacters();if ((key != '=') &&(key != 0x20)&&contains(triggers, key))
修改成這樣,空格和等號(hào)就不會(huì)觸發(fā)自動(dòng)補(bǔ)全了。
如下所示:
(四)保存后導(dǎo)出,替換org.eclipse.jface.text_3.7.0.v20110505-0800.jar里面的
CompletionProposalPopup類,導(dǎo)出是普通的Export-->Jar File
然后使用壓縮軟件打開org.eclipse.jface.text_3.7.0.v20110505-0800.jar把新生成的CompletionProposalPopup類替換掉老的class,注意把CompletionProposalPopup$.*.class之類的也替換掉,保存后,替換掉eclipse的plugins下面的org.eclipse.jface.text_3.7.0.v20110505-0800.jar,替換之前注意備份org.eclipse.jface.text_3.7.0.v20110505-0800.jar。
重啟Eclipse,大功告成,現(xiàn)在按=就可以了,再也不要自己去刪掉補(bǔ)全的部分了。
本文系原創(chuàng),轉(zhuǎn)載請(qǐng)注明出處,謝謝。
聯(lián)系客服