Sound and extensible renaming for java

Sound and extensible renaming for java
复制标题

DOI:
10.1145/1449764.1449787
复制
发表时间:
2008-10
期刊:
Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications
影响因子:
--
通讯作者:
Max Schäfer;Torbjörn Ekman;O. Moor
Max Schäfer;Torbjörn Ekman;O. Moor
中科院分区:
其他
文献类型:
--
作者:
Max Schäfer;Torbjörn Ekman;O. Moor

文献摘要

被引文献

相似文献

描述性名称对于理解代码至关重要。但是,众所周知,好名字很难选择,并且手动更改全球可见名称可能是一场维护噩梦。因此,对自动重命名的工具支持是开发人员的重要援助,并在流行的开发环境中得到了广泛的支持。这项工作改善了当前重构工具中的两个限制:过于弱的先决条件,导致名称在重命名后不绑定正确声明,而过于强大的先决条件,无法更重命名某些程序。我们确定了不健全性的两个主要原因:复杂的名称查找规则使很难定义足够的先决条件,而新的语言功能则需要额外的先决条件。我们通过提出一种新颖的可扩展技术来减轻这两个问题,用于创建符号名称,这些技术可以通过反转查找功能在特定上下文中与所需的实体结合。然后可以量身定制倒置的查找功能,以创建合格的名称,否则会发生冲突,从而使重构可以通过过于强的前提条件来改善问题。我们已经为Java实施了重命名,以扩展到Jastadd可扩展的Java编译器,并将其集成到Eclipse中。我们展示了其他重构引擎的前提条件太弱的例子,以及我们通过插入资格来重命名实体的方法的示例。为了验证该方法的可扩展性,我们已经实施了对Java 5和Fackj(例如Inter-type声明)的重命名支持,作为对初始Java 1.4重构引擎的模块化扩展。重命名的引擎仅是几千条代码,包括扩展和性能与工业实力重构工具相当。
Descriptive names are crucial to understand code. However, good names are notoriously hard to choose and manually changing a globally visible name can be a maintenance nightmare. Hence, tool support for automated renaming is an essential aid for developers and widely supported by popular development environments. This work improves on two limitations in current refactoring tools: too weak preconditions that lead to unsoundness where names do not bind to the correct declarations after renaming, and too strong preconditions that prevent renaming of certain programs. We identify two main reasons for unsoundness: complex name lookup rules make it hard to define sufficient preconditions, and new language features require additional preconditions. We alleviate both problems by presenting a novel extensible technique for creating symbolic names that are guaranteed to bind to a desired entity in a particular context by inverting lookup functions. The inverted lookup functions can then be tailored to create qualified names where otherwise a conflict would occur, allowing the refactoring to proceed and improve on the problem with too strong preconditions. We have implemented renaming for Java as an extension to the JastAdd Extensible Java Compiler and integrated it in Eclipse. We show examples for which other refactoring engines have too weak preconditions, as well as examples where our approach succeeds in renaming entities by inserting qualifications. To validate the extensibility of the approach we have implemented renaming support for Java 5 and AspectJ like inter-type declarations as modular extensions to the initial Java 1.4 refactoring engine. The renaming engine is only a few thousand lines of code including extensions and performance is on par with industrial strength refactoring tools.