reCode : A Lightweight Find-and-Replace Interaction in the IDE for Transforming Code by Example

Software developers frequently confront a recurring challenge of making code transformations—similar but not entirely identical code changes in many places—in their integrated development environments. Through formative interviews (n = 7), we found that developers were aware of many tools intended to help with code transformations, but often made their changes manually because these tools required too much expertise or effort to be able to use effectively. To address these needs, we built an extension for Visual Studio Code, called reCode. reCode improves the familiar find-and-replace experience by allowing the developer to specify a straightforward search term to identify relevant locations, and then demonstrate their intended changes by simply typing a change directly in the editor. Using programming by example, reCode automatically learns a more general code transformation and displays these transformations as before-and-after differences inline, with clickable actions to interactively accept, reject, or refine the proposed changes. In our usability evaluation (n = 12), developers reported that this mixed-initiative, example-driven experience is intuitive, complements their existing workflow, and offers a unified approach to conveniently tackle a variety of common yet frustrating scenarios for code transformations.

[1]  Louis Wasserman Scalable, example-based refactorings with refaster , 2013, WRT '13.

[2]  Tom Mens,et al.  A survey of software refactoring , 2004, IEEE Transactions on Software Engineering.

[3]  Miryung Kim,et al.  Sydit: creating and applying a program transformation from an example , 2011, ESEC/FSE '11.

[4]  Andrew P. Black,et al.  Refactoring Tools: Fitness for Purpose , 2008, IEEE Software.

[5]  Lee E. McMahon Sed—a non-interactive text editor , 1990 .

[6]  Sumit Gulwani,et al.  On the fly synthesis of edit suggestions , 2019, Proc. ACM Program. Lang..

[7]  Manu Sridharan,et al.  Refactoring with synthesis , 2013, OOPSLA.

[8]  Yuzo Fujishima,et al.  Demonstrational automation of text editing tasks involving multiple focus points and conversions , 1998, IUI '98.

[9]  Claire Le Goues,et al.  Lightweight multi-language syntax transformation with parser parser combinators , 2019, PLDI.

[10]  Hoan Anh Nguyen,et al.  Recurring bug fixes in object-oriented programs , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[11]  Hridesh Rajan,et al.  A study of repetitiveness of code changes in software evolution , 2013, 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[12]  R. Stallman EMACS the extensible, customizable self-documenting display editor , 1981, SIGPLAN SIGOA Symposium on Text Manipulation.

[13]  Danny Dig,et al.  Graph-Based Mining of In-the-Wild, Fine-Grained, Semantic Code Change Patterns , 2019, 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).

[14]  Atsushi Sugiura,et al.  Simplifying macro definition in programming by demonstration , 1996, UIST '96.

[15]  Danny Dig,et al.  Type Migration in Ultra-Large-Scale Codebases , 2019, 2019 IEEE/ACM 41st International Conference on Software Engineering (ICSE).

[16]  Miryung Kim,et al.  Lase: Locating and applying systematic edits by learning from examples , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[17]  Hridesh Rajan,et al.  Boa: A language and infrastructure for analyzing ultra-large-scale software repositories , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[18]  Francisco Servant,et al.  Regexes are Hard: Decision-Making, Difficulties, and Risks in Programming Regular Expressions , 2019, 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[19]  Ralph E. Johnson,et al.  How do APIs evolve? A story of refactoring , 2006, J. Softw. Maintenance Res. Pract..

[20]  Sumit Gulwani,et al.  Automating string processing in spreadsheets using input-output examples , 2011, POPL '11.

[21]  Sumit Gulwani,et al.  Learning Syntactic Program Transformations from Examples , 2016, 2017 IEEE/ACM 39th International Conference on Software Engineering (ICSE).

[22]  Eric Horvitz,et al.  Principles of mixed-initiative user interfaces , 1999, CHI '99.

[23]  Michael Philippsen,et al.  Automatic Clustering of Code Changes , 2016, 2016 IEEE/ACM 13th Working Conference on Mining Software Repositories (MSR).

[24]  Miryung Kim,et al.  Discovering and representing systematic code changes , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[25]  Brad A. Myers,et al.  Tourmaline (abstract): macrostyles by example , 1993, INTERCHI.

[26]  Sumit Gulwani,et al.  Feedback-driven semi-supervised synthesis of program transformations , 2020, Proc. ACM Program. Lang..

[27]  Brad A. Myers,et al.  Improving API usability , 2016, Commun. ACM.

[28]  Ian H. Witten,et al.  Cima: An Interactive Concept Learning System for End-User Applications , 1997, Appl. Artif. Intell..

[29]  Sumit Gulwani,et al.  Programming by Examples , 2017, Encyclopedia of Machine Learning and Data Mining.

[30]  Miryung Kim,et al.  An empirical study of code clone genealogies , 2005, ESEC/FSE-13.

[31]  Rob Miller,et al.  Cluster-based find and replace , 2004, CHI '04.

[32]  Rijnard van Tonder,et al.  Lightweight multi-language syntax transformation with parser parser combinators , 2019, PLDI 2019.

[33]  Brad A. Myers,et al.  Invisible programming , 1990, Proceedings of the 1990 IEEE Workshop on Visual Languages.

[34]  Robert Nix,et al.  Editing by example , 1985, POPL '84.

[35]  Shinji Kusumoto,et al.  CCFinder: A Multilinguistic Token-Based Code Clone Detection System for Large Scale Source Code , 2002, IEEE Trans. Software Eng..

[36]  Sumit Gulwani,et al.  Wrex: A Unified Programming-by-Example Interaction for Synthesizing Readable Code for Data Scientists , 2020, CHI.

[37]  Rob Miller,et al.  Interactive Simultaneous Editing of Multiple Text Regions , 2001, USENIX ATC, General Track.

[38]  Andrew P. Black,et al.  How we refactor, and how we know it , 2009, 2009 IEEE 31st International Conference on Software Engineering.