| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> |
| <html> |
| <head> |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. 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> |
| Replace the <tt>TODO</tt> comment with the following lines. |
| When you type the <tt>.</tt> after <tt>fFull</tt>, Eclipse will show a list of possible completions. |
| Notice how the options are narrowed down as you continue to type. |
| <p> |
| <code> |
| assertTrue(fFull.size() == 3);<br> |
| Vector v = new Vector();<br> |
| for (int i=0; i<3; i++)<br> |
| 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+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/editor_vectortest_content_assist.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/editor_vectortest_content_assist_t.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 class="nav_footer" id="nav_footer">Next Section: <A href="qs-7.htm">Identifying problems in your code</A> |
| </P> |
| <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/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> |
| |