CodeMapper: A Language-Agnostic Approach to Mapping Code Regions Across Commits
Huimin Hu, Michael Pradel
Abstract
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 ifstatement, 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 Code-Mapper, 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.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
Lineage
- Accurate method and variable tracking in commit history cites CodeShovel: Constructing Method-Level Source Code Histories
- The evolution of type annotations in python: an empirical study cites CodeShovel: Constructing Method-Level Source Code Histories
Builds on10
- Evaluating Representation Learning of Code Changes for Predicting Patch Correctness in Program RepairHaoye Tian, Kui Liu, Abdoul Kader Kaboré, Anil Koyuncu et al.ASE 2020 · 81 citations
- Mossad: defeating software plagiarism detectionBreanna Devore-McDonald, Emery D. BergerOOPSLA 2020 · 35 citations
- CodeShovel: Constructing Method-Level Source Code HistoriesFelix Grund, Shaiful Alam Chowdhury, Nick C. Bradley, Braxton Hall et al.ICSE 2021 · 33 citations
- The evolution of type annotations in python: an empirical studyLuca Di Grazia, Michael PradelFSE 2022 · 29 citations
- Accurate method and variable tracking in commit historyMehran Jodavi, Nikolaos TsantalisFSE 2022 · 12 citations
Related papers
- A Differential Testing Approach for Evaluating Abstract Syntax Tree Mapping AlgorithmsYuanrui Fan, Xin Xia, David Lo, Ahmed E. Hassan et al.ICSE 2021 · 18 citations
- iASTMapper: An Iterative Similarity-Based Abstract Syntax Tree Mapping AlgorithmNeng Zhang, Qinde Chen, Zibin Zheng, Ying ZouASE 2023 · 2 citations
- Automated Software Entity Matching Between Successive VersionsBo Liu, Hui Liu, Nan Niu, Yuxia Zhang et al.ASE 2023 · 8 citations
- Learning to Update Natural Language Comments Based on Code ChangesSheena Panthaplackel, Pengyu Nie, Milos Gligoric, Junyi Jessy Li et al.ACL 2020 · 1 citation
- Decades of GNU Patch and Git Cherry-Pick: Can We Do Better?Alexander Schultheiß, Alexander Boll, Paul Maximilian Bittner, Sandra Greiner et al.ICSE 2026
