Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 31769 Details for
Bug 117282
Package declaration inserted on wrong CU while copying class if names collide and editor opened
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch and regression test
117282.txt (text/plain), 4.95 KB, created by
Jerome Lanneluc
on 2005-12-14 13:19:46 EST
(
hide
)
Description:
Proposed patch and regression test
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2005-12-14 13:19:46 EST
Size:
4.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java,v >retrieving revision 1.17 >diff -u -r1.17 CopyMoveResourcesTests.java >--- src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java 14 Sep 2005 14:05:49 -0000 1.17 >+++ src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java 14 Dec 2005 18:20:20 -0000 >@@ -196,8 +196,11 @@ > > this.createJavaProject("P", new String[] {"src", "src2"}, "bin"); > } >+static { >+// TESTS_NAMES = new String[] { "testCopyWorkingCopyDestination"}; >+} > public static Test suite() { >- return new Suite(CopyMoveResourcesTests.class); >+ return buildTestSuite(CopyMoveResourcesTests.class); > } > /** > * Cleanup after the previous test. >@@ -557,6 +560,40 @@ > if (copy != null) copy.discardWorkingCopy(); > } > } >+/* >+ * Ensures that a CU can be copied over an existing primary working copy in a different package. >+ * (regression test for bug 117282 Package declaration inserted on wrong CU while copying class if names collide and editor opened) >+ */ >+public void testCopyWorkingCopyDestination() throws CoreException { >+ ICompilationUnit copy = null; >+ try { >+ createFolder("/P/src/p1"); >+ createFile( >+ "/P/src/p1/X.java", >+ "package p1;\n" + >+ "public class X {\n" + >+ " void foo() {}\n" + >+ "}" >+ ); >+ ICompilationUnit cuSource = getCompilationUnit("/P/src/p1/X.java"); >+ >+ createFolder("/P/src/p2"); >+ IPackageFragment pkgDest = getPackage("/P/src/p2"); >+ createFile( >+ "/P/src/p2/X.java", >+ "\n" + >+ "package p1;\n" + >+ "public class X {\n" + >+ "}" >+ ); >+ copy = getCompilationUnit("/P/src/p2/X.java"); >+ copy.becomeWorkingCopy(null, null); >+ >+ copyPositive(cuSource, pkgDest, null, null, true/*force*/); >+ } finally { >+ if (copy != null) copy.discardWorkingCopy(); >+ } >+} > /** > * Ensures that a WorkingCopy can be copied to a different package, replacing an existing WorkingCopy. > */ >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java,v >retrieving revision 1.100 >diff -u -r1.100 CopyResourceElementsOperation.java >--- model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java 1 Jun 2005 18:56:14 -0000 1.100 >+++ model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java 14 Dec 2005 18:20:21 -0000 >@@ -247,27 +247,31 @@ > org.eclipse.jdt.internal.core.CompilationUnit destCU = new org.eclipse.jdt.internal.core.CompilationUnit(dest, destName, DefaultWorkingCopyOwner.PRIMARY); > if (!destFile.equals(sourceResource)) { > try { >- if (destFile.exists()) { >- if (this.force) { >- // we can remove it >- deleteResource(destFile, IResource.KEEP_HISTORY); >- destCU.close(); // ensure the in-memory buffer for the dest CU is closed >+ if (!destCU.isWorkingCopy()) { >+ if (destFile.exists()) { >+ if (this.force) { >+ // we can remove it >+ deleteResource(destFile, IResource.KEEP_HISTORY); >+ destCU.close(); // ensure the in-memory buffer for the dest CU is closed >+ } else { >+ // abort >+ throw new JavaModelException(new JavaModelStatus( >+ IJavaModelStatusConstants.NAME_COLLISION, >+ Messages.bind(Messages.status_nameCollision, destFile.getFullPath().toString()))); >+ } >+ } >+ int flags = this.force ? IResource.FORCE : IResource.NONE; >+ if (this.isMove()) { >+ flags |= IResource.KEEP_HISTORY; >+ sourceResource.move(destFile.getFullPath(), flags, getSubProgressMonitor(1)); > } else { >- // abort >- throw new JavaModelException(new JavaModelStatus( >- IJavaModelStatusConstants.NAME_COLLISION, >- Messages.bind(Messages.status_nameCollision, destFile.getFullPath().toString()))); >+ if (rewrite != null) flags |= IResource.KEEP_HISTORY; >+ sourceResource.copy(destFile.getFullPath(), flags, getSubProgressMonitor(1)); > } >- } >- int flags = this.force ? IResource.FORCE : IResource.NONE; >- if (this.isMove()) { >- flags |= IResource.KEEP_HISTORY; >- sourceResource.move(destFile.getFullPath(), flags, getSubProgressMonitor(1)); >+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE); > } else { >- if (rewrite != null) flags |= IResource.KEEP_HISTORY; >- sourceResource.copy(destFile.getFullPath(), flags, getSubProgressMonitor(1)); >+ destCU.getBuffer().setContents(source.getBuffer().getContents()); > } >- this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE); > } catch (JavaModelException e) { > throw e; > } catch (CoreException e) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 117282
: 31769