Project: JDT
Bug 36978 org.eclipse.jdt.internal.corext.dom.ASTFlattener / for statements ...
Reported: 2003-04-27 03:04:57 | Status: resolved fixed

There is a bug in "public boolean visit(ForStatement node)" You should first do node.getExpression() and then node.getUpdates(). The current code will print the loop "for(int i=0;i<100;i++);" as "for(int i=0;i++;i<100);" A corrected version of the "visit(ForStatement node)" function should look like this: public boolean visit(ForStatement node) { fResult.append("for (");//$NON-NLS-1$ for (Iterator it = node.initializers().iterator(); it.hasNext(); ) { Expression e = (Expression) it.next(); e.accept(this); } fResult.append("; ");//$NON-NLS-1$ if (node.getExpression() != null) { node.getExpression().accept(this); } fResult.append("; ");//$NON-NLS-1$ for (Iterator it = node.updaters().iterator(); it.hasNext(); ) { Expression e = (Expression) it.next(); e.accept(this); } fResult.append(") ");//$NON-NLS-1$ node.getBody().accept(this); return false; }

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java