Databases Reference
In-Depth Information
10.5.1 Resolve Object Types
We use 16 heuristics for resolving object types such as receiver or argu-
ment object type of an API method call in collected code examples. In this
chapter, we explain two of our major heuristics used for identifying the return
type of an API method call. Our heuristics are not complete as these heuris-
tics cannot resolve entire type information. However, the evaluation results of
approaches [25{28] developed based on our life-cycle model show that these
heuristics are often effective in resolving required object type information.
Heuristic 1: The return type of an API method call contained in an ini-
tialization expression is the same as the type or a subtype of the declared
variable.
Consider the code example shown below:
QueueConnectionconnect;QueueSessionsession=
connect.createQueueSession(false,int)
The receiver type of the method createQueueSession is the type of connect
variable. Therefore, the receiver type can be simply inferred by looking at the
declaration of the connect variable. But as our approach mainly deals with
code that is partial and not compilable, it is dicult to get the return type of
the method-invocation createQueueSession . The reason is the lack of access to
method declarations. However, the return type can be inferred from the type
of variable session on the left-hand side of the assignment statement. As the
type of variable session is QueueSession , we can infer that the return type of
the method-invocation createQueueSession is QueueSession .
Heuristic 2: The return type of an outermost API method call contained
in a return statement is the same (or a subtype) as the return type of the
enclosing method declaration.
Consider code example presented below:
public QueueSessiontest() f ...
return connect.createQueueSession(false,int); g
In this code example, the method-invocation statement
createQueueSession is a part of the return statement of the method declara-
tion. In this scenario, we can infer the return type of this method-invocation
from the return type of the method test . As the method test returns
QueueSession , we can infer that the return type of the method-invocation
createQueueSession is also QueueSession .
10.5.2 Generate Candidates
After type resolution based on preceding heuristics, the analyze phase
generates relevant SE data from collected code examples. We refer to these
SE data as pattern candidates. In practice, these pattern candidates are based
on the requirements of SE tasks. For example, for our example SE task, the
 
Search WWH ::




Custom Search