Abstract
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. With various experiments, we show that (1) Clone-Seeker is effective in finding clones from BigCloneBench dataset by applying code queries and natural language queries; 2) Clone-Seeker has a higher recall when searching for semantic code clones (i.e., Type-4) in BigCloneBench than the state-of-the-art; 3) Clone-Seeker is a generalized technique as it is effective in finding clones in Project CodeNet dataset by applying code queries and natural language queries. 4) Clone-Seeker with manual annotation outperforms other variants in finding clones on the basis of natural language queries
Highlights
S OFTWARE plays a central role in society, touching billions of lives on a daily basis.Writing and maintaining source code is a core activity for software developers, who aim to provide reliable and functional software [1]
Our experiments show that the accurate representation of clone methods in terms of metadata increases the effectiveness of code search
1) We present a novel approach called CloneSeeker, which builds a natural language document of each clone method by combining important keywords of each clone method with keywords extracted from a general description of the clone class, annotated either manually or automatically to assist developers in performing codeto-code search and natural language query search
Summary
Writing and maintaining source code is a core activity for software developers, who aim to provide reliable and functional software [1]. Hammad et al.: Preparation of Papers for IEEE ACCESS the challenges a software developer faces when writing new code is to find out how to implement a certain functionality (e.g., how to implement quick sort) [2]. The implementation of such functionality might already be realized by other developers and can be reused rather than written from scratch. This source code can be treated as an important reusable asset for developers [3]
Submitted Version (
Free)
Published Version
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have