一句话:提出两阶段预训练框架 RefBERT,为命名不佳的变量自动生成更准确、可读的新名称。
重命名重构是软件演化中最常见的重构之一,但现有工作多只识别两个版本间的重命名活动,很少关注如何为标识符建议新名称。本文研究变量名的自动重命名重构,指出其与主流学习范式及自然语言文本生成之间的差异。为此提出 RefBERT:先预测新名称包含的子词数量,再据此生成子词;并引入约束掩码语言建模、对比学习和 bag-of-tokens 损失,使其适配变量重命名任务。在自建重构数据集上的大量实验表明,RefBERT 生成的变量名比现有方法更准确、更有意义。
Refactoring is an indispensable practice of improving the quality and maintainability of source code in software evolution. Rename refactoring is the most frequently performed refactoring that suggests a new name for an identifier to enhance readability when the identifier is poorly named. However, most existing works only identify renaming activities between two versions of source code, while few works express concern about how to suggest a new name. In this paper, we study automatic rename refactoring on variable names, which is considered more challenging than other rename refactoring activities. We first point out the connections between rename refactoring and various prevalent learning paradigms and the difference between rename refactoring and general text generation in natural language processing. Based on our observations, we propose RefBERT, a two-stage pre-trained framework for rename refactoring on variable names. RefBERT first predicts the number of sub-tokens in the new name and then generates sub-tokens accordingly. Several techniques, including constrained masked language modeling, contrastive learning, and the bag-of-tokens loss, are incorporated into RefBERT to tailor it for automatic rename refactoring on variable names. Through extensive experiments on our constructed refactoring datasets, we show that the generated variable names of RefBERT are more accurate and meaningful than those produced by the existing method. Our implementation and data are available at https://github.com/KDEGroup/RefBERT.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{LiuWWXWLJ23,
title = {RefBERT: A Two-Stage Pre-trained Framework for Automatic Rename Refactoring},
author = {Hao Liu and Yanlin Wang and Zhao Wei and Yong Xu and Juhong Wang and Hui Li and Rongrong Ji},
booktitle = {ISSTA},
year = {2023},
doi = {10.1145/3597926.3598092}
}