Ding Xue’er, Niu Jun, Zhang Kaile, Mao Xinyi. Code Search Method Based on the Reachability Analysis of Petri Nets[J]. Journal of Computer Research and Development, 2022, 59(1): 236-250. DOI: 10.7544/issn1000-1239.20200586
Citation:
Ding Xue’er, Niu Jun, Zhang Kaile, Mao Xinyi. Code Search Method Based on the Reachability Analysis of Petri Nets[J]. Journal of Computer Research and Development, 2022, 59(1): 236-250. DOI: 10.7544/issn1000-1239.20200586
Ding Xue’er, Niu Jun, Zhang Kaile, Mao Xinyi. Code Search Method Based on the Reachability Analysis of Petri Nets[J]. Journal of Computer Research and Development, 2022, 59(1): 236-250. DOI: 10.7544/issn1000-1239.20200586
Citation:
Ding Xue’er, Niu Jun, Zhang Kaile, Mao Xinyi. Code Search Method Based on the Reachability Analysis of Petri Nets[J]. Journal of Computer Research and Development, 2022, 59(1): 236-250. DOI: 10.7544/issn1000-1239.20200586
1(Faculty of Electrical Engineering and Computer Science, Ningbo University, Ningbo, Zhejiang 315211)
2(Key Laboratory of Embedded System and Service Computing (Tongji University), Ministry of Education, Shanghai 201804)
Funds: This work was supported by the National Natural Science Foundation of China (61672384), the Open Project of Key Laboratory of Embedded System and Service Computing of the Ministry of Education of China (ESSCKF2019-07), and the Natural Science Foundation of Ningbo (2019A610088).
Reusing existing high-quality source codes can improve efficiency of software development and quality of software. At present, code search based on inputoutput queries provided by users is one of the main approaches in the field of code semantic search, but existing approaches are difficult to describe the complete behavior of codes and can only handle a single input type. This paper proposes a code semantic search approach based on the reachability analysis of Petri Nets for matching multiple forms of type. First, the semantic processes of code snippets consisting of the number of data objects and types of data objects in the code corpus are converted into improved Petri Net models. Second, the initial marking and target marking of Petri Net models are constructed according to the number of data objects and types of data objects contained in users’ queries. Matching code snippets is obtained by the analysis of reachable paths in reachability graphs and induced networks of Petri Nets. Analysis and experimental results show that this approach contributes to seeking out desired code snippets by queries that possess multiple forms of inputoutput types provided by users, and compared with traditional approaches, it can significantly improve accuracy and efficiency of code search.