AdaptivePaste: Code Adaptation through Learning Semantics-aware Variable Usage Representations
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.
Code (0)
등록된 구현이 없습니다.
Tasks
Program RepairMethods 이 논문이 사용한 방법론
Similar Papers 제목 키워드 기반
SIGMA: Semantic-complete Graph Matching for Domain Adaptive Object Detection
Domain Adaptive Object Detection (DAOD) leverages a labeled domain to learn an object detector generalizing to a novel domain free of annotations. Recent advances align class-conditional distributions by narrowing down c…
Graph MatchingHallucinationobject-detectionObject DetectionSemantics-aware Test-time Adaptation for 3D Human Pose Estimation
This work highlights a semantics misalignment in 3D human pose estimation. For the task of test-time adaptation, the misalignment manifests as overly smoothed and unguided predictions. The smoothing settles predictions t…
3D human pose and shape estimation3D Human Pose Estimation3D Pose Estimationmotion prediction+4Semantics-Aware Image to Image Translation and Domain Transfer
Image to image translation is the problem of transferring an image from a source domain to a different (but related) target domain. We present a new unsupervised image to image translation technique that leverages the un…
DecoderDomain AdaptationImage-to-Image TranslationObject+2SA$^{2}$GFM: Enhancing Robust Graph Foundation Models with Structure-Aware Semantic Augmentation
We present Graph Foundation Models (GFMs) which have made significant progress in various tasks, but their robustness against domain noise, structural perturbations, and adversarial attacks remains underexplored. A key l…
Graph ClassificationDomain AdaptationSemantics-aware Attention Improves Neural Machine Translation
The integration of syntactic structure into Transformer machine translation has shown positive results, but to our knowledge, no work has attempted to do so with semantic structures. In this work we propose two novel par…
DecoderMachine TranslationTranslation