Motivation

Most of state-of-the-art code completion tools are able to help
in the completion of a single method call or a single object
declaration/initialization. For example, Eclipse's code completion
provides an alphabetical-order list of available methods for a variable
under editing. While some IDEs have done a good job of suggesting the
templates for common program constructs (e.g. for, while) and popular
classes/methods, it is often that they recommend too many options
without ranking and much considering the context of the code under
editing.

To support better API usages, it would be preferable to have a
code completion tool that can help in completion of code under editing
with API usage patterns. Moreover, a good code completion tool should
be able to recognize/predict the developer's intention based on the
current context of code under editing (e.g. API elements currently used
in the incomplete code) in order to provide best-fit API usage
patterns. That motivate our approach in Grapacc.