AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representations
Xiaoyu Liu, Jinu Jang, Neel Sundaresan, Miltiadis Allamanis, Alexey, Svyatkovskiy

TL;DR
AdaptivePaste is a learning-based model that uses transformers and dataflow-aware pre-training to effectively adapt variable identifiers in pasted code snippets, significantly improving accuracy and efficiency in real-world scenarios.
Contribution
The paper introduces AdaptivePaste, a novel transformer-based approach with a specialized pre-training task for semantics-aware variable usage representation in code adaptation.
Findings
Achieves 79.8% accuracy in code adaptation tasks.
Reduces manual adaptation time by nearly 50%.
Helps prevent bugs in code snippets.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Software System Performance and Reliability · Scientific Computing and Data Management
MethodsRepair · simple Copy-Paste
