Abstract
When source code is over-specific to some concrete contexts, developers have to manually change the source code retrieved from the Internet. To solve this problem, we propose the context-aware change pattern (CACP). For a piece of source code, we extract the changes and changes-relevant context from the past code changes, identifying CACP that is the abstract common part of the changes and context. By using CACP, the retrieved source code could be transformed into the suitable one according to different user needs. From the Github we extracted 7 topics, collected 5–6 code snippets per topic and performed 5 different experiments which illustrated that CACP improves code transformation accuracy by 73.84%.
Similar content being viewed by others
References
Yang Y R, Huang Q. IECS: Intent-Enforced code search via extended Boolean model [J]. Journal of Intelligent and Fuzzy Systems, 2017, 33(4): 2565–2576.
Huang Q, Wang X D, Yang Y R, et al. SnippetGen: Enhancing the code search via intent predicting [C] // Proceedings of the 29th International Conference on Software Engineering amp; Knowledge Engineering. Piscataway: IEEE Press, 2017: 307–312.
Huang Q, Yang Y R, Wang X. Query Expansion via Intent Predicting [J]. International Journal of Software Engineering and Knowledge Engineering, 2017, 27(9-10): 1591–1602.
Kim M, Cai D, Kim S. An empirical investigation into the role of API-level refactorings during software evolution [C]// Proceedings of International Conference on Software Engineering. New York: ACM, 2011: 151–160.
Reiss S P. Semantics-based code search [C] // Proceedings of International Conference on Software Engineering. Piscataway: IEEE Computer Society, 2009: 243–253.
Gopinath D, Malik M Z, Khurshid S. Specification-Based program repair using SAT [C] // Proceedings of TOOLS and Algorithms for the Construction and Analysis of Systems. Berlin: Springer-Verlag, 2011: 173–188.
Fluri B, Wuersch M, Pinzger M. Change Distilling:Tree Differencing for fine-grained source code change extraction [J]. IEEE Transactions on Software Engineering, 2007, 33(11): 725–743.
Hunt J W, Szymanski T G. A fast algorithm for computing longest common subsequences [J]. Communications of the ACM, 1977, 20(5): 350–353.
Meng N, Kim M, Mckinley K S. Systematic editing: Generating program transformations from an example [J]. ACM SIGPLAN Notices, 2011, 46(6): 329–342.
Meng N. Automating Program Transformations Based on Examples of Systematic Edits [D]. Austin: The University of Texas, 2014.
Author information
Authors and Affiliations
Corresponding author
Additional information
Foundation item: Supported by the National Natural Science Foundation of China (60373075, 61640221, 61562026, 61672470)
Rights and permissions
About this article
Cite this article
Liu, Z. Context-Aware Change Pattern for Code Transformation. Wuhan Univ. J. Nat. Sci. 23, 355–361 (2018). https://doi.org/10.1007/s11859-018-1334-x
Received:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11859-018-1334-x