Use and refactoring shortcuts of Eclipse refactoring function, and eclipse refactoring

Source: Internet
Author: User

Use and refactoring shortcuts of Eclipse refactoring function, and eclipse refactoring


What is refactoring? After the code is written, improve its design.


Reconstruction classification: physical structure, class hierarchy, and class internal structure.

Name Shortcut Key Literal Translation Scope Description
Rename Alt + Shift + R     You can rename any variables, classes, methods, package names, and folders, and modify them in all the places where they are used.
Move Alt + Shift + V   Field Move fields to other classes and classes to other packages


Name Shortcut Key Literal Translation Scope Description
Change Method Signature Alt + Shift + C Modify method Signature Method You can modify the method name, access permission, add and delete method parameters, modify the Parameter order, and add method exceptions.
Extract Method Alt + Shift + M Extraction Method Method Select any code, convert it to a method, and add the return type of the parameter automatically.
Extract Local Variable Alt + Shift + L Extract local variables Character/Number It is usually used as an expression to extract one of the local variables. For example, 3 + 5 is extracted as int I = 3;
Extract Constant Ctrl + 1 Extract to Constant Extract Constants Character/Number Extracts a string or number from any position as a static global constant. All characters or numbers that use this character are replaced with constants.
Inline Alt + Shift + I Inline Method Replace the place where this method is called with the content of this method. Select any method to use this function. (There are two options: All invocations and Only the selected invocation)


Name Shortcut Key Literal Translation Scope Description
Convert Local Variable to Field Alt + Shift + K Convert local variables to global variables Local variable You can change the local variable name to all variables.
Convert Anonymous Class to Nested   Convert an anonymous class to a nested internal class Anonymous class You can set the type, including the field type.
Move Type to New File   Move class to new file Nested class Create a new class file with nested classes



Name Shortcut Key Literal Translation Scope Description
Extract Supperclass   Extract parent class   Extract the selected field or method and place it in its parent class (note that the field used in the extraction method is extracted first)
Extract Interface   Extraction Interface Class Generate an interface from the method of a class (only the method of the current class will change to the interface, other places that use this method will not)
Use Supertype Where Possible   Use the parent type whenever possible Class Converts the selected reference to the reference of its parent class.
Push Down   Push-down Variables and Methods Move the selected method from the parent class to the subclass, and change the response method in the parent class to the abstract method.
Pull Up   Move up Variables and Methods In contrast to Push Down, move the subclass Method to the parent class.



Name Shortcut Key Literal Translation Scope Description
Extract Class   Extracted as Class Field When all the selected fields are mentioned in the new class, you can choose to create a file or make the internal class
Introduce Parameter Object   Introduce parameter objects Method Extract Method parameters into a class (to avoid the exception of parameter reference modification in the method)

Name Shortcut Key Literal Translation Scope Description
Introduce Indirection       Let other classes call a method of the current class
Introduce Factory   Reference Factory Constructor Returns an object using a method.
Introduce Parameter   Introduce Parameters   Extract fields as parameters in the Method
Encapsulate Filed   Encapsulation Field   Provides the setter/getter Method for fields

Introduce FactorySelected entity is not a constructor invocation or definition.
Name Shortcut Key Literal Translation Scope Description
Generalize Declared Type       Replace a non-original object field (or method parameter) with its parent type.
Infer Generic Type Arguments       Deduce the appropriate generic type for those types in the original form
Generalize Declared Type exception Generalize Declared Type is not supported on primitive types. The original Type is not supported.


Name Shortcut Key Literal Translation Scope Description
Migrate JAR File        
Create Script        
Apply Script        
History        





ReferencesEclipse 3 Advanced Programming
Explore the reconstruction function in Eclipse JDT

Create a new refactoring function in Eclipse




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.