Applying Program Analysis to Code Retrieval
Early code retrieval systems were primarily adaptations of standard text retrieval approaches, and so treated source code as either plain or structured text. While fairly successful, these approaches ignored much of the information that can be extracted from the source code. Recently, researchers have demonstrated a number of ways in which static program analysis can be used to augment text-based retrieval approaches. By taking advantage of the structural and semantic information embedded in source code, advanced code retrieval systems can provide a superior experience.
This chapter begins describing how basic text-based code retrieval systems function. It then introduces a basic form of static program analysis which allows source code to be treated as structured text. Finally, it describes link analysis, an advanced program analysis technique. Link analysis aids code retrieval systems in numerous ways, for example enabling better estimates of result quality and the sharing of descriptive terms. The chapter concludes by describing in great detail a single static program analysis technique called dependency slicing. Dependency slicing is used in code retrieval systems to package up search results as a compilable unit, which supports the reuse of the retrieved results.
KeywordsSource Code Abstract Type Term Extraction Abstract Syntax Tree Type Hierarchy
This material is based upon work supported by the National Science Foundation under Grant No. 1018374.
- Apache Lucene.Google Scholar
- Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. 2006.Google Scholar
- Sushil K. Bajracharya, Joel Ossher, and Cristina V. Lopes. Leveraging usage similarity for effective retrieval of examples in code repositories. In Proceedings of the eighteenth ACM SIGSOFT international symposium on Foundations of software engineering, FSE ’10, pages 157–166, New York, NY, USA, 2010. ACM.Google Scholar
- Michael W. Berry and J. Kogan. Text Mining : Applications and Theory. 2010.Google Scholar
- Barthélémy Dagenais and Laurie Hendren. Enabling static analysis for partial java programs. In Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications, OOPSLA ’08, pages 313–328, New York, NY, USA, 2008. ACM.Google Scholar
- GNU Software Foundation. GNU Grep 2.9 Manual.Google Scholar
- Oliver Hummel, Werner Janjic, and Colin Atkinson. Code Conjurer: Pulling Reusable Software out of Thin AIr. IEEE Software, January 2008.Google Scholar
- Otávio Augusto Lazzarini Lemos, Sushil Bajracharya, Joel Ossher, Ricardo Santos Morla, Paulo Cesar Masiero, Pierre Baldi, and Cristina Videira Lopes. CodeGenie. Proceedings of the twenty-second IEEE/ACM international conference on Automated software engineering - ASE ’07, page 525, 2007.Google Scholar
- Christopher D. Manning and Prabhakar Raghavan. Introduction to Information Retrieval. 2008.Google Scholar
- C McMillan, M Grechanik, and D Poshyvanyk. Portfolio: Finding relevant functions and their usages. In Proceeding of the 33rd, pages 111–120, 2011.Google Scholar
- J. Ossher, S. Bajracharya, and C. Lopes. Automated dependency resolution for open source software. In Mining Software Repositories (MSR), 2010 7th IEEE Working Conference on, pages 130–140, may 2010.Google Scholar
- Suresh Thummalapenta and Tao Xie. SpotWeb: Detecting Framework Hotspots and Coldspots via Mining Open Source Code on the Web. 2008 23rd IEEE/ACM International Conference on Automated Software Engineering, pages 327–336, September 2008.Google Scholar
- Frank Tip, Chris Laffra, Peter F. Sweeney, and David Streeter. Practical experience with an application extractor for java. In Proceedings of the 14th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, OOPSLA ’99, pages 292–305, New York, NY, USA, 1999. ACM.Google Scholar
- Reishi Yokomori, Takashi Ishio, Tetsuo Yamamoto, Makoto Matsushita, Shinji Kusumoto, and Katsuro Inoue. Java program analysis projects in Osaka University: aspect-based slicing system ADAS and ranked-component search system SPARS-J. In Proceedings of the 25th International Conference on Software Engineering, pages 828–829. IEEE Computer Society, 2003.Google Scholar