Refactoring is an integral part of the modern software development process. Often, the refactoring must be performed at the global level with modifications in a large number of files. Making these modifications is a long and painstaking work. However, users rarely employ automated tools for this purpose because they consider them unreliable and difficult to use. In this paper, a new tool for transforming the source code is described. It is based on the intuitively clear specification of transformation rules in the form of short code fragments in C or C++. These rules describe the code before and after the transformation. We believe that, due to the absence of additional abstractions (such as domain-specific languages), this approach can be easily used in practice. Even though the tool uses source code templates, it operates on the level of the abstract syntax tree. This enables the tool to better analyze the code and verify the validity of transformations.
Refactoring is a standard part of any modern development cycle. It helps to reduce technical debt and keep software projects healthy. However, in many cases refactoring requires that transformations are applied globally across multiple files. Applying them manually involves large amounts of monotonous work. Nevertheless, automatic tools are severely underused because users find them unreliable, difficult to adopt, and not customizable enough. This paper presents a new code transformation framework. It delivers an intuitive way to specify the expected outcome of a transformation applied within the whole project. The user provides simple C/C++ code snippets that serve as examples of what the code should look like before and after the transformation. Due to the absence of any additional abstractions (such as domain-specific languages), we believe this approach flattens the learning curve, making adoption easier. Besides using the source code of the provided snippets, the framework also operates at the AST level. This gives it a deeper understanding of the program, which allows it to validate the correctness of the transformation and match the exact cases required by the user.