the blog
Back to -Blog

ActionScript Refactoring #2 - Renaming

refactoring with previews and undo/redo
by Dermot Hogan
Tuesday 7 April 2009.

I’m implementing Refactoring for ActionScript and MXML in Amethyst. Over the next couple of weeks, I’ll describe the refactoring features being developed for Amethyst and how they work for ActionScript and Flex [1].

In Visual Studio, the ‘standard’ refactoring involves
- Rename
- Extract Method
- Encapsulate Field
- Extract Interface
- Promote Local Variable to Parameter
- Remove Parameters
- Reorder Parameters

Let’s have a look at Rename. This involves using the information from Find All References (described in a previous blog entry) and changing the text in the various files to the new text.

However, there’s a couple of tricky bits. The first is that (modelling my code on the C# rename system), there should be a preview of all changes that you are going to make.

It took me a bit of time to figure out how to get all this to work, but here’s the preview (again closely modelled on C# - note the nifty refactoring markers in the preview pane):

The next tricky bit is to get the undo/redo going. One of the things that’s really important with a global name change is the ability to unscramble the mess that you’ve made. It turns out that Visual Studio has a pretty neat undo/redo system which does exactly what’s required – once you’ve figured out how to use it, that is.

Here’s the result:

...and the undo/redo does work as advertised.

Next ... Extracting Methods

[1] Only available in the Professional Edition

Bookmark and Share   Keywords:  Amethyst  development  refactoring
© SapphireSteel Software 2014