*/
public static boolean isValidContextForSetNext(SimpleNode ast, int sourceLine, int targetLine) {
String sourceFunctionName = NodeUtils.getContextName((sourceLine - 1), ast);
String targetFunctionName = NodeUtils.getContextName(targetLine, ast);
if (compareMethodName(sourceFunctionName, targetFunctionName)) {
ASTEntry sourceAST = NodeUtils.getLoopContextName(sourceLine, ast);
ASTEntry targetAST = NodeUtils.getLoopContextName(targetLine + 1, ast);
if (targetAST == null) {
return true; // Target line is not inside some loop
}
if (isValidElseBlock(sourceAST, targetAST, sourceLine, targetLine)) {
return true; // Debug pointer can be set inside else block of
// for..else/while..else
}
if (sourceAST == null && targetAST != null) {
return false; // Source is outside loop and target is inside
// loop
}
if (sourceAST != null && targetAST != null) {
// Both Source and Target is inside some loop
if (sourceAST.equals(targetAST)) {
return isValidInterLoopContext(sourceLine, targetLine, sourceAST, targetAST);
} else {
ASTEntry last = sourceAST;
boolean retVal = false;
while (last != null) {
ASTEntry parentAST = last.parent;
if (parentAST != null && parentAST.equals(targetAST)) {
retVal = true;
break;
}
last = parentAST;
}