Welcome to Wrangler -- an Erlang Refactorer

Copyright © 2006-2009 Huiqing Li, Simon Thompson

Version: 0.8.2

Authors: Huiqing Li , Simon Thompson [web site: http://www.cs.kent.ac.uk/projects/wrangler].

Wrangler is an Erlang refactoring tool that supports interactive refactoring of Erlang programs. The current snapshot (Wrangler 0.8.2) is still a prototype, made available so that you can play with basic refactoring supports for Erlang programs, and give us feedback or bug reports.

Contents

  1. Introduction
  2. The Interface of Wrangler
  3. Support for Macros
  4. Refactoring Code with Syntax Errors
  5. Typed Records and Type Specifications
  6. References
  7. Acknowledgements

Introduction

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 number of basic Erlang refactorings, such as renaming of variable/function/module names, generalisation of a function definition, etc.

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.

In collaboration with the Erlide team, we are now also in the process of integrating Wrangler with the Eclipse Environment.

The Interface of Wrangler

Below is a snapshot of Wrangler embedded in Emacs, 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 sub-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.

Preview of the changes to be made by a refactoring is supported, and the user could choose to commit or abort the refactoring result after preview.

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 done. The Customize Wrangler command from the Refactor sub-menu 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.

Below is a snapshot of Wrangler embedded in Eclipse + Erlide.

Support for Macros

Wrangler makes use of functionalities provided by the epp_dodger module from Erlang SyntaxTools to parse Erlang source code, and should be able to refactor Erlang modules containing preprocessor directives and macro applications, as long as the macro definitions are syntactically "well-behaved".

Refactoring Code with Syntax Errors

Wrangler accepts Erlang programs with syntax errors or macro definitions that cannot be parsed by SyntaxTools. In the case that the program under consideration has syntax errors or unparsable macros, functions/attributes to which these syntax errors belong are not affected by the refactoring process, however warning messages asking for manual inspection of those parts of the program are given after the refactoring.

Typed Records and Type Specification

The current implementation of Wrangler does not support typed records and type specifications yet; functionalities to support these features are being added however.

References

Our Refactoring Functional Programs project website 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.

Acknowledgements

The work was initially supported by EPSRC in the UK, and is now by the European Commission. We are very grateful that we were able to build the tool on top of Distel, Erlang SyntaxTools and make use some of the ideas from DIALYZER.

Generated by EDoc, May 27 2009, 13:11:48.