Identifier lbl = new Identifier().astValue(node.getLabel().toString());
set(node, new LabelledStatement().rawStatement(toTree(node.getStatement())).astLabel(lbl));
}
@Override public void visitForLoop(JCForLoop node) {
For f = new For();
f.rawCondition(toTree(node.getCondition()));
f.rawStatement(toTree(node.getStatement()));
for (JCExpressionStatement upd : node.getUpdate()) {
Node updateNode = toTree(upd.getExpression());
setConversionPositionInfo(updateNode, "exec", getPosition(upd));
f.rawUpdates().addToEnd(updateNode);
}
List<JCStatement> initializers = node.getInitializer();
// Multiple vardefs in a row need to trigger the JCVD version AND be washed through fillList to be turned into 1 VD.
if (!initializers.isEmpty() && initializers.get(0) instanceof JCVariableDecl) {
Block tmp = new Block();
fillList(initializers, tmp.rawContents(), FlagKey.VARDEF_IS_DEFINITION);
Node varDecl = tmp.rawContents().first();
if (varDecl != null) varDecl.unparent();
f.rawVariableDeclaration(varDecl);
} else {
for (JCStatement init : initializers) {
if (init instanceof JCExpressionStatement) {
Node initNode = toTree(((JCExpressionStatement) init).getExpression());
setConversionPositionInfo(initNode, "exec", getPosition(init));
f.rawExpressionInits().addToEnd(initNode);
} else {
f.rawExpressionInits().addToEnd(toTree(init));
}
}
}
set(node, f);
}