Abstract

The number of possible refactorings is unlimited, so no tool vendor will ever be able to provide custom refactorings for all specific user needs. Therefore, we propose a new kind of refactoring tools, which allow users to create, edit and compose required refactorings just like any other documents. The heart of such a refactoring editor is the ability to compose larger refactorings from existing ones. Computing the precondition of the composite refactoring from the preconditions of the composed refactorings is non-trivial since earlier transformations influence the truth of preconditions of later ones. The ability to calculate these effects without referring to a particular program to which the refactorings should be applied is called program-independent composition. It is the prerequisite for creating composite refactorings that are reusable on arbitrary programs. The main contribution of this paper is a formal model for automatic, program-independent composition of conditional program transformations. We show that conditional transformations, including refactorings, can be composed from a limited set of basic operations. Program-independent derivation of a precondition for the composite is based on the notion of “transformation description”, which can be seen as a simplified, yet equally powerful, variant of Roberts’ “postconditions” (Practical analysis for refactoring, Ph.D. Thesis (1999)). Our approach simplifies the implementation of refactoring tools—only the basic operations and the ability for composition must be hard coded in a tool. As a proof of concept, we sketch a transformation framework that implements our approach ( jConditioner) and, based on the framework, an experimental refactoring tool ( ConTraCT) that includes the editing capabilities that motivated our work.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call