Aroma:通过结构代码搜索推荐代码
Aroma: Code Recommendation via Structural Code Search
摘要:
程序员编写的代码通常与在某处编写的现有代码相似。一个可以帮助程序员搜索类似代码的工具将是非常有用的。这样的工具可以帮助程序员扩展部分编写的代码片段以完全实现必要的功能,帮助发现其他程序员通常包括的部分代码的扩展,帮助交叉检查其他程序员编写的类似代码,或者帮助添加额外的代码来修复常见的错误和错误。我们提出了Aroma,这是一种通过结构化代码搜索进行代码推荐的工具和技术。Aroma索引了一个包含数千个开源项目的巨大代码语料库,将部分代码片段作为输入,搜索语料库中包含部分代码片段的方法体,并对搜索结果进行聚类和交叉,以推荐一小部分简洁的代码片段,这些代码片段既包含查询片段,又作为语料库中几个方法的一部分出现。我们对Aroma进行了评估,包括从语料库中随机选择的2000个查询,以及从Stack Overflow(一个流行的代码讨论网站)获得的64个代码片段查询。我们为4种不同的语言实现了Aroma,并为Aroma开发了IDE插件。此外,我们进行了一项研究,要求12名程序员使用Aroma完成编程任务,并收集他们的反馈。我们的研究结果表明,Aroma能够有效地检索和推荐相关的代码片段。
英文摘要:
Programmers often write code that has similarity to existing code written somewhere. A tool that could help programmers to search such similar code would be immensely useful. Such a tool could help programmers to extend partially written code snippets to completely implement necessary functionality, help to discover extensions to the partial code which are commonly included by other programmers, help to cross-check against similar code written by other programmers, or help to add extra code which would fix common mistakes and errors. We propose Aroma, a tool and technique for code recommendation via structural code search. Aroma indexes a huge code corpus including thousands of open-source projects, takes a partial code snippet as input, searches the corpus for method bodies containing the partial code snippet, and clusters and intersects the results of the search to recommend a small set of succinct code snippets which both contain the query snippet and appear as part of several methods in the corpus. We evaluated Aroma on 2000 randomly selected queries created from the corpus, as well as 64 queries derived from code snippets obtained from Stack Overflow, a popular website for discussing code. We implemented Aroma for 4 different languages, and developed an IDE plugin for Aroma. Furthermore, we conducted a study where we asked 12 programmers to complete programming tasks using Aroma, and collected their feedback. Our results indicate that Aroma is capable of retrieving and recommending relevant code snippets efficiently.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。