}
if (type == CASE) {
handleSwitchCase((SwitchCase) node);
} else if (type == IF && parentType == IF) {
final IfStatement elseIfStatement = (IfStatement) node;
final IfStatement ifStatement = (IfStatement) parent;
if (ifStatement.getElsePart() == elseIfStatement) {
flattenElseIf(elseIfStatement, ifStatement);
data.addExecutableLine(getActualLineNumber(node));
}
} else if (parentType != CASE) {
// issue #54
if (parent.getClass() == LabeledStatement.class) {
return;
}
if (parent.hasChildren()) {
parent.addChildBefore(newInstrumentationNode(getActualLineNumber(node)), node);
} else {
// if, else, while, do, for without {} around their respective 'blocks' for some reason
// don't have children. Meh. Creating blocks to ease instrumentation.
final Block block = newInstrumentedBlock(node);
if (parentType == IF) {
final IfStatement ifStatement = (IfStatement) parent;
if (ifStatement.getThenPart() == node) {
ifStatement.setThenPart(block);
} else if (ifStatement.getElsePart() == node) {
ifStatement.setElsePart(block);
}
} else if (parentType == WHILE || parentType == FOR || parentType == DO) {
((Loop) parent).setBody(block);
} else {
logger.warn("Cannot handle node with parent that has no children, parent class: {}, parent source:\n{}",