Search in sources :

Example 1 with RenameMethodProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor in project che by eclipse.

the class RenameVirtualMethodInClassTest 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 RenameVirtualMethodProcessor(classA.getMethod(methodName, signatures));
    RenameRefactoring ref = new RenameRefactoring(processor);
    processor.setNewElementName(newMethodName);
    RefactoringStatus result = performRefactoring(ref);
    assertNotNull("precondition was supposed to fail", result);
}
Also used : RenameVirtualMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) RenameMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor) IType(org.eclipse.jdt.core.IType)

Example 2 with RenameMethodProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor in project che by eclipse.

the class RenameVirtualMethodInClassTest method helper1_not_available.

private void helper1_not_available(String methodName, String[] signatures) throws Exception {
    IType classA = getType(createCUfromTestFile(getPackageP(), "A"), "A");
    RenameMethodProcessor processor = new RenameVirtualMethodProcessor(classA.getMethod(methodName, signatures));
    RenameRefactoring ref = new RenameRefactoring(processor);
    assertTrue(!ref.isApplicable());
}
Also used : RenameVirtualMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor) IType(org.eclipse.jdt.core.IType)

Example 3 with RenameMethodProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor 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);
}
Also used : RenameNonVirtualMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) RenameMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor) IType(org.eclipse.jdt.core.IType)

Example 4 with RenameMethodProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor 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());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RenameNonVirtualMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor) IType(org.eclipse.jdt.core.IType) Test(org.junit.Test)

Example 5 with RenameMethodProcessor

use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor 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());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) RenameNonVirtualMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameMethodProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor) IMethod(org.eclipse.jdt.core.IMethod) IType(org.eclipse.jdt.core.IType)

Aggregations

IType (org.eclipse.jdt.core.IType)5 RenameMethodProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor)5 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)5 RenameNonVirtualMethodProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor)3 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 RenameVirtualMethodProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor)2 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IMethod (org.eclipse.jdt.core.IMethod)1 RenameArguments (org.eclipse.ltk.core.refactoring.participants.RenameArguments)1 Test (org.junit.Test)1