Slicing Based Code Recommendation for Type Based Instance Retrieval

Rui Sun, Hui Liu*, Leping Li

*Corresponding author for this work

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

1 Citation (Scopus)

Abstract

It is common for developers to retrieve an instance of a certain type from another instance of other types. However, it is quite often that developers do not exactly know how to retrieve the instance although they know exactly what they need (the instance to re retrieved, also known as the target instance) and where it could be retrieved (i.e., the source instance). Such kind of instance retrieval is popular and thus their implementations, in different forms, are often publicly available on the Internet. Consequently, a number of approaches have been proposed to retrieve such implementations (code snippets) and release developers from reinventing such snippets. However, the performance of such approaches deserves further improvement. To this end, in this paper, we propose a slicing based approach to recommending code snippets that could retrieve the target instance from the source instance. The approach works as follows. First, from a large code base, it retrieves methods that contain the source instance and the target instance. Second, for each of these methods, it locates the target instances, and extracts related code snippets that generate the target instances by backward code slicing. Third, from the extracted code snippets, it removes those that do not contain the source instance. Fourth, it merges code snippets whose corresponding target instances are at parallel execution paths. Fifth, it removes duplicate code snippets. Finally, it ranks the resulting code snippets, and presents the top ones. We implement the approach as an Eclipse plugin called TIRSnippet. We also evaluate it with real type based instance retrieval queries. Evaluation results suggest that compared to the state-of-the-art approaches, the proposed approach improves the precision and recall by 8.8%, and 25%, respectively.

Original languageEnglish
Title of host publicationReuse in the Big Data Era - 18th International Conference on Software and Systems Reuse, ICSR 2019, Proceedings
EditorsXin Peng, Apostolos Ampatzoglou, Tanmay Bhowmik
PublisherSpringer Verlag
Pages149-167
Number of pages19
ISBN (Print)9783030228873
DOIs
Publication statusPublished - 2019
Event18th International Conference on Software and Systems Reuse, ICSR 2019 - Cincinnati, United States
Duration: 26 Jun 201928 Jun 2019

Publication series

NameLecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Volume11602 LNCS
ISSN (Print)0302-9743
ISSN (Electronic)1611-3349

Conference

Conference18th International Conference on Software and Systems Reuse, ICSR 2019
Country/TerritoryUnited States
CityCincinnati
Period26/06/1928/06/19

Keywords

  • Code search
  • Reuse
  • Slicing

Fingerprint

Dive into the research topics of 'Slicing Based Code Recommendation for Type Based Instance Retrieval'. Together they form a unique fingerprint.

Cite this