When you use the IDE's refactoring operations, you can change the structure of your code and have the rest of your code updated to reflect the changes you have made.
This topic provides short descriptions of the refactoring operations that are available in the IDE. Click the hyperlinked name of the refactoring operation for a full description on how to use the operation.
Refactoring Operation | Description |
---|---|
Rename | Enables you to change the name of a class, variable, or method to something more meaningful. In addition, it updates all source code in your project to reference the element by its new name. |
Introduce Variable, Constant, Field, or Method | Enables you to generate a statement based on the selected code and replace that block of code with a call to the statement. |
Change Method Parameters | Enables you to add parameters to a method and change the access modifier. |
Encapsulate Fields | Generates a getter method and and a setter method for a field and optionally updates all referencing code to access the field using the getter and setter methods. |
Pull Up | Moves methods and fields to a class that their current class inherits from. |
Push Down | Moves inner classes, methods, and fields to all subclasses of their current class. |
Move Class | Moves a class to another package or into another class. In addition, all source code in your project is updated to reference the class in its new location. |
Copy Class | Copies a class to the same or a different package. |
Move Inner to Outer Level | Moves an inner class one level up in hierarchy. |
Convert Anonymous Class to Inner | Converts an anonymous class to an inner class that contains a name and constructor. The anonymous inner class is replaced with a call to the new inner class. |
Extract Interface | Creates a new interface from the selected public non-static methods in a class or interface. |
Extract Superclass | Creates a new abstract class, changes the current class to extend the new class, and moves the selected methods and fields to the new class. |
Use Supertype Where Possible | Changes code that references the selected class (or other type) to instead use a supertype of that type. |
Safely Delete | Checks for references to a code element and then automatically deletes that element if no other code references it. |