| <!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-Language" content="en-us"> |
| <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>Tips and Tricks</title> |
| <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script> |
| </head> |
| |
| <body> |
| |
| <h2>Tips and Tricks</h2> |
| <table border="0" cellpadding="8"> |
| <tbody> |
| <tr> |
| <td width="16%" align="center"><a href="#editing_section">Editing</a></td> |
| <td width="16%" align="center"><a href="#searching_section">Searching</a></td> |
| <td width="16%" align="center"><a href="#navigation_section">Navigation</a></td> |
| <td width="16%" align="center"><a href="#views_section">Views</a></td> |
| <td width="16%" align="center"><a href="#debugging_section">Debugging</a></td> |
| <td width="16%" align="center"><a href="#misc_section">Miscellaneous</a></td> |
| </tr> |
| </tbody> |
| </table> |
| <h3><a name="editing_section"></a>Editing source</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" bgcolor="white"> |
| <tbody> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Content assist</b></td> |
| <td valign="top" align="left" width="80%">Content assist provides you |
| with a list of suggested completions for partially entered strings. |
| In the Java editor press <b>Ctrl+Space</b> or invoke <b>Edit > |
| Content Assist</b>. |
| <p><img src="images/code-assist.png" border="0" alt="Content assist selection dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Content assist in |
| Javadoc comments</b></td> |
| <td valign="top" align="left" width="80%">Content assist is also |
| available in Javadoc comments. |
| <p><img src="images/code-assist-javadoc2.png" border="0" alt="Content assist for Javadoc comments"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Suppress types in code |
| assist</b></td> |
| <td valign="top" align="left" width="80%"> |
| <p>To exclude certain types from appearing in content assist, use the type |
| filter feature configured on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.TypeFilterPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Appearance > Type Filters</b></a> |
| preference page. Types matching one of these filter patterns |
| will not appear in the Open Type dialog and will not be available to |
| code assist, quick fix and organize imports. These filter patterns |
| do not affect the Package Explorer and Type Hierarchy views.</p> |
| <img border="0" src="images/type-filter.png" alt="Type filter preference page"></td> |
| |
| </tr> |
| <tr> |
| |
| <td width="20%" valign="top" align="left"><b>Content assist for |
| variable, method parameter and field name completions</b></td> |
| |
| <td valign="top" align="left" width="80%"> |
| <p>You can use content assist to speed up the creation of fields, method |
| parameters and local variables. With the cursor positioned after the |
| type name of the declaration, invoke <b>Edit > Content Assist</b> |
| or press <b>Ctrl+Space</b>.</p> |
| <p><img src="images/code-assist-fieldname.png" alt="Suggestions for field names"> |
| </p> |
| <p>If you use a name prefix or suffix for fields, local variables or |
| method parameters, be sure to specify this in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> |
| preference page.</p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Parameter Hints</b></td> |
| <td valign="top" align="left" width="80%">With the cursor in a method |
| argument, you can see a list of parameter hints. In the Java Editor |
| press <b>Ctrl+Shift+Space</b> or invoke <b>Edit > Parameter Hints</b>. |
| <p><img src="images/parameter-hints.png" border="0" alt="Parameter hint hover"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Content assist on |
| anonymous classes</b></td> |
| <td valign="top" align="left" width="80%">Content assist also |
| provides help when creating an anonymous class. With the cursor |
| positioned after the opening bracket of a class instance creation, |
| invoke <b>Edit > Content Assist</b> or press <b>Ctrl+Space</b>. |
| <p><img src="images/code-assist-anonym.png" border="0" alt="Content assist for an anonymous class"> |
| </p> |
| This will create the body of the anonymous inner class including all |
| methods that need to be implemented.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Toggle between |
| inserting and replacing code assist</b></td> |
| |
| <td valign="top" align="left" width="80%">When content assist is invoked |
| on an existing identifier, it can either replace the |
| identifier with the chosen completion or do an insert. The |
| default behavior (overwrite or insert) is defined in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeAssistPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Content Assist</b></a> preference page.<br> |
| You can temporarily toggle the behavior while inside the content |
| assist selection dialog by pressing and holding the <b>Ctrl</b> key while |
| selecting the completion.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Incremental content |
| assist</b></td> |
| |
| <td>Per default, content assist will now <b>Insert common prefixes automatically</b>, similar to |
| Unix shell expansion. To change that behavior uncheck the setting on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeAssistPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Content Assist</b></a> preference page.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Create Getter and |
| Setters dialog</b></td> |
| <td valign="top" align="left" width="80%">To create getter and setter |
| methods for a field, select the field's declaration and invoke <b>Source |
| > Generate Getter and Setter</b>. |
| <p><img src="images/create-getter-setter.png" border="0" alt="Generate Getter and Setter dialog"> |
| </p> |
| If you use a name prefix or suffix be sure to specify this in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> |
| preference page.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use content assist to |
| create Getter and Setters</b></td> |
| <td valign="top" align="left" width="80%">Another way to create |
| getters and setters is using content assist. Set the cursor in the |
| type body between members and press <b>Ctrl+Space</b> to get the proposals |
| that create a getter or setter method stub. <br> |
| <img border="0" src="images/codeassist-getter.png" alt="Code assist for creating a setter"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Delete Getters and |
| Setters together with a field</b></td> |
| |
| <td valign="top" align="left" width="80%">When you delete a field |
| from within a view, |
| Eclipse can propose deleting its Getter and Setter methods. |
| If you use a name prefix or suffix for fields, be sure to specify this in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> |
| preference page.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Create delegate methods</b></td> |
| <td valign="top" align="left" width="80%">To create a delegate method |
| for a field select the field's declaration and invoke <b>Source > |
| <b>Generate Delegate Methods</b></b>. This adds the selected methods |
| to the type that contains a forward call to delegated methods. This |
| is an example of a delegate method: <br> |
| <img src="images/delegate-method.png" border="0" alt="Delegate method example"> |
| <TT></TT></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Drag & Drop for |
| refactoring</b></td> |
| <td valign="top" align="left" width="80%">You can move Java |
| compilation units between packages by Drag & Drop - all missing |
| imports will be added and references updated.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Drag & Drop to |
| move and copy Java code elements</b></td> |
| <td valign="top" align="left" width="80%">You can move and copy Java |
| elements such as methods and fields by Drag & Drop. This will not |
| trigger refactoring - only the code will be copied or moved.</td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Templates to create |
| a method</b></td> |
| <td valign="top" align="left" width="80%">You can define a new |
| template that contains a method stub using the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Templates</b></a> preference page. |
| Templates are shown together with the <b>Content |
| Assist (Ctrl+Space)</b> proposals.<br> |
| There are also existing templates, such as 'private_method', |
| 'public_method', 'protected_method' and more.<br> |
| Use the <b>Tab</b> key to navigate between the values to enter |
| (return type, name and arguments). |
| <p><img src="images/templates-create-method.png" border="0" alt="Content assist with new method template proposals"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Quick Fix to create |
| a new method</b></td> |
| <td valign="top" align="left" width="80%">Start with the method |
| invocation and use <b>Quick Fix (Ctrl+1)</b> to create the method. |
| <p><img src="images/quick-fix-create-method.png" border="0" alt="'Create method' quick fix"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Quick Fix to change |
| a method signature</b></td> |
| <td valign="top" align="left" width="80%">Add an argument to a method |
| invocation at a call site. Then use <b>Quick Fix (Ctrl+1)</b> to add the |
| required parameter in the method declaration. |
| <p><img src="images/quickfix-change-signature.png" border="0" alt="'Change signature' quick fix"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Content Assist to |
| create a constructor stub</b></td> |
| <td valign="top" align="left" width="80%">At the location where you |
| want to add the new constructor, use code assist after typing the |
| first letters of the constructor name.<br> |
| <img border="0" src="images/code-assist-add-constructor.png" alt="Create constructor on code assist"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Create new fields from |
| parameters</b></td> |
| <td valign="top" align="left" width="80%">Do you need to create new |
| fields to store the arguments passed in the constructor? Use <b>Quick |
| Assist (Ctrl+1)</b> on a parameter to create the assignment and the |
| field declaration and let Eclipse propose a name according to your Code |
| Style preferences.<br> |
| <img border="0" src="images/quick-assist-create-field.png" alt="'Assign parameter to new field' quick assist"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Content Assist to |
| override a method</b></td> |
| <td valign="top" align="left" width="80%">Invoke <b>Content Assist |
| (Ctrl+Space)</b> in the type body at the location where the method |
| should be added. Content assist will offer all methods that can be |
| overridden. A method body for the chosen method will be created. |
| <p><img src="images/code-assist-newmethod.png" border="0" alt="'Override method' content assist"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Quick Fix to add |
| unimplemented methods</b></td> |
| <td valign="top" align="left" width="80%">To implement a new |
| interface, add the 'implements' declaration first to the type. |
| Even without saving or building, the Java editor will underline the |
| type to signal that methods are missing and will show the Quick Fix |
| light bulb. Click on the light bulb or press <b>Ctrl+1 (Edit > |
| Quick Fix)</b> to choose between adding the unimplemented methods or |
| making your class abstract. |
| <p><img src="images/quick-fix-unimplemented-methods.png" border="0" alt="Quick Fix offering 'Add unimplemented methods' proposal"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Override a method |
| from a base class</b></td> |
| <td valign="top" align="left" width="80%">To create a method that |
| overrides a method from a base class: <br> |
| Select the type where the methods should be added and invoke <b>Source > |
| Override / Implement Methods</b>. This opens a dialog that lets you |
| choose which methods to override. |
| <p><img src="images/override-method.png" border="0" alt="'Override / Implement method' dialog"> |
| </p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Rename in File</b></td><td valign="top" align="left" width="80%">To quickly do a rename that |
| doesn't require full analysis of dependencies in other files, use the |
| 'rename in file' Quick Assist. In the Java Editor, position the |
| cursor in an identifier of a variable, method or type and press <b>Ctrl+1 |
| (Edit > Quick Fix)</b><br> |
| The editor is switched to the linked edit mode (like templates) and |
| changing the identifier simultaneously changes all other references |
| to that variable, method or type. |
| <p><img src="images/quick-fix-localrename.png" border="0" alt="Changing multiple identifiers using 'Local Rename' quick fix"> |
| </p> |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use Quick Fix to handle |
| exceptions</b></td> |
| <td width="80%" valign="top">Dealing with thrown exceptions is |
| easy. Unhandled exceptions are detected while typing and marked with |
| a red line in the editor. |
| <ul> |
| <li>Click on the light bulb or press <b>Ctrl+1</b> to surround the |
| call with a try catch block. If you want to include more statements |
| in the try block, select the statements and use <b>Source > |
| Surround With try/catch Block</b>. You can also select individual |
| statements by using <b>Edit > Expand Selection to </b> and |
| selecting <b>Enclosing</b>, <b>Next</b> or <b>Previous</b>.</li> |
| <li>If the call is already surrounded with a try block, Quick Fix |
| will suggest adding the catch block to the existing block.</li> |
| <li>If you don't want to handle the exception, let Quick Fix add a |
| new thrown exception to the enclosing method declaration</li> |
| |
| </ul> |
| <p><img src="images/quick-fix-uncaught-exception.png" border="0" alt="'Uncaught exception' quick fix proposals"> |
| </p> |
| At any time you can convert a catch block to a thrown exception. Use |
| <b>Ctrl+1 (Edit > Quick Fix)</b> on a catch block.<br> |
| <p><img src="images/quick-assist-catch-to-throws.png" border="0" alt="'Replace catch clause with throws' quick assist"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Less typing for |
| assignments</b></td> |
| <td width="80%" valign="top">Instead of typing an assignment, start |
| with the expression that will be assigned. |
| <p><img src="images/quick-assist-assign-statement.png" border="0" alt="'Assign statement to local variable' quick assist"> |
| </p> |
| Now use <b>Ctrl+1 (Edit > Quick Fix)</b> and choose '<b>Assign |
| statement to new local variable</b>' and Quick Assist will guess a |
| variable name for you. <br> |
| <img src="images/quick-assist-assign-statement2.png" alt="Quick Assist Assignment" border="0"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Less work with cast |
| expressions</b></td> |
| <td width="80%" valign="top">Don't spend too much time with typing casts. Ignore them first and use quick assist to add them after |
| finishing the statement. <br> |
| For example on assignments:<br> |
| <img border="0" src="images/quickfix-addcast1.png" alt="Add cast in assignment"> <br> |
| Or in for method arguments:<br> |
| <img border="0" src="images/quickfix-addcast2.png" alt="Add cast for method arguments"> <br> |
| Or for method call targets<br> |
| <img border="0" src="images/quickfix-addcast3.png" alt="Add cast in method call targets"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Assign a casted |
| expression</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td width="80%" valign="top">After an 'instanceof' check, it is very common to cast the expression and assign it to a new local variable. Invoke <b>Quick |
| Assist (Ctrl+1)</b> on the 'instanceof' keyword to save yourself some typing:<br> |
| <img border="0" src="images/assign-to-casted-quickfix.png" |
| alt="'Introduce new local with casted type' quick fix"> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>More quick assists</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"></td> |
| <td width="80%" valign="top">Check out the <a |
| href="../concepts/cquickassists.htm">quick assist</a> page for a complete list of available code transformations. Amongst them are<ul> |
| <li>Invert if statements</li> |
| <li>Convert 'switch' into 'if-else'</li> |
| <li>Replace 'if-else' with conditional<br>...and many more</li> |
| |
| </ul>A list of quick fixes can be found <a |
| href="../concepts/cquickfix.htm">here</a>. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Shortcuts for Quick Fixes and Assists<br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"></b></td> |
| <td valign="top" align="left" width="80%">Some of the popular quick assists like <b>Rename |
| In File</b> and <b>Assign To Local</b> can be invoked |
| directly with <b>Ctrl+2 R</b> and <b>Ctrl+2 L</b>. Check |
| the keys preference page for more quick fixes that support direct |
| invocation. |
| <p><img src="images/quick-assist-shortcuts.png" alt="Keys preference page with quick assist shortcuts"></p> |
| </td> |
| </tr><tr> |
| <td width="20%" valign="top" align="left"><b>Surround lines</b></td> |
| <td width="80%" valign="top">To surround statements with an if / |
| while / for statement or a block, select the lines to surround and |
| press <b>Ctrl+1 (Edit > Quick Fix)</b>. This lists all templates |
| that contain the variable ${line_selection}. |
| <p><img src="images/surroundwith.png" border="0" alt="'Surround with templates' quick assist"> |
| </p> |
| Templates can be configured on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Templates</b></a> preference page. Edit the corresponding templates or |
| define your own templates to customize the resulting code.<br> |
| </td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Create your own |
| templates</b></td> |
| <td width="80%" valign="top"> |
| <p>To create your own templates, go to the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Templates</b></a> preference page and press the <b>New</b> button to |
| create a template. For example, a template to iterate backwards in an |
| array would look like this:</p> |
| <img border="0" src="images/template-for-iter.png" |
| alt="Template showing backward iteration"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Code assist can insert |
| argument names automatically</b></td> |
| |
| <td width="80%" valign="top"> |
| <p>You can have code assist insert argument names automatically on |
| method completion. This behavior can be customized on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeAssistPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Content Assist</b></a> preference page (see the <b>Fill |
| argument names on completion</b> checkbox.) For example, when |
| you select the second entry here, </p> |
| <p><img src="images/code-assist-argument-proposal.png" alt="code assist window"> |
| </p> |
| <p>code assist will automatically insert argument names:</p> |
| <p><img src="images/code-assist-argument-proposal-inserted.png" alt="code assist inserted argument names"> |
| </p> |
| <p>you can then use the <b>Tab</b> key to navigate between the |
| inserted names.</p> |
| <p>Code assist can also guess argument names - based on their |
| declared types. This can be configured by the <b>Guess filled |
| argument names</b> checkbox on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeAssistPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Content Assist</b></a> preference page.</p> |
| </td> |
| |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Automatically insert |
| type arguments</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td width="80%" valign="top">Enabling <b>Fill argument names on completion</b> on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeAssistPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Content Assist</b></a> preference page |
| is also useful when working with parameterized types in J2SE 5.0.<br> |
| <img border="0" src="images/code-assist-type-arg-guessing.png" |
| alt="Code assist on a parameterized type"> |
| <br>results in<br> |
| <img border="0" src="images/code-assist-type-arg-guessing2.png" |
| alt="Code assist guessed and inserted type argument"> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Remove surrounding |
| statement</b></td> |
| <td width="80%" valign="top">To remove a surrounding statement or |
| block, position the cursor at the opening bracket and press <b>Ctrl+1 |
| (Edit > Quick Fix)</b>. |
| <p><img src="images/quick-assist-remove-surrounding.png" border="0" alt="'Remove surrounding statement' quick assist"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>How was that word spelled again?</b></td> |
| <td>You can enable spell-checking support in the Java editor on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.editors.preferencePages.Spelling)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>General > Editors > Text Editors > Spelling</b></a> |
| preference page. Spelling errors |
| are displayed in the Java editor and corresponding Quick Fixes are available: |
| <p><img alt="An example of a spelling correction proposal." title="Spelling Correction Proposal" src="images/spelling-correction-proposal.png" align="middle"></p> |
| <p>You can make the |
| dictionary also available to the content assist. However, there is currently no dictionary included in Eclipse. The required format |
| is just a list of words separated by new lines and the Quick Fixes allow you to |
| add new words to the dictionary on-the-fly. Contributions of dictionaries would be welcome.</p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Structured selections</b></td> |
| <td width="80%" valign="top">You can quickly select Java code |
| syntactically using the Structured Selection feature.<br> |
| Highlight the text and press <b>Alt+Shift+Arrow Up</b> or select <b>Edit |
| > Expands Selection To > Enclosing Element</b> from the menu |
| bar - the selection will be expanded to the smallest Java-syntax |
| element that contains the selection. You can then further expand the |
| selection by invoking the action again.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Find the matching |
| bracket</b></td> |
| <td width="80%" valign="top">To find a matching bracket select an |
| opening or closing bracket and press <b>Ctrl+Shift+P (Navigate > |
| Go To > Matching Bracket)</b>. You can also <b>double click</b> |
| before an opening or after a closing bracket - this selects the text |
| between the two brackets. |
| <p><img src="images/matching-brackets.png" border="0" alt="Using 'double click' to select text between two brackets"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Smart Javadoc</b></td> |
| <td width="80%" valign="top">Type '/**' and press <b>Enter</b>. This |
| automatically adds a Javadoc comment stub containing the standard |
| @param, @return and @exception tags. |
| <p><img src="images/smart-javadoc.png" border="0" alt="Result of 'Smart Javadoc'"> |
| </p> |
| The templates for the new comment can be configured in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style > Code Templates</b></a> preference page. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use the local history |
| to revert back to a previous edition of a method</b></td> |
| <td valign="top" align="left" width="80%">Whenever you edit a file, |
| its previous contents are kept in the local history. Java tooling |
| makes the local history available for Java elements, so you can |
| revert back to a previous edition of a single method instead of the |
| full file. |
| <p>Select an element and use <b>Replace With > Local History</b> |
| to revert back to a previous edition of the element.</p> |
| <p><img src="images/localhistory-replace.png" border="0" alt="Replace form local history dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use the local history |
| to restore removed methods</b></td> |
| <td valign="top" align="left" width="80%">Whenever you edit a file, |
| its previous contents are kept in the local history. Java tooling |
| makes the local history available for Java elements, so you can |
| restore deleted methods selectively. |
| <p>Select a container and use <b>Restore from Local History</b> to |
| restore any removed members.</p> |
| <p><img src="images/localhistory-restore.png" border="0" alt="Restore from local history dialog"> |
| </p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Customizable code |
| generation</b></td> |
| <td width="80%" valign="top" align="left">The |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style > Code Templates</b></a> preference page |
| allows you to customize |
| generated code and comments in a similar way to normal templates. |
| These code templates are used whenever code is generated.<br> |
| <img |
| src="images/code-templates.png" border="0" |
| alt="Code templates preference page"><br> |
| <br> |
| Since 3.1, it is possible to project specific Code templates, that will also be shared in the team if your project is shared. Open the <b>Properties</b> on project to enable project specific settings. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Create comments in your |
| code</b></td> |
| <td width="80%" valign="top" align="left">Comments can be added explicitly with <b>Source > Generate Element Comment (Ctrl+Shift+J)</b> or automatically by various wizards, refactorings or quick fixes.<br> |
| Configure the comment templates on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeTemplatePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style > Code Templates</b></a> preference page.<br> |
| Enable or disable the automatic generation of comments either directly on the wizard (e.g. using <b>'Generate |
| Comment'</b> checkbox on the new Java type wizards) or by the <b>'Automatically |
| add new comments for new methods and types'</b> checkbox of the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> preference page.<br> |
| All these settings can also be configured on a per project basis. Open the <b>Properties</b> on project to enable project specific settings.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Sort members</b></td> |
| <td width="80%" valign="top" align="left">You can <b>Sort Members</b> |
| of a Java compilation unit according to a category order defined in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.MembersOrderPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Appearance > Members Sort Order</b></a> preference page.<br> |
| You'll find the action under <b>Source > Sort Members</b></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Wrap Strings</b></td> |
| <td width="80%" valign="top" align="left"> |
| <p>You can have String literals wrapped when you edit them. For |
| example, if you have code like this:</p> |
| <pre>String message= "This is a very long message.";</pre> |
| |
| <p>position your caret after the word "very" and press <b>Enter</b>. |
| The code will be automatically changed to:</p> |
| <pre>String message= "This is a very" + |
| " long message.";</pre> |
| <p>This behavior can be customized in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.SmartTypingPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Typing</b></a> preference page.</p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td valign="top" align="left"><b>Smart Typing and how to control it</b></td> |
| <td> |
| The Java editor's Smart Typing features ease your daily work. You can configure |
| them on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.SmartTypingPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Typing</b></a> preference page. |
| <p> |
| <img src="images/typing-preferences.png" border="0" alt="Java editor typing preference page" title="Typing Preference Page" align="middle"> |
| </p> |
| <p> |
| When you enable <b>Automatically insert Semicolons at correct |
| position</b>, typing a semicolon automatically positions the cursor at the end of the statement before inserting the semicolon. This safes you some additional cursor navigation.<br> |
| You can |
| undo this automatic positioning by pressing backspace right afterwards. |
| </p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Fix your code |
| indentation with one key stroke</b></td> |
| <td width="80%" valign="top" align="left">A useful feature is <b>Source |
| > Correct Indentation</b> or <b>Ctrl+I</b>. Select the code where the indents are |
| incorrect and invoke the action.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Quick menus for source and |
| refactoring actions</b></td> |
| <td align="left" valign="top"> |
| <p>The refactoring and source actions can be accessed via a quick |
| menu. Select the element to be manipulated in the Java editor or in a |
| Java view and press <b>Alt+Shift+S</b> for the quick source menu or |
| <b>Alt+Shift+T</b> for the quick refactoring menu.</p> |
| <img border="0" src="images/quick-refactoring-menu.png" alt="Quick refactoring menu"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Find unused code</b></td> |
| <td width="80%" valign="top" align="left">The Java compiler detects |
| unreachable code, unused variables, parameters, imports and unused |
| private types, methods and fields. |
| The setting is on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Compiler > Error/Warnings</b></a> |
| preference page (or set for an individual |
| project using <b>Project > Properties > Java Compiler > |
| Error/Warnings</b>).<p><img src="images/warn-privates.png" border="0" alt="Compiler preference page"> |
| </p> |
| These settings are also detected as you type and a quick fix is |
| offered to remove the unneeded code.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Javadoc comment handling</b></td> |
| <td>The Eclipse Java compiler can process Javadoc comments. Search |
| reports references in doc comments, and refactoring updates these |
| references as well. This feature is controlled from the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavadocProblemsPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Compiler > Javadoc</b></a> |
| preference page (or set for an individual |
| project using <b>Project > Properties > Java Compiler > |
| Javadoc</b>). |
| <p><img src="images/javadoc-prefs.png" alt="Javadoc preference page"> |
| </p>When turned on, malformed Javadoc comments are marked in the Java editor and can be fixed using <b>Edit |
| > Quick Fix (Ctrl+1)</b>: |
| <p> |
| <img src="images/javadoc-quickfix.png" alt="Problems detected in Javadoc" title="Problems detected in Javadoc"> |
| </p></td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Suppress warnings</b><br><img src="images/3.1_tag.png" border="0" alt="New in 3.1"></td> |
| <td>In J2SE 5.0 you can suppress all optional compiler warnings using the 'SuppressWarnings' annotation.<br> |
| In this example 'addAll()' is marked as an unused method. <b>Quick Fix (Ctrl+1)</b> is used to add a SuppressWarnings annotation so that the warning will not be shown for this method.<br> |
| <img src="images/suppresswarningsR31.png" border="0" |
| alt="Quick fix to add SuppressWarning annotation"> |
| </td> |
| </tr> |
| |
| </tbody> |
| </table> |
| <h3><a name="searching_section"></a>Searching</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" |
| bgcolor="white"> |
| <tbody> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Locate variables and |
| their read/write access</b></td> |
| <td valign="top" align="left" width="80%">You can locate variables |
| and see their read/write status by selecting an identifier |
| (variable, method or type reference or declaration) and invoking <b>Search |
| > Occurrences in File</b>. This marks all references of this |
| identifier in the same file. The results are also shown in the search |
| view, along with icons showing the variable's read or write access.<br> |
| <p><img src="images/search.png" border="0" alt="Read and write accesses to a field"> |
| </p> |
| <p>Alternatively, use the <b><a href="#mark_occurrences">Mark |
| Occurrences</a></b> feature to dynamically highlight occurrences. |
| You can search over several files by using the general search |
| features (<b>Search > References</b>). |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Search for methods with |
| a specific return type</b></td> |
| <td valign="top" align="left" width="80%"> |
| <p>To search for methods with a specific return type, use "* |
| <return type>" as follows:</p> |
| |
| <ul> |
| <li>Open the search dialog and click on the <b>Java Search</b> tab.</li> |
| <li>Type '*' and the return type, separated by a space, in the <b>Search |
| string</b>.</li> |
| <li>Select the <b>Case sensitive</b> checkbox.</li> |
| <li>Select <b>Method</b> and <b>Declarations</b> and then click <b>Search.</b></li> |
| </ul> |
| <p><img src="images/search-returntype.png" border="0" alt="Search for method with given return type"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Remove Javadoc results from Java search</b></td> |
| <td width="80%" valign="top" align="left">By default <b>Java Search</b> finds references inside |
| Java code and Javadoc. If you don't want to find references inside Javadoc, you can filter these matches by enabling 'Filter Javadoc' in the view menu (triangle symbol) of the search view </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Trace method call chains |
| with the Call Hierarchy</b></td> |
| <td valign="top" align="left" width="80%"> |
| <p>Have you ever found yourself searching for references to methods |
| again and again? Use the new Call Hierarchy to follow long or complex |
| call chains without losing the original context: Just select a method |
| and invoke <b>Navigate > Open Call Hierarchy</b> (Ctrl+Alt+H).</p> |
| <p><img src="images/call_hierarchy.png" border="0" alt="Call Hierarchy View"> |
| </p> |
| </td> |
| </tr> |
| |
| </tbody> |
| </table> |
| <h3><a name="navigation_section"></a>Code navigation and reading</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" |
| bgcolor="white"> |
| <tbody> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Open on a selection in |
| the Java editor</b></td> |
| <td valign="top" align="left" width="80%">There are two ways that you |
| can open an element from its reference in the Java editor. |
| <ul> |
| <li>Select the reference in the code and press <b>F3 (Navigate > |
| Open Declaration)</b></li> |
| <li>Hold <b>Ctrl </b>and move the mouse pointer over the reference</li> |
| </ul> |
| <img src="images/editor-link-style-open.png" border="0" alt="Hyperlink style navigation"> |
| <br> |
| The hyperlink style navigation can be configured with the |
| <b>Support hyperlink style navigation</b> checkbox in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.ui.preferencePages.GeneralTextEditor)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>General > Editors > Text Editors</b></a> preference page. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>In-place outlines</b></td> |
| <td valign="top" align="left" width="80%">Press <b>Ctrl+F3</b> in the |
| Java editor to pop up an in-place outline of the element at the |
| current cursor position. Or press <b>Ctrl+O (Navigate > Quick |
| Outline)</b> to pop up an in-place outline of the current source |
| file. |
| <p><img src="images/inplace_outline.png" border="0" alt="Inplace outline"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>In-place outlines show inherited members</b></td> |
| <td valign="top" align="left" width="80%">Press <b>Ctrl+O</b> or <b>Ctrl+F3</b> |
| again to add inherited members to an open In-place outline. Inherited members have a gray label. |
| Filter and sort the outline with the menu in the upper right corner. |
| <p><img src="images/quick-outline-inherited.png" border="0" alt="Quick outline view"></p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>In-place hierarchy</b></td> |
| <td valign="top" align="left" width="80%">Find out which are the |
| possible receivers of a virtual call using the 'quick hierarchy'. |
| Place the cursor inside the method call and press |
| <b>Ctrl+T (Navigate > Quick Hierarchy)</b>. |
| The view shows all types that implement the method with a full icon. |
| <p><img border="0" src="images/type-hierarchy-structured-view.png" |
| alt="Quick hierarchy view"> |
| </p> |
| <p>Press <b>Ctrl+T</b> again to switch to the Supertype hierarchy.</p></td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Advanced highlighting</b></td> |
| <td align="left" valign="top"> |
| The Java editor can highlight source code according to its |
| semantics (for example: static fields, local variables, static method |
| invocations). Have a look at the various options on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaEditorColoringPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Syntax Coloring</b></a> |
| preference page.<p><img src="images/advanced-highlighting.png" alt="An example of advanced highlighting." title="Advanced Highlighting" align="middle"> |
| </p> |
| |
| </td> |
| |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Initially folded regions</b></td> |
| <td>You can specify which regions are folded by default when an editor is opened. Have a look at the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.FoldingPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Folding</b></a> |
| preference page to customize this.<p><img src="images/folding-preferences.png" alt="Folding preference page" title="Folding Preference Page" align="middle"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Mark occurrences</b></td> |
| <td valign="top" align="left" width="80%"> |
| <a name="mark_occurrences"></a>When working in the |
| editor, turn on <b>Mark Occurrences</b> in the toolbar (<img src="../images/org.eclipse.jdt.ui/etool16/mark_occurrences.png" alt="Picture of Mark Occurrences Toolbar Button" title="Picture of Mark Occurrences Toolbar Button"> |
| ) or |
| press <b>Alt+Shift+O</b>. You'll see within a file, where a |
| variable, method or type is referenced.<br> |
| <img border="0" src="images/mark-occurrences.png" alt="Editor with occurrences of 'info' marked"><br> |
| Selecting a return type shows you the method's exit points. Select an |
| exception to see where it is thrown.<br> |
| <img border="0" src="images/mark-return-occurrences.png" alt="Editor with method exits marked"><br> |
| Select a super class or interface to see the methods override or implement a method from the selected super type.<br> |
| Fine tune 'mark occurrences' on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.MarkOccurrencesPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Mark Occurrences</b></a> preference page. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Go to next / previous |
| method</b></td> |
| <td valign="top" align="left" width="80%">To quickly navigate to the |
| next or previous method or field, use<br> |
| <b>Ctrl+Shift+Arrow Up (Navigate > Go To > Previous Member</b>) |
| or <b>Ctrl+Shift+Arrow Down (Navigate > Go To > Next Member)</b></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Control your navigation between annotations</b></td> |
| <td> |
| Use the Next / Previous Annotation toolbar buttons or <b>Navigate |
| > Next Annotation</b> (<b>Ctrl+.</b>) and <b>Navigate > Previous |
| Annotation</b> (<b>Ctrl+,</b>) to navigate between annotations |
| in a Java source file. |
| With the button drop-down menus, you can configure on which annotations you want to stop: |
| <p><img src="images/annotation-navigation.png" alt="Next/Previous annotation drop-down." title="Next/Previous Annotation Drop-Down" align="middle"> |
| </p> |
| |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Reminders in your Java |
| code</b></td> |
| <td valign="top" align="left" width="80%">When you tag a comment in |
| Java source code with "TODO" the Java compiler automatically creates |
| a corresponding task as a reminder. Opening the task navigates you |
| back to the "TODO" in the code. Use the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.TodoTaskPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Compiler > Task Tags</b></a> |
| preference page to configure any other special tags (like "FIXME") that you'd |
| like to track in the task list.<p><img src="images/todo-example.png" border="0" alt="Task tags in editor and task view"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Tricks in the Open Type dialog</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td valign="top" align="left" width="80%"> |
| <ul> |
| <li>To find types quickly, only type the capital letters of the type name: IOOBE finds IndexOutOfBoundsException</li> |
| <li>To see all types ending with a given suffix, e.g. all Tests, use '*Test<' to not see all types containing 'Test' somewhere else in the type |
| name.</li> |
| </ul> |
| <img border="0" src="images/open-type-camel-case.png" |
| alt="Open type dialog with camel case matching"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b> Make hovers sticky</b></td> |
| <td valign="top" align="left" width="80%">You can open the text from |
| a hover in a scrollable window by pressing <b>F2 (Edit > Show |
| Tooltip Description)</b>. You can select and copy content from this |
| window. |
| <p><img src="images/editor-hover-window.png" border="0" alt="Window containing content of the hover"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Hovers in the Java |
| editor</b></td> |
| <td valign="top" align="left" width="80%">You can see different hovers in the |
| Java editor by using the |
| modifier keys (Shift, Ctrl, Alt). <br> |
| When you move the mouse over an identifier in the Java editor, by |
| default a hover with the Javadoc extracted from the corresponding |
| source of this element is shown. Holding down the Ctrl key shows you |
| the source code. |
| <p><img src="images/editor-code-hover.png" border="0" alt="Hover showing code of the element in the hover"> |
| </p> |
| You can change this behavior and define the hovers for other modifier |
| keys in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaEditorHoverPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Editor > Hovers</b></a> preference page. |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Generic method inferred signature</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"></td> |
| <td valign="top" align="left" width="80%">You can use hover to show the generic method inferred signature. |
| <p><img src="images/hovergenericsignature.png" border="0" alt="Hover showing generic method inferred signature"> |
| </p></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Open and configure |
| external Javadoc documentation</b></td> |
| <td valign="top" align="left" width="80%">If you want to open the |
| Javadoc documentation for a type, method or field with <b>Shift+F2 |
| (Navigate > Open External Javadoc)</b>, you first have to specify |
| the documentation locations to the elements parent library (JAR, |
| class folder) or project (source folder).<br> |
| For libraries open the build path page (<b>Project > Properties |
| > Java Build Path</b>), go to the <b>Libraries</b>, expand the |
| node of the library where you can edit the 'Javadoc location' node. |
| The documentation can be local on your file system in a folder or |
| archive or on a web server. |
| <p><img src="images/javadoc-location.png" border="0" alt="Configuring Javadoc location in the Java build path dialog"> |
| </p> |
| For types, methods or fields in source folders, go to the (<b>Project |
| > Properties > Javadoc Location</b>).</td> |
| </tr> |
| </tbody> |
| </table> |
| <h3><a name="views_section"></a>Java views</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" |
| bgcolor="white"> |
| <tbody> |
| <tr> |
| <td valign="top" align="left"> |
| <b>Organizing workspace with many projects</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td>Use <b>Show > Working Sets</b> in the Package Explorer's view menu to enable |
| a new mode that shows working sets as top level elements. This mode makes it |
| much easier to manage workspaces containing lots of projects. |
| <p><img alt="Package Explorer in Working Set mode" |
| src="images/package-explorer.png"></p> |
| <p>Use <b>Select Working Sets</b> from the Package Explorer's view |
| menu to configure which working sets get shown. The dialog lets you |
| create new Java working sets, define which working sets are shown and |
| in what order. Working sets can also be rearranged directly in the |
| Package Explorer using drag and drop and copy/paste.</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Declaration view</b></td> |
| <td>The Declaration view |
| (<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.views.showView(org.eclipse.ui.views.showView.viewId=org.eclipse.jdt.ui.SourceView)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Window > Show View > Other... > Java > Declaration</b></a>) shows the source of the |
| element selected in the Java editor or in a Java view. |
| <p><img src="images/DeclarationView.png" title="Declaration view" alt="Declaration view"> |
| </p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td valign="top" align="left"><b>Javadoc view</b></td> |
| <td>There is a Javadoc view ( |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.views.showView(org.eclipse.ui.views.showView.viewId=org.eclipse.jdt.ui.JavadocView)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Window > Show View > Other... > Java > Javadoc</b></a>) which shows the Javadoc of the element |
| selected in the Java editor or in a Java view. The Javadoc view uses |
| the SWT Browser widget to display HTML on platforms which support it. |
| <p><img src="images/JavadocView.png" title="Javadoc view" alt="Javadoc view"> |
| </p> |
| </td> |
| </tr><tr> |
| <td width="20%" valign="top" align="left"><b>Type Hierarchy view and method |
| implementations / definitions</b></td> |
| <td valign="top" align="left" width="80%">To find out |
| which types in a hierarchy override a method, use the 'Show Members in |
| Hierarchy' feature. |
| <ul> |
| <li>Select the method to look at and press <b>F4 (Navigate > Open |
| Type Hierarchy)</b>. This opens the type hierarchy view on the |
| method's declaring type.</li> |
| <li>With the method selected in the Hierarchy view, press the 'Lock |
| View and Show Members in Hierarchy' tool bar button.</li> |
| <li>The hierarchy view now shows only types that implement or define |
| the 'locked' method. You can for example see that 'isEmpty()' is |
| defined in 'List' and implemented in 'ArrayList' and 'Vector' but |
| not in 'AbstractList'.</li> |
| </ul> |
| <p><img src="images/hierarchy-lockview.png" border="0" alt="Lock view and show members in Hierarchy"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Type hierarchy view |
| supports grouping by defining type</b></td> |
| <td valign="top" align="left" width="80%">The type hierarchy method |
| view lets you sort the selected type's methods by its defining types. |
| For example, for AbstractList you can see that it contains methods |
| that were defined in Object, Collection and List: |
| <p><img src="images/sort-by-def.png" border="0" alt="Sort members by the defining type in the type hierarchy"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Tricks in the type |
| hierarchy</b></td> |
| <td valign="top" align="left" width="80%"> |
| <ul> |
| <li>Focus the type hierarchy on a new type by pressing <b>F4 |
| (Navigate > Open Type Hierarchy)</b> on an element or a selected |
| name.</li> |
| <li>You can open the Hierarchy view not only on types but also on |
| packages, source folders, JAR archives and Java projects.</li> |
| <li>You can Drag & Drop an element onto the Hierarchy view to |
| focus it on that element.</li> |
| <li>You can change the orientation (from the default vertical to |
| horizontal) of the Hierarchy view from the view's toolbar menu.</li> |
| </ul> |
| </td> |
| </tr> |
| |
| |
| <tr> |
| <td valign="top" align="left"><b>Structural compare of Java source</b> |
| </td> |
| |
| <td valign="top" align="left">A structural comparison of Java source |
| ignores the textual order of Java elements like methods and fields |
| and shows more clearly which elements were changed, added, or removed. <br> |
| For initiating a structural comparison of Java files you have two |
| options: |
| <ul> |
| <li>Select two Java compilation units and choose <b>Compare With</b> |
| > <b>Each Other</b> from the view's context menu. If the files |
| have differences, they are opened into a Compare Editor. The top |
| pane shows the differing Java elements; double clicking on one of |
| them shows the source of the element in the bottom pane.</li> |
| <li>In any context where a file comparison is involved (e.g. a CVS |
| Synchronization) a double click on a Java file not only shows the |
| content of the file in a text compare viewer, but it also performs a |
| structural compare and opens a new pane showing the results.</li> |
| </ul> |
| <p><img src="images/compare-java.png" alt="Structural compare of Java source"> |
| </p> |
| You can even ignore comments and formatting changes when performing |
| the structural compare: turn on the <strong>Ignore Whitespace</strong> |
| option via the Compare Editor's toolbar button, or the CVS |
| Synchronization View's drop down menu.</td> |
| </tr><tr> |
| <td valign="top" align="left"><b>Structural compare of property |
| files</b></td> |
| |
| <td valign="top" align="left">A structural comparison of Java |
| property files (extension: .properties) ignores the textual order of |
| properties and shows which properties were changed, added, or |
| removed. <br> |
| For initiating a structural comparison of property files you have two |
| options: |
| <ul> |
| <li>Select two files in the Package Explorer or Navigator and choose |
| <b>Compare With</b> > <b>Each Other</b> from the view's context |
| menu.</li> |
| <li>In any context where a file comparison is involved (e.g. a CVS |
| Synchronization) a double click on a property file not only shows |
| the content of the file in a text compare viewer, but it also |
| performs a structural compare and opens a new pane showing the |
| results.</li> |
| </ul> |
| <p><img src="images/compare-properties.png" alt="Structural compare of property files"> |
| </p> |
| </td> |
| </tr><tr> |
| <td width="20%" valign="top" align="left"><b>Hierarchical vs. flat |
| layout of packages</b></td> |
| <td valign="top" align="left" width="80%">An option on the Java |
| Packages view (and Package Explorer view) allows you to change the |
| way packages are displayed. <b>Hierarchical</b> displays packages in |
| a tree, with sub-packages below packages; <b>Flat</b> displays them |
| in the standard arrangement, as a flat list with all packages and |
| sub-packages as siblings.<br> |
| <table border="0"> |
| <tbody> |
| <tr align="left" valign="top"> |
| <td><img src="images/packages-flat.png" border="0" alt="Flat packages layout"> |
| </td> |
| <td><img src="images/packages-hierarchical.png" border="0" alt="Hierarchical package layout"> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </td> |
| </tr><tr> |
| <td width="20%" valign="top" align="left"><b>Logical packages</b></td> |
| <td valign="top" align="left" width="80%">The Java Packages view |
| (Java Browsing perspective) coalesces packages of the same name |
| across source folders within a project. This shows the Packages view |
| containing a logical package. |
| <p><img src="images/packages-compound.png" border="0" alt="Java browsing perspective containing a logical package" align="bottom"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Compress package names</b></td> |
| <td valign="top" align="left" width="80%">If your package names are |
| very long you can configure a compressed name that appears in the viewers. |
| Configuration of the compression pattern is done in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.AppearancePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Appearance</b></a> preference page. |
| <p><img src="images/compress-packages1.png" border="0" alt="Compression pattern configuration in the Java appearance preference page"> |
| </p> |
| Using this example, packages are rendered the following way:<p><img src="images/compress-packages2.png" border="0" alt="Compressed package names"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Manipulating the Java |
| build path directly in the package explorer</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td valign="top" align="left" width="80%">Instead of manipulating the Java Build path on <b>Project |
| > Properties > Java Build Path</b>, use the actions in the package explorer's context menu.<br>You can for example add new source folders, archives and libraries to the build path or in- and exclude file and folders from a source folder.<br> |
| <img border="0" src="images/build-path-actions.png" |
| alt="Build path context menu"> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <h3><a name="misc_section"></a>Miscellaneous</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" |
| bgcolor="white"> |
| <tbody> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Project specific |
| preferences<br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </b><br></td> |
| <td valign="top" align="left" width="80%">All code style and compiler options can now be defined per project.<br> |
| Open the project property pages with <b>Project > Properties</b> on a project or use the link on the workspace preferences (e.g. the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> preference page) |
| to open a project property page and enable project specific settings.<br> |
| <img border="0" src="images/project-specific-settings.png" |
| alt="Project property page with 'Enable project specific settings' checkbox"> |
| <br>The project specific settings are stored in a configuration file inside the project (in the '.settings' folder). When you share a project in a team, team members will also get these project specific settings.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Access Rules</b><br> |
| <img border="0" src="images/3.1_tag.png" alt="New in 3.1"> |
| </td> |
| <td valign="top" align="left" width="80%">Access rules give you the possibility to enforce API rules for types from referenced libraries. On the Java build path page (<b>Project |
| > Properties > Java Build Path</b>) edit the 'Access Rules' node available on referenced projects, archives, class folders and libraries.<br> |
| Packages or types in these references can be classified as:<ul> |
| <li>Accessible</li> |
| <li>Discouraged</li> |
| <li>Forbidden</li> |
| </ul>According to the settings on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Compiler > Errors/Warnings</b></a> preference page, |
| the compiler will mark discouraged and forbidden references with warning or errors.<br><img |
| border="0" src="images/type-access-rules.png" alt="Access rules configuration dialog"></td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>JUnit</b></td> |
| <td valign="top" align="left" width="80%">Select a JUnit test method |
| in a view and choose <b>Run > JUnit Test</b> from the context menu or <b>Run |
| > Run As > JUnit Test</b> from the main menu. This |
| creates a launch configuration to run the selected test.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Hide JUnit view until |
| errors or failures occur</b></td> |
| |
| <td valign="top" align="left" width="80%">You can make the JUnit view |
| open only when there are errors or failures. That way, you can have |
| the view set as a fast view and never look at it when there are no |
| failing tests. While there are no problems in your tests you will see |
| this icon <img src="../images/org.eclipse.jdt.junit/prgss/ss4.png" alt="Successfully running"> (the |
| number of small green squares will grow, indicating progress) |
| while running them and this icon <img src="../images/org.eclipse.jdt.junit/eview16/junitsucc.png" alt="Successfully finished"> |
| after they are finished. If, however, |
| errors or failures occur, the icon will change to <img src="../images/org.eclipse.jdt.junit/prgss/ff4.png" alt="Failure or error occurred"> |
| (or <img src="../images/org.eclipse.jdt.junit/eview16/juniterr.png" alt="Finished with failure or error"> |
| if |
| tests are finished) and the JUnit view will appear. This behavior can |
| be configured via the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.junit.preferences)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > JUnit</b></a> preference page.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Content assist in dialog fields</b> |
| </td> |
| <td>Content Assist (Ctrl+Space) is now also available in input fields |
| of various Java dialogs. Look for small light bulb icon beside the |
| field when it has focus. |
| <p><img src="images/new-class.png" alt="New Class Dialog"> |
| </p> |
| <p>Content Assist is e.g. implemented in the New Java Class, New Java |
| Interface, and New JUnit Test wizards, as well as in the refactoring |
| dialogs for Change Method Signature and moving static members.</p> |
| <p>The Extract Local Variable, Convert Local Variable to Field, and |
| Introduce Parameter refactorings offer content assist proposals for |
| the new element name.</p> |
| </td> |
| </tr> |
| |
| |
| |
| |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Define prefixes or |
| suffixes for fields, parameters and local variables</b></td> |
| <td valign="top" align="left" width="80%">In addition to configuring |
| the prefix or suffix for fields, you can also specify the prefix or |
| suffix for static fields, parameters, and local variables. These |
| settings on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.CodeStylePreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Code Style</b></a> preference page are used |
| in content assist, quick fix, and refactoring whenever a variable |
| name is computed. |
| <p><img src="images/name-conventions.png" border="0" alt="Name conventions in the code style preference page"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Organize Imports works |
| on more than single files</b></td> |
| <td valign="top" align="left" width="80%">You can invoke Organize |
| Imports on sets of compilation units, packages, source folders or |
| Java projects.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Format more than one |
| file</b></td> |
| <td valign="top" align="left" width="80%">Select all |
| Java files to format and choose Source > Format to format them |
| all. The format action is also available on packages, source folders |
| or Java projects.</td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use project specific |
| compiler settings</b></td> |
| <td valign="top" align="left" width="80%">Each project can |
| use the global compiler settings or you can define project specific |
| settings. Select the project and open the Java compiler page in the |
| project properties <b>(Project > Properties > Java Compiler)</b><p><img src="images/compiler-projectspecific.png" border="0" alt="Project specific Java compiler settings"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Use a specific JRE for |
| a project</b></td> |
| <td valign="top" align="left" width="80%">When creating new projects the JRE that |
| is added by default is the one selected in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.preferences.VMPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Installed JREs</b></a> |
| preference page. To set a project specific JRE, open the |
| project's Java Build path property page <b>(Project > Properties |
| > Java Build Path)</b>, then the<b> Libraries</b> page, select |
| 'JRE System Library' and press <b>Edit</b>. In the 'Edit Library' |
| dialog you can select either the default JRE or a project specific |
| JRE to add to new projects. |
| <p><img src="images/project-specific-jre.png" alt="Edit JRE system library" border="0"> |
| </p> |
| </td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Propagating deprecation |
| tag</b></td> |
| <td width="80%" valign="top" align="left"> |
| The Java compiler can be configured to diagnose deprecation using |
| options on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Compiler > Errors/Warnings</b></a> preference page. |
| <p><img src="images/warn-deprecation-opt.png" border="0" alt="Compiler preference page"> |
| </p> |
| Using this configuration, the result is: |
| <p><img src="images/warn-deprecation-i.png" border="0" alt="I.java"></p> |
| <p><img src="images/warn-deprecation-x.png" border="0" alt="X.java"></p> |
| <p><img src="images/warn-deprecation-y.png" border="0" alt="Y.java"></p> |
| If you're unable to fix a usage of a deprecated construct, we recommend that you |
| tag the enclosing method, field or type as deprecated. |
| This way, you acknowledge that you did override a deprecated construct, |
| and the deprecation flag is propagated to further dependents. |
| <p><img src="images/warn-deprecation-x2.png" border="0" alt="X.java"></p> |
| <p><img src="images/warn-deprecation-y2.png" border="0" alt="Y.java"></p></td> |
| </tr> |
| |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Recovering from abnormal |
| inconsistencies</b></td> |
| <td width="80%" valign="top" align="left"> |
| In the rare event of a dysfunction, JDT could reveal some inconsistencies |
| such as: |
| <ul> |
| <li>missing results in a <b>Java Search</b> or <b>Open Type</b></li> |
| <li>invalid items in package explorer</li> |
| </ul> |
| <br> |
| To make it consistent again, the following actions need to be performed |
| in this exact order: |
| <ol> |
| <li>Close all projects using navigator <b>Close Project</b> menu action</li> |
| <li>Exit and restart Eclipse</li> |
| <li>Open all projects using navigator <b>Open Project</b> menu action</li> |
| <li>Manually trigger a clean build of entire workspace (<b>Project > |
| Clean...</b>)</li> |
| </ol> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h3><a name="debugging_section"></a>Debugging</h3> |
| |
| <table border="1" cellpadding="10" cellspacing="0" width="600" |
| bgcolor="white"> |
| <tbody> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>Launching from the Context Menu</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| <p>You can run and debug Java applications from the context menu. |
| You can launch a source file, package, method, type, etc. by |
| choosing <b>Run As</b> (or <b>Debug As</b>)<b> > Java Application</b> |
| from the context menu in a view or editor. Alternatively, you can |
| use the Java application launch shortcut key binding (Alt-Shift-D, J). The |
| top level <b>Run As</b> (or <b>Debug As</b>) actions are also |
| sensitive to the current selection or active editor.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/context_menu_launch.png" alt="Context menu with launch option"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Evaluations in the |
| debugger</b></td> |
| <td width="80%" valign="top" align="left"> |
| <p>Snippet evaluation is available from a number of places in the |
| debugger. Choosing <b>Display</b> or <b>Inspect</b> from the context |
| menu of the editor or <b>Variables view</b> will show the result in a |
| pop-up whose result can be sent to the <b>Display</b> or <b>Expressions |
| views</b>.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/inspect_popup.png" alt="Result of an inspect in a pop-up"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>View Management in Non-Debug perspectives</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| |
| <p>The Debug view automatically manages debug related views based on the view selection |
| (displaying Java views for Java stack frames and C views for C stack frames, |
| for example). By default, this automatic view management only occurs in |
| the Debug perspective, but you can enable it for other perspectives via |
| the <b>View Management</b> preference page available from the <b>Debug |
| view</b> toolbar pulldown.</p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>Environment Variables</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| |
| <p>You can now specify the environment used to launch Java applications |
| via the <b>Environment</b> tab.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/env_tab.png" alt="Environment tab in the launch configuration dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>String Substitutions</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| |
| <p>Variables are now supported for many parameters of Java Application launch |
| configurations. Most fields that support variables have a <b>Variables...</b> |
| button next to them, such as the program and VM arguments fields. The <b>Main Type</b> field |
| supports variables as |
| well; the <i>${java_type_name}</i> variable allows you to create a configuration |
| that will run the selected type.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/args_tab.png" alt="Arguments tab in the launch configuration dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>Logical Structures</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| |
| <p>The <b>Logical Structures</b> toggle on the <b>Variables view</b> toolbar |
| presents alternate structures for common types. JDT provides logical views |
| for Maps, Collections, and SWT Composites. You can define |
| logical structures for other types from the <b>Logical Structures</b> |
| preference page.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/logical_structure_toggle.png" alt="Vector displayed as a logical structure in the variable view"> |
| </p> |
| </td> |
| |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"> |
| <p><b>Default VM Arguments</b></p> |
| </td> |
| <td width="80%" valign="top" align="left"> |
| <p>If you specify the same arguments to a certain VM frequently, |
| you can configure <b>Default VM Arguments</b> in the <b>Installed JREs</b> |
| preference page. This is more convenient than specifying them for |
| each launch configuration.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/def_vm_args.png" alt="JRE preference page with default argument specified"> |
| </p> |
| </td> |
| |
| </tr> |
| <tr> |
| <td width="20%" valign="top" align="left"><b>Stop in Main</b></td> |
| <td width="80%" valign="top" align="left"> |
| <p>You can use <b>Stop in main </b>in a Java Application launch |
| configuration to cause your program to stop at the first executable |
| line of the main method when you run it under debug mode.</p> |
| |
| <p><img src="images/org.eclipse.jdt.debug.ui/stop_in_main.png" alt="Main tab with Stop in Main option selected"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Conditional breakpoints</b></td> |
| <td valign="top" align="left">You can use conditional breakpoints in |
| <b> Breakpoint Properties... </b>to control when a breakpoint |
| actually halts execution. You can specify whether you want the |
| breakpoint to suspend execution only when the condition is true, or |
| when the condition value changes. |
| <p><img src="images/org.eclipse.jdt.debug.ui/breakpoint_condition.png" alt="Breakpoint condition editor in breakpoint properties dialog"></p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Disabling breakpoints</b></td> |
| <td valign="top" align="left"> |
| <p>If you find yourself frequently adding and removing a breakpoint |
| in the same place, consider disabling the breakpoint when you don't |
| need it and enabling it when needed again. This can be done using <b>Disable |
| Breakpoint </b>in the breakpoint context menu or by unchecking the |
| breakpoint in the <b>Breakpoints view</b>.</p> |
| <p>You can also temporarily disable all breakpoints using the <b>Skip |
| All Breakpoints</b> action in the <b>Breakpoints view</b> toolbar. |
| This will tell the debugger to skip all breakpoints while maintaining |
| their current enabled state.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/breakpoint_menu.png" alt="Disable Breakpoint action in the ruler context menu"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Changing variable values</b></td> |
| <td valign="top" align="left"> |
| |
| <p>When a thread is suspended in the debugger, you can change the values |
| of Java primitives and Strings in the <b>Variables</b> view. From the |
| variable's context menu, choose <b>Change Variable Value</b>. You can |
| also change the value by typing a new value into the Details pane and |
| using the <strong>Assign Value </strong>action in the context menu (CTRL-S |
| key binding).</p> |
| |
| <p><img src="images/org.eclipse.jdt.debug.ui/assign_value.png" alt="Change variable value from detail pane"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Variable values in hover help</b></td> |
| <td valign="top" align="left">When a thread is suspended and the |
| cursor is placed over a variable in the Java editor, the value of |
| that variable is displayed as hover help. |
| <p><img src="images/org.eclipse.jdt.debug.ui/variable_hover.png" alt="Variable value hover in the editor"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Drop to Frame</b></td> |
| <td valign="top" align="left"> |
| <p>When stepping through your code, you might occasionally step too |
| far, or step over a line you meant to step into. Rather than |
| restarting your debug session, you can use the <b>Drop to Frame</b> |
| action to quickly go back to the beginning of a method. Select the |
| stack frame corresponding to the Java method you wish to restart, and |
| select <b>Drop to Frame</b> from <b>Debug view</b> toolbar or the |
| stack frame's context menu. The current instruction pointer will be |
| reset to the first executable statement in the method. This works for |
| non-top stack frames as well.</p> |
| <p>Note that Drop to frame is only available when debugging with a |
| 1.4 or higher VM, or the J9 VM. There are some situations where a JVM |
| may be unable to pop the desired frames from the stack. For example, |
| it is generally impossible to drop to the bottom frame of the stack |
| or to any frame below a native method.</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Hot code replace</b></td> |
| |
| <td valign="top" align="left">The debugger supports Hot Code Replace when |
| debugging with a 1.4 or higher VM, or the J9 VM. This lets you make changes |
| to code you are currently debugging. Note that some changes such as new |
| or deleted methods, class variables or inner classes cannot be hot swapped, |
| depending on the support provided by a particular VM.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Stepping into selections</b></td> |
| <td valign="top" align="left"> |
| <p>The Java debugger allows you to step into a single method within a |
| series of chained or nested method calls. Simply highlight the method |
| you wish to step into and select <b>Step into Selection</b> from the |
| Java editor context menu.</p> |
| <p>This feature works in places other than the currently executing |
| line. Try debugging to a breakpoint and stepping into a method a few |
| lines below the currently instruction pointer.</p> |
| |
| <p><img src="images/org.eclipse.jdt.debug.ui/step_into_selection.png" |
| alt="Stepping into selection"></p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Controlling<br> |
| your console</b></td> |
| |
| |
| <td valign="top" align="left">Output displayed in the console can be locked |
| to a specific process via the <strong>Pin Console</strong> action in the |
| Console view toolbar. There's also a <strong>Scroll Lock </strong>action |
| that stops the console from automatically scrolling as new output is appended. |
| <p><img src="images/org.eclipse.jdt.debug.ui/pin_console.png" alt="Console view with process drop-down"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Creating watch items</b></td> |
| |
| <td valign="top" align="left">A watch item is an expression in the <b>Expressions</b> |
| view whose value is updated as you debug. You can create watch items from |
| the Java editor by selecting an expression or variable and choosing <b>Watch</b> |
| from its context menu or the top-level <b>Run</b> menu.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Watch points</b></td> |
| <td valign="top" align="left"> |
| |
| <p>A watch point is a breakpoint that suspends execution whenever a specified |
| variable is accessed or modified. To set a watchpoint, select a variable |
| in the Outline view and choose <b>Toggle Watchpoint</b> from its context |
| menu. To configure a watchpoint, select the watchpoint in the <b>Breakpoints</b> |
| view and choose <b>Properties...</b> from its context menu. The most important |
| properties for this type of breakpoint are the <b>Access</b> and <b>Modification</b> |
| checkboxes which control when the breakpoint can suspend execution.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/watchpoint_properties.png" alt="Breakpoint properties dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| |
| <td valign="top" align="left"><b>Threads and Monitors</b></td> |
| <td valign="top" align="left"> |
| <p>The Java debugger optionally displays monitor information |
| in the <b>Debug</b> view. Use the <b>Show Monitors</b> action in the |
| Debug view drop down menu to show which threads are holding locks and |
| which are waiting to acquire locks. Threads involved in a deadlock |
| are rendered in red.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/deadlock.png" |
| alt="Debug view showing deadlock cycles"></p> |
| |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Step filters</b></td> |
| |
| <td valign="top" align="left">Step filters prevent the debugger from suspending |
| in specified classes and packages when stepping into code. Step filters |
| are established with the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.JavaStepFilterPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Debug > Step Filtering</b></a> preference page. |
| When the <b>Use Step Filters</b> toggle (on the debug |
| toolbar and menu) is on, step filters are applied to all step actions. In |
| the Debug view, the selected stack frame's package or declaring type can |
| be quickly added to the list of filters by selecting <b>Filter Type</b> |
| or <b>Filter Package</b> from the stack frame's context menu.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Using the scrapbook</b></td> |
| <td valign="top" align="left"> |
| |
| <p>If you want to experiment with API or test out a new algorithm, it's |
| frequently easier to use a Java scrapbook page than create a new class. |
| A scrapbook page is a container for random snippets of code that you can |
| execute at any time without a context. To create a scrapbook page, create |
| a new file with a <strong>.jpage</strong> extension (or use the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.debug.ui.snippetEditor.NewSnippetFileCreationWizard)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>New Scrapbook Page</b></a> wizard). |
| Enter whatever code you wish to execute, then select it. There are three |
| ways to execute your code:</p> |
| |
| <ul> |
| <li>Execute the selected code and place the returned result in the |
| Expressions view</li> |
| <li>Execute the selected code and place the String result right in |
| the scrapbook page |
| <p><img src="images/org.eclipse.jdt.debug.ui/scrapbook.png" alt="Scrapbook page displaying result"> |
| </p> |
| </li> |
| <li>Execute the selected code (and ignore any returned result)</li> |
| </ul> |
| <p>These actions are in the workbench toolbar and also in the |
| scrapbook page's context menu.</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Editing<br> |
| launch<br> |
| configurations</b></td> |
| <td valign="top" align="left">Holding down the <b>Ctrl</b> key and |
| making a selection from the <b>Run</b> or <b>Debug</b> drop-down menu |
| opens the associated launch configuration for editing. The launch |
| configuration can also be opened from the context menu associated |
| with any item in the Debug view.</td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Favorite launch configurations</b></td> |
| <td valign="top" align="left"> |
| |
| <p>Launch configurations appear in the Run/Debug drop-down menus in most |
| recently launched order. However it is possible to force a launch configuration |
| to always appear at the top of the drop-downs by making the configuration |
| a 'favorite'. Use the <strong>Organize Favorites...</strong> action from |
| the appropriate drop down menu to configure your favorite launch configurations.</p> |
| |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Detail formatters</b></td> |
| <td valign="top" align="left"> |
| <p>In the <b>Variables</b> & <b>Expressions</b> views, the detail |
| pane shows an expanded representation of the currently selected |
| variable. By default, this expanded representation is the result of |
| calling <b>toString()</b> on the selected object, but you can create |
| a custom detail formatter that will be used instead by choosing <b>New |
| Detail Formatter</b> from the variable's context menu. This detail |
| formatter will be used for all objects of the same type. You can view |
| and edit all detail formatters in the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.JavaDetailFormattersPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Debug > Detail Formatters</b></a> preference page.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/detail_formatter.png" alt="Detail formatter dialog"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Running code with compile errors</b></td> |
| <td valign="top" align="left"> |
| <p>You can run and debug code that did not compile cleanly. The only |
| difference between running code with and without compile errors is |
| that if a line of code with a compile error is executed, one of two |
| things will happen:</p> |
| <ul> |
| <li>If the 'Suspend execution on compilation errors' preference on the |
| <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.debug.ui.JavaDebugPreferencePage)")'> |
| <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"> |
| <b>Java > Debug</b></a> preference page is set and you are |
| debugging, the debug session will suspend as if a breakpoint had |
| been hit. Note that if your VM supports Hot Code Replace, you could |
| then fix the compilation error and resume debugging</li> |
| <li>Otherwise, execution will terminate with a 'unresolved |
| compilation' error</li> |
| </ul> |
| <p>It is important to emphasize that as long as your execution path |
| avoids lines of code with compile errors, you can run and debug just |
| as you normally do.</p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Word wrap in Variables view</b></td> |
| <td valign="top" align="left">The details area of the debugger's <b>Variables</b> |
| and <b>Expressions</b> views supports word wrap, available from the |
| view drop-down menu. |
| <p><img src="images/org.eclipse.jdt.debug.ui/word_wrap.png" alt="Word wrap action in Variables view drop-down menu"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Code assist in the debugger</b></td> |
| <td valign="top" align="left"> |
| <p>Code assist is available in many contexts beyond writing code in |
| the Java editor:</p> |
| <ul> |
| <li>When entering a <b>breakpoint condition</b></li> |
| <li>In the <b>Details</b> pane of the <b>Variables</b> & <b>Expressions</b> view</li> |
| <li>When entering a <b>Detail Formatter</b> code snippet</li> |
| <li>When entering a <b>Logical Structure</b> code snippet</li> |
| <li>When entering code in a <b>Scrapbook</b> page</li> |
| <li>In the <b>Display</b> view</li> |
| </ul> |
| <p><img src="images/org.eclipse.jdt.debug.ui/code_assist.png" alt="Display view code assist pop-up"> |
| </p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Command line details</b></td> |
| |
| <td valign="top" align="left">You can always see the exact command |
| line used to launch a program in run or debug mode by selecting <b>Properties</b> |
| from the context menu of a process or debug target, even if the |
| launch has terminated. |
| <p><img src="images/org.eclipse.jdt.debug.ui/process_properties.png" alt="Command line details"></p> |
| </td> |
| </tr> |
| <tr> |
| <td valign="top" align="left"><b>Stack trace<br> |
| hyperlinks</b></td> |
| <td valign="top" align="left"> |
| |
| <p>Java stack traces in the console appear with hyperlinks. When you place |
| the mouse over a line in a stack trace the pointer changes to the hand. |
| Pressing the mouse button opens the |
| associated Java source file and positions the cursor at the corresponding |
| line. Pressing the mouse button on the exception name at the top of the |
| stack trace will create an exception breakpoint.</p> |
| <p><img src="images/org.eclipse.jdt.debug.ui/stack_trace.png" alt="Stack traces in Console view with hyperlinks"> |
| </p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| |
| |
| |
| </body> |
| </html> |