A Hybrid Refactoring Engine Driven by Code Semantics and Developer Intent
Authors
Annapurna Shobitha S, Sushma D S, Ankitha, Damodaran D, Soham Ghosh
Abstract
Refactoring is a critical software maintenance activity aimed at improving code structure without altering its external behaviour. However, conventional refactoring tools often fail to align with the nuanced intent of developers, leading to suboptimal transformations and unintended behavioural shifts. This paper proposes a novel code refactoring engine that integrates semantic drift detection with developer intent analysis to guide context-aware transformations. Our approach models semantic drift by tracking latent shifts in code meaning across version histories using vectorized representations derived from abstract syntax trees (ASTs) and control-flow graphs (CFGs). Simultaneously, developer intent is inferred from commit messages, inline comments, and historical code edit patterns through natural language processing and graph-based reasoning. By fusing these two dimensions, the system dynamically generates refactoring suggestions that preserve program correctness while remaining faithful to the original design rationale. We evaluate our engine on multiple open-source repositories across diverse domains and demonstrate significant improvements in maintainability metrics such as cyclomatic complexity, cohesion, and code smell reduction, compared to baseline refactoring tools. Our results underline the importance of semantically-grounded and intentaware refactoring as a path toward intelligent software evolution.