Refactoring Support

A good IDE provides useful refactoring support. Since we’re planning to build a really good IDE for C, we have started adding a couple of them. Here is the list that is currently supported:

  • Extract Into new Module: one or more module contents (functions, variables, statemachines, etc) can be selected and moved into a new module. The system prompts for the new module’s name, creates it, moves the contents there and then adds an import of the new module to the original module. The contents in the new module are set to be exported if they are referenced from the original one.
  • Move to Imported Module: similar to the previous one, but this one does not create a new module. Instead it moves the selected contents into one of the modules that are already imported.
  • Introduce Variable: an expression, maybe a sub-expression of another one, is selected. The refactoring then prompts for a name, and proceeds to create a local variable with that name. The type of the variable is the type of the selected expression and the init value is the expression itself. The occurrence of the expression is replaced by a reference to the new variable.

This is obviously a small list, but it was only three hours work. MPS provides a DSL/API for expressing refactorings, and it is relatively straight forward to implement those. MPS also provides support for data flow analysis. That’s a topic we’ll have to investigate soon, so we can build more sophisticated refactorings.


2 thoughts on “Refactoring Support

  1. Sorry, are you thinking about upgrading to the MPS 2.0 version. Because I was trying to make an automatic upgrade and there are a bunch of errors.. so I couldn’t check your implementation. Anyway I think is a great project, keep working 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s