Refactoring in the DVT Eclipse IDE - How to Perform Extract to Variable Refactoring
Description
Using DVT's Extract to Variable refactoring, an expression inside a function or task can easily be extracted to a local variable. Just select the expression and press Ctrl+1 - the variable will be declared and initialized with the extracted expression in the correct scope. You may chose to replace all the occurrences of the expression with the newly created variable, or only the selected one.
Explore the design and verification tools: https://www.dvteclipse.com
Or request a license: https://www.dvteclipse.com/request-license
Transcript
An expression inside a function or task can be extracted to a local variable.
Extracting the Expression
- Select the expression and press
CTRL+1
. - Use the up and down arrows to pick a proposal from the list and press
Enter
to apply it. - You may change the variable name and type.
- Press the
Tab
key to switch between the edit boxes andEnter
when done. - The variable is declared and initialized with the extracted expression in the correct scope.
Replacing Multiple Occurrences
If the expression occurs multiple times throughout the function, you may choose to replace all the occurrences with the newly created variable or only the selected one.