use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.
the class RenamePackageTest method test2.
@Test
public void test2() throws Exception {
fIsPreDeltaTest = true;
RenamePackageProcessor processor = helper2(new String[] { "r", "fred" }, new String[][] { { "A" }, { "A" } }, "p1");
// test that participants are correctly informed after '< Back': https://bugs.eclipse.org/bugs/show_bug.cgi?id=280068
performUndo();
ParticipantTesting.reset();
String secondName = "pipapo";
processor.setNewElementName(secondName);
String[] renameHandles = ParticipantTesting.createHandles(new Object[] { processor.getPackage(), processor.getPackage().getResource() });
RenameRefactoring refactoring = (RenameRefactoring) processor.getRefactoring();
refactoring.checkFinalConditions(new NullProgressMonitor());
refactoring.createChange(new NullProgressMonitor());
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments(secondName, true), new RenameArguments(secondName, true) });
}
use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.
the class RenamePackageTest method testPackageRenameWithResource2.
// ---------- tests -------------
@Test
public void testPackageRenameWithResource2() throws Exception {
IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);
StringBuffer buf = new StringBuffer();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append("}\n");
fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
IFile file = ((IFolder) fragment.getResource()).getFile("x.properties");
byte[] content = "This is about 'org.test' and more".getBytes();
file.create(new ByteArrayInputStream(content), true, null);
file.refreshLocal(IResource.DEPTH_ONE, null);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_PACKAGE);
descriptor.setJavaElement(fragment);
descriptor.setNewName("org.test2");
descriptor.setUpdateReferences(true);
descriptor.setUpdateHierarchy(true);
descriptor.setUpdateQualifiedNames(true);
descriptor.setFileNamePatterns("*.properties");
Refactoring refactoring = createRefactoring(descriptor);
RefactoringStatus status = performRefactoring(refactoring);
if (status != null)
assertTrue(status.toString(), status.isOK());
RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
checkMappingUnchanged(jm, rm, new Object[] { getRoot().getJavaProject(), getRoot() });
IPackageFragment newFragment = getRoot().getPackageFragment("org.test2");
IFile newFile = ((IContainer) newFragment.getResource()).getFile(new Path("x.properties"));
assertEquals("This is about 'org.test2' and more", getContents(newFile));
checkMappingChanged(jm, rm, new Object[][] { { file, newFile } });
}
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, boolean references) throws Exception {
IType declaringType = getType(createCUfromTestFile(getPackageP(), "A"), typeName);
RenameTypeParameterProcessor processor = new RenameTypeParameterProcessor(declaringType.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.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.
the class RenameEnumConstRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameEnumConstProcessor processor = new RenameEnumConstProcessor(arguments, status);
return new RenameRefactoring(processor);
}
use of org.eclipse.ltk.core.refactoring.participants.RenameRefactoring in project che by eclipse.
the class RenameLocalVariableRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameLocalVariableProcessor processor = new RenameLocalVariableProcessor(arguments, status);
return new RenameRefactoring(processor);
}
Aggregations