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

Graph-based Patterns


Example 1
Figure 1. SWT Usage Example 1


As seen in all presented usage patterns, the API elements are used with semantic (e.g. data and control) dependencies. Some elements have strict usage orders, while others do not. For example, in the SWT button creation pattern (lines 4-7 of Figure 1), the constructor of Button must be called before the three other method calls setText, setSize, and setLocation. However, there is no required order among those three method calls. In contrast, in the pattern of creating a GUI window, the orders and dependencies among API elements (classes/methods) and control structures (if, while) must follow a specific order/structure as in the lines 1-2 and 9-15.

The existence of such (partial) control and data dependencies suggests that, the usage patterns and the context of code under editing should be represented via graph-based structures, rather than the sequences of method calls or the sets of method calls as in previous code completion/searching approaches. A sequence has a total order n which any pair of its elements must have an order, thus, could not represent the partially-ordered method calls. In contrast, if sets of API elements are used to represent the contexts or usages, the required orders among API elements and/or control structures would be missing.

Example 3
Figure 2. Graph-based Usage Pattern


Figure 2 shows a way to graphically represent usage pattern in figure 1.