论文标题
代码克隆匹配:找到代码段的实用有效方法
Code Clone Matching: A Practical and Effective Approach to Find Code Snippets
论文作者
论文摘要
在源代码中找到相同或相似的代码段是软件维护中的基本活动之一。基于文本的模式匹配工具(例如GREP)经常用于此目的,但是对预期结果进行适当的查询并不容易。代码克隆探测器可以使用,但它们的特征和结果通常过多。在本文中,我们提出了代码克隆匹配(简称CC匹配),该匹配使用了基于令牌的克隆检测和元tokens的元模式的组合。用户只需提供几个元tokens的查询代码段,然后获得所得的摘要,在查询和结果之间形成类型1、2或3代码克隆对。通过将带有元tokens的代码段作为查询,将得到的匹配受到用户的良好控制。 CC匹配已被用作具有GREP样用户界面的实用和高效工具,名为CCGREP。评估表明,查找各种代码段非常有效。
Finding the same or similar code snippets in source code is one of fundamental activities in software maintenance. Text-based pattern matching tools such as grep is frequently used for such purpose, but making proper queries for the expected result is not easy. Code clone detectors could be used but their features and result are generally excessive. In this paper, we propose Code Clone matching (CC matching for short) that employs a combination of token-based clone detection and meta-patterns enhanced with meta-tokens. The user simply gives a query code snippet possibly with a few meta-tokens and then gets the resulting snippets, forming type 1, 2, or 3 code clone pairs between the query and result. By using a code snippet with meta-tokens as the query, the resulting matches are well controlled by the users. CC matching has been implemented as a practical and efficient tool named ccgrep, with grep-like user interface. The evaluation shows that ccgrep~ is a very effective to find various kinds of code snippets.