Reducing Mismatches in Syntax Coupled Hunks

Chunhua Yang, Xiufang Li · Proceedings/Proceedings of the ... International Conference on Software Engineering and Knowledge Engineering · 2022

Hunks generated by textual-differencing tools are often used for understanding code changes.However, in the side-by-side view, the match between the deleted and added lines of a hunk is sometimes inconsistent with actual changes to the corresponding syntax entities.This mismatch usually occurs in syntax coupled hunks, i.e. hunks that contain changes to multiple syntax entities.It makes the hunks incomprehensible and misleading.A hybrid differencing algorithm is proposed to alleviate this problem.It applies tree-differencing to syntax coupled hunks to generate edits.It then maps edits back to the source code to generate adjusted hunks.Based on the current implementation, we conducted a case study on 10 open source projects.The results showed that 15% of commits contain syntax coupled hunks.And, we evaluated the results of the algorithm on 1,500 randomly drawn samples, and the correct matching rate was as high as 97%, demonstrating the effectiveness of the algorithm in reducing mismatches.

Read the paper · More papers on PaperTik