Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Renaming Java elements

In this section, you will rename a Java element using refactoring.  Refactoring actions change the structure of your code without changing its semantics (behavior).

  1. In the Package Explorer view, select junit.framework/TestCase.java.
  2. From its context menu, select Refactor > Rename.
  3. In the New Name field on the Rename Compilation Unit page, type "TestCase2".

    Rename refactoring wizard

  4. To preview the changes that will be made as a result of renaming the class, press Next.
  5. The workbench analyzes the proposed change and presents you with a preview of the changes that would take place if you rename this resource. 

    Since renaming a compilation unit will affect the import statements in other compilation units, there are other compilation units affected by the change.  These are shown in a list of changes in the preview pane.

    Refactoring wizard preview page

  6. On the Refactoring preview page, you can scroll through the proposed changes and select or deselect changes, if necessary.  You will typically accept all of the proposed changes.
  7. Click Finish to accept all proposed changes.

You have seen that a refactoring action can cause many changes in different compilation units.  These changes can be undone as a group.

  1. In the menu bar, select Edit > Undo Rename Compilation Unit.

    Refactor menu

  2. The refactoring changes are undone, and the workbench returns to its previous state. You can undo refactoring actions right up until you change and save a compilation unit, at which time the refactoring undo buffer is cleared.
Related concepts

Refactoring support

Related reference

Refactoring actions
Refactoring wizard
Java preferences


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire