AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representations

05/23/2022
by   Xiaoyu Liu, et al.
0

In software development, it is common for programmers to copy-paste code snippets and then adapt them to their use case. This scenario motivates code adaptation task – a variant of program repair which aims to adapt all variable identifiers in a pasted snippet of code to the surrounding, preexisting source code. Nevertheless, no existing approach have been shown to effectively address this task. In this paper, we introduce AdaptivePaste, a learning-based approach to source code adaptation, based on the transformer model 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. Evaluation results suggest that our model can learn to adapt copy-pasted code with 79.8% accuracy.

READ FULL TEXT
research
11/18/2019

Commit2Vec: Learning Distributed Representations of Code Changes

Deep learning methods, which have found successful applications in field...
research
11/18/2019

patch2vec: Distributed Representation of Code Changes

Deep learning methods, which have found successful applications in field...
research
05/28/2021

Learning to Extend Program Graphs to Work-in-Progress Code

Source code spends most of its time in a broken or incomplete state duri...
research
07/18/2022

What does Transformer learn about source code?

In the field of source code processing, the transformer-based representa...
research
10/08/2021

Towards Learning (Dis)-Similarity of Source Code from Program Contrasts

Understanding the functional (dis)-similarity of source code is signific...
research
06/27/2022

DeepPERF: A Deep Learning-Based Approach For Improving Software Performance

Improving software performance is an important yet challenging part of t...

Please sign up or login with your details

Forgot password? Click here to reset