use of org.eclipse.ltk.core.refactoring.participants.MoveArguments in project che by eclipse.
the class RenamePackageTest method testHierarchicalToSuperpackage2.
@Test
@Ignore
public void testHierarchicalToSuperpackage2() throws Exception {
fRenameSubpackages = true;
PackageRename rename = new PackageRename(new String[] { "a.b", "a.b.c", "a.c", "p" }, new String[][] { { "B" }, { "BC" }, {} }, "a", true);
IPackageFragment thisPackage = rename.fPackages[0];
IFolder src = (IFolder) getRoot().getResource();
IFolder a = src.getFolder("a");
IFolder ab = src.getFolder("a/b");
IFolder ac = src.getFolder("a/c");
IFolder abc = src.getFolder("a/b/c");
ParticipantTesting.reset();
String[] createHandles = {};
String[] deleteHandles = ParticipantTesting.createHandles(ab);
String[] moveHandles = ParticipantTesting.createHandles(ab.getFile("B.java"), abc.getFile("BC.java"));
String[] renameHandles = ParticipantTesting.createHandles(JavaElementUtil.getPackageAndSubpackages(thisPackage));
rename.createAndPerform(RefactoringStatus.OK);
rename.checkExpectedState();
ParticipantTesting.testCreate(createHandles);
ParticipantTesting.testDelete(deleteHandles);
ParticipantTesting.testMove(moveHandles, new MoveArguments[] { new MoveArguments(a, true), new MoveArguments(ac, true) });
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments("a", true), new RenameArguments("a.c", true) });
performUndo();
// empty package is not recreated, but that's OK
rename.fPackageNames = new String[] { "a.b", "a.b.c", "a", "p" };
rename.checkOriginalState();
}
use of org.eclipse.ltk.core.refactoring.participants.MoveArguments in project che by eclipse.
the class RenamePackageTest method testHierarchical02.
@Test
@Ignore
public void testHierarchical02() throws Exception {
if (BUG_PACKAGE_CANT_BE_RENAMED_TO_A_PACKAGE_THAT_ALREADY_EXISTS) {
printTestDisabledMessage("package can't be renamed to a package that already exists.");
return;
}
fRenameSubpackages = true;
PackageRename rename = new PackageRename(new String[] { "my", "my.a", "my.b", "your" }, new String[][] { { "MyA" }, { "ATest" }, { "B" }, { "Y" } }, "your");
IPackageFragment thisPackage = rename.fPackages[0];
IPath srcPath = thisPackage.getParent().getPath();
IFolder target = ResourcesPlugin.getWorkspace().getRoot().getFolder(srcPath.append("your"));
ParticipantTesting.reset();
String[] createHandles = ParticipantTesting.createHandles(target.getFolder("a"), target.getFolder("b"));
String[] deleteHandles = ParticipantTesting.createHandles(thisPackage.getResource());
String[] moveHandles = ParticipantTesting.createHandles(new Object[] { rename.fCus[0][0].getResource(), rename.fCus[1][0].getResource(), rename.fCus[2][0].getResource() });
String[] renameHandles = ParticipantTesting.createHandles(JavaElementUtil.getPackageAndSubpackages(thisPackage));
rename.execute();
ParticipantTesting.testCreate(createHandles);
ParticipantTesting.testDelete(deleteHandles);
ParticipantTesting.testMove(moveHandles, new MoveArguments[] { new MoveArguments(target, true), new MoveArguments(target.getFolder("a"), true), new MoveArguments(target.getFolder("b"), true) });
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments(rename.getNewPackageName(rename.fPackageNames[0]), true), new RenameArguments(rename.getNewPackageName(rename.fPackageNames[1]), true), new RenameArguments(rename.getNewPackageName(rename.fPackageNames[2]), true) });
}
use of org.eclipse.ltk.core.refactoring.participants.MoveArguments in project che by eclipse.
the class RenameModifications method addResourceModifications.
private IFolder addResourceModifications(IPackageFragment rootPackage, RenameArguments args, IPackageFragment pack, boolean renameSubPackages) throws CoreException {
IContainer container = (IContainer) pack.getResource();
if (container == null)
return null;
IFolder target = computeTargetFolder(rootPackage, args, pack);
createIncludingParents(target);
MoveArguments arguments = new MoveArguments(target, args.getUpdateReferences());
IResource[] resourcesToMove = collectResourcesOfInterest(pack);
Set<IResource> allMembers = new HashSet<IResource>(Arrays.asList(container.members()));
for (int i = 0; i < resourcesToMove.length; i++) {
IResource toMove = resourcesToMove[i];
getResourceModifications().addMove(toMove, arguments);
allMembers.remove(toMove);
}
for (Iterator<IResource> iter = allMembers.iterator(); iter.hasNext(); ) {
IResource element = iter.next();
if (element instanceof IFile) {
getResourceModifications().addDelete(element);
iter.remove();
}
}
if (!renameSubPackages && allMembers.isEmpty()) {
getResourceModifications().addDelete(container);
}
return target;
}
use of org.eclipse.ltk.core.refactoring.participants.MoveArguments in project che by eclipse.
the class ResourceModifications method addMove.
/**
* Adds the given resource to the list of resources
* to be moved.
*
* @param move the resource to be moved
* @param arguments the move arguments
*/
public void addMove(IResource move, MoveArguments arguments) {
if (fMove == null) {
fMove = new ArrayList<IResource>(2);
fMoveArguments = new ArrayList<MoveArguments>(2);
}
fMove.add(move);
fMoveArguments.add(arguments);
if (fIgnoreCount == 0) {
IPath destination = ((IResource) arguments.getDestination()).getFullPath().append(move.getName());
internalAdd(new MoveDescription(move, destination));
}
}
use of org.eclipse.ltk.core.refactoring.participants.MoveArguments in project che by eclipse.
the class ResourceModifications method getParticipants.
public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
List result = new ArrayList(5);
if (fDelete != null) {
DeleteArguments arguments = new DeleteArguments();
for (Iterator iter = fDelete.iterator(); iter.hasNext(); ) {
DeleteParticipant[] deletes = ParticipantManager.loadDeleteParticipants(status, processor, iter.next(), arguments, natures, shared);
result.addAll(Arrays.asList(deletes));
}
}
if (fCreate != null) {
CreateArguments arguments = new CreateArguments();
for (Iterator iter = fCreate.iterator(); iter.hasNext(); ) {
CreateParticipant[] creates = ParticipantManager.loadCreateParticipants(status, processor, iter.next(), arguments, natures, shared);
result.addAll(Arrays.asList(creates));
}
}
if (fMove != null) {
for (int i = 0; i < fMove.size(); i++) {
Object element = fMove.get(i);
MoveArguments arguments = (MoveArguments) fMoveArguments.get(i);
MoveParticipant[] moves = ParticipantManager.loadMoveParticipants(status, processor, element, arguments, natures, shared);
result.addAll(Arrays.asList(moves));
}
}
if (fCopy != null) {
for (int i = 0; i < fCopy.size(); i++) {
Object element = fCopy.get(i);
CopyArguments arguments = (CopyArguments) fCopyArguments.get(i);
CopyParticipant[] copies = ParticipantManager.loadCopyParticipants(status, processor, element, arguments, natures, shared);
result.addAll(Arrays.asList(copies));
}
}
if (fRename != null) {
for (int i = 0; i < fRename.size(); i++) {
Object resource = fRename.get(i);
RenameArguments arguments = (RenameArguments) fRenameArguments.get(i);
RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource, arguments, natures, shared);
result.addAll(Arrays.asList(renames));
}
}
return (RefactoringParticipant[]) result.toArray(new RefactoringParticipant[result.size()]);
}
Aggregations