Copyright © 2006-2008 Huiqing Li, Simon Thompson
Authors: Huiqing Li (email@example.com) [web site: http://www.cs.kent.ac.uk/projects/forse].
Wrangler is an Erlang refactoring tool that supports interactive refactoring of Erlang programs. The current snapshot (Wrangler 0.1) is still a prototype, made available so that you can play with basic refactoring support for Erlang programs, and give us feedback or bug reports.
We DO NOT recommend to use this prototype on your production source just yet!
Refactoring is the process of improving the design of a program without changing its external behaviour. While refactoring by hand is possible, tool support for refactoring is invaluable as it is more reliable, and allows refactoring to be done (or undone) easily. Wrangler is such a tool that supports interactive refactoring of Erlang programs. The current snapshot of Wrangler supports a small number of basic Erlang refactorings, including renaming variable/function/module names and generalisation of a function definition.
Built on top of the functionalities provided by the Erlang syntax-tools package, Wrangler is embedded in the Emacs editing environment, and makes use of the functionalities provided by Distel, an Emacs-based user interface toolkit for Erlang, to manage the communication between the refactoring tool and Emacs.
Below is a snapshot of Wrangler, which shows a particular refactoring scenario. The user has selected the expression
io:format("Hello") in the definition of
repeat/1 , has chosen the Generalise Function Definition command from the Refactor menu, and has just entered a new parameter name A in the mini-buffer.
The result of this refactoring is shown in the snapshot below.
All the implemented refactorings are module-aware. In the case that a refactoring affects more than one module in the program, a message telling which files have been modified by the refactorer will be given after the refactoring has been successfully dine. The Customize command from the Refactor allows the user to specify the boundary of the program, i.e. the directories that will be searched and analysed by the refactorer, as shown in the example snapshot below.
Undo is supported by the refactorer. Applying undo once will revert the program back to the status right before the last refactoring performed. However, PLEASE NOTE that the refactorer undo is currently separate from the Emacs undo, and undoing a refactoring will lose all the editing activities after the refactoring.
Wrangler makes use of functionalities provided by the
epp_dodger module from Erlang SyntaxTools to parse Erlang source code, and the refactorer should be able to refactor Erlang modules
containing preprocessor directives and macro applications, as long as these are syntactically
"well-behaved" , otherwise the refactorer will give a syntax error message.
Our Refactoring Functional Programs project webpage contains more information and references about refactoring functional, especially Haskell, programs; and our progress and ideas about refactoring Erlang programs are available at our FORSE project webpage.