This commit is contained in:
Dmitry Jemerov
2009-09-11 16:52:51 +04:00
parent 6b902c21b2
commit 709e8381fc
31 changed files with 6 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
package com.intellij.refactoring;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.refactoring.rename.RenameProcessor;
import com.intellij.JavaTestUtil;
import org.jetbrains.annotations.NonNls;
public class RenameClassTest extends MultiFileTestCase {
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testNonJava() throws Exception {
doTest("pack1.Class1", "Class1New");
}
public void testCollision() throws Exception {
doTest("pack1.MyList", "List");
}
public void testInnerClass() throws Exception {
doTest("pack1.OuterClass.InnerClass", "NewInnerClass");
}
public void testImport() throws Exception {
doTest("a.Blubfoo", "BlubFoo");
}
public void testConstructorJavadoc() throws Exception {
doTest("Test", "Test1");
}
public void testCollision1() throws Exception {
doTest("Loader", "Reader");
}
public void testImplicitReferenceToDefaultCtr() throws Exception {
doTest("pack1.Parent", "ParentXXX");
}
public void testImplicitlyImported() throws Exception {
doTest("pack1.A", "Object");
}
private void doTest(@NonNls final String qClassName, @NonNls final String newName) throws Exception {
doTest(new PerformAction() {
public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
RenameClassTest.this.performAction(qClassName, newName);
}
});
}
private void performAction(String qClassName, String newName) throws Exception {
PsiClass aClass = myJavaFacade.findClass(qClassName);
assertNotNull("Class " + qClassName + " not found", aClass);
new RenameProcessor(myProject, aClass, newName, true, true).run();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
}
protected String getTestRoot() {
return "/refactoring/renameClass/";
}
}