天天看點

【Eclipse】使用指南(7)使用内容助手

(翻譯說明:http://my.oschina.net/ywlaker/blog/468911)

Using content assist

使用内容助手

In this section you will use content assist to finish writing a new method. Open the file junit.samples/VectorTest.java in the Java editor if you do not already have it open and select the

testSizeIsThree()

method in the Outline view. If the file doesn't contain such a method see Adding new methods for instructions on how to add this method.

本小節你将使用内容助手完成新方法的添加。在編輯器中打開junit.samples/VectorTest.java 檔案(如果還沒有打開的話),在Outline視圖中選擇

testSizeIsThree()

方法。如果該源檔案中還沒有該方法,請參考上一節《添加新方法》。

  1. Replace the TODO comment with the following lines.      

    用以下代碼替換TODO注釋。      

    assertTrue(fFull.size() == 3);         Vector v = new Vector();           for (int i=0; i<3; i++)           v.addElement(new Object());           assert          

  2. With your cursor at the end of the word

    assert

    , press Ctrl+Space to activate content assist. The content assist window with a list of proposals will appear. Scroll the list to see the available choices.      

    光标停在單詞 

    assert 

    最後的同時,按下 Alt + / (不是Ctrl + Space)快捷鍵激活内容助手,會出現一個顯示推薦清單的輔助視窗,拖動滾動條可以看到所有可選項。      
    【Eclipse】使用指南(7)使用内容助手
  3. With the content assist window still active, type the letter 't' in the source code after

    assert

    (with no space in between). The list is narrowed and only shows entries starting with 'assert'. Single-click various items in the list to view any available Javadoc help for each item.      

    在輔助視窗仍在的情況下,在單詞

    assert

    後輸入字元t(注意不要有空格),推薦清單的條目會變少但更精确,可單擊條目檢視幫助文檔。      
    【Eclipse】使用指南(7)使用内容助手
  4. Select

    assertTrue(boolean)

    from the list and pressEnter. The code for the

    assertTrue(boolean)

    method is inserted.      

    選擇

    assertTrue(boolean)

    方法并按Enter鍵,該方法的代碼就被插入到編輯器中了。
  5. Complete the line so that it reads as follows:    

    修改方法參數如下:      

    assertTrue(v.size() == fFull.size());

  6. Save the file.    

    儲存檔案。

(完)

轉載于:https://my.oschina.net/ywlaker/blog/470836