CodeMapper:一种跨提交映射代码区域的语言无关方法
CodeMapper: A Language-Agnostic Approach to Mapping Code Regions Across Commits
AI总结:
CodeMapper 提出一种语言无关的代码区域映射方法,通过差异分析、移动检测和相似度计算,在跨提交场景中准确找到对应代码区域,并在多语言数据集上显著优于现有基线。
摘要:
在软件演化过程中,开发者通常面临将一个提交中的特定代码区域映射到另一个提交的问题。例如,他们可能想确定 if 语句的条件、配置文件中的特定行或函数定义是如何变化的。我们称此为代码映射问题。现有技术(如 git diff)只能不充分地解决这一问题,因为它们显示对文件所做的所有更改,而不是聚焦于开发者所选择的代码区域。其他技术则专注于特定的代码元素和编程语言(例如 Java 中的方法),限制了其适用性。本文介绍了 CodeMapper,一种以独立于特定程序元素和编程语言的方式解决代码映射问题的方法。给定一个提交中的代码区域,CodeMapper 在另一个提交中找到相应区域。该方法包括两个阶段:(i)通过分析差异、检测代码移动和搜索特定代码片段来计算候选区域,以及(ii)通过计算相似度来选择最可能的目标区域。我们的评估将 CodeMapper 应用于四个数据集,其中包括两个新的人工标注数据集,包含十种流行编程语言中的代码区域对。CodeMapper 在所有情况下正确识别预期目标区域的比例为 71.0%--94.5%,比最佳可用基线提高了 1.5--58.8 个绝对百分点。
英文摘要:
During software evolution, developers commonly face the problem of mapping a specific code region from one commit to another. For example, they may want to determine how the condition of an if-statement, a specific line in a configuration file, or the definition of a function changes. We call this the code mapping problem. Existing techniques, such as git diff, address this problem only insufficiently because they show all changes made to a file instead of focusing on a code region of the developer's choice. Other techniques focus on specific code elements and programming languages (e.g., methods in Java), limiting their applicability. This paper introduces CodeMapper, an approach to address the code mapping problem in a way that is independent of specific program elements and programming languages. Given a code region in one commit, CodeMapper finds the corresponding region in another commit. The approach consists of two phases: (i) computing candidate regions by analyzing diffs, detecting code movements, and searching for specific code fragments, and (ii) selecting the most likely target region by calculating similarities. Our evaluation applies CodeMapper to four datasets, including two new hand-annotated datasets containing code region pairs in ten popular programming languages. CodeMapper correctly identifies the expected target region in 71.0%--94.5% of all cases, improving over the best available baselines by 1.5--58.8 absolute percent points.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。