use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameMethodProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
RenameArguments args = new RenameArguments(getNewElementName(), getUpdateReferences());
for (Iterator<IMethod> iter = fMethodsToRename.iterator(); iter.hasNext(); ) {
IMethod method = iter.next();
result.rename(method, args);
}
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameTypeProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() {
RenameModifications result = new RenameModifications();
result.rename(fType, new RenameTypeArguments(getNewElementName(), getUpdateReferences(), getUpdateSimilarDeclarations(), getSimilarElements()), createParticipantDescriptorFilter());
if (isPrimaryType()) {
ICompilationUnit cu = fType.getCompilationUnit();
String newCUName = getNewCompilationUnit().getElementName();
result.rename(cu, new RenameArguments(newCUName, getUpdateReferences()));
}
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class ResourceModifications method getParticipants.
public RefactoringParticipant[] getParticipants(RefactoringStatus status, RefactoringProcessor processor, String[] natures, SharableParticipants shared) {
List<RefactoringParticipant> result = new ArrayList<RefactoringParticipant>(5);
if (fDelete != null) {
DeleteArguments arguments = new DeleteArguments();
for (Iterator<IResource> 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<IResource> 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 = 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 = 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 = fRenameArguments.get(i);
RenameParticipant[] renames = ParticipantManager.loadRenameParticipants(status, processor, resource, arguments, natures, shared);
result.addAll(Arrays.asList(renames));
}
}
return result.toArray(new RefactoringParticipant[result.size()]);
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameNonPrivateFieldTest method helper2.
private void helper2(String fieldName, String newFieldName, boolean createDelegates) throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType classA = getType(cu, "A");
IField field = classA.getField(fieldName);
boolean isEnum = JdtFlags.isEnum(field);
String id = isEnum ? IJavaRefactorings.RENAME_ENUM_CONSTANT : IJavaRefactorings.RENAME_FIELD;
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(id);
descriptor.setJavaElement(field);
descriptor.setNewName(newFieldName);
descriptor.setUpdateReferences(fUpdateReferences);
descriptor.setUpdateTextualOccurrences(fUpdateTextualMatches);
if (!isEnum) {
descriptor.setRenameGetters(fRenameGetter);
descriptor.setRenameSetters(fRenameSetter);
descriptor.setKeepOriginal(createDelegates);
descriptor.setDeprecateDelegate(true);
}
RenameRefactoring refactoring = (RenameRefactoring) createRefactoring(descriptor);
RenameFieldProcessor processor = (RenameFieldProcessor) refactoring.getProcessor();
List elements = new ArrayList();
elements.add(field);
List args = new ArrayList();
args.add(new RenameArguments(newFieldName, fUpdateReferences));
if (fRenameGetter) {
elements.add(processor.getGetter());
args.add(new RenameArguments(processor.getNewGetterName(), fUpdateReferences));
}
if (fRenameSetter) {
elements.add(processor.getSetter());
args.add(new RenameArguments(processor.getNewSetterName(), fUpdateReferences));
}
String[] renameHandles = ParticipantTesting.createHandles(elements.toArray());
RefactoringStatus result = performRefactoring(refactoring);
assertEquals("was supposed to pass", null, result);
assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
ParticipantTesting.testRename(renameHandles, (RenameArguments[]) args.toArray(new RenameArguments[args.size()]));
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
RefactoringCore.getUndoManager().performRedo(null, new NullProgressMonitor());
assertEqualLines("invalid redo", getFileContents(getOutputTestFileName("A")), cu.getSource());
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenamePackageTest method testHierarchicalToSuperpackage.
@Test
@Ignore
public void testHierarchicalToSuperpackage() throws Exception {
fRenameSubpackages = true;
PackageRename rename = new PackageRename(new String[] { "a.b", "a.b.b", "a", "p" }, new String[][] { { "B" }, { "BB" }, {} }, "a", true);
IPackageFragment thisPackage = rename.fPackages[0];
IFolder src = (IFolder) getRoot().getResource();
IFolder a = src.getFolder("a");
IFolder ab = src.getFolder("a/b");
IFolder abb = src.getFolder("a/b/b");
ParticipantTesting.reset();
String[] createHandles = {};
String[] deleteHandles = {};
String[] moveHandles = ParticipantTesting.createHandles(ab.getFile("B.java"), abb.getFile("BB.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(ab, true) });
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments("a", true), new RenameArguments("a.b", true) });
performUndo();
rename.checkOriginalState();
}
Aggregations