@Override
public Void visitLoopExpression(LoopExpression loop) {
// start outer scope for temporary variables
appendLine("{");
Expression delimiter = loop.getDelimiter();
String boolVar = createVarName("bool");
if (!delimiter.alwaysEmpty()) {
formatLine("boolean %s = false;", boolVar);
}
String tmpKeyVar = null, keyVar = null;
if (loop.getKey() != null) {
tmpKeyVar = createVarName("key");
keyVar = JAVA.validateName(alertSink, loop, loop.getKey());
formatLine("int %s = 0;", tmpKeyVar);
}
if (loop.getIterator() != null && loop.getIterator().canEvaluateAs(JAVA)) {
String iterVar = createVarName("iter");
Expression iter = loop.getIterator();
formatLine(iter.getSourcePosition(),
"final java.util.Iterator<? extends %s> %s = %s;",
JavaUtil.toReferenceType(toJavaType(loop.getType())),
iterVar,
getJavaExpression(iter));