Refactoring in the DVT Eclipse IDE - How to Perform Rename Refactoring
Overview
Sometimes you need to change the name of a class, module, function or signal. This operation, known as Rename Refactoring, requires changing both the declaration and all of the usages of the renamed element.
Unlike plain text search and replace, Rename Refactoring in DVT is accurate. This is because in the DVT Eclipse IDE the code is compiled, each identifier is resolved, and only the relevant occurrences are updated by Rename Refactoring.
Explore the design and verification tools: https://www.dvteclipse.com
Or request a license: https://www.dvteclipse.com/request-license
Details
Introduction
Sometimes you need to change the name of a class, module, function or signal. This operation, known as Rename Refactoring, requires changing both the declaration and all of the usages of the renamed element.
Renaming a Function
Let's start with a function.
- Place the editor cursor on the function name and right-click, Refactor > Rename, or just press the
Alt+Shift+R
keyboard shortcut. - A dialog prompting for the new function name appears.
- Edit the name and press Preview to see what changes are about to be performed.
- A list of the files about to be changed is shown in the upper panel, while the lower panel shows a compare view per file before and after the refactoring operation.
- You can see that the function name will be changed in the external function declaration, the function definition and its end tag, as well as the function usage in a different file.
Renaming a Virtual Interface Signal
Now let's do the same for a virtual interface signal.
- Press
Ctrl+Shift+T
to bring up the Quick Types View and typea_i
to open up the apb interface. - Place the editor cursor on the
paddr
port and pressAlt+Shift+R
, enter new name, press Preview and OK.
The Advantages of Rename Refactoring
Unlike plain text search and replace, Rename Refactoring is accurate. Note that the paddr
port of the apb master interface is untouched. This is because in the DVT Eclipse IDE the code is compiled, each identifier is resolved, and only the relevant occurrences are updated by Rename Refactoring. Rename Refactoring works for any identifier, for example macros, modules, parameters, classes, and so on.