mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
193 lines
5.3 KiB
Java
193 lines
5.3 KiB
Java
/*
|
|
* Copyright 2000-2012 JetBrains s.r.o.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package com.intellij.refactoring;
|
|
|
|
import com.intellij.JavaTestUtil;
|
|
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
|
import com.intellij.openapi.vfs.VirtualFile;
|
|
import com.intellij.psi.CommonClassNames;
|
|
import com.intellij.psi.PsiClass;
|
|
import com.intellij.psi.search.GlobalSearchScope;
|
|
import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperProcessor;
|
|
import org.jetbrains.annotations.NonNls;
|
|
|
|
public class TurnRefsToSuperTest extends MultiFileTestCase {
|
|
|
|
@Override
|
|
protected String getTestDataPath() {
|
|
return JavaTestUtil.getJavaTestDataPath();
|
|
}
|
|
|
|
public void testSuperClass() throws Exception {
|
|
doTest("AClass", "ASuper", true);
|
|
}
|
|
|
|
public void testMethodFromSuper() throws Exception {
|
|
doTest("AClass", "ASuper", true);
|
|
}
|
|
|
|
public void testRemoveImport() throws Exception {
|
|
doTest("pack1.AClass", "pack1.AnInterface", true);
|
|
}
|
|
|
|
public void testToArray() throws Exception {
|
|
doTest("A", "I", true);
|
|
}
|
|
|
|
|
|
public void testArrayElementAssignment() throws Exception {
|
|
doTest("C", "I", true);
|
|
}
|
|
|
|
public void testReturnValue() throws Exception {
|
|
doTest("A", "I", true);
|
|
}
|
|
|
|
public void testReturnValue2() throws Exception {
|
|
doTest("A", "I", true);
|
|
}
|
|
|
|
public void testCast() throws Exception {
|
|
doTest("A", "I", true);
|
|
}
|
|
|
|
|
|
public void testUseAsArg() throws Exception {
|
|
doTest("AClass", "I", true);
|
|
}
|
|
|
|
public void testClassUsage() throws Exception {
|
|
doTest("A", "I", true);
|
|
}
|
|
|
|
public void testInstanceOf() throws Exception {
|
|
doTest("A", "I", false);
|
|
}
|
|
|
|
public void testFieldTest() throws Exception {
|
|
doTest("Component1", "IDoSomething", false);
|
|
}
|
|
|
|
public void testScr34000() throws Exception {
|
|
doTest("SimpleModel", "Model", false);
|
|
}
|
|
|
|
public void testScr34020() throws Exception {
|
|
doTest(CommonClassNames.JAVA_UTIL_LIST, "java.util.Collection", false);
|
|
}
|
|
|
|
public void testCommonInheritor() throws Exception {
|
|
doTest("Client.V", "Client.L", false);
|
|
}
|
|
|
|
public void testCommonInheritorFail() throws Exception {
|
|
doTest("Client.V", "Client.L", false);
|
|
}
|
|
|
|
public void testCommonInheritorResults() throws Exception {
|
|
doTest("Client.V", "Client.L", false);
|
|
}
|
|
|
|
public void testCommonInheritorResultsFail() throws Exception {
|
|
doTest("Client.V", "Client.L", false);
|
|
}
|
|
|
|
public void testCommonInheritorResultsFail2() throws Exception {
|
|
doTest("Client.V", "Client.L", false);
|
|
}
|
|
|
|
|
|
public void testIDEA6505() throws Exception {
|
|
doTest("Impl", "IB", false);
|
|
}
|
|
|
|
public void testIDEADEV5517() throws Exception {
|
|
doTest("Xyz", "Xint", false);
|
|
}
|
|
|
|
public void testIDEADEV5517NOOP() throws Exception {
|
|
doTest("Xyz", "Xint", false);
|
|
}
|
|
|
|
public void testIDEADEV6136() throws Exception {
|
|
doTest("A", "B", false);
|
|
}
|
|
|
|
public void testIDEADEV25669() throws Exception {
|
|
doTest("p.A", "p.Base", false);
|
|
}
|
|
|
|
public void testIDEADEV23807() throws Exception {
|
|
doTest("B", "A", false);
|
|
}
|
|
|
|
public void testTypeArgumentsRH() throws Exception {
|
|
doTest("IImpl", "I", false);
|
|
}
|
|
|
|
public void testTypeArgumentsRH1() throws Exception {
|
|
doTest("IImpl", "I", false);
|
|
}
|
|
|
|
public void testAnonymousWithTypeArguments() throws Exception {
|
|
doTest("Clazz", "Intf", false);
|
|
}
|
|
|
|
public void testTypeArgumentsParam() throws Exception {
|
|
doTest("Clazz", "Intf", false);
|
|
}
|
|
|
|
public void _testStaticCallArguments() throws Exception {
|
|
doTest("Impl", "Int", false);
|
|
}
|
|
|
|
public void _testListArgs() throws Exception {
|
|
doTest("Impl", "Int", false);
|
|
}
|
|
|
|
public void _testCovariantReturnTypes() throws Exception {
|
|
doTest("Impl", "Int", false);
|
|
}
|
|
|
|
public void _testNewExpr() throws Exception {
|
|
doTest("Impl", "Int", false);
|
|
}
|
|
|
|
private void doTest(@NonNls final String className, @NonNls final String superClassName, final boolean replaceInstanceOf) throws Exception {
|
|
doTest(new PerformAction() {
|
|
@Override
|
|
public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
|
|
TurnRefsToSuperTest.this.performAction(className, superClassName, replaceInstanceOf);
|
|
}
|
|
}, true);
|
|
}
|
|
|
|
@Override
|
|
public String getTestRoot() {
|
|
return "/refactoring/turnRefsToSuper/";
|
|
}
|
|
|
|
private void performAction(final String className, final String superClassName, boolean replaceInstanceOf) {
|
|
final PsiClass aClass = myJavaFacade.findClass(className, GlobalSearchScope.allScope(myProject));
|
|
assertNotNull("Class " + className + " not found", aClass);
|
|
PsiClass superClass = myJavaFacade.findClass(superClassName, GlobalSearchScope.allScope(myProject));
|
|
assertNotNull("Class " + superClassName + " not found", superClass);
|
|
|
|
new TurnRefsToSuperProcessor(myProject, aClass, superClass, replaceInstanceOf).run();
|
|
FileDocumentManager.getInstance().saveAllDocuments();
|
|
}
|
|
}
|