Summary: | [AST] CompilationUnit.rewrite() removes whitespace between return type and method name | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Konstantin Scheglov <Konstantin.Scheglov> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | markus.kell.r, Olivier_Thomann, philippe_mulet | ||||
Version: | 3.3 | ||||||
Target Milestone: | 3.6 M7 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Konstantin Scheglov
2007-06-12 11:55:13 EDT
I have two fixes: 1) one that keeps the existing comment between the old return type and the new one. 2) one that removes the existing comment and only make sure a space is inserted. Markus, any preference ? I prefer a solution that is consistent with the API specs and with how this is handled in other places. ASTRewrite says it uses a default TargetSourceRangeComputer, so the comments should be removed in both cases. Here's a test case I used. It also shows the same problem in method argument lists and field declarations. Apply Quick Fixes to see what the ASTRewrite does. I think we'll need to set a NoCommentSourceRangeComputer in some of the quick fixes to avoid losing comments. package xy; import java.util.List; @SuppressWarnings("rawtypes") public class Try { List/*important*/getUsers2() { return; } List /*important*/getUsers() { return fField; } String/**/fField; void foo(List/**/l) { foo(""); foo(/**/q); } } Since ASTReweitre(In reply to comment #2) > I prefer a solution that is consistent with the API specs and with how this is > handled in other places. ASTRewrite says it uses a default > TargetSourceRangeComputer, so the comments should be removed in both cases. Yes, I checked the doc later on and indeed it is specified to use the extended range. So comments should be removed in both cases. I'll fix it that way. I'll also check the two other cases you mentioned. Created attachment 162312 [details]
Proposed fix + regression tests
Released for 3.6M7. Regression tests added in: org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0007 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0008 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0009 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0010 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0011 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0012 org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingReplaceTest#test0013 This fixes the initial issue with method return type, but also the field type and method arguments issues reported by Markus. Verified for 3.6M7 using I20100425-2000. |