Community
Participate
Working Groups
20020502 setup is: 2 jProjects a and b - both with 1 source folder src and a package p inside i call copy(destination, null, null, true, pm) were the receiver is 'p' in 'a' and 'destination' is 'src' in 'b' it does not overwrite as spec'ed
I traced the problem till org.eclipse.jdt.internal.corext.refactoring.changes.CopyPackageChange protected void doPerform(IProgressMonitor pm) throws JavaModelException{ getPackage().copy(getDestination(), null, getNewName(), true, pm); } if you replace this call with: protected void doPerform(IProgressMonitor pm) throws JavaModelException{ getPackage().copy(getDestination(), null, null, true, pm); } it works as expected. Then I cannot reproduce the problem. Here is the scenario I tried: 1) Create a project P with a source folder src, in which you create a package p, in which you create a class A. 2) Create a project P1 with a source folder src, in which you create a package p, in which you create a class A with a different contents from A in P. 3) Select p in P/src and copy it. 4) Paste in P1/src. 5) Open A in P1. It has the same contents than A in P. So I believe it is working as expected. If my test case doesn't work for you, please give me the complete steps and the version of JDT/Core you are using.
the thing is - getName() equals null so it is the same code really. here's my scenario: 1. project s, source folder src, package p, file A.java, X.java 2. project s1, source folder src, package p, files A.java (different content than the other A.java) and B.java now, after asking you to overwrite it does overwrite A.java's content but X.java is not deleted as i'd expect
I don't see why the class X would be removed. It is not a conflict case. For me it should only override the conflicts between the source and the destination.
then the doc is confusing - it says that the content will be replaced. so i assumed that the content of the package will be replaced. but it was just merged. it's really merging - not overwritting
Then I will simply clarify the doc and then close the PR. Is this ok for you?
Could you please tell me which doc is incorrect? I looked at the ISourceManipulation documentation for the method copy and IJavaModel copy and they looked pretty straight forward.
it is straighforawrd but the actual behavior is different than what the doc says. the doc: * @param replace <code>true</code> if any existing child in the container with * the target name should be replaced, and <code>false</code> to throw an * exception in the event of a name collision behavior: target is not replaced - it is merged with the existing target
No, I disagree. It is replaced. It is not merged. The contents of a conflict is replaced with the contents of the conflicting file from the source container. It doesn't say that the target container will be replaced with the contents of the source container. It simply refers to the child collision case. I don't want to be picky, but I would say the doc is clear enough.
it's really ok for me. would have to check what explorer does when you do 'overwrite' on folders. but i guess you're right - it does the same as jcore. ok to close. will reopen if anything. thanks.
This appears not to be a bug. Closed.