结合代码嵌入和静态分析的函数调用完成方法
Combining Code Embedding with Static Analysis for Function-Call Completion
摘要:
代码完成是集成开发环境(IDE)的一个重要特性。它允许开发人员更快地生成代码,特别是那些不完全熟悉API和其他代码的新手。以前关于代码完成的工作主要利用程序设计语言的静态类型系统或正在开发的项目或使用公共API的其他项目的代码历史。在这项工作中,我们提出了一种新的方法来改善当前的函数调用完成工具,通过学习独立的代码库,使用众所周知的自然语言处理模型,可以学习向量表示的源代码(代码嵌入)。我们的模型不是基于特定项目的历史数据进行训练的。相反,我们的方法允许学习高级概念及其在数千个项目中的关系。因此,所得到的系统能够提供不特定于特定项目或API的一般建议。此外,通过考虑完成调用的上下文,我们的方法建议与该上下文相关的函数调用。我们在一组培训期间看不到的开源项目上评估了我们的方法。结果表明,使用经过训练的模型以及基于静态类型分析的代码建议插件可以显著提高完成建议的正确性。
英文摘要:
Code completion is an important feature of integrated development environments (IDEs). It allows developers to produce code faster, especially novice ones who are not fully familiar with APIs and others code. Previous works on code completion have mainly exploited static type systems of programming languages or code history of the project under development or of other projects using common APIs. In this work, we present a novel approach for improving current function-calls completion tools by learning from independent code repositories, using well-known natural language processing models that can learn vector representation of source code (code embeddings). Our models are not trained on historical data of specific projects. Instead, our approach allows to learn high-level concepts and their relationships present among thousands of projects. As a consequence, the resulting system is able to provide general suggestions that are not specific to particular projects or APIs. Additionally, by taking into account the context of the call to complete, our approach suggests function calls relevant to that context. We evaluated our approach on a set of open-source projects unseen during the training. The results show that the use of the trained model along with a code suggestion plug-in based on static type analysis improves significantly the correctness of the completion suggestions.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。