View | Details | Raw Unified | Return to bug 142990
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/RenameTests.java (-2 / +32 lines)
Lines 13-18 Link Here
13
import junit.framework.Test;
13
import junit.framework.Test;
14
14
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IWorkspaceRunnable;
17
import org.eclipse.core.resources.IWorkspaceRunnable;
17
18
18
import org.eclipse.core.resources.IncrementalProjectBuilder;
19
import org.eclipse.core.resources.IncrementalProjectBuilder;
Lines 316-322 Link Here
316
/**
317
/**
317
 *
318
 *
318
 */
319
 */
319
public void testRenameCU() throws CoreException {
320
public void testRenameCU1() throws CoreException {
320
	this.cu.rename("NewX.java", false, null);
321
	this.cu.rename("NewX.java", false, null);
321
	assertTrue("Original CU should not exist", !this.cu.exists());
322
	assertTrue("Original CU should not exist", !this.cu.exists());
322
323
Lines 337-343 Link Here
337
		"			X.java[-]: {MOVED_TO(NewX.java [in <default> [in src [in P]]])}"
338
		"			X.java[-]: {MOVED_TO(NewX.java [in <default> [in src [in P]]])}"
338
	);
339
	);
339
}
340
}
340
public void testRenameCUForce() throws CoreException {
341
public void testRenameCU2() throws CoreException {
341
	this.createFile(
342
	this.createFile(
342
		"/P/src/Y.java",
343
		"/P/src/Y.java",
343
		"public class Y {\n" +
344
		"public class Y {\n" +
Lines 371-376 Link Here
371
	);
372
	);
372
}
373
}
373
/*
374
/*
375
 * Ensures that the correct scheduling rule is used when running ICompilationUnit.rename(...)
376
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 )
377
 */
378
public void testRenameCU3() throws Exception {
379
	IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
380
		public void run(IProgressMonitor monitor) throws CoreException {
381
			RenameTests.this.cu.rename("NewX.java", false, null);
382
			assertTrue("Original CU should not exist", !RenameTests.this.cu.exists());
383
		}
384
	};
385
	getWorkspace().run(runnable, getFolder("/P/src"), IResource.NONE, null);
386
}
387
/*
388
 * Ensures that the correct scheduling rule is used when running ICompilationUnit.rename(...)
389
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 )
390
 */
391
public void testRenameCU4() throws Exception {
392
	createFolder("/P/src/p1");
393
	createFile("/P/src/p1/X.java", "package p1; public class X {}");
394
	IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
395
		public void run(IProgressMonitor monitor) throws CoreException {
396
			ICompilationUnit x = getCompilationUnit("/P/src/p1/X.java");
397
			x.rename("NewX.java", false, null);
398
			assertTrue("Original CU should not exist", !x.exists());
399
		}
400
	};
401
	getWorkspace().run(runnable, getFolder("/P/src/p1"), IResource.NONE, null);
402
}
403
/*
374
 * Ensures that renaming an empty package fragment doesn't make it disappear
404
 * Ensures that renaming an empty package fragment doesn't make it disappear
375
 * (regression test for bug 24505 Refactoring an empty package makes it disappears)
405
 * (regression test for bug 24505 Refactoring an empty package makes it disappears)
376
 */
406
 */
(-)src/org/eclipse/jdt/core/tests/model/CopyMoveResourcesTests.java (-19 / +59 lines)
Lines 13-18 Link Here
13
import junit.framework.Test;
13
import junit.framework.Test;
14
14
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IWorkspaceRunnable;
16
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.QualifiedName;
20
import org.eclipse.core.runtime.QualifiedName;
Lines 214-220 Link Here
214
/**
216
/**
215
 * Ensures that a CU can be copied to a different package.
217
 * Ensures that a CU can be copied to a different package.
216
 */
218
 */
217
public void testCopyCU() throws CoreException {
219
public void testCopyCU01() throws CoreException {
218
	this.createFolder("/P/src/p1");
220
	this.createFolder("/P/src/p1");
219
	this.createFile(
221
	this.createFile(
220
		"/P/src/p1/X.java",
222
		"/P/src/p1/X.java",
Lines 236-242 Link Here
236
 * This operation should fail as copying a CU and a CU member at the
238
 * This operation should fail as copying a CU and a CU member at the
237
 * same time is not supported.
239
 * same time is not supported.
238
 */
240
 */
239
public void testCopyCUAndType() throws CoreException {
241
public void testCopyCU02() throws CoreException {
240
	this.createFolder("/P/src/p1");
242
	this.createFolder("/P/src/p1");
241
	this.createFile(
243
	this.createFile(
242
		"/P/src/p1/X.java",
244
		"/P/src/p1/X.java",
Lines 257-263 Link Here
257
/**
259
/**
258
 * Ensures that a CU can be copied to a different package, replacing an existing CU.
260
 * Ensures that a CU can be copied to a different package, replacing an existing CU.
259
 */
261
 */
260
public void testCopyCUForce() throws CoreException {
262
public void testCopyCU03() throws CoreException {
261
	this.createFolder("/P/src/p1");
263
	this.createFolder("/P/src/p1");
262
	this.createFile(
264
	this.createFile(
263
		"/P/src/p1/X.java",
265
		"/P/src/p1/X.java",
Lines 281-287 Link Here
281
/**
283
/**
282
 * Ensures that a CU can be copied from a default package to a non-default package.
284
 * Ensures that a CU can be copied from a default package to a non-default package.
283
 */
285
 */
284
public void testCopyCUFromDefaultToNonDefault() throws CoreException {
286
public void testCopyCU04() throws CoreException {
285
	createFile(
287
	createFile(
286
		"/P/src/X.java",
288
		"/P/src/X.java",
287
		"public class X {\n" +
289
		"public class X {\n" +
Lines 301-307 Link Here
301
 * Ensures that a CU can be copied to a different package,
303
 * Ensures that a CU can be copied to a different package,
302
 * and be renamed.
304
 * and be renamed.
303
 */
305
 */
304
public void testCopyCURename() throws CoreException {
306
public void testCopyCU05() throws CoreException {
305
	this.createFolder("/P/src/p1");
307
	this.createFolder("/P/src/p1");
306
	this.createFile(
308
	this.createFile(
307
		"/P/src/p1/X.java",
309
		"/P/src/p1/X.java",
Lines 319-325 Link Here
319
/**
321
/**
320
 * Ensures that a read-only CU can be copied to a different package.
322
 * Ensures that a read-only CU can be copied to a different package.
321
 */
323
 */
322
public void testCopyCUReadOnly() throws CoreException {
324
public void testCopyCU06() throws CoreException {
323
	if (!Util.isReadOnlySupported()) {
325
	if (!Util.isReadOnlySupported()) {
324
		// Do not test if file system does not support read-only attribute
326
		// Do not test if file system does not support read-only attribute
325
		return;
327
		return;
Lines 359-365 Link Here
359
 * Ensures that a CU can be copied to a different package,
361
 * Ensures that a CU can be copied to a different package,
360
 * and be renamed, overwriting an existing CU
362
 * and be renamed, overwriting an existing CU
361
 */
363
 */
362
public void testCopyCURenameForce() throws CoreException {
364
public void testCopyCU07() throws CoreException {
363
	this.createFolder("/P/src/p1");
365
	this.createFolder("/P/src/p1");
364
	this.createFile(
366
	this.createFile(
365
		"/P/src/p1/X.java",
367
		"/P/src/p1/X.java",
Lines 383-389 Link Here
383
/**
385
/**
384
 * Ensures that a CU cannot be copied to a different package,over an existing CU when no force.
386
 * Ensures that a CU cannot be copied to a different package,over an existing CU when no force.
385
 */
387
 */
386
public void testCopyCUWithCollision() throws CoreException {
388
public void testCopyCU08() throws CoreException {
387
	this.createFolder("/P/src/p1");
389
	this.createFolder("/P/src/p1");
388
	this.createFile(
390
	this.createFile(
389
		"/P/src/p1/X.java",
391
		"/P/src/p1/X.java",
Lines 407-413 Link Here
407
/**
409
/**
408
 * Ensures that a CU cannot be copied to an invalid destination
410
 * Ensures that a CU cannot be copied to an invalid destination
409
 */
411
 */
410
public void testCopyCUWithInvalidDestination() throws CoreException {
412
public void testCopyCU09() throws CoreException {
411
	this.createFolder("/P/src/p1");
413
	this.createFolder("/P/src/p1");
412
	this.createFile(
414
	this.createFile(
413
		"/P/src/p1/X.java",
415
		"/P/src/p1/X.java",
Lines 422-428 Link Here
422
/**
424
/**
423
 * Ensures that a CU can be copied to a null container
425
 * Ensures that a CU can be copied to a null container
424
 */
426
 */
425
public void testCopyCUWithNullContainer() throws CoreException {
427
public void testCopyCU10() throws CoreException {
426
	this.createFolder("/P/src/p1");
428
	this.createFolder("/P/src/p1");
427
	this.createFile(
429
	this.createFile(
428
		"/P/src/p1/X.java",
430
		"/P/src/p1/X.java",
Lines 443-449 Link Here
443
 * Ensures that a CU can be copied to along with its server properties.
445
 * Ensures that a CU can be copied to along with its server properties.
444
 * (Regression test for PR #1G56QT9)
446
 * (Regression test for PR #1G56QT9)
445
 */
447
 */
446
public void testCopyCUWithServerProperties() throws CoreException {
448
public void testCopyCU11() throws CoreException {
447
	this.createFolder("/P/src/p1");
449
	this.createFolder("/P/src/p1");
448
	this.createFile(
450
	this.createFile(
449
		"/P/src/p1/X.java",
451
		"/P/src/p1/X.java",
Lines 470-475 Link Here
470
		propertyValue
472
		propertyValue
471
	);
473
	);
472
}
474
}
475
/*
476
 * Ensures that the correct scheduling rule is used when copying a CU
477
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 )
478
 */
479
public void testCopyCU12() throws Exception {
480
	createFolder("/P/src/p1");
481
	createFile("/P/src/p1/X.java", "package p1; public class X {}");
482
	this.createFolder("/P/src/p2");
483
484
	IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
485
		public void run(IProgressMonitor monitor) throws CoreException {
486
			ICompilationUnit cuSource = getCompilationUnit("/P/src/p1/X.java");
487
			IPackageFragment pkgDest = getPackage("/P/src/p2");
488
			cuSource.copy(pkgDest, null, null, false, null);
489
			assertTrue("/P/src/p2/X.java should exist", getCompilationUnit("/P/src/p2/X.java").exists());
490
		}
491
	};
492
	getWorkspace().run(runnable, getFolder("/P/src/p2"), IResource.NONE, null);
493
}
473
/**
494
/**
474
 * Ensures that a package fragment can be copied to a different package fragment root.
495
 * Ensures that a package fragment can be copied to a different package fragment root.
475
 */
496
 */
Lines 743-749 Link Here
743
/**
764
/**
744
 * Ensures that a CU can be moved to a different package.
765
 * Ensures that a CU can be moved to a different package.
745
 */
766
 */
746
public void testMoveCU() throws CoreException {
767
public void testMoveCU01() throws CoreException {
747
	this.createFolder("/P/src/p1");
768
	this.createFolder("/P/src/p1");
748
	this.createFile(
769
	this.createFile(
749
		"/P/src/p1/X.java",
770
		"/P/src/p1/X.java",
Lines 765-771 Link Here
765
 * This operation should fail as moving a CU and a CU member at the
786
 * This operation should fail as moving a CU and a CU member at the
766
 * same time is not supported.
787
 * same time is not supported.
767
 */
788
 */
768
public void testMoveCUAndType() throws CoreException {
789
public void testMoveCU02() throws CoreException {
769
	this.createFolder("/P/src/p1");
790
	this.createFolder("/P/src/p1");
770
	this.createFile(
791
	this.createFile(
771
		"/P/src/p1/X.java",
792
		"/P/src/p1/X.java",
Lines 787-793 Link Here
787
 * Ensures that a CU can be moved to a different package, replacing an
808
 * Ensures that a CU can be moved to a different package, replacing an
788
 * existing CU.
809
 * existing CU.
789
 */
810
 */
790
public void testMoveCUForce() throws CoreException {
811
public void testMoveCU03() throws CoreException {
791
	this.createFolder("/P/src/p1");
812
	this.createFolder("/P/src/p1");
792
	this.createFile(
813
	this.createFile(
793
		"/P/src/p1/X.java",
814
		"/P/src/p1/X.java",
Lines 812-818 Link Here
812
 * Ensures that a CU can be moved to a different package,
833
 * Ensures that a CU can be moved to a different package,
813
 * be renamed
834
 * be renamed
814
 */
835
 */
815
public void testMoveCURename() throws CoreException {
836
public void testMoveCU04() throws CoreException {
816
	this.createFolder("/P/src/p1");
837
	this.createFolder("/P/src/p1");
817
	this.createFile(
838
	this.createFile(
818
		"/P/src/p1/X.java",
839
		"/P/src/p1/X.java",
Lines 831-837 Link Here
831
 * Ensures that a CU can be moved to a different package,
852
 * Ensures that a CU can be moved to a different package,
832
 * be renamed, overwriting an existing resource.
853
 * be renamed, overwriting an existing resource.
833
 */
854
 */
834
public void testMoveCURenameForce() throws CoreException {
855
public void testMoveCU05() throws CoreException {
835
	this.createFolder("/P/src/p1");
856
	this.createFolder("/P/src/p1");
836
	this.createFile(
857
	this.createFile(
837
		"/P/src/p1/X.java",
858
		"/P/src/p1/X.java",
Lines 856-862 Link Here
856
 * Ensures that a CU cannot be moved to a different package, replacing an
877
 * Ensures that a CU cannot be moved to a different package, replacing an
857
 * existing CU when not forced.
878
 * existing CU when not forced.
858
 */
879
 */
859
public void testMoveCUWithCollision() throws CoreException {
880
public void testMoveCU06() throws CoreException {
860
	this.createFolder("/P/src/p1");
881
	this.createFolder("/P/src/p1");
861
	this.createFile(
882
	this.createFile(
862
		"/P/src/p1/X.java",
883
		"/P/src/p1/X.java",
Lines 880-886 Link Here
880
/**
901
/**
881
 * Ensures that a CU cannot be moved to an invalid destination.
902
 * Ensures that a CU cannot be moved to an invalid destination.
882
 */
903
 */
883
public void testMoveCUWithInvalidDestination() throws CoreException {
904
public void testMoveCU07() throws CoreException {
884
	this.createFolder("/P/src/p1");
905
	this.createFolder("/P/src/p1");
885
	this.createFile(
906
	this.createFile(
886
		"/P/src/p1/X.java",
907
		"/P/src/p1/X.java",
Lines 895-901 Link Here
895
/**
916
/**
896
 * Ensures that a CU cannot be moved to a null container
917
 * Ensures that a CU cannot be moved to a null container
897
 */
918
 */
898
public void testMoveCUWithNullContainer() throws CoreException {
919
public void testMoveCU08() throws CoreException {
899
	this.createFolder("/P/src/p1");
920
	this.createFolder("/P/src/p1");
900
	this.createFile(
921
	this.createFile(
901
		"/P/src/p1/X.java",
922
		"/P/src/p1/X.java",
Lines 912-917 Link Here
912
	}
933
	}
913
	assertTrue("Should not be able to move a cu to a null container", false);
934
	assertTrue("Should not be able to move a cu to a null container", false);
914
}
935
}
936
/*
937
 * Ensures that the correct scheduling rule is used when moving a CU
938
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=142990 )
939
 */
940
public void testMoveCU09() throws Exception {
941
	createFolder("/P/src/p1");
942
	createFile("/P/src/p1/X.java", "package p1; public class X {}");
943
	this.createFolder("/P/src/p2");
944
945
	IWorkspaceRunnable runnable = new IWorkspaceRunnable(){
946
		public void run(IProgressMonitor monitor) throws CoreException {
947
			ICompilationUnit cuSource = getCompilationUnit("/P/src/p1/X.java");
948
			IPackageFragment pkgDest = getPackage("/P/src/p2");
949
			cuSource.move(pkgDest, null, null, false, null);
950
			assertFalse("/P/src/p1/X.java should no longer exist", cuSource.exists());
951
		}
952
	};
953
	getWorkspace().run(runnable, getFolder("/P/src"), IResource.NONE, null);
954
}
915
/**
955
/**
916
 * Ensures that a package fragment can be moved to a different package fragment root.
956
 * Ensures that a package fragment can be moved to a different package fragment root.
917
 */
957
 */
(-)model/org/eclipse/jdt/internal/core/JavaModelOperation.java (-6 / +18 lines)
Lines 247-257 Link Here
247
	/**
247
	/**
248
	 * Convenience method to copy resources
248
	 * Convenience method to copy resources
249
	 */
249
	 */
250
	protected void copyResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
250
	protected void copyResources(IResource[] resources, IPath container) throws JavaModelException {
251
		IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
251
		IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
252
		IWorkspace workspace = resources[0].getWorkspace();
252
		IWorkspaceRoot root =  ResourcesPlugin.getWorkspace().getRoot();
253
		try {
253
		try {
254
			workspace.copy(resources, destinationPath, false, subProgressMonitor);
254
			for (int i = 0, length = resources.length; i < length; i++) {
255
				IResource resource = resources[i];
256
				IPath destination = container.append(resource.getName());
257
				if (root.findMember(destination) == null) {
258
					resource.copy(destination, false, subProgressMonitor);
259
				}
260
			}
255
			setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
261
			setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
256
		} catch (CoreException e) {
262
		} catch (CoreException e) {
257
			throw new JavaModelException(e);
263
			throw new JavaModelException(e);
Lines 561-574 Link Here
561
	/**
567
	/**
562
	 * Convenience method to move resources
568
	 * Convenience method to move resources
563
	 */
569
	 */
564
	protected void moveResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
570
	protected void moveResources(IResource[] resources, IPath container) throws JavaModelException {
565
		IProgressMonitor subProgressMonitor = null;
571
		IProgressMonitor subProgressMonitor = null;
566
		if (this.progressMonitor != null) {
572
		if (this.progressMonitor != null) {
567
			subProgressMonitor = new SubProgressMonitor(this.progressMonitor, resources.length, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
573
			subProgressMonitor = new SubProgressMonitor(this.progressMonitor, resources.length, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
568
		}
574
		}
569
		IWorkspace workspace = resources[0].getWorkspace();
575
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
570
		try {
576
		try {
571
			workspace.move(resources, destinationPath, false, subProgressMonitor);
577
			for (int i = 0, length = resources.length; i < length; i++) {
578
				IResource resource = resources[i];
579
				IPath destination = container.append(resource.getName());
580
				if (root.findMember(destination) == null) {
581
					resource.move(destination, false, subProgressMonitor);
582
				}
583
			}
572
			setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
584
			setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
573
		} catch (CoreException e) {
585
		} catch (CoreException e) {
574
			throw new JavaModelException(e);
586
			throw new JavaModelException(e);
(-)model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java (-7 / +72 lines)
Lines 16-21 Link Here
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.IPath;
17
import org.eclipse.core.runtime.IPath;
18
import org.eclipse.core.runtime.Path;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.jobs.ISchedulingRule;
20
import org.eclipse.core.runtime.jobs.MultiRule;
19
import org.eclipse.jdt.core.*;
21
import org.eclipse.jdt.core.*;
20
import org.eclipse.jdt.core.dom.AST;
22
import org.eclipse.jdt.core.dom.AST;
21
import org.eclipse.jdt.core.dom.ASTParser;
23
import org.eclipse.jdt.core.dom.ASTParser;
Lines 73-85 Link Here
73
	protected ASTParser parser;
75
	protected ASTParser parser;
74
	/**
76
	/**
75
	 * When executed, this operation will copy the given resources to the
77
	 * When executed, this operation will copy the given resources to the
76
	 * given container.
77
	 */
78
	public CopyResourceElementsOperation(IJavaElement[] resourcesToCopy, IJavaElement destContainer, boolean force) {
79
		this(resourcesToCopy, new IJavaElement[]{destContainer}, force);
80
	}
81
	/**
82
	 * When executed, this operation will copy the given resources to the
83
	 * given containers.  The resources and destination containers must be in
78
	 * given containers.  The resources and destination containers must be in
84
	 * the correct order. If there is > 1 destination, the number of destinations
79
	 * the correct order. If there is > 1 destination, the number of destinations
85
	 * must be the same as the number of resources being copied/moved.
80
	 * must be the same as the number of resources being copied/moved.
Lines 192-197 Link Here
192
	protected String getMainTaskName() {
187
	protected String getMainTaskName() {
193
		return Messages.operation_copyResourceProgress;
188
		return Messages.operation_copyResourceProgress;
194
	}
189
	}
190
	protected ISchedulingRule getSchedulingRule() {
191
		if (this.elementsToProcess == null)
192
			return null;
193
		int length = this.elementsToProcess.length;
194
		if (length == 1)
195
			return getSchedulingRule(this.elementsToProcess[0]);
196
		ISchedulingRule[] rules = new ISchedulingRule[length];
197
		int index = 0;
198
		for (int i = 0; i < length; i++) {
199
			ISchedulingRule rule = getSchedulingRule(this.elementsToProcess[i]);
200
			if (rule != null) {
201
				rules[index++] = rule;
202
			}
203
		}
204
		if (index != length)
205
			System.arraycopy(rules, 0, rules = new ISchedulingRule[index], 0, index);
206
		return new MultiRule(rules);
207
	}
208
	private ISchedulingRule getSchedulingRule(IJavaElement element) {
209
		if (element == null)
210
			return null;
211
		IResource sourceResource = getResource(element);
212
		IResource destContainer = getResource(getDestinationParent(element));
213
		if (!(destContainer instanceof IContainer)) {
214
			return null;
215
		}
216
		String newName;
217
		try {
218
			newName = getNewNameFor(element);
219
		} catch (JavaModelException e) {
220
			return null;
221
		}
222
		if (newName == null)
223
			newName = element.getElementName();
224
		IResource destResource;
225
		String sourceEncoding = null;
226
		if (sourceResource.getType() == IResource.FILE) {
227
			destResource = ((IContainer) destContainer).getFile(new Path(newName));
228
			try {
229
				sourceEncoding = ((IFile) sourceResource).getCharset(false);
230
			} catch (CoreException ce) {
231
				// use default encoding
232
			}
233
		} else {
234
			destResource = ((IContainer) destContainer).getFolder(new Path(newName));
235
		}
236
		IResourceRuleFactory factory = ResourcesPlugin.getWorkspace().getRuleFactory();
237
		ISchedulingRule rule;
238
		if (isMove()) {
239
			rule = factory.moveRule(sourceResource, destResource);
240
		} else {
241
			rule = factory.copyRule(sourceResource, destResource);
242
		}
243
		if (sourceEncoding != null) {
244
			rule = new MultiRule(new ISchedulingRule[] {rule, factory.charsetRule(destResource)});
245
		}
246
		return rule;
247
	}
248
	private IResource getResource(IJavaElement element) {
249
		if (element == null)
250
			return null;
251
		if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) {
252
			String pkgName = element.getElementName();
253
			int firstDot = pkgName.indexOf('.');
254
			if (firstDot != -1) {
255
				element = ((IPackageFragmentRoot) element.getParent()).getPackageFragment(pkgName.substring(0, firstDot));
256
			}
257
		}
258
		return element.getResource();
259
	}
195
	/**
260
	/**
196
	 * Sets the deltas to register the changes resulting from this operation
261
	 * Sets the deltas to register the changes resulting from this operation
197
	 * for this source element and its destination.
262
	 * for this source element and its destination.

Return to bug 142990