(翻译说明: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()
方法。如果该源文件中还没有该方法,请参考上一节《添加新方法》。
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());
assertWith 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)快捷键激活内容助手,会出现一个显示推荐列表的辅助窗口,拖动滚动条可以看到所有可选项。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(注意不要有空格),推荐列表的条目会变少但更精确,可单击条目查看帮助文档。Select
assertTrue(boolean)
from the list and pressEnter. The code for theassertTrue(boolean)
method is inserted.
选择assertTrue(boolean)
方法并按Enter键,该方法的代码就被插入到编辑器中了。Complete the line so that it reads as follows:
修改方法参数如下:assertTrue(v.size() == fFull.size());
Save the file.
保存文件。
(完)