| <!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> |
| Adding new methods |
| </title> |
| <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> |
| </head> |
| <body> |
| <h1> |
| Adding new methods |
| </h1> |
| <ol> |
| <li> |
| Start adding a method by typing the following at the end of the <em>VectorTest.java</em> file (but before the closing |
| brackets of the type) in the Java editor:<br> |
| <code>public void testSizeIsThree()</code><br> |
| As soon as you type the method name in the editor area, the new method appears at the bottom of the Outline view. |
| <p> |
| <img src="../images/qs-13.png" alt="New method in outline view"> |
| </p> |
| In addition, error annotations (red boxes) appear in the overview ruler positioned on the right hand side |
| of the editor. These error annotations indicate that the compilation unit is currently not correct. If you hover |
| over the second red box, a tool tip appears: <em>Unmatched bracket</em>; <em>Syntax error on token ")", |
| { expected after this token</em>, which is correct since the method doesn't have a body yet. Note that error |
| annotations in the editor's rulers are updated as you type. This behavior can be controlled via the |
| <STRONG>Report problems as you type</STRONG> option located on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaEditorPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Goto the Java editor preference page"> |
| <strong>Java > Editor</strong></a> preference page. |
| <p> |
| <img src="../images/qs-13a.png" alt="Error annotations in overview ruler"> |
| </p> |
| |
| </li> |
| <li> |
| Click the <strong>Save</strong> button. The compilation unit is compiled automatically and errors appear in the |
| Package Explorer view, in the Problems view and on the vertical ruler (left hand side of the editor). In the Package |
| Explorer view, the errors are propagated up to the project of the compilation unit containing the error. |
| <p> |
| <img src="../images/qs-14.png" alt="Error propagation in package explorer"> |
| </p> |
| </li> |
| <li> |
| Complete the new method by typing the following:<br> |
| <p><code> |
| {<br> |
| assertTrue(fFull.size() == 3);<br> |
| </code></p> |
| Note that the closing curly bracket has been auto inserted. |
| </li> |
| <li> |
| Save the file. Notice that the error indicators disappear since the |
| missing bracket has been added. |
| </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> |
| </p> |
| <p> |
| <img src="../images/ngrelr.png" alt="Related reference"> |
| </p> |
| <p> |
| <a href="../reference/ref-21.htm">Java Editor Preferences</a><br> |
| </p> |
| |
| </body> |
| </html> |
| |