论文标题
HANCUP:混合分析和基于注意力的及时评论更新
HatCUP: Hybrid Analysis and Attention based Just-In-Time Comment Updating
论文作者
论文摘要
更改代码时,开发人员有时会忽略更新相关注释,带来不一致或过时的评论。这些评论增加了程序理解的成本,并大大降低了软件可维护性。研究人员提出了一些解决方案,例如CUP和HEBCUP,这些解决方案有效地更新了评论,以进行简单的代码更改(即修改单个令牌),但对于复杂的代码而言还不够好。在本文中,我们提出了一种名为HATCUP的方法(混合分析和基于注意力的评论更新程序),以提供一种新的机制来评论更新任务。 HANCUP注意混合分析和信息。首先,HATCUP考虑了代码结构更改信息,并引入了结构引导的注意机制,并结合了代码更改图分析和乐观的数据流依赖关系分析。借助基于RNN的通常流行的编码器架构,HATCUP采用了代码编辑,语法,语义和结构代码更改的动作,而旧评论则作为输入,并生成了当前代码段中更改的结构表示。此外,HATCUP不是直接生成新的评论,而是通过生成一系列编辑操作并构建修改后的RNN模型来集成新开发的组件,而是提出了一种新的编辑或非编辑机制来模仿人类编辑行为。在流行数据集上的评估表明,HATCUP的表现优于最先进的深度学习方法(CUP)的准确性53.8%,召回率为31.3%,原始指标的流星的召回率为14.3%。与基于启发式的方法(HEBCUP)相比,HATCUP还显示出更好的整体性能。
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.