Program transformation by demonstration can be helpful to complete the code automatically based on the examples given by developers. For instance, automatic transformation can be done with systematic edits that are similar but not identical edits to multiple locations for bug fixes, feature editions, and new API adaptation. However, existed transformation tools are not popular because of its tedious configuration process, unintuitive variable names, and lack of impact analysis.
To address the limitations mentioned above, we implement a systematic editing tool called Clipboard to demonstrate examples via drag-and-drop, recommend suitable recipes based on the live edit stream on the fly, synthesize reasonable names based on the naming patterns, and inform developers of the speculative impact of the program transformation.
Our evaluation through blind experiments and controlled user studies shows that our approach greatly improves the usability of existed program transformation tools, the name generated by Clipboard is equally intuitive as the manual created variable names, and the speculative analysis encourage developers to perform safe transformations to multiple places while reminding them of the relevant changes that should be applied before making a systematic edit.
We makes the following three contributions
-
To simplify the definition, invocation, and configuration process of example-based systematic edits, we allow developers to manipulate the region of systematic edits intuitively via drag-and-drop. Given a list of edit recipes, we match the most suitable systematic edit on the fly and invoke the transformation based on the incoming edit stream.
-
We conduct a speculative analysis of the potential compilation errors caused by the transformation and inform the developer of the problems along with the preview of the target code region after the transformation.
-
To increase the comprehension of the auto-generated transformation code, we leverage naming patterns between relevant identifiers and synthesize the identifier names initialized by the changes.