skip to main content
10.1145/2950290.2950341acmconferencesArticle/Chapter ViewAbstractPublication PagesfseConference Proceedingsconference-collections
research-article

Relationship-aware code search for JavaScript frameworks

Published: 01 November 2016 Publication History

Abstract

JavaScript frameworks, such as jQuery, are widely used for developing web applications. To facilitate using these JavaScript frameworks to implement a feature (e.g., functionality), a large number of programmers often search for code snippets that implement the same or similar feature. However, existing code search approaches tend to be ineffective, without taking into account the fact that JavaScript code snippets often implement a feature based on various relationships (e.g., sequencing, condition, and callback relationships) among the invoked framework API methods. To address this issue, we present a novel Relationship-Aware Code Search (RACS) approach for finding code snippets that use JavaScript frameworks to implement a specific feature. In advance, RACS collects a large number of code snippets that use some JavaScript frameworks, mines API usage patterns from the collected code snippets, and represents the mined patterns with method call relationship (MCR) graphs, which capture framework API methods’ signatures and their relationships. Given a natural language (NL) search query issued by a programmer, RACS conducts NL processing to automatically extract an action relationship (AR) graph, which consists of actions and their relationships inferred from the query. In this way, RACS reduces code search to the problem of graph search: finding similar MCR graphs for a given AR graph. We conduct evaluations against representative real-world jQuery questions posted on Stack Overflow, based on 308,294 code snippets collected from over 81,540 files on the Internet. The evaluation results show the effectiveness of RACS: the top 1 snippet produced by RACS matches the target code snippet for 46% questions, compared to only 4% achieved by a relationship-oblivious approach.

References

[1]
Annie T. T. Ying and Martin P. Robillard. Selection and presentation practices for code example summarization. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE '14), pp. 460-471, 2014.
[2]
Siddharth Subramanian and Reid Holmes. Making sense of online code snippets. In Proceedings of the 10th Working Conference on Mining Software Repositories (MSR '13), pp. 85-88, 2013.
[3]
David Mandelin, Lin Xu, Rastislav Bodik, and Doug Kimelman. Jungloid mining: helping to navigate the API jungle. In Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI '05), pp. 48-61, 2005.
[4]
Yan Xu, Lili Mou, Ge Li, Yunchuan Chen, Hao Peng, and Zhi Jin. Classifying relations via long short term memory networks along shortest dependency paths. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing (EMNLP '15), pp. 1785-1794, 2015.
[5]
Suresh Thummalapenta and Tao Xie. PARSEWeb: A programmer assistant for reusing open source code on the web. In Proceedings of the 22nd IEEE/ACM International Conference on Automated Software Engineering (ASE '07), pp. 204-213, 2007.
[6]
Hao Zhong, Tao Xie, Lu Zhang, Jian Pei, and Hong Mei. MAPO: Mining and recommending API usage patterns. In Proceedings of the 23rd European Conference on Object-Oriented Programming (ECOOP '09), pp. 318-343, 2009.
[7]
Shaunak Chatterjee, Sudeep Juvekar, and Koushik Sen. SNIFF: A search engine for Java using free-form queries. In Proceedings of the 12th International Conference on Fundamental Approaches to Software Engineering (FASE '09), pp. 385-400, 2009.
[8]
Iman Keivanloo, Juergen Rilling, and Ying Zou. Spotting working code examples. In Proceedings of the 36th International Conference on Software Engineering (ICSE '14), pp. 664-675, 2014.
[9]
Hung Viet Nguyen, Hoan Anh Nguyen, Anh Tuan Nguyen, and Tien N. Nguyen. Mining interprocedural, data-oriented usage patterns in JavaScript web applications. In Proceedings of the 36th International Conference on Software Engineering (ICSE '14), pp. 791-802, 2014.
[10]
Vasile Rus, Mihai Lintean, Rajendra Banjade, Nobal Niraula, and Dan Stefanescu. SEMILAR: The semantic similarity toolkit. In Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics (ACL '13), Demo Track, 2013.
[11]
Sumit Gulwani and Mark Marron. NLyze: interactive programming by natural language for spreadsheet data analysis and manipulation. In Proceedings of the 2014 ACM SIGMOD International Conference on Management of Data (SIGMOD '14), pp. 803-814, 2014.
[12]
Vu Le, Sumit Gulwani, and Zhendong Su. SmartSynth: synthesizing smartphone automation scripts from natural language. In Proceeding of the 11th Annual International Conference on Mobile Systems, Applications, and Services (MobiSys '13), pp. 193-206, 2013.
[13]
Rada Mihalcea, Courtney Corley, and Carlo Strapparava. Corpus-based and knowledge-based measures of text semantic similarity. In Proceedings of the 21st National Conference on Artificial Intelligence (AAAI '06), pp. 775-780, 2006.
[14]
Lili Mou, Ge Li, Lu Zhang, Tao Wang, and Zhi Jin. Convolutional neural networks over tree structures for programming language processing. In Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence (AAAI '16), pp. 1287-1293, 2016.
[15]
Esben Andreasen and Anders Møller. Determinacy in static analysis for jQuery. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA '14), pp. 17-31, 2014.
[16]
http://w3techs.com/technologies/overview/JavaScript_library/all
[17]
Rahul Pandita, Xusheng Xiao, Hao Zhong, Tao Xie, Stephen Oney, and Amit Paradkar. Inferring method specifications from natural language API descriptions. In Proceedings of the 34th International Conference on Software Engineering (ICSE '12), pp. 815-825, 2012.
[18]
Xusheng Xiao, Amit Paradkar, Suresh Thummalapenta, and Tao Xie. Automated extraction of security policies from natural-language software documents. In Proceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering (FSE '12), pp. 1-11, 2012.
[19]
Dan Klein and Christopher D. Manning. Accurate unlexicalized parsing. In Proceedings of the 41st Annual Meeting on Association for Computational Linguistics (ACL 03), pp. 423-430, 2003.
[20]
Hao Zhong, Lu Zhang, Tao Xie, and Hong Mei. Inferring resource specifications from natural language API documentation. In Proceedings of the 2009 IEEE/ACM International Conference on Automated Software Engineering (ASE '09), pp. 307-318, 2009.
[21]
Emily Hill, Lori Pollock, and K. Vijay-Shanker. Automatically capturing source code context of NL-queries for software maintenance and reuse. In Proceedings of the 31st International Conference on Software Engineering (ICSE '09), pp. 232-242, 2009.
[22]
Jue Wang, Yingnong Dang, Hongyu Zhang, Kai Chen, Tao Xie, and Dongmei Zhang. Mining succinct and high-coverage API usage patterns from source code. In Proceedings of the 10th Working Conference on Mining Software Repositories (MSR '13), pp. 319-328, 2013.
[23]
Reid Holmes, Robert J. Walker, and Gail C. Murphy. Strathcona example recommendation tool. In Proceedings of the 10th European Software Engineering Conference held jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering (ESEC/FSE '13), pp. 237-240, 2005.
[24]
Alon Mishne, Sharon Shoham, and Eran Yahav. Typestate-based semantic code search over partial programs. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '12), pp. 997-1016, 2012.
[25]
Naiyana Sahavechaphan and Kajal Claypool. XSnippet: mining For sample code. In Proceedings of the 21st ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA '06), pp. 413-430, 2006.
[26]
Steven P. Reiss. Semantics-based code search. In Proceedings of the 31st International Conference on Software Engineering (ICSE '09), pp. 243-253, 2009.
[27]
Collin McMillan, Mark Grechanik, Denys Poshyvanyk, Qing Xie, and Chen Fu. Portfolio: finding relevant functions and their usage. In Proceedings of the 33rd International Conference on Software Engineering (ICSE '11), pp. 111-120, 2011.
[28]
http://www.alexa.com/topsites
[29]
Jeffrey Stylos and Brad A. Myers. Mica: A web-search tool for finding API components and examples. In Proceedings of the Visual Languages and Human-Centric Computing (VLHCC '06), pp. 195-202, 2006.
[30]
Emily Hill, Zachary P. Fry, Haley Boyd, Giriprasad Sridhara, Yana Novikova, Lori Pollock, and K. Vijay-Shanker. AMAP: automatically mining abbreviation expansions in programs to enhance software maintenance tools. In Proceedings of the 2008 International Working Conference on Mining Software Repositories (MSR '08), pp. 79-88, 2008.
[31]
Mark Grechanik, Chen Fu, Qing Xie, Collin McMillan, Denys Poshyvanyk, and Chad Cumby. A search engine for finding highly relevant applications. In Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering (ICSE '10), pp. 475-484, 2010.
[32]
Giriprasad Sridhara, Lori Pollock, and K. Vijay-Shanker. Automatically detecting and describing high level actions within methods. In Proceedings of the 33rd International Conference on Software Engineering (ICSE '11) pp. 101-110, 2011.
[33]
Ethan Fast, Daniel Steffee, Lucy Wang, Joel R. Brandt, and Michael S. Bernstein. Emergent, crowd-scale programming practice in the IDE. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems (CHI '14), pp. 2491-2500, 2014.
[34]
Wing-Kwan Chan, Hong Cheng, and David Lo. Searching connected API subgraph via text phrases. In Proceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering (FSE '12), pp. 1-11, 2012.
[35]
Fei Lv, Hongyu Zhang, Jian-guang Lou, Shaowei Wang, Dongmei Zhang, and Jianjun Zhao. CodeHow: Effective code search based on API understanding and extended boolean model. In Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering (ASE '15), pp. 260-270, 2015.
[36]
Hao Peng, Lili Mou, Ge Li, Yuxuan Liu, Lu Zhang, and Zhi Jin. Building program vector representations for deep learning. In Proceedings of the 8th International Conference on Knowledge Science, Engineering and Management (KSEM '15), pp. 547-553, 2015.

Cited By

View all
  • (2025)MM-SCS: Leveraging Multimodal Features to Enhance Smart Contract Code SearchIEEE Transactions on Software Engineering10.1109/TSE.2025.353169251:2(638-649)Online publication date: Feb-2025
  • (2024)Effective Hard Negative Mining for Contrastive Learning-Based Code SearchACM Transactions on Software Engineering and Methodology10.1145/369599434:3(1-35)Online publication date: 11-Oct-2024
  • (2024)RAPID: Zero-Shot Domain Adaptation for Code Search with Pre-Trained ModelsACM Transactions on Software Engineering and Methodology10.1145/364154233:5(1-35)Online publication date: 18-Jan-2024
  • Show More Cited By

Index Terms

  1. Relationship-aware code search for JavaScript frameworks

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Conferences
      FSE 2016: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering
      November 2016
      1156 pages
      ISBN:9781450342186
      DOI:10.1145/2950290
      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Sponsors

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 01 November 2016

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. Code search
      2. JavaScript code mining
      3. natural language processing

      Qualifiers

      • Research-article

      Conference

      FSE'16
      Sponsor:

      Acceptance Rates

      Overall Acceptance Rate 17 of 128 submissions, 13%

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)26
      • Downloads (Last 6 weeks)0
      Reflects downloads up to 28 Feb 2025

      Other Metrics

      Citations

      Cited By

      View all
      • (2025)MM-SCS: Leveraging Multimodal Features to Enhance Smart Contract Code SearchIEEE Transactions on Software Engineering10.1109/TSE.2025.353169251:2(638-649)Online publication date: Feb-2025
      • (2024)Effective Hard Negative Mining for Contrastive Learning-Based Code SearchACM Transactions on Software Engineering and Methodology10.1145/369599434:3(1-35)Online publication date: 11-Oct-2024
      • (2024)RAPID: Zero-Shot Domain Adaptation for Code Search with Pre-Trained ModelsACM Transactions on Software Engineering and Methodology10.1145/364154233:5(1-35)Online publication date: 18-Jan-2024
      • (2023)Big Code Search: A BibliographyACM Computing Surveys10.1145/360490556:1(1-49)Online publication date: 26-Aug-2023
      • (2023)XCoS: Explainable Code Search Based on Query Scoping and Knowledge GraphACM Transactions on Software Engineering and Methodology10.1145/359380032:6(1-28)Online publication date: 29-Sep-2023
      • (2023)Code Search: A Survey of Techniques for Finding CodeACM Computing Surveys10.1145/356597155:11(1-31)Online publication date: 9-Feb-2023
      • (2023)deGraphCS: Embedding Variable-based Flow Graph for Neural Code SearchACM Transactions on Software Engineering and Methodology10.1145/354606632:2(1-27)Online publication date: 30-Mar-2023
      • (2023)Do Pretrained Language Models Indeed Understand Software Engineering Tasks?IEEE Transactions on Software Engineering10.1109/TSE.2023.330895249:10(4639-4655)Online publication date: 1-Oct-2023
      • (2023)NCQ: Code Reuse Support for Node.js DevelopersIEEE Transactions on Software Engineering10.1109/TSE.2023.324811349:5(3205-3225)Online publication date: 1-May-2023
      • (2023)MulCS: Towards a Unified Deep Representation for Multilingual Code Search2023 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER)10.1109/SANER56733.2023.00021(120-131)Online publication date: Mar-2023
      • Show More Cited By

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Figures

      Tables

      Media

      Share

      Share

      Share this Publication link

      Share on social media