Automated Syntactic Refactoring—Using AST Differencing as a Case Study

碩士 === 國立交通大學 === 資訊科學與工程研究所 === 107 === With the increasing complexity and scale of nowadays software systems, programmers havespent more time on repetitive code refactoring tasks such as fixing security bugs or upgradingdevelopment libraries. Those tasks are error-prone and undermine programmers’...

Full description

Bibliographic Details
Main Authors: Lee, Yun-Wei, 李昀瑋
Other Authors: You, Yi-Ping
Format: Others
Language:en_US
Published: 2019
Online Access:http://ndltd.ncl.edu.tw/handle/6ypyek
Description
Summary:碩士 === 國立交通大學 === 資訊科學與工程研究所 === 107 === With the increasing complexity and scale of nowadays software systems, programmers havespent more time on repetitive code refactoring tasks such as fixing security bugs or upgradingdevelopment libraries. Those tasks are error-prone and undermine programmers’ productivitygradually. Unfortunately, there is no tool that automates these tasks, and the cost of developingan exclusive tool for a specific refactoring task is extremely high. In this thesis, we propose aframework, calledSyntaFactor, that helps to automate the code refactoring process with usersof the framework providing code refactoring guidelines, which are written in the same languagethat they used for programming with only some new operators for expressing the changes aftercode refactoring. Given an input source code of a program and a code refactoring guideline,SyntaFactor transforms the input source code according to the guideline via an execution en-gine, which (1) constructs the abstract syntax trees (AST) of the program fragment before andafter refactoring from the guideline and also the AST of the input source code, (2) locates whereto perform refactoring in the input source code, (3) determines what to change by differentiat-ing the ASTs before and after refactoring, and (4) finally modifies the input source code withthe information in steps (2) and (3). A language-independent representation is also proposed inSyntaFactor in order to allow SyntaFactor to be extendable for supporting different program-ming languages. Our evaluations demonstrated that we have successfully automated the processof non-trivial API upgrades for four renowned open source projects and also the process of fix-ing MISRA C non-compliances (with a reduction of 80%) for five MIRSA C rules in five opensource projects. We believe that with SyntaFactor, we can free programmers from dealing withtedious and error-prone tasks and thus allow them to devote their time to more productive work.