arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.09499cs.SEcs.AIcs.CL
收藏

基于图的扁平抽象树模型的代码完成

Code Completion by Modeling Flattened Abstract Syntax Trees as Graphs

Microsoft Research Asia(微软亚洲研究院);School of Informatics, Xiamen University(厦门大学信息学院)

Yanlin Wang, Hui Li

摘要:

代码完成已经成为集成开发环境的重要组成部分。当代的代码完成方法依赖于抽象语法树(AST)来生成语法正确的代码。然而,它们不能完全捕获编写代码的顺序和重复模式以及AST的结构信息。为了缓解这些问题,我们提出了一个新的代码完成方法命名为CCAG,模型的部分AST的扁平序列作为AST图。CCAG使用我们提出的AST图注意块来捕获AST图中的不同依赖关系,以用于代码完成中的表示学习。代码完成的子任务通过CCAG中的多任务学习进行优化,并且使用不确定性自动实现任务平衡,而无需调整任务权重。实验结果表明,CCAG具有优越的性能比国家的最先进的方法,它能够提供智能代码完成。

英文摘要:

Code completion has become an essential component of integrated development environments. Contemporary code completion methods rely on the abstract syntax tree (AST) to generate syntactically correct code. However, they cannot fully capture the sequential and repetitive patterns of writing code and the structural information of the AST. To alleviate these problems, we propose a new code completion approach named CCAG, which models the flattened sequence of a partial AST as an AST graph. CCAG uses our proposed AST Graph Attention Block to capture different dependencies in the AST graph for representation learning in code completion. The sub-tasks of code completion are optimized via multi-task learning in CCAG, and the task balance is automatically achieved using uncertainty without the need to tune task weights. The experimental results show that CCAG has superior performance than state-of-the-art approaches and it is able to provide intelligent code completion.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑