Community
Participate
Working Groups
Build Identifier: Build Identifier: Version: Indigo Release Build id: M20120208-0800 When using the quick-fix actions on an if .. else statement, some comments are consumed and disappear. Reproducible: Always Steps to Reproduce: 1. Create this class -------------------------------------- public class Test { public void x() { boolean condition = (1 == 0); // If-comment if (condition) { System.out.println(true); } // Else-comment else { System.out.println(false); } } } -------------------------------------- 2. Put the cursor on "if" 3. Click Ctrl-1 4. Choose any of the quick fix options: - Invert 'if' statement - Change 'else' block to statement - Change 'if' block to statement - Change 'if-else' blocks to statements 5. The outcome is the following (using Invert 'if' statement): -------------------------------------- // If-comment if (!condition) { System.out.println(false); } else { System.out.println(true); } -------------------------------------- The "Else-comment" has gone. While it is hard to find a better solution for "Invert 'if' statement" (as the comments would have to switch, too), the right solution is easy to see for the other actions. One could argue that the "If-comment" and "Else-comment" could go inside the respective blocks, but I think think this is a matter of taste. The way I usually do it (comments before keyword) seems to be quite popular. Some feedback to a blog post of mine: http://www.javacodegeeks.com/2012/01/if-else-coding-style-best-practices.html http://blog.jooq.org/2012/01/18/if-else-coding-style-best-practices/ (original)
*** Bug 106371 has been marked as a duplicate of this bug. ***
*** Bug 367866 has been marked as a duplicate of this bug. ***
(In reply to comment #1) > *** Bug 106371 has been marked as a duplicate of this bug. *** (In reply to comment #2) > *** Bug 367866 has been marked as a duplicate of this bug. *** While the quick assists mentioned in these bugs are different, it is best to deal with all these issues in one go.
Also see https://bugs.eclipse.org/bugs/show_bug.cgi?id=385478
*** This bug has been marked as a duplicate of bug 250142 ***