Clone-based and interactive recommendation for modifying pasted code
Authors:
Open Access
- 30 August 2015
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 520-531
Abstract
Developers often need to modify pasted code when programming with copy-and-paste practice. Some modifications on pasted code could involve lots of editing efforts, and any missing or wrong edit could incur bugs. In this paper, we propose a clone-based and interactive approach to recommending where and how to modify the pasted code. In our approach, we regard clones of the pasted code as the results of historical copy-and-paste operations and their differences as historical modifications on the same piece of code. Our approach first retrieves clones of the pasted code from a clone repository and detects syntactically complete differences among them. Then our approach transfers each clone difference into a modification slot on the pasted code, suggests options for each slot, and further mines modifying regulations from the clone differences. Based on the mined modifying regulations, our approach dynamically updates the suggested options and their ranking in each slot according to developer's modifications on the pasted code. We implement a proof-of-concept tool CCDemon based on our approach and evaluate its effectiveness based on code clones detected from five open source projects. The results show that our approach can identify 96.9% of the to-be-modified positions in pasted code and suggest 75.0% of the required modifications. Our human study further confirms that CCDemon can help developers to accomplish their modifications of pasted code more efficiently.Keywords
Funding Information
- National Natural Science Foundation of China (61370079)
- National High Technology Development 863 Program of China (2013\\AA01A605)
This publication has 32 references indexed in Scilit:
- Learning natural coding conventions2014
- EUKLAS2014
- CSCC: Simple, Efficient, Context Sensitive Code Completion2014
- On the naturalness of software2012
- An Empirical Study of Long-Lived Code Clones2011
- JCCD2010
- Change Distilling:Tree Differencing for Fine-Grained Source Code Change ExtractionIEEE Transactions on Software Engineering, 2007
- Clone Smells in Software Evolution2007
- Determining detailed structural correspondence for generalization tasks2007
- CLUSTAL: a package for performing multiple sequence alignment on a microcomputerGene, 1988