Identifying problems in your code

In this section, you will review the different indicators for identifying problems in your code.
 
1.
Build problems are always displayed in the Tasks view.  (At this point the Tasks view should be empty.)
2.
Open junit.framework.TestCase.java in the editor from the Package Explorer view.
3.
Add a syntax error by deleting the semicolon at the end of the first line in the file (package junit.framework;).
Editor with missing semicolon
4.
Click the Save button when you are done. The project is incrementally built, and the problem is revealed.
Note: Only the changed file and the files depending on it are recompiled.
5.
The problem is indicated as follows:
  • In the Tasks view, the problems are listed
  • In the Package Explorer view, the Type Hierarchy or the Outline view, problem ticks appear on affected Java elements and their parent elements 
  • In the editor, a problem marker is displayed near the affected line
  • Squiggly lines appear under the word which might cause the error
  • The overview ruler of the editor contains a problem indicator (see picture in step 3 and 6)
  • The editor tabs will also be annotated with a problem marker
Problem marker in Package Explorer, editor and Tasks view
6.
You can hover over the problem marker in the marker bar to view a description of the problem.
Problem marker hover
7.
Click the Close button on the editor's tab to close the editor.
8.
In the Tasks view, select a problem in the list. Open its context menu and select Go To. The file is opened in the editor at the location of the problem.
Tasks view
9.
Correct the problem in the editor by adding back the semicolon, then click the Save button. 
The project is built automatically on save, and all problem indicators in the workbench disappear.
10.
In the Outline view, select the method getName().  The editor will scroll to this method.
11.
On the first line of the method change the returned variable fName to fTestName. 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.
12.
On the marker bar a light bulb marker appears. The light bulb signals that correction proposals are available for this problem.
Light bulb and problem highlight line
13.
Set the cursor inside the marked range and choose Quick Fix from the Edit menu bar. You can also press Ctrl+1 or left click the light bulb. A selection dialog appears with possible corrections.
Correction proposals
14.
Select 'Change to fName' to fix the problem. The problem highlight line will disappear as the correction is applied.
15.
Close the file without saving.
16.
You can enable or disable the various problem indicators under Window > Preferences > Java > Editor > Problem Indication