| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//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." > |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"> |
| <title> |
| Using Quick Fix |
| </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> |
| Using Quick Fix |
| </h1> |
| To use the Quick Fix feature: |
| <ul> |
| |
| <li>You need to have the |
| <strong>Report problems as you type</strong> checkbox selected 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"> |
| <strong>Java > Editor</strong></a> preference page. |
| </li> |
| <li> |
| In the Java editor, if you see an error or a warning underlined with a squiggly line, position the caret inside the underlined range and do one of the following |
| <ul> |
| <li> |
| Press <kbd>Ctrl+1</kbd> or |
| </li> |
| <li> |
| From the menu bar, select <strong>Edit > Quick Fix</strong> |
| </li> |
| </ul> |
| </li> |
| <li> |
| A list of suggested corrections is presented, with a preview displayed when an entry is selected. |
| </li> |
| <li> |
| Select an entry form the list and press <kbd>Enter</kbd>. |
| </li> |
| </ul> |
| Light bulb icons appear on the left-hand side vertical ruler to indicate Quick Fix'able problems. You can then click on |
| one of the light bulb icons to invoke Quick Fix. |
| <p> |
| <strong>Note:</strong> Occasionally, invoking Quick Fix will not suggest any corrections. A message saying '<strong>No suggestions available</strong>' will be |
| displayed in such cases. |
| </p> |
| |
| <h1> |
| Using Quick Assist |
| </h1> |
| <p> |
| The Java editor also offers some common code changes even when there's no error or warning in your code. |
| For example, set the caret into the <code>if</code> of the following if-else statement, press <kbd>Ctrl+1</kbd>, and select "Change 'if-else' statements to blocks": |
| </p> |
| <pre> |
| String test(int arg) { |
| if (arg > 1000) |
| return "big"; |
| else |
| return "small"; |
| } |
| </pre> |
| <p> |
| Braces are added around the return statements: |
| </p> |
| <pre> |
| String test(int arg) { |
| if (arg > 1000) { |
| return "big"; |
| } else { |
| return "small"; |
| } |
| } |
| </pre> |
| <p> |
| Check out the |
| <a href="../concepts/cquickfix.htm">Available Quick Fix proposals</a> |
| and the |
| <a href="../concepts/cquickassists.htm">Available Quick Assist proposals</a>, or |
| just press <kbd>Ctrl+1</kbd> to see what quick fixes or quick assists Eclipse offers in your current context. |
| </p> |
| |
| <p> |
| <img src="../images/ngrelc.png" alt="Related concepts" border="0" ><br> |
| <a href="../concepts/concepts-7.htm">Java editor</a><br> |
| <a href="../concepts/cquickfix.htm">Available Quick Fix proposals</a><br> |
| <a href="../concepts/cquickassists.htm">Available Quick Assist proposals</a><br> |
| </p> |
| <p> |
| <img src="../images/ngrelt.png" alt="Related tasks" border="0" ><br> |
| <a href="tasks-54.htm">Using the Java editor</a> |
| </p> |
| <p> |
| <img src="../images/ngrelr.png" alt="Related reference" border="0" ><br> |
| <a href="../reference/ref-java-editor-quickfix.htm">Quick Fix</a><br> |
| </p> |
| |
| </body> |
| </html> |
| |