Graph-based Pattern-oriented, Context-sensitive Code Completion

Anh Tuan Nguyen, Tung Thanh Nguyen, Hoan Anh Nguyen, Ahmed Tamrawi, Hung Viet Nguyen, Jafar Al-Kofahi,
Tien N. Nguyen

Video Demo Downloads

Motivating Examples

Interleaving Patterns

 

Example 1
Figure 1. SWT Usage Example 1

 

The example in Figure 1 illustrates a common case that during programming, a developer can use multiple usage patterns that are interleaved with each other. The code for the pattern of creating a GUI window is intermixed with the code for the pattern of creating a SWT button.

This nature of multiple, interleaving usage patterns during programming implies that a pattern-oriented, context-sensitive code completion tool should consider the current focus code position (i.e. the current editing cursor) as one of the more important contextual information. Then, the tool should be able to switch between those patterns for code completion depending on such context, e.g. when the focus code position is changed. In other words, the code on focus and under modification by a user, and the related API usage pattern are important in determining the context of the code, and thus, the intention of the user. For example, if (s)he is in the middle of editing line 2 of Figure 1, the tool must recognize that the usage pattern for GUI window creation is most relevant and recommend the code for that pattern as in the lines 9-15. Assume that during filling the details of that pattern (i.e. editing the lines 9-15), (s)he switches to write the code to create a new Button (e.g. as in new Button(...)). The tool must be able to recognize the switching and recommend code completion for the SWT button creation pattern.