一句话:提出 AutoSC,将程序分析与统计语言模型结合,实现频繁且类型正确的代码语句补全。
代码补全能提升开发者效率,但补全部分代码语句时需兼顾候选项的高频性与语法、类型正确性。AutoSC 在大规模代码语料上训练得到候选语句模板,再利用程序分析对模板进行验证和具体化,生成语法与类型有效的候选语句,最后用基于源代码词法形式训练的语言模型对候选排序。在真实项目的大型数据集上,AutoSC 的语句补全 top-1 准确率为 38.9–41.3%,top-5 为 48.2–50.1%,top-1 较当时最佳方法提升 9X–69X。
Automatic code completion helps improve developers' productivity in their programming tasks. A program contains instructions expressed via code statements, which are considered as the basic units of program execution. In this paper, we introduce AutoSC, which combines program analysis and the principle of software naturalness to fill in a partially completed statement. AutoSC benefits from the strengths of both directions, in which the completed code statement is both frequent and valid. AutoSC is first trained on a large code corpus to derive the templates of candidate statements. Then, it uses program analysis to validate and concretize the templates into syntactically and type-valid candidate statements. Finally, these candidates are ranked by using a language model trained on the lexical form of the source code in the code corpus. Our empirical evaluation on the large datasets of real-world projects shows that AutoSC achieves 38.9-41.3% top-1 accuracy and 48.2-50.1% top-5 accuracy in statement completion. It also outperforms a state-of-the-art approach from 9X-69X in top-1 accuracy.
DOI 原文 ·
@inproceedings{paperbot5333,
title = {Combining Program Analysis and Statistical Language Model for Code Statement Completion},
author = {Son Nguyen and Tien Nguyen and Yi Li and Shaohua Wang},
booktitle = {ASE},
year = {2019},
doi = {10.1109/ase.2019.00072}
}