use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor in project che by eclipse.
the class RenameMethodRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) throws JavaModelException {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
String input = arguments.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT);
IMethod method = (IMethod) JavaRefactoringDescriptorUtil.handleToElement(arguments.getProject(), input);
if (method == null) {
status.addFatalError(Messages.format(RefactoringCoreMessages.RenameMethodRefactoringContribution_could_not_create, new Object[] { BasicElementLabels.getResourceName(arguments.getProject()), input }));
return null;
}
JavaRenameProcessor processor;
if (MethodChecks.isVirtual(method)) {
processor = new RenameVirtualMethodProcessor(method, arguments, status);
} else {
processor = new RenameNonVirtualMethodProcessor(method, arguments, status);
}
return new RenameRefactoring(processor);
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor in project che by eclipse.
the class RenamePrivateMethodTest method helper1_0.
private void helper1_0(String methodName, String newMethodName, String[] signatures) throws Exception {
IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(classA.getMethod(methodName, signatures));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName(newMethodName);
RefactoringStatus result = performRefactoring(refactoring);
assertNotNull("precondition was supposed to fail", result);
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor in project che by eclipse.
the class RenamePrivateMethodTest method test18.
@Test
public void test18() throws Exception {
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
ICompilationUnit cuC = createCUfromTestFile(getPackageP(), "C");
IType classB = getType(cu, "B");
RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(classB.getMethod("m", new String[] { "I" }));
RenameRefactoring refactoring = new RenameRefactoring(processor);
processor.setNewElementName("kk");
assertEquals("was supposed to pass", null, performRefactoring(refactoring));
assertEqualLines("invalid renaming A", getFileContents(getOutputTestFileName("A")), cu.getSource());
assertEqualLines("invalid renaming C", getFileContents(getOutputTestFileName("C")), cuC.getSource());
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor 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());
}
Aggregations