Retaining comments when refactoring code

  • Authors:
  • Peter Sommerlad;Guido Zgraggen;Thomas Corbat;Lukas Felber

  • Affiliations:
  • IFS Institute for Software at HSR Rapperswil, Rapperswil, Switzerland;IFS Institute for Software at HSR Rapperswil, Rapperswil, Switzerland;IFS Institute for Software at HSR Rapperswil, Rapperswil, Switzerland;IFS Institute for Software at HSR Rapperswil, Rapperswil, Switzerland

  • Venue:
  • Companion to the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

Today's software developer depends on automated refactoring tools. While implementing such refactoring tools based on the Eclipse platform for a variety of languages, we faced the problem that carefully crafted formatting and comments can disappear when refactoring source code. This is annoying. Therefore, a useful refactoring tool should keep comments and move them along with the source code they belong to. We present different approaches on how to retain comments when refactoring source code. Usually comments are not present in an abstract syntax tree (AST) used by an integrated development environment (IDE). We achieve comment retention by associating them with nodes in an AST. The different attempts on gathering comments and implementing that association are shown and evaluated. Details of comment handling in different refactoring plug-ins that we have implemented for Eclipse, are given as well as a brief comparison with comment handling when refactoring with the Eclipse Java Development Tools (JDT). We hope, that this paper enables others to implement comment-preserving refactoring tools for more languages and IDEs. Every programmer, language and IDE deserves good refactoring support or they might become endangered.