Clone-Seeker:使用注释的有效代码克隆搜索
Clone-Seeker: Effective Code Clone Search Using Annotations
摘要:
源代码搜索在软件开发中起着重要的作用,例如探索性开发或从代码库中重新使用现有代码。通常,需要探索具有相同功能的不同实现,以完成自动化软件移植、软件多样化和软件修复等任务。代码克隆是语法或语义相似的代码片段,是此类任务的理想候选者。搜索代码克隆涉及给定的搜索查询以检索相关的代码片段。我们提出了一种新的方法,称为克隆搜索器,专注于利用克隆类功能检索代码克隆。为此,我们以自然语言文档的形式为每个代码克隆生成元数据。元数据包括来自代码克隆的标识符的预处理列表,该标识符的预处理列表用指示代码克隆的语义的关键字的列表来扩充。这个关键字列表可以从克隆类的手动注释的一般描述中提取,也可以从整个克隆类的源代码中自动生成。此方法可帮助开发人员基于编写为源代码术语或自然语言的搜索查询来执行代码克隆搜索。在我们的定量评估中,我们表明(1)克隆搜索者在搜索语义代码克隆时具有更高的召回率(即,Type-4);(2)Clone-Seeker可以通过应用自然语言查询来准确地搜索相关的代码克隆。
英文摘要:
Source code search plays an important role in software development, e.g. for exploratory development or opportunistic reuse of existing code from a code base. Often, exploration of different implementations with the same functionality is needed for tasks like automated software transplantation, software diversification, and software repair. Code clones, which are syntactically or semantically similar code fragments, are perfect candidates for such tasks. Searching for code clones involves a given search query to retrieve the relevant code fragments. We propose a novel approach called Clone-Seeker that focuses on utilizing clone class features in retrieving code clones. For this purpose, we generate metadata for each code clone in the form of a natural language document. The metadata includes a pre-processed list of identifiers from the code clones augmented with a list of keywords indicating the semantics of the code clone. This keyword list can be extracted from a manually annotated general description of the clone class, or automatically generated from the source code of the entire clone class. This approach helps developers to perform code clone search based on a search query written either as source code terms, or as natural language. In our quantitative evaluation, we show that (1) Clone-Seeker has a higher recall when searching for semantic code clones (i.e., Type-4) in BigCloneBench than the state-of-the-art; and (2) Clone-Seeker can accurately search for relevant code clones by applying natural language queries.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。