IntelliJ IDEA’s Move Refactoring for ActionScript/Flex gets Smarter

At JetBrains we not only bring you new powerful features that make your life better, but also take care to polish the good old stuff to perfection. Let’s take a look at the Move refactoring for ActionScript classes, Flex components and all other types of top-level declarations (namespaces, functions, variables and constants), that has just got a little smarter. By the way, this refactoring also works for inner declarations (also known as helpers or file-local declarations), defined in ActionScript file out of the package statement.

Generally speaking there’s nothing special about Move refactoring, but in complex multi-module projects choosing a right folder may turn out harder than it seems to be. Well, not anymore it isn’t, and here’s the proof.

We’ll start with, invoking Move action by pressing F6 in editor, Project view or UML diagram (don’t forget to select your class/top-level function/whatever else first):

Here we specify the target package (thinking in terms of packages instead of directories is a lot more natural, isn’t it?). As we type, IntelliJ IDEA assists us with completion and highlights packages that don’t exist with red, which means they will be created on-the-fly, which is good, because we can start coding right away without preparing package structure in advance.

We can opt to searching for out-of-the-code usages (e.g. comments, string constants and properties files), and finally, if we need to move a class to a different source folder (e.g. to another module), all we need to to is to select an appropriate option! This way, after pressing Refactor or Preview we’ll be able to choose which module and source root to move to (current source root will be preselected):

And that’s it! No need to bother with directories anymore!

Of course, all changes can be previewed first, so that we can see the entire picture without making any actual changes, which is cool, because not all changes are safe. Press Preview and here we go:

All the usages of moved element grouped by type and location, plus we can easily exclude usages we don’t want modified.

Another interesting case is to move inner class to the top-level. This may be useful when some utility class has grown enough to deserve a separate file. Here’s an example:

Just as before, place the caret at the class and press F6:

Now accept the name and package of a new top-level class, and IntelliJ IDEA will take care about the rest.

We wish you safe refactoring, and keep watching this blog for the latest news!

image description