} else
if(e instanceof MethodInvocation) {
/**
* Go back through a method invocation.
* */
MethodInvocation mi = (MethodInvocation) e;
SimpleName methodName = mi.getName();
log("Going back through callee " + methodName.toString());
HistoryDefinitionLocation callDL;
if(!first){
callDL= new HistoryDefinitionLocation(
mi.toString(),
resource,
cu.getLineNumber(mi.getStartPosition()),
mi,
parent, HistoryDefinitionLocation.CALL);
}
else{
callDL=parent;
}
if(registerExpansion(callDL)) {
Collection/*<MethodDeclarationUnitPair>*/ callees = CallerFinder.findCallees(monitor, methodName.toString(), null, false);
if(callees.isEmpty()) {
if(SinkView.isDerivationName(methodName.getFullyQualifiedName()))
{
HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
mi.getExpression().toString(),
resource,
cu.getLineNumber(mi.getStartPosition()),
mi.getExpression(), callDL, HistoryDefinitionLocation.DERIVATION);
if(registerExpansion(dl)) {
Expression expr = mi.getExpression();
if(expr != null) {
// Recurse on the returned expression
processExpression(dl, expr, cu, resource, stack, monitor, HistoryDefinitionLocation.DERIVATION,false);
}
}
}
else{
logError("No suitable callees for " + methodName + " in " + resource + " found");
System.out.println("No suitable callees for " + methodName + " in " + resource + " found");
}
} else
for (Iterator iter = callees.iterator(); iter.hasNext();) {
Utils.MethodDeclarationUnitPair element
= (Utils.MethodDeclarationUnitPair) iter.next();
MethodDeclaration methodDeclaration = element.getMethod();
CompilationUnit nextCU = element.getCompilationUnit();
IResource nextResource = element.getResource();
if(methodDeclaration != null){
if(!LapsePlugin.FOLLOW_INTO_FUNCTIONS) {
/*HistoryDefinitionLocation dl = */new HistoryDefinitionLocation(
"Method " + methodDeclaration.getName().getFullyQualifiedName(),
nextResource,
nextCU.getLineNumber(e.getStartPosition()),
methodDeclaration, callDL, HistoryDefinitionLocation.RETURN);
} else {
Collection/*<ReturnStatement>*/ returns = CallerFinder.findReturns(monitor, methodDeclaration, null);
for (Iterator iter2 = returns.iterator(); iter2.hasNext();) {
ReturnStatement returnStmt = (ReturnStatement) iter2.next();
HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
returnStmt.toString(),
nextResource,
nextCU.getLineNumber(returnStmt.getStartPosition()),
returnStmt, callDL, HistoryDefinitionLocation.RETURN);
if(registerExpansion(dl)) {
Expression expr = returnStmt.getExpression();
if(expr != null) {
// Recurse on the returned expression
stack.addLast(mi);
processExpression(dl, expr, nextCU, nextResource, stack, monitor, HistoryDefinitionLocation.COPY,false);
stack.removeLast();
}
}
}
}
}
else{
//check if it is a derivtion expression
if(SinkView.isDerivationName(methodName.getFullyQualifiedName()))
{
processExpression(callDL, mi.getExpression(), cu, resource, stack, monitor, HistoryDefinitionLocation.DERIVATION,false);
break;
}
}
}