MerGen: A Smart Code Merging Approach for Automatically Generated Code

Xiao He, Letian Tang, Yi Liu · 2022 IEEE 46th Annual Computers, Software, and Applications Conference (COMPSAC) · 2022

In model-driven low-code development, developers obtain the initial system implementation by generating the source code from models and then modify the generated code for custom-ization. In the subsequent development, the models may evolve so the code must be re-generated. How to merge the modified code with the newly generated code is an important issue. Existing model-driven development tools simply discard the code changed by developers or preserve developers' code based on some special annotations manually appended by developers. This paper pro-poses MerGen, a smart code merger for the generated code. Mer-Gen relies on universal unique identifiers that are associated with the generated code entities (i.e., types, fields, and methods) to pair the parts to be merged. Then, MerGen computes the digest of an entity in the normalized form to automatically determine whether the entity has been changed. Finally, MerGen uses a two-way re-factoring-based merging algorithm to merge the semantic code changes, rather than directly merging the code textually. We im-plement a prototype tool for the Eclipse Modeling Framework (EMF) and conduct a case study to evaluate the feasibility and the effectiveness of MerGen. The study results show that MerGen can effectively merge the modified code with the newly generated code compared with the default code merger of the EMF.

Read the paper · More papers on PaperTik