| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//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." > |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <title> Identifying problems in your code </title> |
| <link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css"> |
| <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> |
| </head> |
| <body> |
| <h1> Identifying problems in your code </h1> |
| <p> In this section, you will review the different indicators for identifying |
| problems in your code. </p> |
| <p>Build problems are displayed in the Problems view and annotated in the vertical |
| ruler of your source code. </p> |
| <ol> |
| <li> Open <em>junit.framework.TestCase.java</em> in the editor from the |
| Package Explorer view. </li> |
| <li> Add a syntax error by deleting the semicolon at the end of the package |
| declaration in the source code. |
| <p> <img src="images/editor_testcase_error_unsaved.png" alt="Editor with missing semicolon"> |
| </p> |
| </li> |
| <li> Click the <strong>Save</strong> button. The project is rebuilt |
| and the problem is indicated in several ways: |
| <ul> |
| <li> In the Problems view, the problems are listed, </li> |
| <li> In the Package Explorer view, the Type Hierarchy or the Outline view, |
| problem ticks appear on the affected Java elements and their parent elements, |
| </li> |
| <li> In the editor's vertical ruler, a problem marker is displayed near the affected line, |
| </li> |
| <li> Squiggly lines appear under the word which might have caused the error, and</li> |
| <li> The editor tab is annotated with a problem marker. </li> |
| </ul> |
| <p><img src="images/workbench_testcase_errors.png" alt="Problem marker in Package Explorer, editor and Tasks view"> |
| </p> |
| </li> |
| <li> You can hover over the problem marker in the vertical ruler to view a description |
| of the problem. |
| <p> <img src="images/editor_testcase_error_hover.png" alt="Problem marker hover"> |
| </p> |
| </li> |
| <li> Click the <strong>Close</strong> ("X") button on the editor's tab to |
| close the editor. </li> |
| <li> In the Problems view, select a problem in the list. Open its context menu |
| and select <strong>Go To</strong>. The file is opened in the editor at the location of the |
| problem. |
| <p> <img src="images/view_problems_goto.png" alt="Problems view"> |
| </p> |
| </li> |
| <li> Correct the problem in the editor by adding the semicolon. Click |
| the <strong>Save</strong> button. The project is rebuilt and the problem indicators disappear. </li> |
| <li> In the Outline view, select the method <em>getName()</em>. The editor will |
| scroll to this method. </li> |
| <li> On the first line of the method change the returned variable <code>fName</code> |
| to <code>fTestName</code>. While you type, a problem highlight underline appears |
| on fTestName, to indicate a problem. Hovering over the highlighted problem |
| will display a description of the problem.</li> |
| <li> On the marker bar a light bulb marker appears. The light bulb signals that |
| correction proposals are available for this problem. |
| <p> <img src="images/editor_testcase_error_getname.png" alt="Light bulb and problem highlight line"> |
| </p> |
| </li> |
| <li> Click to place the cursor onto the highlighted error, and choose <strong>Quick Fix</strong> |
| from the Edit menu bar. You can also press <kbd>Ctrl+1</kbd> or left click the light |
| bulb. A selection dialog appears with possible corrections. |
| <p> <img src="images/editor_testcase_error_getname_quickfix.png" alt="Correction proposals"> |
| </p> |
| </li> |
| <li> Select 'Change to fName' to fix the problem. The problem highlight |
| line will disappear as the correction is applied. </li> |
| <li> Close the file without saving. </li> |
| <li> You can configure how problems are indicated on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.editors.preferencePages.Annotations)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Goto the annotations preference page"> |
| <strong>General > Editors > Text Editors > Annotations</strong></a> |
| preference page.</li> |
| </ol> |
| <P class="nav_footer" id="nav_footer">Next Section: <A href="qs-EditorTemplates.htm">Using code templates</A> |
| </P> |
| |
| <img src="../images/ngrelc.png" alt="Related concepts" border="0"> |
| <p> <a href="../concepts/concepts-7.htm">Java editor</a><br> |
| <a href="../concepts/cjavaviews.htm">Java views</a><br> |
| <a href="../concepts/concepts-4.htm">Java builder</a> </p> |
| |
| <p> <img src="../images/ngrelr.png" alt="Related reference" border="0"> |
| </p> |
| <p> <a href="../reference/ref-21.htm">Editor preference page</a><br> |
| <a href="../reference/ref-java-editor-quickfix.htm">Quick Fix</a> </p> |
| |
| </body> |
| </html> |
| |