When changing code, developers sometimes neglect updating the related comments, bringing inconsistent or outdated comments. These comments increase the cost of program understanding and greatly reduce software maintainability. Researchers have put forward some solutions, such as CUP and HEBCUP, which update comments efficiently for simple code changes (i.e. modifying of a single token), but not good enough for complex ones. In this paper, we propose an approach, named HatCUP (Hybrid Analysis and Attention based Comment UPdater), to provide a new mechanism for comment updating task. HatCUP pays attention to hybrid analysis and information. First, HatCUP considers the code structure change information and introduces a structure-guided attention mechanism combined with code change graph analysis and optimistic data flow dependency analysis. With a generally popular RNN-based encoder-decoder architecture, HatCUP takes the action of the code edits, the syntax, semantics and structure code changes, and old comments as inputs and generates a structural representation of the changes in the current code snippet. Furthermore, instead of directly generating new comments, HatCUP proposes a new edit or non-edit mechanism to mimic human editing behavior, by generating a sequence of edit actions and constructing a modified RNN model to integrate newly developed components. Evaluation on a popular dataset demonstrates that HatCUP outperforms the state-of-the-art deep learning-based approaches (CUP) by 53.8% for accuracy, 31.3% for recall and 14.3% for METEOR of the original metrics. Compared with the heuristic-based approach (HEBCUP), HatCUP also shows better overall performance.
翻译:当修改代码时,开发者有时忽视更新相关评论,带来不一致或过时的评论。这些评论增加了程序理解的成本,并大大降低了软件的可维护性。研究人员提出了一些解决方案,如CUP和HEBCUP,它们为简单的代码修改(即修改一个单一符号)而有效地更新评论,但对于复杂的代码修改则不够好。在本文件中,我们提议了一种名为 HATCUP(基于 Hybrid 的分析和注意的注释更新器)的方法,为更新评论任务提供一个新的机制。HCCUP 关注混合分析和信息。首先,HCCUP考虑代码结构改变信息,并引入了结构引导关注机制,加上代码改变图分析和乐观的数据流依赖分析。在普遍流行的 RNNED 编码变换编码结构架构中,HATC 将代码编辑、语法、语法分析和结构改变的旧评论作为输入当前代码的更新工具。此外,HCUPFP提出一个新的或非结构引导引引引引的注意机制,将R-RERERRRRRUD的校正的校正校正校正校略方法用于新的人类数据编辑。