Bug 22458 - Refactoring a package does not move the package's directory
Summary: Refactoring a package does not move the package's directory
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows All
: P2 major (vote)
Target Milestone: 2.0.2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-08-14 20:52 EDT by Peter Hack CLA
Modified: 2002-09-20 09:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hack CLA 2002-08-14 20:52:49 EDT
When refactoring a package (ex. refactoring a package from 'org.eclipse.foo' 
to 'org.eclipse.bar' from the Packages view) does not appear to use the 
Eclipse 'move' operation to move 'org\eclipse\foo' to 'org\eclipse\bar'.  
Instead, it appears as though the 'org\eclipse\foo' directory is deleted and 
the 'org\eclipse\bar' directory is create new.  Then the refactored in-
memory .java files are written out in the new location.

This causes a *significant* problem for users of version-control systems.  
Moving the directory to the new name allows the Team Provider to make sure the 
version history of everything in the package follows to the new location.  By 
implementing the operation as described in the first paragraph, the version 
history association is lost.

Note that this was observed with GM1.  I have not yet tested GM6.
Comment 1 Dirk Baeumer CLA 2002-08-19 11:22:28 EDT
I assume that you executed Refactor->Rename on org.eclipse.foo and specified 
org.eclipse.bar as the new name.

In build 2.0 the corresponding refactoring action calls IPackageFragment.rename
(...) to do the actual rename (see RenamePackageChange#doRename()). The 
JDT/Core code uses Workspace.move(...) to move the resources from the old 
package to the new package (see JavaModelOperation#moveResources(...)).

Nick, two questions:
  - did you use Refactor->Rename to refactor the package
  - can you please use the 2.0 build. If you still don't get the corresponding
    move hook there might be a problem in core resources

Philippe, do you have additional comments ?
Comment 2 Dirk Baeumer CLA 2002-08-19 11:24:32 EDT
"Nick" should of course read "Peter" <g>.
Comment 3 Philipe Mulet CLA 2002-09-03 10:07:47 EDT
Please also backport a fix in 2.0.1 branch (for forthcoming 2.0.2 rollup).
Comment 4 Jerome Lanneluc CLA 2002-09-04 07:15:45 EDT
Actually JDT/Core was not using move() for package fragments.
Fixed CopyResourceElementsOperation to use move() when possible.
However the following cases cannot use move():
1. If you have a package x.y and you rename it to x.y.z, then the folder x/y 
cannot be moved to x/y/z (Platform/Core restriction). So in this case, the 
folder x/y/z is created and the compilation units in x/y are moved to x/y/z.
2. If you have 2 packages x and x.y and you rename x to z, the the folder x 
cannot be moved to z since we do not want to touch package x.y. So in this 
case, z is created and the compilation units directly in x are moved to z.
Comment 5 Jerome Lanneluc CLA 2002-09-04 07:41:15 EDT
Fix backported to 2.0.1 branch.
Comment 6 Philipe Mulet CLA 2002-09-12 06:03:58 EDT
Backporting to 2.0.2 agreed by PMC
Comment 7 David Audel CLA 2002-09-20 09:51:26 EDT
Verified in 2.1 M1