blob: 872f24b7e5aafd47d49d2eb022918c630784f70c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>
Using content assist
</title>
</head>
<body>
<h1>
Using content assist
</h1>
<p>
In this section you will use <em>content assist</em> to finish writing a new
method. Open <em>junit.samples.VectorTest.java</em> file in the Java
editor if you do not already have it open and select the <code>testSizeIsThree()</code> method
in the Outline view. If the file doesn't contain such a method see <a href="qs-AddMethod.htm">Adding new methods</a>
for instructions on how to add this method.
</p>
<ol>
<li>
Add the following lines to the end of the method.
When you type the <tt>.</tt> after <tt>v</tt>, Eclipse will show a list of possible completions.
Notice how the options are narrowed down as you continue to type.
<p>
<code>
Vector v = new Vector();<br>
for (int i=0; i&lt;3; i++)<br>
&nbsp;&nbsp;v.addElement(new Object());<br>
assert<br>
</code>
</p>
</li>
<li>
With your cursor at the end of the word <code>assert</code>, press <kbd>Ctrl</kbd>+<kbd>Space</kbd> to activate content assist. The content assist window with a list of
proposals will appear. Scroll the list to see the available choices.
<p>
<img src="../images/qs-16.png" alt="Content assist">
</p>
</li>
<li>
With the content assist window still active, type the letter 't'
in the source code after <code>assert</code> (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.
<p>
<img src="../images/qs-17.png" alt="Content assist filtered">
</p>
</li>
<li>
Select <code>assertTrue(boolean)</code> from the list and press <kbd>Enter</kbd>. The code for the <code>assertTrue(boolean)</code> method is inserted.
</li>
<li>
Complete the line so that it reads as follows:<br>
<p><code>
assertTrue(v.size() == fFull.size());
</code></p>
</li>
<li>
Save the file.
</li>
</ol>
<p>
<img border="0" src="../images/ngrelc.png" alt="Related concepts" >
</p>
<p>
<a href="../concepts/concepts-7.htm">Java editor</a><br>
</p>
<p>
<img src="../images/ngrelt.png" alt="Related tasks" border="0" >
</p>
<p>
<a href="../tasks/tasks-54.htm">Using the Java editor</a><br>
<a href="../tasks/tasks-65.htm">Using content assist</a><br>
</p>
<p>
<img src="../images/ngrelr.png" alt="Related reference">
</p>
<p>
<a href="../reference/ref-143.htm">Java Content Assist</a><br>
<a href="../reference/ref-21.htm">Java Editor Preferences</a><br>
</p>
</body>
</html>