Font Size: a A A

Automatically Based On The Abstract Syntax Tree And Static Analysis Of The Cloned Code Refactoring

Posted on:2010-04-08Degree:MasterType:Thesis
Country:ChinaCandidate:D Q YuFull Text:PDF
GTID:2208360275991458Subject:Computer software and theory
Abstract/Summary:PDF Full Text Request
Code clone in single software system or several similar systems makes software maintenance very difficult.Therefore,a lot of research on reverse engineering focuses on how to assist the detection and refactoring of cloned code.At present,relevant research mainly focuses on code clone detection;however,research on refacoring of cloned code is rare.First,this paper offers an automatic refactoring method of detected cloned code based on abstract syntax tree and static analysis.At first,this method builds abstract syntax trees for cloned code separately.Then the difference between statements is used to establish the relationship between flow control statements in abstract syntax trees.Based on these steps,this method analyses the difference between flow control statements and the difference between simple statement blocks,and finally combines the cloned code through extracting the variation points in source code.Second,this paper offers an automatic refactoring method of object oriented software systems based on the method mentioned above.This paper utilizes the semantic information such as the comment and the signature of a method,as well as syntactic information of the method body to find exactly the same methods or similar methods in several sub-classes which shares a common father-class.First,for each method pair,we compute the combined similarity of comment and signature.As the first filter,we perform syntactic analysis and comparison and compute the total similarity of methods only on those method pairs whose combined similarity of comment and signature is above certain threshold.Then,we make the total similarity of methods the metric of the second filter.It is the criterion of whether to perform refactoring or not.Finally we combine the method pairs which pass the second filter into a single method using the method of variation points analysis and extraction mentioned above.The resulting method can be pulled up into the father-class thus realizes refactoring.Based on this method,we have developed a prototype tool which supports refactoring of cloned code of Java.And experiments on automatic refactoring are taken on cloned code in JDK1.5 and a business system.The initial result shows that this method can assist developer achieve the goal of automatically refactoring of cloned code both accurately and effectively.At the same time,because we filter method pairs based on combined similarity of comment and signature,the amount of method pairs which needs syntactic analysis and comparison is greatly reduced.
Keywords/Search Tags:Refactoring, Variation point extraction, Code clone, Abstract syntax tree, Reengineering, Reverse engineering
PDF Full Text Request
Related items