跨方法的细粒度移动重构的形式化与自动化
Formalizing and Automating Fine-Grained Move Refactorings Across Methods
浏览论文内容
中文总结 AI 辅助
本文将五种Move语句重构形式化,结合现有技术实现更细粒度移动,经十个项目评估,93.3%-97.0%适用案例可生成可编译代码,行为变化源于副作用重排,验证了方法的有效性。
中文摘要 AI 辅助
开发者使用自动化的Move重构来改进源代码的模块化结构与职责分配。现代IDE已实现类级和方法级Move重构的自动化,但调整方法边界的语句级和表达式级移动仍基本未实现自动化。我们将五种Move语句重构变体形式化为基于四个基本条件的前置条件与步骤,这四个条件涵盖编译所需的数据可达性、执行次数、副作用和句法约束,其中除副作用条件外其余均为静态检查。结合现有技术,这也能实现表达式和部分表达式的更细粒度移动。我们针对真实项目迭代细化该形式化,推导二十个额外前置条件与步骤以处理实践中的Java句法多样性。我们在十个项目上评估适用性与可编译性,并在其中一个项目的案例研究中评估行为保留:Move语句重构在93.3%-97.0%的适用案例中生成可编译代码,案例研究显示观测到的行为变化源于留给开发者判断的副作用重排,而非静态检查条件的缺陷。
英文摘要
Developers use automated Move refactorings to improve the modular structure of source code and the assignment of responsibilities. Class- and method-level Move refactorings are automated in modern IDEs, but statement- and expression-level moves that adjust method boundaries remain largely unautomated. We formalize five variants of Move Statement refactoring as preconditions and steps grounded in four basic conditions covering data reachability, execution count, side effects, and syntactic constraints required for compilation, of which all but the side-effect condition are checked statically. Combined with existing techniques, this also yields finer-grained moves of expressions and partial expressions. We further refine the formalization iteratively against a real project, deriving twenty additional preconditions and steps that handle Java syntactic diversity in practice. We evaluate applicability and compilability on ten projects, and behavior preservation in a case study on one of them: Move Statement refactorings yield compilable code in 93.3-97.0% of applicable cases, and the case study shows that the observed behavioral changes stem from side-effect reordering left to developer judgment, not from defects in the statically checked conditions.