Summary: | [ast rewrite] convert control statement removes comments by mistake | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Daniel Felix Ferber <dfferber> |
Component: | Core | Assignee: | Sarika Sinha <sarika.sinha> |
Status: | NEW --- | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | andreas.hoehmann, benno.baumgartner, cletavernier, daniel_megert, entwurf, garydgregory, jarthana, Lars.Vogel, loskutov, lukas.eder, luke.hutch, manoj.palat, markus.kell.r, robin.rosenberg, ullenboom |
Version: | 3.4 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | stalebug fix candidate | ||
Bug Depends on: | |||
Bug Blocks: | 200680 |
Description
Daniel Felix Ferber
2008-10-08 13:41:05 EDT
Simpler test case: 1. have an if-statement that has a comment on the same line, e.g.: if (true) // this is a test 2. run clean up with only 'Convert control statement bodies to block' ==> comment lost This is a bug in org.eclipse.jdt.core.dom.rewrite.ASTRewrite.set(ASTNode, StructuralPropertyDescriptor, Object, TextEditGroup). I understand that the general problem of handling/loosing comments is very hard to solve in the ASTRewrite but I guess it should not be to hard to handle this concrete problem (i.e. EndOfLineComment after if). *** Bug 153264 has been marked as a duplicate of this bug. *** This bug has been reported several times now. Martin always refused to fix it but I think we should try to do something at least for this special case if possible. Even easier to reproduce with quick fixes that add/remove blocks: if (true) // quick fix change to block System.out.println(-42); if (true) { // quick fix change to statement System.out.println(42); } CompilationUnit#getExtended*(ASTNode) should probably include these comments (map them to the statement on the next line). Bug 153264 is a similar problem (but not exactly the same). >Bug 153264 is a similar problem (but not exactly the same). Right, bug 153264 contains more (complex) samples/dups of comment problems. Please don't defer this one just because there are too many cases. We should try to at least solve the scenario where the EndOfLine comment is on the same line as the if and the else (if): if (xxx) // comment ... else if (xxx) // comment else // comment e.g. if (xxx) // comment ... ==> if (xxx) // comment { ... } or (maybe?) better: if (xxx) { // comment ... } But we need to be careful that this doesn't become: if (xxx) { // comment ... } if such formatter prefs are used. *** Bug 378139 has been marked as a duplicate of this bug. *** *** Bug 385478 has been marked as a duplicate of this bug. *** *** Bug 261207 has been marked as a duplicate of this bug. *** *** Bug 429079 has been marked as a duplicate of this bug. *** *** Bug 453692 has been marked as a duplicate of this bug. *** The best solution for such problems is usually to call ASTRewrite#setTargetSourceRangeComputer(TargetSourceRangeComputer) and set a NoCommentSourceRangeComputer or a properly configured TightSourceRangeComputer. *** Bug 491720 has been marked as a duplicate of this bug. *** *** Bug 501860 has been marked as a duplicate of this bug. *** *** Bug 535440 has been marked as a duplicate of this bug. *** Still in 4.11... Just hit it on mass-cleanup of PDE code... This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |