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

Bug 99121

Summary: [refactoring] CompilationUnitRewrite silently fails with multiple createChange calls
Product: [Eclipse Project] JDT Reporter: Tobias Widmer <tobias_widmer>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard: stalebug

Description Tobias Widmer CLA 2005-06-09 06:09:14 EDT
3.1 RC1

The current implementation of CompilationUnitRewrite allows multiple calls to 
createChange. This however can yield to errors if the change is displayed in 
the refactoring wizard preview (the text edit groups are shared and not 
emptied between invocations of createChange)

There are two solutions:
- Disallow multiple calls to createChange()
- Remove existing text edits from the text edit groups before filling in the 
new ones
Comment 1 Dirk Baeumer CLA 2005-06-09 09:53:12 EDT
Markus, something we should look at in 3.2
Comment 2 Markus Keller CLA 2005-06-09 10:29:49 EDT
I don't know whether removing text edits from the groups is a good idea, since
this could invalidate existing changes in a subtle way.

Tobias, could you please outline why you need to call createChange() twice, such
that your context is not lost when we get to this bug again in 3.2.
Comment 3 Tobias Widmer CLA 2005-06-09 10:35:02 EDT
I am not saying that multiple calls to createChange() should make sense. All I 
am saying is that we either should disallow multiple calls by throwing an 
exception (preferred) or make sure either the text edit groups are emptied or 
cloned on subsequent calls to createChange().
Comment 4 Markus Keller CLA 2005-06-09 10:43:02 EDT
Cloning text edit groups will not work, since clients pass them to the
ASTRewrite, and the edits generated by ASTRewrite.rewriteAST(..) will not be
linked properly then.

So, the way to go is javadocing (and maybe preventing) multiple calls to
createChange().
Comment 5 Markus Keller CLA 2005-06-09 13:12:06 EDT
This is probably also a problem when ASTRewrite#rewriteAST(..) is called
multiple times and the edits are executed in between.
Comment 6 Eclipse Genie CLA 2019-09-10 07:10:47 EDT
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.