use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor 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);
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor 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());
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor 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());
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor in project che by eclipse.
the class RenameTypeParameterRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(arguments, status);
return new RenameRefactoring(processor);
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor in project che by eclipse.
the class RenameSupport method create.
/**
* Creates a new rename support for the given {@link ITypeParameter}.
*
* @param parameter the {@link ITypeParameter} to be renamed.
* @param newName the parameter's new name. <code>null</code> is a valid value
* indicating that no new name is provided.
* @param flags flags controlling additional parameters. Valid flags are
* <code>UPDATE_REFERENCES</code>, or <code>NONE</code>.
* @return the {@link RenameSupport}.
* @throws CoreException if an unexpected error occurred while creating
* the {@link RenameSupport}.
* @since 3.1
*/
public static RenameSupport create(ITypeParameter parameter, String newName, int flags) throws CoreException {
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(parameter);
processor.setUpdateReferences(updateReferences(flags));
return new RenameSupport(processor, newName, flags);
}
Aggregations