Scala Refactoring Term Project
If you’re a Java programmer and haven’t yet heard of Scala, take a look at this nice Scala Tutorial.
What follows is my project proposal for my master term project (12 ECTS, ~360 hours of work, the same as a bachelor thesis actually). The project starts next week and will keep my busy for the next 14 weeks.
If Scala wants to succeed Java, it needs strong IDE support, and this includes automated refactorings. Although studies show that refactoring tools are underused, they still serve as a strong selling point to convince programmers to use an IDE (or even a whole language) over a simple text editor. Several Scala IDEs are under development, but all of them lack extensive support for refactoring.
I’ve worked on various projects implementing (Ruby, C++) and supervising (JavaScript, Groovy) refactoring tools. Taking advantage of these experiences, I believe that a sound refactoring engine can be built for Scala in due time.
Objectives
Scala should get an IDE independent facility to perform refactorings. This API can then be used by all IDEs and other tools to refactor Scala code – fostering collaboration to get truly great refactoring capabilities instead of several half-baked implementations from competing IDEs (as the situation with other languages – e.g. Ruby – is today).
The basis to create a successful tool is the code manipulation strategy, i.e. how the source is modified, and most important, how the changed source is obtained (formatting, comments, white-space). In the past, we at the Institute for Software experimented with different strategies but have yet to come up with a silver bullet. Therefore, the first focus of this project will be to analyze existing ways and to come up with a suitable code representation for this project. Additionally, Scala’s functional aspects (especially pattern matching) should lend itself ideally to the manipulation of tree-like data-structures.
Finally, to make the implementation of refactorings easier, several granularities of abstractions will be needed. Basic building blocks to modify the source trees (e.g. ‘move x to y’, ‘rename x to y’, ‘create a new X at y’) can then be assembled to complete refactorings (“cursor position is x, rename all references to ‘y'”) and exposed together with – probably already existing – query-operations (‘what can be renamed’, ‘what is located at the current cursor position’) and feedback (warnings, errors) through the API. The result of such a refactoring operation will be a set of diffs the IDE can then apply and show to the user.
Vision
To my knowledge there exists no language that has IDE independent refactoring support, and the only people creating new refactorings are the developers of the IDE. If this project succeeds, Scala will have a simple API to manipulate its source code on which refactorings and other code manipulation tools (e.g. quick fixes, code generators) can be built by Scala programmers and not only IDE adepts.
Desired Results
An API to do refactoring together with an implementation and ideally two reference users in the form of automated tests and an Eclipse plug-in. Whether these goals are realistic will be determined during the project and adapted if necessary. A more detailed project plan will be developed in the first week of the project, as soon as the effort can be better estimated with regards to the available environment (e.g. the richness and suitability of the AST).
Now, what do you think? How important is automated refactoring support for you in choosing an IDE or a language?
the only two independent refactoring lib’s I heard of are for python:
* http://rope.sourceforge.net/
* http://bicyclerepair.sourceforge.net/
but I’m sure there are some more out there for other languages. 😉
hth
pretty interesting the idea of having an API for refactorings. I’m coding with .NET/C# at the moment and I like to work with VisualStudio, despite the fact that it’s pretty bloated. I don’t use the refactoring tools too much, but when needed, they’re useful and the likelihood of making errors while refactoring is very low (near 0) compared to manual refactorings. but I have to admit, that when choosing a language to study or to work with, I don’t look how well automated refactoring is supported. certainly it’s good when a language comes with automated refactoring possibilities (it’s a little plus point), but I don’t think that it’s crucial for choosing a language.
it will be interesting to see how everything will shape up in the next 14 weeks. surely it’s an interesting project
Hi Mirko,
Glad you’re working on Scala refactoring. I’m also addict to refactoring and I too believe refactoring support for a language is crucial for its adoption by a wider audience, especially in the industry.
Given Scala’s very strong typing, refactoring possibilities with Scala look very promising.
Hoping you make it a reality 🙂
Kind regards,
Cédric