Search in sources :

Example 11 with RenameRefactoring

use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring 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 12 with RenameRefactoring

use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring 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 13 with RenameRefactoring

use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.

the class RenameTypeParameterTest method helper1.

private void helper1(String parameterName, String newParameterName, String typeName, String methodName, String[] methodSignature, boolean references) throws Exception {
    IType declaringType = getType(createCUfromTestFile(getPackageP(), "A"), typeName);
    IMethod[] declaringMethods = getMethods(declaringType, new String[] { methodName }, new String[][] { methodSignature });
    RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(declaringMethods[0].getTypeParameter(parameterName));
    RenameRefactoring refactoring = new RenameRefactoring(processor);
    processor.setNewElementName(newParameterName);
    processor.setUpdateReferences(references);
    RefactoringStatus result = performRefactoring(refactoring);
    assertNotNull("precondition was supposed to fail", result);
}
Also used : RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameTypeParameterProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IMethod(org.eclipse.jdt.core.IMethod) IType(org.eclipse.jdt.core.IType)

Example 14 with RenameRefactoring

use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.

the class RenameTypeParameterTest method helper2.

private void helper2(String parameterName, String newParameterName, String typeName, String methodName, String[] methodSignature, boolean references) throws Exception {
    ParticipantTesting.reset();
    ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
    IType declaringType = getType(cu, typeName);
    IMethod[] declaringMethods = getMethods(declaringType, new String[] { methodName }, new String[][] { methodSignature });
    ITypeParameter typeParameter = declaringMethods[0].getTypeParameter(parameterName);
    RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(typeParameter);
    RenameRefactoring refactoring = new RenameRefactoring(processor);
    processor.setNewElementName(newParameterName);
    processor.setUpdateReferences(references);
    RefactoringStatus result = performRefactoring(refactoring);
    assertEquals("was supposed to pass", null, result);
    assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
    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());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameTypeParameterProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ITypeParameter(org.eclipse.jdt.core.ITypeParameter) IMethod(org.eclipse.jdt.core.IMethod) IType(org.eclipse.jdt.core.IType)

Example 15 with RenameRefactoring

use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.

the class RenameTypeParameterTest method helper2.

private void helper2(String parameterName, String newParameterName, String typeName, boolean references) throws Exception {
    ParticipantTesting.reset();
    ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
    IType declaringType = getType(cu, typeName);
    ITypeParameter typeParameter = declaringType.getTypeParameter(parameterName);
    RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(typeParameter);
    RenameRefactoring refactoring = new RenameRefactoring(processor);
    processor.setNewElementName(newParameterName);
    processor.setUpdateReferences(references);
    RefactoringStatus result = performRefactoring(refactoring);
    assertEquals("was supposed to pass", null, result);
    assertEqualLines("invalid renaming", getFileContents(getOutputTestFileName("A")), cu.getSource());
    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());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameTypeParameterProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ITypeParameter(org.eclipse.jdt.core.ITypeParameter) IType(org.eclipse.jdt.core.IType)

Aggregations

RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)36 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)13 IType (org.eclipse.jdt.core.IType)12 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 JavaRefactoringArguments (org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringArguments)8 RenameJavaElementDescriptor (org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor)5 RenameMethodProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor)5 RenameTypeParameterProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor)5 RenameArguments (org.eclipse.ltk.core.refactoring.participants.RenameArguments)5 RefactoringWizard (org.eclipse.ltk.ui.refactoring.RefactoringWizard)5 RefactoringWizardOpenOperation (org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation)5 RenameRefactoringWizard (org.eclipse.wst.xsd.ui.internal.refactor.wizard.RenameRefactoringWizard)5 CoreException (org.eclipse.core.runtime.CoreException)4 IMethod (org.eclipse.jdt.core.IMethod)4 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)4 RenameVirtualMethodProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameVirtualMethodProcessor)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IFile (org.eclipse.core.resources.IFile)3