paperbot · PL 论文追踪

全部论文 待读 收藏

P2 An Automated Approach to Extracting Local Variables

一种自动提取局部变量的方法
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 3/10 · 论文属于静态程序分析与IDE重构工具,且有Eclipse工业落地,但未涉及用户核心关注的LLM/Agent与静态分析交叉、浮点程序分析或贝叶斯程序分析。其问题和方法与当前研究画像中的AI/LLM主线关联较弱。引用 9 inbox
Xiaye Chi, Hui Liu, Guangjie Li, Weixiao Wang, Yunni Xia, Yanjie Jiang, Yuxia Zhang, Weixing Ji
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 ValExtractor,用轻量静态分析自动执行提取局部变量重构并避免语义错误。

提取局部变量是常用重构,但现有 IDE 工具因缺乏深入分析可能引入语义错误。本文提出 ValExtractor,在无需动态执行程序的情况下自动完成该重构。核心挑战是高效准确地识别被提取表达式的副作用及其与上下文的潜在交互。ValExtractor 采用轻量级静态源码分析,验证所选表达式的副作用,并判断哪些出现可一并提取而不改变程序语义或引入新异常。在开源 Java 应用上的评估表明,Eclipse 与 IntelliJ IDEA 等主流重构引擎产生大量错误提取,而 ValExtractor 成功避免了所有这些错误;该方法已被合并进 Eclipse 并随其分发,以提升提取局部变量重构的安全性。

问题
已有 IDE 的提取局部变量重构工具缺少深入分析,可能造成语义错误或引入新异常,如何自动且可靠地完成该重构。
方法
提出 ValExtractor,用轻量静态源码分析验证所选表达式的副作用,并识别可安全一起提取的表达式出现。
评估
在开源 Java 应用上与 Eclipse、IntelliJ IDEA 对比,ValExtractor 避免了所有故障重构,并已在 Eclipse 中集成分发。
原文摘要(Abstract)

Extract local variable is a well-known and widely used refactoring. It is frequently employed to replace one or more occurrences of a complex expression with simple accesses to a newly added variable. Although most IDEs provide tool support for extract local variables, such tools without deep analysis of the refactorings may result in semantic errors. To this end, in this paper, we propose a novel and more reliable approach, called ValExtractor, to conduct extract variable refactorings automatically. The major challenge of automated extract local variable refactorings is how to efficiently and accurately identify the side effect of the extracted expressions and the potential interaction between the extracted expressions and their contexts without time-consuming dynamic execution of the involved programs. To resolve this challenge, ValExtractor leverages a lightweight static source code analysis to validate the side effect of the selected expression, and to identify which occurrences of the selected expression could be extracted together without changing the semantics of the program or introducing potential new exceptions. Our evaluation results on open-source Java applications suggest that Eclipse and IntelliJ IDEA, the state-of-the-practice refactoring engines, resulted in a large number of faulty extract variable refactorings whereas ValExtractor successfully avoided all such errors. The proposed approach has been merged into (and distributed with) Eclipse to improve the safety of extract local variable refactoring.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@inproceedings{ChiLLWXJZJ23,
  title = {An Automated Approach to Extracting Local Variables},
  author = {Xiaye Chi and Hui Liu and Guangjie Li and Weixiao Wang and Yunni Xia and Yanjie Jiang and Yuxia Zhang and Weixing Ji},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616261}
}