收藏切换
Non-Contiguous Code Refactoring: A Hybrid Approach of Static Analysis and Large Language Model
收藏切换
Youqing Ji1, Yingzhou Zhang1, 2, *, Yupeng Su1, Gang Wang1, Wenzhi Zhang1, Jinyan Xie1
Journal of Computer Research and Development | 2026, 63(4) : 868 - 883
Less
收藏切换
Journal of Computer Research and Development | 2026, 63(4): 868-883
• Special Issue on LLMs and Software Engineering •
Non-Contiguous Code Refactoring: A Hybrid Approach of Static Analysis and Large Language Model
Full
Youqing Ji1, Yingzhou Zhang1, 2, *, Yupeng Su1, Gang Wang1, Wenzhi Zhang1, Jinyan Xie1
Affiliations
  • 1School of Computer Science, School of Software, School of Cyberspace Security, Nanjing University of Posts and Telecommunications, Nanjing 210023
  • 2State Key Laboratory of Tibetan Language Intelligence (Nanjing University of Posts and Telecommunications), Nanjing 210023
  • born in 2000. Master. Her main research interests include program analysis and software engineering

    born in 1978. PhD, professor, master supervisor. His main research interests include program analysis and program slicing

    born in 2001. Master candidate. His main research interests include program analysis and defects detection

    born in 2000. Master candidate. His main research interests include program analysis and malware detection

    born in 2000. Master candidate. His main research interests include program analysis and malware detection

    born in 1999. Master. His main research interests include program analysis and program slicing

About Author:

born in 2000. Master. Her main research interests include program analysis and software engineering

born in 1978. PhD, professor, master supervisor. His main research interests include program analysis and program slicing

born in 2001. Master candidate. His main research interests include program analysis and defects detection

born in 2000. Master candidate. His main research interests include program analysis and malware detection

born in 2000. Master candidate. His main research interests include program analysis and malware detection

born in 1999. Master. His main research interests include program analysis and program slicing

Published: 2026-04-01 doi: 10.7544/issn1000-1239.202550688
Outline
收藏切换

The widespread adoption of large language model (LLM) in software engineering has made automated code refactoring, leveraging their powerful code comprehension and generation capabilities, a crucial direction for enhancing software quality and development efficiency. However, when refactoring non-contiguous code clones which arise from statement interleaving, reordering, and similar transformations, LLM faces core challenges: dispersed semantic context, difficulty in capturing critical dependencies, and susceptibility to “hallucination” errors. To address these challenges, we propose a novel method for non-contiguous code clone refactoring that integrates static analysis with LLM. Our method first efficiently and accurately identifies non-contiguous clones by combining program slicing with an algebraic classifier. Next, a context-aware refactoring opportunity identification algorithm determines the optimal refactoring targets for the LLM. Finally, a chain-of-thought few-shot prompting strategy guides the LLM to generate high-quality “extract method” refactoring suggestions, and a verification mechanism, inspired by metamorphic relations, validates the semantic and structural consistency of the generated results. Experiments on the open-source datasets Google Code Jam and BigCloneBench demonstrate that our proposed refactoring method reduces clone code by 66% to 71% in real-world projects like Junit. Furthermore, our detection method achieves an F1-score 2% to 18% higher than existing mainstream tools. On the Community Corpus-A refactoring opportunity identification benchmark, it reaches an F1-score of 0.415, surpassing the state-of-the-art tool GEMS by 7.5%, enhancing software quality.

large language models  /  static analysis  /  non-contiguous code clone  /  code refactoring  /  prompt engineering
嵇友晴, 张迎周, 苏玉鹏, 王刚, 张文智, 谢金言. 融合静态分析与大语言模型的非连续代码重构方法. 计算机研究与发展, 2026 , 63 (4) : 868 -883 . DOI: 10.7544/issn1000-1239.202550688
Youqing Ji, Yingzhou Zhang, Yupeng Su, Gang Wang, Wenzhi Zhang, Jinyan Xie. Non-Contiguous Code Refactoring: A Hybrid Approach of Static Analysis and Large Language Model[J]. Journal of Computer Research and Development, 2026 , 63 (4) : 868 -883 . DOI: 10.7544/issn1000-1239.202550688
Year 2026 volume 63 Issue 4
71
34
Cite this Article
BibTeX
Article Info
doi: 10.7544/issn1000-1239.202550688
  • Receive Date:2025-09-21
  • Online Date:2026-11-17
  • Published:2026-04-01
Article Data
Affiliations
History
  • Received:2025-09-21
  • Revised:2025-12-31
Affiliations
    1School of Computer Science, School of Software, School of Cyberspace Security, Nanjing University of Posts and Telecommunications, Nanjing 210023
    2State Key Laboratory of Tibetan Language Intelligence (Nanjing University of Posts and Telecommunications), Nanjing 210023
References
Share
https://castjournals.cast.org.cn/joweb/jsjyjyfz/EN/10.7544/issn1000-1239.202550688
Share to
QR

Scan QR to access full text

Cite this article
BibTeX
Citations
表12种不同金属材料的力学参数
科
Family
属数
Number of
genus
种数
Number of
species
占总种数比例
Percentage of
total species (%)
属
Genus
种数
Number of
species
占总种数比例
Percentage of total
species (%)
鹅膏菌科Amanitaceae 2 11 5.26 鹅膏菌属 Amanita 10 4.78
小菇科 Mycenaceae 2 12 5.74 丝盖伞属 Inocybe 5 2.39
多孔菌科 Polyporaceae 8 14 6.70 蜡蘑属 Laccaria 5 2.39
红菇科 Russulaceae 3 23 11.00 小皮伞属 Marasmius 6 2.87
小菇属 Mycena 11 5.26
光柄菇属 Pluteus 5 2.39
红菇属 Russula 17 8.13
栓菌属 Trametes 5 2.39
关闭全屏
  • BibTeX
  • EndNote
  • RefWorks
  • TxT