paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Next Syntactic-Unit Code Completion and Applications

下一个语法单元代码补全及其应用
ASE Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering2022匹配度 3/10 · 论文属于基于 AST 统计语言模型的代码补全,涉及程序语言与机器学习交叉,但与用户核心关注的静态分析、Agentic/LLM 程序分析、浮点程序分析或贝叶斯程序分析关联较弱;且方法基于传统统计模型而非当前 LLM/Agent。引用 4 inbox
Anh Tuan Nguyen, Aashish Yadavally, Tien N. Nguyen
crossref: 2026-09-12

AI 速览

一句话:提出 AstCC,用 AST 统计语言模型预测下一个语法单元,并给出其在修复、测试生成与模式挖掘中的应用。

IDE 中的代码补全能显著提升开发效率,但现有方法多局限于补全当前 token、下一个 token/语句或代码模式,补全粒度较粗。本文提出 AstCC:一种以 AST 为基础的统计语言模型,它从大规模代码语料中学习,推断出代表一个语法单元的下一个 AST 子树,再利用当前程序作用域中的具体变量填充该子树模板,从而实现“下一个语法单元”级别的补全。作者在真实代码上进行了实证评估:AstCC 能够在 33% 的情形下正确给出下一个语法单元,在 62% 的情形下正确答案出现在前五个候选中。论文还讨论了该方法在自动程序修复、自动测试用例生成以及句法模式挖掘等任务上的潜在应用。

问题
现有代码补全方法只针对当前 token、下一个 token/语句或固定代码模式,粒度不足以直接给出完整的下一个语法单元。
方法
提出 AstCC,使用基于 AST 的统计语言模型从大规模代码语料学习下一个语法单元对应的 AST 子树,并用当前作用域中的具体变量填充该模板。
评估
在真实代码上进行实证评估,报告 33% 的 top-1 正确率与 62% 的 top-5 正确率,并讨论其在程序修复、测试生成与句法模式挖掘中的应用前景。
原文摘要(Abstract)

Code completion is an important feature in an IDE to improve developers’ productivity. Existing code completion approaches focus on completing the current code token, next token or statement, or code pattern. We propose AstCC, a code completion approach to suggest the next syntactic unit via an AST-based statistical language model. AstCC learns from a large code corpus to derive the next AST subtree representing a syntactic unit, and then fills in the template with the concrete variables from the current program scope. Our empirical evaluation shows that AstCC can correctly suggest the next syntactic unit in 33% of the cases, and in 62% of the cases, it correctly suggests within five candidates. We will also explain the potential applications of AstCC in automated program repair, automated test case generation, and syntactic pattern mining.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot7340,
  title = {Next Syntactic-Unit Code Completion and Applications},
  author = {Anh Tuan Nguyen and Aashish Yadavally and Tien N. Nguyen},
  booktitle = {ASE},
  year = {2022},
  doi = {10.1145/3551349.3559544}
}