Project: JDT
Bug 4052 document change infrastructure - missing functionality (1GH2DWC)
Reported: 2001-10-10 23:05:15 | Status: resolved fixed

AK (7/18/2001 4:45:27 PM) i stumbled across this when doing Reorder Parameters. consider the following text: m(m(1, 2),3) lets's say you want to swap the parameters. so your desired output is: m(3, m(2, 1)) you create 4 move entries in the change creator (first 'm' has position 1): . move(5, 1] -> 7 //moves the first parameter of the inner call . move[7, 1] -> 5 //moves the 2nd parameter of the inner call . move [3, 6] -> 10 //moves the first parameter of the outer call . move [10, 1] -> 3 //moves the 2nd parameter of the outer call this gets splitted into 4 replaces (will not give details here - see code of AbstractTextBufferChange) anyways, the replaces are sorted backwards before execution. to cut the story short - you end up with: m(3, m(1, 2)) the reason is: the moves are treated in the same way as replaces. they should not be, if they overlap. there should a hierarchy of moves - or another way to say: 'this move must be done before that move' in the case above - the inner moves must be done before the outer ones. this is quite serious and i'm not sure how to nicely work around it. DB (31.07.2001 15:12:06) The current change infrastructure doesn't support any kind of overlapping manipulation. So this is somehow by design. What you can do is to create two distinct text changes. The first changing m(1,2) to m(2,1) and a second one changing m(m(2,1), 3) to m(3, m(2,1)). DB (08.08.2001 14:50:58) I opt to not fix this PR since creating two document changes fixes the problem, although it is not optimal from a speed point of view (the document gets read two times). May be with an improved IBuffer implementation (see 1GEJ61L) the speed trade off isn't a problem anymore.

Files changed in fix:
org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/codemanipulation/ImportEdit.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/textmanipulation/MultiTextEdit.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/textmanipulation/SimpleTextEdit.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/textmanipulation/TextBufferEditor.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/textmanipulation/TextEdit.java org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Bindings.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExceptionAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodAnalyzer.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExtractMethodRefactoring.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/StatementAnalyzer.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/ChangeElementTreeViewer.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/InlineTempWizard.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/NewPreviewWizardPage.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/PreviewWizardPage.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RenameParametersWizard.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/RenameRefactoringWizard.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/actions/ExtractMethodAction.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/code/ExtractMethodWizard.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizard.java org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/sef/SelfEncapsulateFieldWizard.java