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
刚刚
NexusExplorer的应助被科研通管家采纳,获得10
刚刚
1秒前
1秒前
1秒前
1秒前
zxr发布了新的文献求助10
1秒前
Ava的应助被科研通管家采纳,获得10
1秒前
搜集达人的应助被科研通管家采纳,获得10
1秒前
大个的应助被yuxinyue采纳,获得10
1秒前
隐形曼青的应助被科研通管家采纳,获得10
1秒前
ding的应助被科研通管家采纳,获得10
1秒前
桐桐的应助被坚强冰枫采纳,获得10
1秒前
小蘑菇的应助被科研通管家采纳,获得10
1秒前
小蘑菇的应助被科研通管家采纳,获得10
2秒前
深情安青的应助被科研通管家采纳,获得10
2秒前
Wenge完成签到,获得积分10
2秒前
2秒前
Orange的应助被科研通管家采纳,获得10
2秒前
2秒前
2秒前
脑洞疼的应助被科研通管家采纳,获得10
2秒前
2秒前
Nole的应助被大眼猫采纳,获得10
2秒前
Lucas的应助被科研通管家采纳,获得10
2秒前
2秒前
Magic完成签到,获得积分10
2秒前
高乐发布了新的文献求助10
3秒前
秋风的应助被大眼猫采纳,获得10
3秒前
3秒前
无花果的应助被时尚笑白采纳,获得10
3秒前
SciGPT的应助被大眼猫采纳,获得10
3秒前
lpls发布了新的文献求助10
3秒前
桐桐的应助被风中紫蓝采纳,获得10
3秒前
哇塞的应助被大眼猫采纳,获得10
3秒前
秋风的应助被大眼猫采纳,获得10
3秒前
hyd1640发布了新的文献求助20
3秒前
乐乐的应助被坚强冰枫采纳,获得10
3秒前
秋风的应助被大眼猫采纳,获得10
3秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
拉伸高分子熔体中缠结行为的模拟和小角中子散射研究 2000
Handbook of Sport Coaching Research 1000
Orthognathic Surgery - 2 Volume Set 500
高分子基功能界面水蒸发材料与应用研究 500
外场增强的水汽发电研究 500
基于结构调控的功能化水诱导发电材料与器件研究 500
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 计算机科学 工程类 有机化学 化学工程 生物化学 物理 复合材料 内科学 催化作用 光电子学 人工智能 细胞生物学 无机化学 物理化学 数学
热门帖子
关注 科研通微信公众号,转发送积分 8200524
求助须知:如何正确求助?哪些是违规求助? 9585273
关于积分的说明 21899059
捐赠科研通 7802279
什么是DOI,文献DOI怎么找? 3439718
关于科研通互助平台的介绍 2562541
邀请新用户注册赠送积分活动 2486709