An Algorithm for Layout Preservation in Refactoring Transformations

Maartje de Jonge, Eelco Visser. An Algorithm for Layout Preservation in Refactoring Transformations. In Anthony M. Sloane, Uwe AƟmann, editors, Software Language Engineering - 4th International Conference, SLE 2011, Braga, Portugal, July 3-4, 2011, Revised Selected Papers. Volume 6940 of Lecture Notes in Computer Science, pages 40-59, Springer, 2011. [doi]


Transformations and semantic analysis for source-to-source transformations such as refactorings are most effectively implemented using an abstract representation of the source code. An intrinsic limitation of transformation techniques based on abstract syntax trees is the loss of layout, i.e. comments and whitespace. This is especially relevant in the context of refactorings, which produce source code for human consumption. In this paper, we present an algorithm for fully automatic source code reconstruction for source-to-source transformations. The algorithm preserves the layout and comments of the unaffected parts and reconstructs the indentation of the affected parts, using a set of clearly defined heuristic rules to handle comments.

Technical report

The following is a technical report version of this publication:


The following are older variants of this publication: