跳到主要导航 跳到搜索 跳到主要内容

Wired for Reuse: Automating Context-Aware Code Adaptation in IDEs via LLM-Based Agent

  • Taiming Wang
  • , Yanjie Jiang*
  • , Chunhao Dong
  • , Yuxia Zhang
  • , Hui Liu
  • *此作品的通讯作者
  • Beijing Institute of Technology
  • Tianjin University

科研成果: 书/报告/会议事项章节会议稿件同行评审

摘要

Copy-paste-modify is a widespread and pragmatic practice in software development, where developers adapt reused code snippets, sourced from platforms such as Stack Overflow, GitHub, or LLM outputs, into their local codebase. A critical yet underexplored aspect of this adaptation is code wiring: the context-aware process of substituting unresolved variables in pasted code with suitable variables or expressions from the surrounding context. Existing solutions either rely on heuristic rules or historical templates, often failing to effectively utilize contextual information, despite studies showing that over half of adaptation cases are context-dependent. In this paper, we introduce WIRL, an LLM-based agent for code wiring framed as a Retrieval-Augmented Generation (RAG) infilling task. WIRL combines an LLM, a customized toolkit, and an orchestration module to identify unresolved variables, retrieve context, and perform context-aware substitutions. To balance efficiency and autonomy, the agent adopts a mixed strategy: deterministic rule-based steps for common patterns, and a state-machine-guided decision process for intelligent exploration. We evaluate WIRL on a carefully curated, high-quality dataset consisting of real-world code adaptation scenarios. Our approach achieves an exact match precision of 91.7% and a recall of 90.0%, outperforming advanced LLMs by 22.6 and 13.7 percentage points in precision and recall, respectively, and surpassing IntelliJ IDEA by 54.3 and 49.9 percentage points. These results underscore its practical utility, particularly in contexts with complex variable dependencies or multiple unresolved variables. We believe WIRL paves the way for more intelligent and context-aware developer assistance in modern IDEs.

源语言英语
主期刊名Proceedings - 2025 40th IEEE/ACM International Conference on Automated Software Engineering, ASE 2025
出版商Institute of Electrical and Electronics Engineers Inc.
178-190
页数13
ISBN(电子版)9798350357332
DOI
出版状态已出版 - 2025
已对外发布
活动2025 40th IEEE/ACM International Conference on Automated Software Engineering, ASE 2025 - Seoul, 韩国
期限: 16 11月 202520 11月 2025

出版系列

姓名Proceedings - 2025 40th IEEE/ACM International Conference on Automated Software Engineering, ASE 2025

会议

会议2025 40th IEEE/ACM International Conference on Automated Software Engineering, ASE 2025
国家/地区韩国
Seoul
时期16/11/2520/11/25

指纹

探究 'Wired for Reuse: Automating Context-Aware Code Adaptation in IDEs via LLM-Based Agent' 的科研主题。它们共同构成独一无二的指纹。

引用此