Search in sources :

Example 26 with RenameRefactoring

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) });
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) RenamePackageProcessor(org.eclipse.jdt.internal.corext.refactoring.rename.RenamePackageProcessor) RenameArguments(org.eclipse.ltk.core.refactoring.participants.RenameArguments) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) Test(org.junit.Test)

Example 27 with RenameRefactoring

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 } });
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IFile(org.eclipse.core.resources.IFile) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IResourceMapper(org.eclipse.ltk.core.refactoring.IResourceMapper) ByteArrayInputStream(java.io.ByteArrayInputStream) RefactoringProcessor(org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor) IJavaElementMapper(org.eclipse.jdt.core.refactoring.IJavaElementMapper) RenameJavaElementDescriptor(org.eclipse.jdt.core.refactoring.descriptors.RenameJavaElementDescriptor) IContainer(org.eclipse.core.resources.IContainer) Refactoring(org.eclipse.ltk.core.refactoring.Refactoring) RenameRefactoring(org.eclipse.ltk.core.refactoring.participants.RenameRefactoring) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 28 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, 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);
}
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) IType(org.eclipse.jdt.core.IType)

Example 29 with RenameRefactoring

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

Example 30 with RenameRefactoring

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

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