【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)快捷键激活内容助手,会出现一个显示推荐列表的辅助窗口,拖动滚动条可以看到所有可选项。      

    image

  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(注意不要有空格),推荐列表的条目会变少但更精确,可单击条目查看帮助文档。      

    image

  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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值