一句话:提出 CoEdPilot,用多 Transformer 预测后续代码编辑的位置与内容,并支持项目级影响和交互式反馈。
代码编辑比从零生成更常见,但现有方法多基于已知先验编辑和上下文生成一次编辑,难以处理编辑会话中的无关编辑及项目级连锁影响。本文提出 CoEdPilot,一个 LLM 驱动的编辑推荐方案:Subsequent Edit Analysis 先定位项目中最相关文件及每行应保持、插入或替换,Edit-content Generator 结合 Edit-dependency Analyzer 的相关历史变更生成具体内容,二者利用先验编辑反馈迭代调整。作者从 471 个开源项目、5 种语言收集 18 万余次提交训练模型。实验显示,编辑位置预测准确率 70.8%–85.3%,内容精确匹配率 41.8%、BLEU4 60.7,并使 GRACE、CCT5 的精确匹配率提升 8.57 个百分点、BLEU4 提升 18.08;18 人用户研究显示其优于 Copilot。
Recent years have seen the development of LLM-based code generation. Compared to generating code in a software project, incremental code edits are empirically observed to be more frequent. The emerging code editing approaches usually formulate the problem as generating an edit based on known relevant prior edits and context. However, practical code edits can be more complicated. First, an editing session can include multiple (ir)relevant edits to the code under edit. Second, the inference of the subsequent edits is non-trivial as the scope of its ripple effect can be the whole project. In this work, we propose CoEdPilot, an LLM-driven solution to recommend code edits by discriminating the relevant edits, exploring their interactive natures, and estimating its ripple effect in the project. Specifically, CoEdPilot orchestrates multiple neural transformers to identify what and how to edit in the project regarding both edit location and edit content. When a user accomplishes an edit with an optional editing description, an Subsequent Edit Analysis first reports the most relevant files in the project with what types of edits (e.g., keep, insert, and replace) can happen for each line of their code. Next, an Edit-content Generator generates concrete edit options for the lines of code, regarding its relevant prior changes reported by an Edit-dependency Analyzer. Last, both the Subsequent Edit Analysis and the Edit-content Generator capture relevant prior edits as feedback to readjust their recommendations. We train our models by collecting over 180K commits from 471 open-source projects in 5 programming languages. Our extensive experiments show that (1) CoEdPilot can well predict the edits (i.e., predicting edit location with accuracy of 70.8%-85.3%, and the edit content with exact match rate of 41.8% and BLEU4 score of 60.7); (2) CoEdPilot can well boost existing edit generators such as GRACE and CCT5 on exact match rate by 8.57% points and BLEU4 score by 18.08. Last, our user study on 18 participants with 3 editing tasks (1) shows that CoEdPilot can be effective in assisting users to edit code in comparison with Copilot, and (2) sheds light on the future improvement of the tool design. The video demonstration of our tool is available at https://sites.google.com/view/coedpilot/home.
@inproceedings{paperbot8583,
title = {CoEdPilot: Recommending Code Edits with Learned Prior Edit Relevance, Project-wise Awareness, and Interactive Nature},
author = {Chenyan Liu and Yufan Cai and Yun Lin and Yuhuan Huang and Yunrui Pei and Bo Jiang and Ping Yang and Jin Song Dong and Hong Mei},
booktitle = {ISSTA},
year = {2024},
doi = {10.1145/3650212.3652142}
}