arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.19120cs.SE
收藏

一种用于自动行级代码补全的朴素方法

A Naive Approach for Automatic Line-level Code Completion

Shamima Naznin, Dr. Manishankar Mondal

AI总结:

本文提出一种基于代码相似性分析的朴素行级代码补全框架,可跨 C 和 Java 补全任意程序语句;实验显示其能补全约 22% 语句、平均准确率达 87%,且 10 字符前缀精度最高。

摘要:

编码是编程不可或缺的一个方面。程序员在编写少量 token 后即可自动补全代码片段,这一自动补全过程被称为代码补全。此前已有若干关于代码补全的研究,主要针对方法体补全和方法参数补全。然而,这项基础性研究探索的是对任意程序语句的自动补全,这些语句甚至可能不属于某个方法。其目标是通过识别和分析代码相似性,在整个代码库中为程序员提供代码补全建议。所提出的方法可被视为自动化代码补全的基础框架。通过对用 C 和 Java 编写的四个目标系统的数百个修订版本进行调查,可以观察到,所提出的方法能够自动补全程序员在开发期间编写的约 22% 的代码语句,平均准确率为 87%,从而加快软件开发时间。实证分析进一步表明,该方法可以在编程语言无关的情况下使用。研究最后说明,在调用补全前以 10 个字符作为前缀可获得最高精度。

英文摘要:

Coding is an integral aspect of programming. A programmer can automatically complete a code fragment after writing a few tokens, and the process of automatic completion is known as code completion. Several research studies on code completion have previously been conducted for method body completion and method parameter completion. However, this fundamental study explores the automatic completion of any program statement that might not even be part of a method. The goal is to provide suggestions to the programmer for completing code throughout the codebase by identifying and analyzing code similarities. The proposed methodology can be regarded as a fundamental framework for automated code completion. From the investigation of hundreds of revisions of four subject systems written in C and Java, it is observed that the proposed method can automatically complete around 22% of code statements with an average accuracy of 87% that a programmer writes during development, accelerating software development time. The empirical analysis further demonstrates that the approach can be used with programming language neutrality. The study concludes by illustrating that taking 10 characters as prefixes before invoking completion provides maximum precision.

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

↑