Summary: | [quick assist] "Invert if statement" fails when comment follows | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olaf Kock <eclipse-bugzilla> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | daniel_megert, markus.kell.r, Olivier_Thomann | ||||
Version: | 3.5.1 | ||||||
Target Milestone: | 3.6 M7 | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Olaf Kock
2009-10-28 07:31:00 EDT
Can reproduce using I20091027-0100. Deepak, please investigate. The transformation and comment shifting is done using ASTRewrite in JDT core. Also if there is a line gap in the comment(as shown below) the comment is left as it is if(Math.random() < 0.5) { System.out.println("<"); } else { System.out.println(">"); } // some comment This might be a bug in the extended range for a node. The comment following the '}' should not be included within that range if it is located on the next line. Thank you for taking care of this issue. In reply to the previous comment I'd argue that it shouldn't result in this behaviour even if the comment was on the same line as the closing '}'. This code: if(Math.random() < 0.5) { System.out.println("<"); } else { System.out.println(">"); } // some comment should also be valid after an "invert 'if' statement" quickfix, otherwise it would be 'invalidated', not 'inverted'. Created attachment 162313 [details]
Proposed fix + regression tests
Released for 3.6M7. Regression test added in: org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingStatementsTest#testIfStatementReplaceElse5 Verified for 3.6M7 using I20100425-2000. |