Use of the Eclipse Refactoring feature and refactoring shortcut keys

Source: Internet
Author: User



What is refactoring? Improve the design of the code after it has been written.


Refactoring classification: Physical structure, class hierarchy, class internal structure.

Name Shortcut keys Literal translation Function range Describe
Rename Alt + Shift + R You can rename any variable, class, method, package name, folder, and all the places you use will be modified uniformly.
Move Alt + Shift + V Field Move a field to another class, move the class to another package


Name Shortcut keys Literal translation Function range Describe
Change Method Signature Alt + Shift + C modifying method signatures Method Operation of the method, you can modify the method name, access permissions, increase the deletion method parameters, modify the parameter order, add method exception
Extract Method Alt + Shift + M Extract as Method Method Arbitrarily select a piece of code, automatically convert to method, add parameter return type automatically.
Extract Local Variable Alt + Shift + L Extracting Local variables Character/number Usually used for expressions, to extract one of the local variables, such as 3 + 5 is extracted to int i = 3;
Extract Constant Ctrl+1 Extract to Constant Extracting constants Character/number Extracts a string or a number from any position into a static global constant. Any use of this character or number will be replaced with a constant.
Inline Alt + Shift + I Inline Method Replace the place where this method is called directly with the contents of this method. Select any method to use this feature. (with all invocations and only the selected invocation two options)


Name Shortcut keys Literal translation Function range Describe
Convert Local Variable to Field Alt + Shift + K Local variables are transformed into global variables Local variables The variable name can be re-modified by converting the local variable to all variables.
Convert Anonymous Class to Nested Anonymous classes are converted to nested inner classes Anonymous class You can set the type, internally containing the field type, and so on.
Move Type to New File Move a class to a new file Nested classes Create a new class file in a nested class



Name Shortcut keys Literal translation Function range Describe
Extract Supperclass Extract Parent class Extracts the selected field or method into its parent class (note that the fields used in the extraction method are extracted first)
Extract Interface Extract Interface Class Generate an interface from a method of a class (only the method of the current class becomes an interface, and other places where this method is used)
Use supertype Where Possible Use parent type whenever possible Class Change the selected reference up to a reference to its parent class
Push down Push down Variables, methods Move the selected method from the parent class to the child class, and the response method in the parent class becomes an abstract method
Pull Up Move Up Variables, methods In contrast to push down, the method of the handle class is moved to the parent class



Name Shortcut keys Literal translation Function range Describe
Extract Class Extract as Class Field To refer to the new class for all the selected fields, you can choose to create a new file or make the inner class
Introduce Parameter Object Introducing Parameter objects Method Extracting a method parameter into a class (to avoid referencing the modified exception in the method)

Name Shortcut keys Literal translation Function range Describe
Introduce indirection Allow other classes to invoke a method of the current class
Introduce Factory Reference Factory constructor function Returns an object using a method
Introduce Parameter Introducing Parameters To extract a field as a parameter in a method
Encapsulate Filed Encapsulate Fields To provide a Setter/getter method for a field

Introduce factoryselected entity is a constructor invocation or definition.
Name Shortcut keys Literal translation Function range Describe
Generalize declared Type Replaces a non-primitive object field (or method parameter) with its parent type.
Infer Generic Type Arguments Speculate on the appropriate generic type for those types in the original form
Generalize declared type may occur with an exception Generalize declared type is not supported on primitive types. Original type not supported


Name Shortcut keys Literal translation Function range Describe
Migrate JAR File
Create Script
Apply Script
History





References"Eclipse 3 Advanced Programming"
Explore the refactoring features in Eclipse JDT

Create a new refactoring feature in Eclipse




Use of the Eclipse Refactoring feature and refactoring shortcut keys

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.