| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> | |
| <html lang="en"> | |
| <head> | |
| <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2011. 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 the file <em>junit.samples/VectorTest.java</em> 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. | |
| <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> | |
| <h3 class="related">Related concepts</h3> | |
| <a href="../concepts/concept-java-editor.htm">Java editor</a><br> | |
| <h3 class="related">Related references</h3> | |
| <a href="../reference/ref-java-editor-code-assist.htm">Java Content Assist</a><br> | |
| <a href="../reference/preferences/java/ref-preferences-editor.htm">Java Editor Preferences</a><br> | |
| </body> | |
| </html> | |