The development lifecycle of a software system demands incessant improvements in the source code of a system to maintain its high quality with improved performance and code readability.Refactoring is a common software development practice that reshapes the internal structure and non-functional properties of a system without modifying its core functionality. Many simple refactorings like renaming code elements, extracting a snippet from large method to form new method etc. can be performed with the help of automatic tools. Renaming code elements like classes, interfaces or methods is a widely used refactoring activity. With tool support, rename refactorings can rely on the program structure to ensure correctness of the code transformation. Unfortunately, the textual references to the renamed identifier present in unstructured comment text cannot be formally detected through the syntax of the programming language. These textual references to the previous version of a renamed identifier pose threats to the consistency between code and comments, which leads to poor program comprehensibility. The comments containing such textual references become fragile with respect to the renamed program element and are referred to as fragile comments.This thesis proposes a new rule-based approach to detect and fix the fragile comments that result from renaming the identifiers. We implemented this approach for the Java programming language in the form of an Eclipse plug-in called Fraco. Fraco takes into account the type of an identifier, its morphology i.e. the part-of-speech tag and its inflectional form, its scope that defines its visibility in the source code and the location of comments in the source code with respect to the identifier.i We evaluated the performance of our technique, as implemented for Java in Fraco, by comparing its precision and recall against hand-annotated benchmarks created for both development and test sets each containing six target Java systems, and also compared the results against the performance of Eclipse's automated in-comment identifier replacement feature. Fraco performed with an average of 99% precision and recall on most components of both development and test data sets, and generally outperformed the baseline Eclipse feature. An average percentage of 25% of the total identifiers of category type and method in the data sets had fragile comments after renaming, which further motivates the need for research on automatic comment refactoring.
ACKNOWLEDGMENTSThe completion of this thesis has been a great learning journey which has left me indebted to many people who have supported, contributed and guided me, many a times, by going out of their way in doing so.First and foremost, I would like to thank my supervisor Prof. Martin P. Robillard for his unconditional support, methodical guidance and utmost care towards the ideation, development and completion of this thesis. Being confidently able to finish this thesis, I respect and admire his patience in successfully training and repeatedly enc...