blob: 60a1b034d9b84cc3bfaa8d0d01135dab55ba007c [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<title>Quick Fix</title>
</head>
<body>
<h1>Quick Fix</h1>
<p>The Java editor offers corrections to problems found while typing and after compiling. To show that
correction proposals are available for a problem or warning, a 'light bulb' is visible on the editor's annotation bar.<br>
Left click on the light bulb or invoking Ctrl+1 (Edit / Quick Fix) brings up the proposals for the problem at the cursor position.<br>
<img src="../images/c-quickfix.gif" width=417 height=206 border="0" alt="Quick fix selection dialog">
</p>
<p>The following quick fixes are available:</p>
<table border="0" cellpadding="10" cellspacing="0" width="700">
<tbody>
<tr>
<td width="20%" valign="top" align="right"><b>Package Declaration</b></td>
<td width="80%" valign="top" align="left">
<ul>
<li>Add missing package declaration or correct package declaration</li>
<li>Move compilation unit to package that corresponds to the package declaration</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Imports</b></td>
<td valign="top" align="left">
<ul>
<li>Remove unused, unresolvable or non-visible import</li>
<li>Invoke 'Organize import' on problems in imports</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Types</b></td>
<td valign="top" align="left">
<ul>
<li>Create new class or interface for references to types that can not be resolved</li>
<li>Change visibility for types that are accessed but not visible</li>
<li>Rename to a similar type for references to types that can not be resolved</li>
<li>Add import statement for types that can not be resolved but exist in the project</li>
<li>Add explicit import statement for ambiguous type references (two import-on-demands for the same type)</li>
<li>If the type name is not matching with the compilation unit name either rename the type or rename the compilation unit</li>
<li>Remove unused private types</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Constructors</b></td>
<td valign="top" align="left">
<ul>
<li>Create new constructor for references to constructors that can not be resolved (this, super or new class creation)</li>
<li>Reorder or remove arguments for constructor references that mismatch parameters</li>
<li>Change method with constructor name to constructor (remove return type)</li>
<li>Change visibility for constructors that are accessed but not visible</li>
<li>Remove unused private constructor</li>
<li>Create constructor when super call of the implicit default constructor is undefined, not visible or throws an exception</li>
<li>If type contains unimplemented methods, change type modifier to 'abstract' or add the method to implement</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Methods</b></td>
<td valign="top" align="left">
<ul>
<li>Create new method for references to methods that can not be resolved</li>
<li>Rename to a similar method for references to methods that can not be resolved</li>
<li>Reorder or remove arguments for method references that mismatch parameters</li>
<li>Correct access (visibility, static) of referenced methods</li>
<li>Remove unused private methods</li>
<li>Correct return type for methods that have a missing return type or where the return type does not match the return statement</li>
<li>Add return statement if missing</li>
<li>For non-abstract methods with no body change to 'abstract' or add body</li>
<li>For an abstract method in a non-abstract type remove abstract modifier of the method or make type abstract</li>
<li>For an abstract/native method with body remove the abstract or native modifier or remove body</li>
<li>Change method access to 'static' if method is invoked inside a constructor invocation (super, this)</li>
<li>Change method access to default access to avoid emulated method access</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Fields and variables</b></td>
<td valign="top" align="left">
<ul>
<li>Correct access (visibility, static) of referenced fields</li>
<li>Create new fields, parameters or local variables for references to variables that can not be resolved</li>
<li>Rename to a variable with similar name for references that can not be resolved</li>
<li>Remove unused private fields</li>
<li>Correct non-static access of static fields</li>
<li>Add 'final' modifier to local variables accessed in outer types</li>
<li>Change field access to default access to avoid emulated method access</li>
<li>Change local variable type to fix a type mismatch</li>
<li>Initialize a variable that has not been initialized</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Exception Handling</b></td>
<td valign="top" align="left">
<ul>
<li>Remove unneeded catch block</li>
<li>Handle uncaught exception by surrounding with try/catch or adding catch block to a surrounding try block</li>
<li>Handle uncaught exception by adding a throw declaration to the parent method or by generalize an existing throw declaration</li>
</ul>
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Others</b></td>
<td valign="top" align="left">
<ul>
<li>Add cast or change cast to fix type mismatches</li>
<li>For non-NLS strings open the NLS wizard or mark as non-NLS</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>Quick Assist are proposals available even if there is no problem or warning: There is no light bulb shown so the user has to know the available assists.</p>
<table border="0" cellpadding="10" cellspacing="0" width="700">
<tbody>
<tr>
<td width="20%" valign="top" align="right"><b>Quick Assists</b></td>
<td width="80%" valign="top" align="left">
<ul>
<li>Replace catch clause with throws declaration on the parent method</li>
<li>Transform an expression statement to an assignment to a new local or new field</li>
<li>Remove surrounding 'if', 'for', 'while', 'do' statement</li>
<li>Remove surrounding try block with a single catch or finally block</li>
<li>Remove surrounding anonymous class, block or parenthesis</li>
<li>Local rename of a type, method or variable in a linked 'template' mode</li>
<li>Surround selected lines with templates (''if', 'while'..)</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>
<img src="../images/ngrelc.gif" width=159 height=27 alt="Related concepts" border="0"><br>
<a href="../concepts/concepts-7.htm">Java editor</a></p><p><img src="../images/ngrelr.gif" width=159 height=27 alt="Related reference" border="0"><br>
<a href="../reference/ref-2.htm">JDT actions</a><a href="../reference/ref-152.htm"></a><br>
</p>
<p><a href="../hglegal2003.htm"><img src="../images/ngibmcpy2003.gif" width=324 height=14 alt="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." border="0"></a></p>
</body>
</html>