paperbot · PL 论文追踪

全部论文 待读 收藏

P2 AdaptivePaste: Intelligent Copy-Paste in IDE

AdaptivePaste:IDE 中的智能复制粘贴
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 4/10 · 该论文属于 ML×PL 交叉的工具型工作,用到了数据流感知的预训练来学习变量使用模式,与用户对静态分析应用(PL→AI)有一定交集;但其目标是代码粘贴适配这一具体 IDE 任务,并未涉及静态分析/形式化验证本身的改进,也与浮点、贝叶斯程序分析、Agentic 程序分析等核心方向无关。引用 5 inbox
Xiaoyu Liu, Jinu Jang, Neel Sundaresan, Miltiadis Allamanis, Alexey Svyatkovskiy
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:用数据流感知预训练的 Transformer 自动改写粘贴代码中的变量标识符,实现代码适配。

开发者在复制粘贴代码片段后,通常需要手动修改变量名以匹配周围已有上下文,这一「代码适配」任务(程序修复的变体)此前缺乏有效方法。本文提出 AdaptivePaste,一种基于 Transformer 的源代码适配学习方法,并设计了一个数据流感知的去混淆预训练任务,以学习变量使用模式的有意义表示。在 Python 代码片段上,该方法取得 67.8% 的精确匹配准确率;通过并行解码器 Transformer 并结合置信度阈值的选择性适配设置,模型精度可进一步提升至 85.9%。作者还针对真实复制粘贴实例对 Python 开发者开展用户研究,结果表明 AdaptivePaste 将停留时间缩短至手动移植代码的近一半,并有助于避免缺陷,同时依据参与者反馈指出了改进方向。

问题
程序员复制粘贴代码片段后需手动调整变量标识符以适配周围上下文,而现有方法无法有效完成这一代码适配任务。
方法
提出 AdaptivePaste,基于 Transformer 并采用数据流感知的去混淆预训练任务来学习变量使用模式表示,同时使用并行解码器支持带置信度阈值的选择性代码适配。
评估
在 Python 源代码片段上评测适配精确匹配率,并分析置信度阈值对精度的影响;此外对 Python 开发者进行真实复制粘贴场景的用户研究,测量停留时间与缺陷避免情况。
原文摘要(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 context. 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 demonstrate that AdaptivePaste can learn to adapt Python source code snippets with 67.8% exact match accuracy. We study the impact of confidence thresholds on the model predictions, showing the model precision can be further improved to 85.9% with our parallel-decoder transformer model in a selective code adaptation setting. To assess the practical use of AdaptivePaste we perform a user study among Python software developers on real-world copy-paste instances. The results show that AdaptivePaste reduces dwell time to nearly half the time it takes to port code manually, and helps to avoid bugs. In addition, we utilize the participant feedback to identify potential avenues for improvement.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@inproceedings{LiuJSAS23,
  title = {AdaptivePaste: Intelligent Copy-Paste in IDE},
  author = {Xiaoyu Liu and Jinu Jang and Neel Sundaresan and Miltiadis Allamanis and Alexey Svyatkovskiy},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3613895}
}