A Multiple-Path Learning Neural Network Model for Code Completion
Yi Liu, Jianxun Liu, Xiangping Zhang, Haize Hu · 2023
Code completion, which can accelerate the software development process and improve the quality of software products, is an essential part of today’s integrated development environments. It has become an important research topic in the field of software engineering. Recent studies have shown that the method of code completion based on the Abstract Syntax Tree (AST) learns syntactic information about the code, which helps to improve the accuracy of code completion. However, when modeling neural networks for ASTs, the sequencing operation of nodes leads to the loss of their hierarchical structure information. Meanwhile, traditional neural networks cannot predict many Out-of-Vocabulary (OoV) words in the terminal node values of AST. To alleviate the above problem, in this paper, we propose a Multiple-Path Learning neural network model for code completion (MPL) based on an AST by learning from a large-scale corpus. In this model, multiple paths such as context path, root path, and terminal node path are established to understand different code features required for node prediction and improve code representation ability. Based on the principle of program local repeatability, it also adopts a replication mechanism to copy the appropriate OoV words from the local terminal node path as the prediction result, further improving the prediction accuracy. The experimental results show that the MPL model has better performance than existing methods on the code completion task.