use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor in project che by eclipse.
the class RenameTypeTest method checkMappedSimilarElementsExist.
private void checkMappedSimilarElementsExist(Refactoring ref) {
RenameTypeProcessor rtp = (RenameTypeProcessor) ((RenameRefactoring) ref).getProcessor();
IJavaElementMapper mapper = (IJavaElementMapper) rtp.getAdapter(IJavaElementMapper.class);
IJavaElement[] similarElements = rtp.getSimilarElements();
if (similarElements == null)
return;
for (int i = 0; i < similarElements.length; i++) {
IJavaElement element = similarElements[i];
if (!(element instanceof ILocalVariable)) {
IJavaElement newElement = mapper.getRefactoredJavaElement(element);
TestCase.assertTrue(newElement.exists());
Assert.assertFalse(element.exists());
}
}
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor in project che by eclipse.
the class RenameTypeRefactoringContribution method createRefactoring.
/**
* {@inheritDoc}
*/
@Override
public Refactoring createRefactoring(JavaRefactoringDescriptor descriptor, RefactoringStatus status) {
JavaRefactoringArguments arguments = new JavaRefactoringArguments(descriptor.getProject(), retrieveArgumentMap(descriptor));
RenameTypeProcessor processor = new RenameTypeProcessor(arguments, status);
return new RenameRefactoring(processor);
}
use of org.eclipse.jdt.internal.corext.refactoring.rename.RenameTypeProcessor in project che by eclipse.
the class RenameTypeTest method checkMappers.
private void checkMappers(Refactoring refactoring, IType type, String newCUName, IJavaElement[] someClassMembers) {
RenameTypeProcessor rtp = (RenameTypeProcessor) ((RenameRefactoring) refactoring).getProcessor();
ICompilationUnit newUnit = (ICompilationUnit) rtp.getRefactoredJavaElement(type.getCompilationUnit());
TestCase.assertTrue(newUnit.exists());
TestCase.assertTrue(newUnit.getElementName().equals(newCUName));
IFile newFile = (IFile) rtp.getRefactoredResource(type.getResource());
TestCase.assertTrue(newFile.exists());
TestCase.assertTrue(newFile.getName().equals(newCUName));
if ((type.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) && type.getCompilationUnit().getElementName().equals(type.getElementName() + ".java")) {
Assert.assertFalse(type.getCompilationUnit().exists());
Assert.assertFalse(type.getResource().exists());
}
IPackageFragment oldPackage = (IPackageFragment) type.getCompilationUnit().getParent();
IPackageFragment newPackage = (IPackageFragment) rtp.getRefactoredJavaElement(oldPackage);
Assert.assertEquals(oldPackage, newPackage);
for (int i = 0; i < someClassMembers.length; i++) {
IMember member = (IMember) someClassMembers[i];
IJavaElement refactoredMember = rtp.getRefactoredJavaElement(member);
if (member instanceof IMethod && member.getElementName().equals(type.getElementName()))
// constructor
continue;
TestCase.assertTrue(refactoredMember.exists());
Assert.assertEquals(member.getElementName(), refactoredMember.getElementName());
Assert.assertFalse(refactoredMember.equals(member));
}
}
Aggregations