Search in sources :

Example 1 with ChangeSignatureProcessor

use of org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor in project che by eclipse.

the class RenameParametersTest method helper1.

private void helper1(String[] newNames, String[] signature) throws Exception {
    ICompilationUnit cu = createCUfromTestFile(getPackageP(), true, true);
    IType classA = getType(cu, "A");
    IMethod method = classA.getMethod("m", signature);
    Assert.assertTrue("refactoring not available", RefactoringAvailabilityTester.isChangeSignatureAvailable(method));
    ChangeSignatureProcessor processor = new ChangeSignatureProcessor(method);
    Refactoring ref = new ProcessorBasedRefactoring(processor);
    //ref.setUpdateReferences(updateReferences);
    //ref.setNewParameterNames(newNames);
    //ref.setNewNames(createRenamings(method, newNames));
    modifyInfos(processor.getParameterInfos(), newNames);
    RefactoringStatus result = performRefactoring(ref);
    Assert.assertEquals("precondition was supposed to pass", null, result);
    IPackageFragment pack = (IPackageFragment) cu.getParent();
    String newCuName = getSimpleTestFileName(true, true);
    ICompilationUnit newcu = pack.getCompilationUnit(newCuName);
    Assert.assertTrue(newCuName + " does not exist", newcu.exists());
    Assert.assertEquals("invalid renaming", getFileContents(getTestFileName(true, false)).length(), newcu.getSource().length());
    assertEqualLines("invalid renaming", getFileContents(getTestFileName(true, false)), newcu.getSource());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IMethod(org.eclipse.jdt.core.IMethod) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) IType(org.eclipse.jdt.core.IType) ChangeSignatureProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor)

Example 2 with ChangeSignatureProcessor

use of org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor in project che by eclipse.

the class RenameParametersTest method helper2.

private void helper2(String[] newNames, String[] signature) throws Exception {
    IType classA = getType(createCUfromTestFile(getPackageP(), false, false), "A");
    //DebugUtils.dump("classA" + classA);
    IMethod method = classA.getMethod("m", signature);
    Assert.assertTrue("refactoring not available", RefactoringAvailabilityTester.isChangeSignatureAvailable(method));
    ChangeSignatureProcessor processor = new ChangeSignatureProcessor(method);
    Refactoring ref = new ProcessorBasedRefactoring(processor);
    modifyInfos(processor.getParameterInfos(), newNames);
    RefactoringStatus result = performRefactoring(ref);
    Assert.assertNotNull("precondition was supposed to fail", result);
}
Also used : RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IMethod(org.eclipse.jdt.core.IMethod) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) IType(org.eclipse.jdt.core.IType) ChangeSignatureProcessor(org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor)

Aggregations

IMethod (org.eclipse.jdt.core.IMethod)2 IType (org.eclipse.jdt.core.IType)2 ChangeSignatureProcessor (org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureProcessor)2 Refactoring (org.eclipse.ltk.core.refactoring.Refactoring)2 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)2 ProcessorBasedRefactoring (org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1