New ActionScript/Flex Refactoring: Pull Members Up

Today we’re continuing our series of posts about new ActionScript/Flex refactorings that you can find in the latest Maia EAP, with presentation of this new aid: pull class members up the classes hierarchy.

Let’s have look at this simple example. Say, we’re designing an API for handling and displaying 2D shapes. We begin with Drawable interface, surprisingly containing method draw() and Rectange class, that implements this interface and also contains property visible:

We may eventually find out that all these members are actually valid not only for rectangles, but for any other shape as well, so we’re creating a base class Shape and are about to bring them there:

Refactoring we’re talking about here makes it simple. All we need is to place the caret somewhere inside of Rectangle class code and invoke Refactor | Pull Members Up.

Note: we can move not only class members, but also interfaces from the implements list! Cool, isn’t it?

Now, select members to be moved, and their new parent — a class or interface. When we select a member that is using another, the latter is highlighted with red (if not selected). When we select an implements XXX item, all methods from XXX interface are highlighted with blue (again, unselected ones).

Well, it’s time to click OK and see what happens!

Note: When we’re pulling a class method to an interface, IntelliJ IDEA does not remove it from the class, but instead creates a method declaration in that interface. For such methods IntelliJ IDEA shows a dialog with make abstract option selected and also lets you choose how to handle their ASDoc: keep as is, copy, or move to interface.

Note: You can seamlessly pull from/to Flex MXML components.

We hope you find this refactoring useful!

This entry was posted in New Features and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>