Software modifications are often systematic—they consist of similar,
but not identical, program changes to multiple contexts. Existing
tools for systematic program transformation are limited because
they require programmers to manually prescribe edits or only suggest
a location to edit with a related example. This paper presents
the design and implementation of a program transformation tool
called SYDIT. Given an example edit, SYDIT generates a contextaware,
abstract edit script, and then applies the edit script to new
program locations. To correctly encode a relative position of the
edits in a new location, the derived edit script includes unchanged
statements on which the edits are control and data dependent. Furthermore,
to make the edit script applicable to a new context using
different identifier names, the derived edit script abstracts variable,
method, and type names. The evaluation uses 56 systematic
edit pairs from five large software projects as an oracle. SYDIT has
high coverage and accuracy. For 82% of the edits (46/56), SYDIT
matches the context and applies an edit, producing code that is 96%
similar to the oracle. Overall, SYDIT mimics human programmers
correctly on 70% (39/56) of the edits. Generation of edit scripts
seeks to improve programmer productivity by relieving developers
from tedious, error-prone, manual code updates. It also has the
potential to guide automated program repair by creating program
transformations applicable to similar contexts.