Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 308886

Summary: CompilationUnit.rewrite produces wrong result/
Product: [Eclipse Project] JDT Reporter: David Schuler <schulerdavid>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: martinae, Olivier_Thomann
Version: 3.6   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: stalebug
Attachments:
Description Flags
JUnit Test to reproduce the bug none

Description David Schuler CLA 2010-04-12 12:20:12 EDT
Build Identifier: 20100318-1801

The compilation CompilationUnit.rewrite produces an incorrect result in case of an else if statement. The CompilationUnit.toString method, however produces a correct result.

On older eclipse verions the attached test causes a bug similar to this one:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=304656


Reproducible: Always

Steps to Reproduce:
1. Run attached JUnit test. It tries to add a log statement to every existing statement. Invoking CompilationUnit.rewrite however produces the wrong result,
while CompilationUnit.toString produces a correct one.
Comment 1 David Schuler CLA 2010-04-12 12:22:57 EDT
Created attachment 164583 [details]
JUnit Test to reproduce the bug
Comment 2 David Schuler CLA 2010-04-13 03:38:17 EDT
Comment on attachment 164583 [details]
JUnit Test to reproduce the bug

There is a missing brace in the String returned by getSource() method of the test case. However, this does not influence the results.
Comment 3 Olivier Thomann CLA 2010-04-14 13:46:37 EDT
The modifying approach doesn't quite work in this case when applying modifications on modifications.
I'll try to rewrite it using the descriptive approach.
Comment 4 Olivier Thomann CLA 2010-04-21 14:21:37 EDT
The descriptive approach doesn't work as well in this case.
This is too late to try to fix this for 3.6.

I'll continue to investigate.
Comment 5 Olivier Thomann CLA 2010-07-13 13:12:08 EDT
Martin, would you have any documentation I could go through to understand the way the internals of rewrite is working?
Comment 6 Martin Aeschlimann CLA 2010-07-14 03:12:59 EDT
Sorry, there is only the code... I'll gladly help, and maybe also David still remembers how things work.
Comment 7 Eclipse Genie CLA 2019-11-10 06:35:13 EST
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.