Skip to main content
Log in

Context-Aware Change Pattern for Code Transformation

  • Computer Science
  • Published:
Wuhan University Journal of Natural Sciences

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%.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. 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.

    Article  Google Scholar 

  2. 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.

    Google Scholar 

  3. 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.

    Article  Google Scholar 

  4. 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.

    Google Scholar 

  5. Reiss S P. Semantics-based code search [C] // Proceedings of International Conference on Software Engineering. Piscataway: IEEE Computer Society, 2009: 243–253.

    Google Scholar 

  6. 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.

    Google Scholar 

  7. 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.

    Article  Google Scholar 

  8. Hunt J W, Szymanski T G. A fast algorithm for computing longest common subsequences [J]. Communications of the ACM, 1977, 20(5): 350–353.

    Article  Google Scholar 

  9. Meng N, Kim M, Mckinley K S. Systematic editing: Generating program transformations from an example [J]. ACM SIGPLAN Notices, 2011, 46(6): 329–342.

    Article  Google Scholar 

  10. Meng N. Automating Program Transformations Based on Examples of Systematic Edits [D]. Austin: The University of Texas, 2014.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Zhiping Liu.

Additional information

Foundation item: Supported by the National Natural Science Foundation of China (60373075, 61640221, 61562026, 61672470)

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

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

Download citation

  • Received:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11859-018-1334-x

Key words

CLC number

Navigation