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
2秒前
dd完成签到 ,获得积分10
2秒前
王一刻完成签到,获得积分20
2秒前
wangyi完成签到,获得积分10
4秒前
gc55发布了新的文献求助10
6秒前
BAEK完成签到,获得积分10
6秒前
小徐完成签到 ,获得积分10
6秒前
8秒前
端庄代荷完成签到 ,获得积分10
11秒前
清脆的谷波完成签到 ,获得积分10
12秒前
伶俐书蝶完成签到 ,获得积分10
13秒前
活泼学生完成签到 ,获得积分10
15秒前
感动清炎完成签到,获得积分10
16秒前
xiaowang完成签到,获得积分10
16秒前
16秒前
吴开珍完成签到 ,获得积分10
16秒前
小宝完成签到,获得积分10
20秒前
xiaowang发布了新的文献求助10
21秒前
23秒前
wing完成签到 ,获得积分10
27秒前
派大星星完成签到 ,获得积分10
28秒前
YPF完成签到 ,获得积分10
29秒前
29秒前
粗心的语芹完成签到,获得积分10
29秒前
可可爱爱小豆豆完成签到 ,获得积分10
30秒前
希希完成签到 ,获得积分10
33秒前
nhzz2023完成签到 ,获得积分0
37秒前
0lessthan2完成签到,获得积分10
40秒前
愛愛愛愛完成签到,获得积分10
42秒前
研友_LX7zK8完成签到,获得积分10
43秒前
lhl完成签到,获得积分0
43秒前
Minta完成签到 ,获得积分10
45秒前
YJ完成签到,获得积分10
45秒前
执着道之完成签到 ,获得积分10
45秒前
2025210129完成签到 ,获得积分10
45秒前
Kao应助科研通管家采纳,获得10
46秒前
Kao应助科研通管家采纳,获得10
46秒前
Kao应助科研通管家采纳,获得30
46秒前
leilei完成签到 ,获得积分10
49秒前
握瑾怀瑜完成签到 ,获得积分0
49秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
Principles of town planning: translating concepts to applications 1000
Navigating Normative Orders. Interdisciplinary Perspectives 800
1 Peter and Christ's Descent to the Dead in Its Early Christian Reception 700
Organizational Behavior 510
Management and the Arts 510
Matrix Methods in Data Mining and Pattern Recognition Second Edition 510
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7738975
求助须知:如何正确求助?哪些是违规求助? 9287929
关于积分的说明 20185072
捐赠科研通 7316956
什么是DOI,文献DOI怎么找? 3306016
关于科研通互助平台的介绍 2458506
邀请新用户注册赠送积分活动 2315956