Community
Participate
Working Groups
3.0 M7 A do-while controling a single statement (no braces) is not properly formatted (the "while" part ends up in the same line as the controled statement): class Foo { void m1() { int x; do x = 1; while (true); } }
Should be easy to fix.
Fixed and released in HEAD. Regression test added.
Verified for 3.0 using build I200403250010.
In fact the fix was wrong. If the option to insert a new line before the while is off, then the formatting was ok.
However we can decide that when there is only one statement that is not a block, the while should be on a new line.
When only one statement is the do statement action and this statement is not a block, the most natural formatting is: class Foo { void m1() { int x; do x = 1; while (true); } } This is also do for a try statement. Fixed and resolved in HEAD. Updated org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.test119. Change in org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.visit(DoStatement,BlockScope)
Verified in I20050920-0010 for 3.2M2