Next-Generation Refactoring: Combining LLM Insights and IDE Capabilities for Extract Method

重构代码 计算机科学 软件工程 程序设计语言 软件
作者
Dorin Pomian,Abhiram Bellur,Malinda Dilhara,Zarina Kurbatova,Egor Bogomolov,Timofey Bryksin,Danny Dig
标识
DOI:10.1109/icsme58944.2024.00034
摘要

Long methods that encapsulate multiple responsibilities within a single method are challenging to maintain. Choosing which statements to extract into new methods has been the target of many research tools. Despite steady improvements, these tools often fail to generate refactorings that align with developers' preferences and acceptance criteria. Given that Large Language Models (LLMs) have been trained on large code corpora, if we harness their familiarity with the way developers form functions, we could suggest refactorings that developers are likely to accept. In this paper, we advance the science and practice of refactoring by synergistically combining the insights of LLMs with the power of IDEs to perform Extract Method (EM). Our formative study on 1752 EM scenarios revealed that LLMs are very effective for giving expert suggestions, yet they are unreliable: up to 76.3% of the suggestions are hallucinations. We designed a novel approach that removes hallucinations from the candidates suggested by LLMs, then further enhances and ranks suggestions based on static analysis techniques from program slicing, and finally leverages the IDE to execute refactorings correctly. We implemented this approach in an IntelliJ IDEA plugin called EM-Assist. We empirically evaluated EM-Assist on a diverse corpus that replicates 1752 actual refactorings from open-source projects. We found that EM-Assist outperforms previous state of the art tools: EM-Assist suggests the developer-performed refactoring in 53.4% of cases, improving over the recall rate of 39.4% for previous best-in-class tools. Furthermore, we conducted firehouse surveys with 16 industrial developers and suggested refactorings on their recent commits. 81.3% of them agreed with the recommendations provided by EM-Assist. This shows the usefulness of our approach and ushers us into a new era when LLMs become effective AI assistants for refactoring.
最长约 10秒,即可获得该文献文件

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
诚心的鸽子完成签到,获得积分10
刚刚
刚刚
橙汁完成签到,获得积分10
刚刚
刚刚
1秒前
秦王绕柱走完成签到,获得积分10
1秒前
1秒前
蓝韵发布了新的文献求助15
2秒前
吉祥咩咩完成签到,获得积分10
2秒前
xkl完成签到,获得积分10
2秒前
啦啦啦完成签到,获得积分10
3秒前
Qiancheni发布了新的文献求助10
3秒前
风清扬发布了新的文献求助10
3秒前
高兴的易形完成签到 ,获得积分10
3秒前
耍酷的剑身完成签到,获得积分10
3秒前
曹沛岚完成签到,获得积分10
3秒前
随录江晚完成签到,获得积分10
3秒前
小池同学发布了新的文献求助10
4秒前
小马完成签到,获得积分10
4秒前
gao发布了新的文献求助10
4秒前
5秒前
sheep完成签到,获得积分10
5秒前
犹豫的宛筠完成签到,获得积分20
5秒前
青青发布了新的文献求助10
5秒前
6秒前
研友_VZG7GZ应助叮叮叮采纳,获得10
6秒前
Hhj完成签到 ,获得积分10
6秒前
李不乐发布了新的文献求助10
6秒前
今晚去吃烤肉完成签到,获得积分10
6秒前
6秒前
必胜发布了新的文献求助10
7秒前
7秒前
8秒前
CipherSage应助Yeyuntian采纳,获得10
8秒前
KIQING发布了新的文献求助10
8秒前
帅气琦发布了新的文献求助10
9秒前
沅沅完成签到 ,获得积分10
9秒前
FashionBoy应助随录江晚采纳,获得10
11秒前
LVZHIPENG完成签到,获得积分10
11秒前
荒年完成签到,获得积分10
12秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
The Organometallic Chemistry of the Transition Metals 800
Chemistry and Physics of Carbon Volume 18 800
The Organometallic Chemistry of the Transition Metals 800
Leading Academic-Practice Partnerships in Nursing and Healthcare: A Paradigm for Change 800
The formation of Australian attitudes towards China, 1918-1941 640
Signals, Systems, and Signal Processing 610
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 物理 内科学 复合材料 催化作用 物理化学 光电子学 电极 细胞生物学 基因 无机化学
热门帖子
关注 科研通微信公众号,转发送积分 6438633
求助须知:如何正确求助?哪些是违规求助? 8252741
关于积分的说明 17562345
捐赠科研通 5496923
什么是DOI,文献DOI怎么找? 2899037
邀请新用户注册赠送积分活动 1875695
关于科研通互助平台的介绍 1716489