一句话:提出 CARER,利用动静态上下文与命名惯例为 Java 字段重命名推荐新名称,大幅提升 IDE 推荐准确率。
重命名是常见软件重构,但主流 IDE 自动推荐的新名称常不正确:例如 IntelliJ IDEA 对字段重命名的推荐精确率低至 6.3%。为此,本文提出轻量级上下文感知方法 CARER,用于 Java 字段重命名的名称推荐。不同于依赖初始化器和数据类型的 IDE,CARER 同时利用重命名处的动态与静态上下文以及命名惯例。作者在开源应用中收集的 1.1K 个真实字段重命名上进行评估,结果显示精确率从 6.30% 提升至 61.15%,召回率从 6.30% 提升至 41.50%,且效率与 IntelliJ IDEA 相当,适合集成进 IDE。
Renaming is one of the most popular software refactorings. Although developers may know what the new name should be when they conduct a renaming, it remains valuable for refactoring tools to recommend new names automatically so that developers can simply hit Enter and efficiently accept the recommendation to accomplish the refactoring. Consequently, most IDEs automatically recommend new names for renaming refactorings by default. However, the recommendation made by mainstream IDEs is often incorrect. For example, the precision of IntelliJ IDEA in recommending names for field renamings is as low as 6.3%. To improve the accuracy, in this paper, we propose a context-aware lightweight approach (called CARER) to recommend new names for Java field renamings. Different from mainstream IDEs that rely heavily on initializers and data types of the to-be-renamed fields, CARER exploits both dynamic and static contexts of the renamings as well as naming conventions. We evaluate CARER on 1.1K real-world field renamings discovered from open-source applications. Our evaluation results suggest that CARER can significantly improve the state of the practice in recommending new names for field renamings, improving the precision from 6.30% to 61.15%, and recall from 6.30% to 41.50%. Our evaluation results also suggest that CARER is as efficient as IntelliJ IDEA is, making it suitable to be integrated into IDEs.