一句话:提出 TrigIt,将 trigger-action TODO 注释写成可执行规约,在构建时自动执行查询、通知与代码变换。
自然语言 TODO 注释常用来描述在特定条件(触发器)满足时需执行的任务(动作),但因非形式化,随着项目演化容易过时或被遗忘。本文提出首个将 trigger-action TODO 注释可执行化的框架 TrigIt:规约用宿主语言(如 Java)编写,并作为构建过程的一部分求值。触发器是对抽象语法树、构建配置脚本、issue 跟踪系统和系统时钟的查询;动作可以是通知开发者或代码变换。作者在 Java 上实现 TrigIt,并从多个流行开源项目迁移了 44 条 trigger-action 注释。用户研究表明用户认为 TrigIt 易学易用,有望促进大型代码仓库中注释的编写与维护纪律。
Natural language elements, e.g., todo comments, are frequently used to communicate among developers and to describe tasks that need to be performed (actions) when specific conditions hold on artifacts related to the code repository (triggers), e.g., from the Apache Struts project: “remove expectedJDK15 and if() after switching to Java 1.6”. As projects evolve, development processes change, and development teams reorganize, these comments, because of their informal nature, frequently become irrelevant or forgotten. We present the first framework, dubbed TrigIt, to specify trigger-action todo comments in executable format. Thus, actions are executed automatically when triggers evaluate to true. TrigIt specifications are written in the host language (e.g., Java) and are evaluated as part of the build process. The triggers are specified as query statements over abstract syntax trees, abstract representation of build configuration scripts, issue tracking systems, and system clock time. The actions are either notifications to developers or code transformation steps. We implemented TrigIt for the Java programming language and migrated 44 existing trigger-action comments from several popular open-source projects. Evaluation of TrigIt, via a user study, showed that users find TrigIt easy to learn and use. TrigIt has the potential to enforce more discipline in writing and maintaining comments in large code repositories.
@inproceedings{paperbot5044,
title = {A framework for writing trigger-action todo comments in executable format},
author = {Pengyu Nie and Rishabh Rai and Junyi Jessy Li and Sarfraz Khurshid and Raymond J. Mooney and Milos Gligoric},
booktitle = {FSE},
year = {2019},
doi = {10.1145/3338906.3338965}
}