use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameTypeTest method testSimilarElements22.
@Test
public void testSimilarElements22() throws Exception {
// Test transplanter for fields in types inside of initializers
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "SomeClass");
IType someClass = getType(cu, "SomeClass");
List handleList = new ArrayList();
List argumentList = new ArrayList();
List similarOldHandleList = new ArrayList();
List similarNewNameList = new ArrayList();
List similarNewHandleList = new ArrayList();
final String newName = "SomeNewClass";
// field in class in initializer
IField inInitializer = someClass.getInitializer(1).getType("InInitializer", 1).getField("someClassInInitializer");
similarOldHandleList.add(inInitializer.getHandleIdentifier());
similarNewNameList.add("someNewClassInInitializer");
similarNewHandleList.add("Lp/SomeNewClass$InInitializer;.someNewClassInInitializer");
// Type Stuff
handleList.add(someClass);
argumentList.add(new RenameArguments(newName, true));
handleList.add(cu);
argumentList.add(new RenameArguments(newName + ".java", true));
handleList.add(cu.getResource());
argumentList.add(new RenameArguments(newName + ".java", true));
String[] handles = ParticipantTesting.createHandles(handleList.toArray());
RenameArguments[] arguments = (RenameArguments[]) argumentList.toArray(new RenameArguments[0]);
RenameJavaElementDescriptor descriptor = createRefactoringDescriptor(someClass, newName);
setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED);
RefactoringStatus status = performRefactoring(descriptor);
Assert.assertNull("was supposed to pass", status);
checkResultInClass(newName);
ParticipantTesting.testRename(handles, arguments);
ParticipantTesting.testSimilarElements(similarOldHandleList, similarNewNameList, similarNewHandleList);
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameTypeTest method testSimilarElements23.
@Test
public void testSimilarElements23() throws Exception {
// Test transplanter for elements inside types inside fields
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "SomeClass");
IType someClass = getType(cu, "SomeClass");
List handleList = new ArrayList();
List argumentList = new ArrayList();
List similarOldHandleList = new ArrayList();
List similarNewNameList = new ArrayList();
List similarNewHandleList = new ArrayList();
final String newName = "SomeNewClass";
// some field
IField anotherSomeClass = someClass.getField("anotherSomeClass");
similarOldHandleList.add(anotherSomeClass.getHandleIdentifier());
similarNewNameList.add("anotherSomeNewClass");
similarNewHandleList.add("Lp/SomeNewClass;.anotherSomeNewClass");
// field in class in method in field declaration ;)
IField inInner = anotherSomeClass.getType("", 1).getMethod("foo", new String[0]).getType("X", 1).getField("someClassInInner");
similarOldHandleList.add(inInner.getHandleIdentifier());
similarNewNameList.add("someNewClassInInner");
similarNewHandleList.add("Lp/SomeNewClass$1$X;.someNewClassInInner");
// Type Stuff
handleList.add(someClass);
argumentList.add(new RenameArguments(newName, true));
handleList.add(cu);
argumentList.add(new RenameArguments(newName + ".java", true));
handleList.add(cu.getResource());
argumentList.add(new RenameArguments(newName + ".java", true));
String[] handles = ParticipantTesting.createHandles(handleList.toArray());
RenameArguments[] arguments = (RenameArguments[]) argumentList.toArray(new RenameArguments[0]);
RenameJavaElementDescriptor descriptor = createRefactoringDescriptor(someClass, newName);
setTheOptions(descriptor, true, false, true, null, RenamingNameSuggestor.STRATEGY_EMBEDDED);
RefactoringStatus status = performRefactoring(descriptor);
Assert.assertNull("was supposed to pass", status);
checkResultInClass(newName);
ParticipantTesting.testRename(handles, arguments);
ParticipantTesting.testSimilarElements(similarOldHandleList, similarNewNameList, similarNewHandleList);
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class TestRenameParticipantShared method testArguments.
public static void testArguments(RenameArguments[] args) {
testNumberOfElements(args.length);
for (int i = 0; i < args.length; i++) {
RenameArguments expected = args[i];
RenameArguments actual = (RenameArguments) fgInstance.fArguments.get(i);
Assert.assertEquals(expected.getNewName(), actual.getNewName());
Assert.assertEquals(expected.getUpdateReferences(), actual.getUpdateReferences());
}
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameCompilationUnitProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() {
RenameModifications result = new RenameModifications();
result.rename(fCu, new RenameArguments(getNewElementName(), getUpdateReferences()));
if (fRenameTypeProcessor != null) {
String newTypeName = removeFileNameExtension(getNewElementName());
RenameTypeArguments arguments = new RenameTypeArguments(newTypeName, getUpdateReferences(), getUpdateSimilarDeclarations(), getSimilarElements());
result.rename(fRenameTypeProcessor.getType(), arguments, getUpdateSimilarDeclarations() ? new RenameTypeProcessor.ParticipantDescriptorFilter() : null);
}
return result;
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameFieldProcessor method computeRenameModifications.
@Override
protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
result.rename(fField, new RenameArguments(getNewElementName(), getUpdateReferences()));
if (fRenameGetter) {
IMethod getter = getGetter();
if (getter != null) {
result.rename(getter, new RenameArguments(getNewGetterName(), getUpdateReferences()));
}
}
if (fRenameSetter) {
IMethod setter = getSetter();
if (setter != null) {
result.rename(setter, new RenameArguments(getNewSetterName(), getUpdateReferences()));
}
}
return result;
}
Aggregations