AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representations
Liu, Xiaoyu, Jang, Jinu, Sundaresan, Neel, Allamanis, Miltiadis, Svyatkovskiy, Alexey
–arXiv.org Artificial Intelligence
In software development, it is common for programmers to copy-paste or port code snippets and then adapt them to their use case. This scenario motivates the code adaptation task -- a variant of program repair which aims to adapt variable identifiers in a pasted snippet of code to the surrounding, preexisting source code. However, no existing approach has been shown to effectively address this task. In this paper, we introduce AdaptivePaste, a learning-based approach to source code adaptation, based on transformers and a dedicated dataflow-aware deobfuscation pre-training task to learn meaningful representations of variable usage patterns. We evaluate AdaptivePaste on a dataset of code snippets in Python. Results suggest that our model can learn to adapt source code with 79.8% accuracy. To evaluate how valuable is AdaptivePaste in practice, we perform a user study with 10 Python developers on a hundred real-world copy-paste instances. The results show that AdaptivePaste reduces the dwell time to nearly half the time it takes for manual code adaptation, and helps to avoid bugs. In addition, we utilize the participant feedback to identify potential avenues for improvement of AdaptivePaste.
arXiv.org Artificial Intelligence
Oct-6-2023
- Country:
- Europe > United Kingdom
- England > Cambridgeshire > Cambridge (0.04)
- North America > United States
- California > Alameda County
- Berkeley (0.04)
- District of Columbia > Washington (0.05)
- New York > New York County
- New York City (0.04)
- North Carolina > Wake County
- Cary (0.04)
- Washington > King County
- Redmond (0.04)
- California > Alameda County
- Europe > United Kingdom
- Genre:
- Research Report > New Finding (1.00)
- Industry:
- Information Technology (0.93)
- Technology:
- Information Technology
- Artificial Intelligence
- Machine Learning > Neural Networks (1.00)
- Natural Language (1.00)
- Representation & Reasoning (0.93)
- Software (0.94)
- Software Engineering (1.00)
- Artificial Intelligence
- Information Technology