The latest beta of Amethyst provides SmartTags for refactoring. If you change the name of a variable, class or method, a tag appears to let rename all references to that identifier throughout your entire project. In fact, Amethyst also supports another sort of SmartTag for organizing imports (Dermot Hogan’s blog entry gives a few examples) and future betas will add a few others too.
Here is a short example of how to use Amethyst SmartTags for refactoring by renaming:
This is a method that I want to rename...
I rename it by editing the text. When I do so, a little red ‘tag’ appears at the end of the method name (just under the ‘s’ of ‘exploreThings’):
I hover over the tag and a small box appears. I click the drop-down arrow-head in this box and a menu appears, showing me the renaming options available. Here I decide to preview the changes before going ahead and renaming all the references to this method:
Now the ‘rename preview’ dialog pops up. This shows me all the references to this method in my project. I can deselect specific references by unchecking them if I wish. When I click ‘Apply’ any code which previously called ‘exploreWidgets’ method will automatically be rewritten so that it calls the method by its new name, ‘exploreThings’:
As I said, SmartTags can also be used to rename other identifiers such as variables and classes. I’ll have more to say about some new SmartTag refactoring features after the release of our next major beta of Amethyst.