use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenamePackageTest method testHierarchical01.
@Test
public void testHierarchical01() throws Exception {
fRenameSubpackages = true;
PackageRename rename = new PackageRename(new String[] { "my", "my.a", "my.b" }, new String[][] { { "MyA" }, { "ATest" }, { "B" } }, "your");
IPackageFragment thisPackage = rename.fPackages[0];
ParticipantTesting.reset();
List toRename = new ArrayList(Arrays.asList(JavaElementUtil.getPackageAndSubpackages(thisPackage)));
toRename.add(thisPackage.getResource());
String[] renameHandles = ParticipantTesting.createHandles(toRename.toArray());
rename.execute();
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments(rename.getNewPackageName(rename.fPackageNames[0]), true), new RenameArguments(rename.getNewPackageName(rename.fPackageNames[1]), true), new RenameArguments(rename.getNewPackageName(rename.fPackageNames[2]), true), new RenameArguments("your", true) });
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments 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.RenameArguments in project che by eclipse.
the class RenameTypeTest method testSimilarElements11.
@Test
public void testSimilarElements11() throws Exception {
//Assure participants get notified of normal stuff (type rename
//and resource changes) AND similarly named elements.
ParticipantTesting.reset();
ICompilationUnit cu = createCUfromTestFile(getPackageP(), "SomeClass");
IType someClass = getType(cu, "SomeClass");
IType other = getClassFromTestFile(getPackageP(), "SomeOtherClass");
List handleList = new ArrayList();
List argumentList = new ArrayList();
List similarOldHandleList = new ArrayList();
List similarNewNameList = new ArrayList();
List similarNewHandleList = new ArrayList();
final String newName = "SomeNewClass";
// f-Field + getters/setters
IField f3 = other.getField("fSomeClass");
similarOldHandleList.add(f3.getHandleIdentifier());
similarNewHandleList.add("Lp/SomeOtherClass;.fSomeNewClass");
similarNewNameList.add("fSomeNewClass");
IMethod m3 = other.getMethod("getSomeClass", new String[0]);
similarOldHandleList.add(m3.getHandleIdentifier());
similarNewNameList.add("getSomeNewClass");
similarNewHandleList.add("Lp/SomeOtherClass;.getSomeNewClass()V");
IMethod m4 = other.getMethod("setSomeClass", new String[] { "QSomeClass;" });
similarOldHandleList.add(m4.getHandleIdentifier());
similarNewNameList.add("setSomeNewClass");
similarNewHandleList.add("Lp/SomeOtherClass;.setSomeNewClass(QSomeNewClass;)V");
// non-f-field + getter/setters
IField f1 = someClass.getField("someClass");
similarOldHandleList.add(f1.getHandleIdentifier());
similarNewNameList.add("someNewClass");
similarNewHandleList.add("Lp/SomeNewClass;.someNewClass");
IMethod m1 = someClass.getMethod("getSomeClass", new String[0]);
similarOldHandleList.add(m1.getHandleIdentifier());
similarNewNameList.add("getSomeNewClass");
similarNewHandleList.add("Lp/SomeNewClass;.getSomeNewClass()V");
IMethod m2 = someClass.getMethod("setSomeClass", new String[] { "QSomeClass;" });
similarOldHandleList.add(m2.getHandleIdentifier());
similarNewNameList.add("setSomeNewClass");
similarNewHandleList.add("Lp/SomeNewClass;.setSomeNewClass(QSomeNewClass;)V");
// fs-field
IField f2 = someClass.getField("fsSomeClass");
similarOldHandleList.add(f2.getHandleIdentifier());
similarNewNameList.add("fsSomeNewClass");
similarNewHandleList.add("Lp/SomeNewClass;.fsSomeNewClass");
// 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);
checkResultInClass("SomeOtherClass");
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 test0.
@Test
public void test0() throws Exception {
ParticipantTesting.reset();
String newName = "B";
String[] renameHandles = helper2("A", newName);
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments(newName, true), new RenameArguments(newName + ".java", true), new RenameArguments(newName + ".java", true) });
}
use of org.eclipse.ltk.core.refactoring.participants.RenameArguments in project che by eclipse.
the class RenameTypeTest method test61.
@Test
public void test61() throws Exception {
ParticipantTesting.reset();
String[] renameHandles = helperWithTextual("A", "Inner", "InnerB", "A", true, false);
ParticipantTesting.testRename(renameHandles, new RenameArguments[] { new RenameArguments("InnerB", true) });
}
Aggregations