A Simple, Efficient, Context‐sensitive Approach for Code Completion

Code completion helps developers use application programming interfaces (APIs) and frees them from remembering every detail. In this paper, we first describe a novel technique called Context‐sensitive Code Completion (CSCC) for improving the performance of API method call completion. CSCC is context sensitive in that it uses new sources of information as the context of a target method call. CSCC indexes method calls in code examples by their context. To recommend completion proposals, CSCC ranks candidate methods by the similarities between their contexts and the context of the target call. Evaluation using a set of subject systems and five popular state‐of‐the‐art techniques suggests that CSCC performs better than existing type or example‐based code completion systems. We conduct experiments to find how different contextual elements of the target call benefit CSCC. Next, we investigate the adaptability of the technique to support another form of code completion, i.e., field completion. Evaluation with eight different subject systems suggests that CSCC can easily support field completion with high accuracy. Finally, we compare CSCC with four popular statistical language models that support code completion. Results of statistical tests from our study suggest that CSCC not only outperforms those techniques that are based on token level language models, but also in most cases performs better or equally well with GraLan, the state‐of‐the‐art graph‐based language model. Copyright © 2016 John Wiley & Sons, Ltd.

[1]  Zhendong Su,et al.  On the naturalness of software , 2012, ICSE 2012.

[2]  Gurmeet Singh Manku,et al.  Detecting near-duplicates for web crawling , 2007, WWW '07.

[3]  Mik Kersten,et al.  How are Java software developers using the Elipse IDE? , 2006, IEEE Software.

[4]  Moses Charikar,et al.  Similarity estimation techniques from rounding algorithms , 2002, STOC '02.

[5]  Daqing Hou,et al.  Towards a better code completion system by API grouping, filtering, and popularity-based ranking , 2010, RSSE '10.

[6]  Rob Miller,et al.  Keyword programming in java , 2007, ASE '07.

[7]  Romain Robbes,et al.  How Program History Can Improve Code Completion , 2008, 2008 23rd IEEE/ACM International Conference on Automated Software Engineering.

[8]  J. NORMAN LOCKYER The Eclipse , 1878, Nature.

[9]  Anh Tuan Nguyen,et al.  GraPacc: A graph-based pattern-oriented, context-sensitive code completion tool , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[10]  Daqing Hou,et al.  BCC: Enhancing code completion for better API usability , 2009, 2009 IEEE International Conference on Software Maintenance.

[11]  Charles A. Sutton,et al.  Learning natural coding conventions , 2014, SIGSOFT FSE.

[12]  José Nelson Amaral,et al.  Syntax errors just aren't natural: improving error reporting with language models , 2014, MSR 2014.

[13]  Rob Miller,et al.  Code Completion from Abbreviated Input , 2009, 2009 IEEE/ACM International Conference on Automated Software Engineering.

[14]  Anh Tuan Nguyen,et al.  A statistical semantic language model for source code , 2013, ESEC/FSE 2013.

[15]  Daqing Hou,et al.  An evaluation of the strategies of sorting, filtering, and grouping API methods for Code Completion , 2011, 2011 27th IEEE International Conference on Software Maintenance (ICSM).

[16]  Yi Zhang,et al.  Automatic parameter recommendation for practical API usage , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[17]  Mira Mezini,et al.  Learning from examples to improve code completion systems , 2009, ESEC/SIGSOFT FSE.

[18]  Premkumar T. Devanbu,et al.  On the localness of software , 2014, SIGSOFT FSE.

[19]  R. Holmes,et al.  Using structural context to recommend source code examples , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[20]  Mik Kersten,et al.  How are lava software developers using the eclipse IDE , 2006 .

[21]  Anh Tuan Nguyen,et al.  Graph-Based Statistical Language Model for Code , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[22]  Chanchal Kumar Roy,et al.  On the Effectiveness of Simhash for Detecting Near-Miss Clones in Large Scale Software Systems , 2011, 2011 18th Working Conference on Reverse Engineering.

[23]  Eran Yahav,et al.  Code completion with statistical language models , 2014, PLDI.

[24]  Christopher D. Manning,et al.  Introduction to Information Retrieval , 2010, J. Assoc. Inf. Sci. Technol..

[25]  Thomas D. LaToza,et al.  Active code completion , 2011, 2012 34th International Conference on Software Engineering (ICSE).

[26]  R. Hill,et al.  Automatic method completion , 2004 .

[27]  Premkumar T. Devanbu,et al.  CACHECA: A Cache Language Model Based Code Suggestion Tool , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[28]  Mira Mezini,et al.  On evaluating recommender systems for API usages , 2008, RSSE '08.

[29]  William W. Cohen,et al.  Natural Language Models for Predicting Programming Comments , 2013, ACL.

[30]  Miryung Kim,et al.  Cookbook: in situ code completion using edit recipes learned from examples , 2014, ICSE Companion.

[31]  Hung Viet Nguyen,et al.  Graph-based pattern-oriented, context-sensitive source code completion , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[32]  Sarfraz Khurshid,et al.  Temporal code completion and navigation , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[33]  Chanchal Kumar Roy,et al.  CSCC: Simple, Efficient, Context Sensitive Code Completion , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[34]  Brad A. Myers,et al.  Calcite: Completing Code Completion for Constructors Using Crowds , 2010, 2010 IEEE Symposium on Visual Languages and Human-Centric Computing.