| Summary: | ASTRewrite#replace(..) does not consider the TargetSourceRangeComputer | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||||
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | deepakazad, Olivier_Thomann | ||||||
| Version: | 3.7 | Flags: | Olivier_Thomann:
review+
|
||||||
| Target Milestone: | 3.7 M6 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows 7 | ||||||||
| Whiteboard: | |||||||||
| Bug Depends on: | |||||||||
| Bug Blocks: | 331116 | ||||||||
| Attachments: |
|
||||||||
|
Description
Markus Keller
Ayushman, if you get some time, please take a look. Created attachment 188141 [details]
proposed fix v1.0 + regression tests
This patch makes sure that whenever a replace operation takes place in the ASTRewriteAnalyzer, we check for comments, and place the starting point beyond the end of comments so that they dont get removed.
Created attachment 188210 [details]
proposed fix v1.1 + regression tests
Modified the fix a bit to handle multiple comments and to make sure the comments in the extended source range of a node are also replaced with the node.
Unfortunately, since the extended source range is defined to include comments and whitespaces just preceeding or trailing a node, they will get deleted if the node is replaced by another node. ASTRewritingModifyingReplaceTest.test0014b() shows such a case.
Anyway, the fix takes care of preserving all other comments and will fix several UI bugs where comments are deleted upon refactoring, etc.
Olivier, can you please review? Thanks. I'll also get the JDT/UI tests run with the patch. > I'll also get the JDT/UI tests run with the patch.
All UI tests pass.
Looks good to me. Released in HEAD for 3.7M6 Verified for 3.7M6. |