摘要
内联函数(Inline method)和替换算法(Substitute algorithm)是2种在代码重构中常用的重构手法,本文提出一种基于代码变更块和抽象语法树的重构模式识别算法,首先筛选出变更前后2个文件的代码变更块,找到可能属于这2种重构模式的代码变更块,再建立抽象语法树对这些变更块中的代码进行准确的语法分析,对其是否属于此2种模式进行判定。该算法在4个开源项目上进行了实验验证,表明了其具有较高的准确率。
Inline method and Substitute algorithm are two kinds of refactoring methods which are used in code refactoring frequently.This paper proposes a refactoring pattern recognition algorithm based on hunk and abstract syntax tree.First filter out all the hunks of the two files,find the specific hunks that may contain these two kinds of refactoring patterns,then establish an abstract syntax tree to analyze the code in this hunks more accurately and verdict whether it matches these two refactoring patterns.The algorithm has been experimentally verified on four open source projects,indicating that it has a high accuracy.
作者
张志浩
杨春花
ZHANG Zhihao;YANG Chunhua(School of Computer Science and Technology,Qilu University of Technology(Shandong Academy of Sciences),Jinan 250353,China)
出处
《智能计算机与应用》
2019年第3期146-150,共5页
Intelligent Computer and Applications
基金
国家自然科学基金(61502259)
关键词
重构模式
抽象语法树
代码变更块
内联函数
替换算法
refactoring pattern
abstract syntax tree
hunk
Inline method
Substitute algorithm