use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenamePackageProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
result.rename(fPackage, new RenameArguments(getNewElementName(), getUpdateReferences()), fRenameSubpackages);
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameTypeParameterProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
result.rename(fTypeParameter, new RenameArguments(getNewElementName(), getUpdateReferences()));
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenamePrivateFieldTest method helper2.
private void helper2(String fieldName, String newFieldName, boolean updateReferences, boolean updateTextualMatches, boolean renameGetter, boolean renameSetter, boolean expectedGetterRenameEnabled, boolean expectedSetterRenameEnabled) throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType classA = getType(cu, "A");
IField field = classA.getField(fieldName);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_FIELD);
descriptor.setJavaElement(field);
descriptor.setNewName(newFieldName);
descriptor.setUpdateReferences(updateReferences);
descriptor.setUpdateTextualOccurrences(updateTextualMatches);
descriptor.setRenameGetters(renameGetter);
descriptor.setRenameSetters(renameSetter);
RenameRefactoring refactoring = (RenameRefactoring) createRefactoring(descriptor);
RenameFieldProcessor processor = (RenameFieldProcessor) refactoring.getProcessor();
assertEquals("getter rename enabled", expectedGetterRenameEnabled, processor.canEnableGetterRenaming() == null);
assertEquals("setter rename enabled", expectedSetterRenameEnabled, processor.canEnableSetterRenaming() == null);
String newGetterName = processor.getNewGetterName();
String newSetterName = processor.getNewSetterName();
List elements = new ArrayList();
elements.add(field);
List args = new ArrayList();
args.add(new RenameArguments(newFieldName, updateReferences));
if (renameGetter && expectedGetterRenameEnabled) {
elements.add(processor.getGetter());
args.add(new RenameArguments(newGetterName, updateReferences));
}
if (renameSetter && expectedSetterRenameEnabled) {
elements.add(processor.getSetter());
args.add(new RenameArguments(newSetterName, updateReferences));
}
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 RenamePrivateMethodTest method helper2_0.
private void helper2_0(String methodName, String newMethodName, String[] signatures, boolean updateReferences, boolean createDelegate) throws Exception {
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
IType classA = getType(cu, "A");
IMethod method = classA.getMethod(methodName, signatures);
String[] handles = ParticipantTesting.createHandles(method);
RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(method);
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setUpdateReferences(updateReferences);
processor.setNewElementName(newMethodName);
processor.setDelegateUpdating(createDelegate);
assertEquals("was supposed to pass", null, performRefactoring(refactoring));
assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
ParticipantTesting.testRename(handles, new RenameArguments[] { new RenameArguments(newMethodName, updateReferences) });
assertTrue("anythingToUndo", RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("! anythingToRedo", !RefactoringCore.getUndoManager().anythingToRedo());
//assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size());
RefactoringCore.getUndoManager().performUndo(null, new NullProgressMonitor());
assertEqualLines("invalid undo", getFileContents(getInputTestFileName("A")), cu.getSource());
assertTrue("! anythingToUndo", !RefactoringCore.getUndoManager().anythingToUndo());
assertTrue("anythingToRedo", RefactoringCore.getUndoManager().anythingToRedo());
//assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size());
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 TestRenameParticipantSingle method testArguments.
public static void testArguments(RenameArguments[] args) {
testNumberOfInstances(args.length);
for (int i = 0; i < args.length; i++) {
RenameArguments expected = args[i];
RenameArguments actual = getInstance(i).getArguments();
Assert.assertEquals(expected.getNewName(), actual.getNewName());
Assert.assertEquals(expected.getUpdateReferences(), actual.getUpdateReferences());
}
}
Aggregations