block.addChildBefore(newInstrumentationNode(lineNr), elseIfStatement);
}
private AstNode newInstrumentationNode(final int lineNr) {
final ExpressionStatement instrumentationNode = new ExpressionStatement();
final UnaryExpression inc = new UnaryExpression();
inc.setIsPostfix(true);
inc.setOperator(Token.INC);
final ElementGet outer = new ElementGet();
final ElementGet inner = new ElementGet();
outer.setTarget(inner);
final Name covDataVar = new Name();
covDataVar.setIdentifier(ScriptInstrumenter.COVERAGE_VARIABLE_NAME);
inner.setTarget(covDataVar);
final StringLiteral fileName = new StringLiteral();
fileName.setValue(data.getSourceUriAsString());
fileName.setQuoteCharacter('\'');
inner.setElement(fileName);
final NumberLiteral index = new NumberLiteral();
index.setNumber(lineNr);
index.setValue(Integer.toString(lineNr));
outer.setElement(index);
inc.setOperand(outer);
instrumentationNode.setExpression(inc);
instrumentationNode.setHasResult();
return instrumentationNode;