LASE: Locating and Applying Systematic Edits by Learning from Examples

Reviewed by Fayola Peters / 2013-09-20
Keywords: Refactoring

Meng2013 Na Meng, Miryung Kim, and Kathryn S. McKinley: "Lase: Locating and applying systematic edits by learning from examples". 2013 35th International Conference on Software Engineering (ICSE), 10.1109/icse.2013.6606596.

Adding features and fixing bugs often require systematic edits that make similar, but not identical, changes to many code locations. Finding all the relevant locations and making the correct edits is a tedious and error-prone process for developers. This paper addresses both problems using edit scripts learned from multiple examples. We design and implement a tool called LASE that (1) creates a context-aware edit script from two or more examples, and uses the script to (2) automatically identify edit locations and to (3) transform the code.

We evaluate LASE on an oracle test suite of systematic edits from Eclipse JDT and SWT. LASE finds edit locations with 99% precision and 89% recall, and transforms them with 91% accuracy. We also evaluate LASE on 37 example systematic edits from other open source programs and find LASE is accurate and effective. Furthermore, we confirmed with developers that LASE found edit locations which they missed. Our novel algorithm that learns from multiple examples is critical to achieving high precision and recall; edit scripts created from only one example produce too many false positives, false negatives, or both. Our results indicate that LASE should help developers in automating systematic editing. Whereas most prior work either suggests edit locations or performs simple edits, LASE is the first to do both for nontrivial program edits.

It's a pain to go into a large code base to change something because of the inclusion of new features, as is locating all the areas in a code base where similar, but not identical changes are needed. Recognizing that the literature tackles one problem, or both problems (but in a trivial manner), Meng et al. present LASE for Locating and Applying Systematic Edits.

What sets LASE apart from previous work by the same authors (Sydit), is the use of multiple example methods (rather than one) to learn an edit script (to avoid over specification and over generalization). Also, LASE automatically locates other methods to change while Sydit requires the developer locate these methods. LASE also helps the developer by suggesting changed methods based on the customized edit scripts for methods located by the edit script.

To evaluate their tool, Meng et al., experimented with two oracle test suites:

  1. Consists of multiple systematic edits that fix the same bug in multiple commits, drawn from two open-source programs, Eclipse JDT and Eclipse SWT.
  2. Contains 37 systematic edits from five Java open-source programs (jEdit, Eclipse jdt.core, Eclipse compare, Eclipse core.runtime, and Eclipse debug).

With impressive results of 99% precision and 89% recall for finding edit locations and transforms at 91% accuracy, LASE can be a great help to developers especially when dealing with very large code bases. A demonstration of LASE can be seen at: