Leveraging LLMs, IDEs, and Semantic Embeddings for Automated Move Method Refactoring

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Bellur, Abhiram, Batole, Fraol, Ullah, Mohammed Raihan, Dilhara, Malinda, Zharov, Yaroslav, Bryksin, Timofey, Ishikawa, Kai, Chen, Haifeng, Morimoto, Masaharu, Motoura, Shota, Hosomi, Takeo, Nguyen, Tien N., Rajan, Hridesh, Tsantalis, Nikolaos, Dig, Danny
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912652629901312
author Bellur, Abhiram
Batole, Fraol
Ullah, Mohammed Raihan
Dilhara, Malinda
Zharov, Yaroslav
Bryksin, Timofey
Ishikawa, Kai
Chen, Haifeng
Morimoto, Masaharu
Motoura, Shota
Hosomi, Takeo
Nguyen, Tien N.
Rajan, Hridesh
Tsantalis, Nikolaos
Dig, Danny
author_facet Bellur, Abhiram
Batole, Fraol
Ullah, Mohammed Raihan
Dilhara, Malinda
Zharov, Yaroslav
Bryksin, Timofey
Ishikawa, Kai
Chen, Haifeng
Morimoto, Masaharu
Motoura, Shota
Hosomi, Takeo
Nguyen, Tien N.
Rajan, Hridesh
Tsantalis, Nikolaos
Dig, Danny
contents MOVEMETHOD is a hallmark refactoring. Despite a plethora of research tools that recommend which methods to move and where, these recommendations do not align with how expert developers perform MOVEMETHOD. Given the extensive training of Large Language Models and their reliance upon naturalness of code, they should expertly recommend which methods are misplaced in a given class and which classes are better hosts. Our formative study of 2016 LLM recommendations revealed that LLMs give expert suggestions, yet they are unreliable: up to 80% of the suggestions are hallucinations. We introduce the first LLM fully powered assistant for MOVEMETHOD refactoring that automates its whole end-to-end lifecycle, from recommendation to execution. We designed novel solutions that automatically filter LLM hallucinations using static analysis from IDEs and a novel workflow that requires LLMs to be self-consistent, critique, and rank refactoring suggestions. As MOVEMETHOD refactoring requires global, projectlevel reasoning, we solved the limited context size of LLMs by employing refactoring-aware retrieval augment generation (RAG). Our approach, MM-assist, synergistically combines the strengths of the LLM, IDE, static analysis, and semantic relevance. In our thorough, multi-methodology empirical evaluation, we compare MM-assist with the previous state-of-the-art approaches. MM-assist significantly outperforms them: (i) on a benchmark widely used by other researchers, our Recall@1 and Recall@3 show a 1.7x improvement; (ii) on a corpus of 210 recent refactorings from Open-source software, our Recall rates improve by at least 2.4x. Lastly, we conducted a user study with 30 experienced participants who used MM-assist to refactor their own code for one week. They rated 82.8% of MM-assist recommendations positively. This shows that MM-assist is both effective and useful.
format Preprint
id arxiv_https___arxiv_org_abs_2503_20934
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Leveraging LLMs, IDEs, and Semantic Embeddings for Automated Move Method Refactoring
Bellur, Abhiram
Batole, Fraol
Ullah, Mohammed Raihan
Dilhara, Malinda
Zharov, Yaroslav
Bryksin, Timofey
Ishikawa, Kai
Chen, Haifeng
Morimoto, Masaharu
Motoura, Shota
Hosomi, Takeo
Nguyen, Tien N.
Rajan, Hridesh
Tsantalis, Nikolaos
Dig, Danny
Software Engineering
Artificial Intelligence
MOVEMETHOD is a hallmark refactoring. Despite a plethora of research tools that recommend which methods to move and where, these recommendations do not align with how expert developers perform MOVEMETHOD. Given the extensive training of Large Language Models and their reliance upon naturalness of code, they should expertly recommend which methods are misplaced in a given class and which classes are better hosts. Our formative study of 2016 LLM recommendations revealed that LLMs give expert suggestions, yet they are unreliable: up to 80% of the suggestions are hallucinations. We introduce the first LLM fully powered assistant for MOVEMETHOD refactoring that automates its whole end-to-end lifecycle, from recommendation to execution. We designed novel solutions that automatically filter LLM hallucinations using static analysis from IDEs and a novel workflow that requires LLMs to be self-consistent, critique, and rank refactoring suggestions. As MOVEMETHOD refactoring requires global, projectlevel reasoning, we solved the limited context size of LLMs by employing refactoring-aware retrieval augment generation (RAG). Our approach, MM-assist, synergistically combines the strengths of the LLM, IDE, static analysis, and semantic relevance. In our thorough, multi-methodology empirical evaluation, we compare MM-assist with the previous state-of-the-art approaches. MM-assist significantly outperforms them: (i) on a benchmark widely used by other researchers, our Recall@1 and Recall@3 show a 1.7x improvement; (ii) on a corpus of 210 recent refactorings from Open-source software, our Recall rates improve by at least 2.4x. Lastly, we conducted a user study with 30 experienced participants who used MM-assist to refactor their own code for one week. They rated 82.8% of MM-assist recommendations positively. This shows that MM-assist is both effective and useful.
title Leveraging LLMs, IDEs, and Semantic Embeddings for Automated Move Method Refactoring
topic Software Engineering
Artificial Intelligence
url https://arxiv.org/abs/2503.20934