Search in sources :

Example 1 with RenameTypeParameterProcessor

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);
}
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 2 with RenameTypeParameterProcessor

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());
}
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 3 with RenameTypeParameterProcessor

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());
}
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)

Example 4 with RenameTypeParameterProcessor

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);
}
Also used : JavaRefactoringArguments(org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringArguments) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RenameTypeParameterProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor)

Example 5 with RenameTypeParameterProcessor

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);
}
Also used : RenameTypeParameterProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor)

Aggregations

RenameTypeParameterProcessor (org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeParameterProcessor)6 RenameRefactoring (org.eclipse.ltk.core.refactoring.participants.RenameRefactoring)5 IType (org.eclipse.jdt.core.IType)4 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 IMethod (org.eclipse.jdt.core.IMethod)2 ITypeParameter (org.eclipse.jdt.core.ITypeParameter)2 JavaRefactoringArguments (org.eclipse.jdt.internal.corext.refactoring.JavaRefactoringArguments)1