summaryrefslogtreecommitdiff
path: root/plugins/typeMigration/test/com
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/typeMigration/test/com')
-rw-r--r--plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java30
-rw-r--r--plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java30
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java26
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java148
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java561
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java100
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java44
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java883
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java193
-rw-r--r--plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java170
10 files changed, 0 insertions, 2185 deletions
diff --git a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java b/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java
deleted file mode 100644
index 4a0b73dde767..000000000000
--- a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.intellij.codeInsight;
-
-import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
-import com.intellij.openapi.application.PluginPathManager;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author anna
- */
-public class ConvertToAtomicIntentionTest extends LightQuickFixParameterizedTestCase {
- @Override
- protected boolean shouldBeAvailableAfterExecution() {
- return true;
- }
-
- @Override
- protected String getBasePath() {
- return "/intentions/atomic";
- }
-
- @NotNull
- @Override
- protected String getTestDataPath() {
- return PluginPathManager.getPluginHomePath("typeMigration") + "/testData";
- }
-
- public void test() throws Exception {
- doAllTests();
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java b/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java
deleted file mode 100644
index 389ced7354af..000000000000
--- a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.intellij.codeInsight;
-
-import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
-import com.intellij.openapi.application.PluginPathManager;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author anna
- */
-public class ConvertToThreadLocalIntentionTest extends LightQuickFixParameterizedTestCase {
- @Override
- protected boolean shouldBeAvailableAfterExecution() {
- return true;
- }
-
- @Override
- protected String getBasePath() {
- return "/intentions/threadLocal";
- }
-
- @NotNull
- @Override
- protected String getTestDataPath() {
- return PluginPathManager.getPluginHomePath("typeMigration") + "/testData";
- }
-
- public void test() throws Exception {
- doAllTests();
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java b/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java
deleted file mode 100644
index 2fb8d9054628..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * User: anna
- * Date: 04-Aug-2008
- */
-package com.intellij.refactoring;
-
-import com.intellij.codeInsight.ConvertToAtomicIntentionTest;
-import com.intellij.codeInsight.ConvertToThreadLocalIntentionTest;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTypeMigrationTests {
- @SuppressWarnings({"UnusedDeclaration"})
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTestSuite(TypeMigrationTest.class);
- suite.addTestSuite(TypeMigrationByAtomicRuleTest.class);
- suite.addTestSuite(TypeMigrationByThreadLocalRuleTest.class);
- suite.addTestSuite(MigrateTypeSignatureTest.class);
- suite.addTestSuite(ChangeTypeSignatureTest.class);
- suite.addTestSuite(WildcardTypeMigrationTest.class);
- suite.addTestSuite(ConvertToAtomicIntentionTest.class);
- suite.addTestSuite(ConvertToThreadLocalIntentionTest.class);
- return suite;
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java b/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java
deleted file mode 100644
index e85b2f79fd30..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * User: anna
- * Date: 18-Mar-2008
- */
-package com.intellij.refactoring;
-
-import com.intellij.openapi.application.PluginPathManager;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.PsiImmediateClassType;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.typeMigration.TypeMigrationLabeler;
-import com.intellij.refactoring.typeMigration.TypeMigrationProcessor;
-import com.intellij.refactoring.typeMigration.TypeMigrationRules;
-import com.intellij.testFramework.LightCodeInsightTestCase;
-import org.jetbrains.annotations.NotNull;
-
-public class ChangeTypeSignatureTest extends LightCodeInsightTestCase {
- @NotNull
- @Override
- protected String getTestDataPath() {
- return PluginPathManager.getPluginHomePath("typeMigration") + "/testData";
- }
-
- private void doTest(boolean success, String migrationTypeText) throws Exception {
- String dataPath = "/refactoring/changeTypeSignature/";
- configureByFile(dataPath + getTestName(false) + ".java");
- final PsiFile file = getFile();
- final PsiElement element = file.findElementAt(getEditor().getCaretModel().getOffset());
- final PsiReferenceParameterList parameterList = PsiTreeUtil.getParentOfType(element, PsiReferenceParameterList.class);
- assert parameterList != null;
- final PsiClass superClass = (PsiClass)((PsiJavaCodeReferenceElement)parameterList.getParent()).resolve();
- assert superClass != null;
-
- PsiType migrationType = getJavaFacade().getElementFactory().createTypeFromText(migrationTypeText, null);
-
- try {
- final TypeMigrationRules rules = new TypeMigrationRules(TypeMigrationLabeler.getElementType(parameterList));
- rules.setMigrationRootType(PsiSubstitutor.EMPTY.put(superClass.getTypeParameters()[0], migrationType).substitute(new PsiImmediateClassType(superClass, PsiSubstitutor.EMPTY)));
- rules.setBoundScope(GlobalSearchScope.projectScope(getProject()));
- new TypeMigrationProcessor(getProject(), parameterList, rules).run();
- if (success) {
- checkResultByFile(dataPath + getTestName(false) + ".java.after");
- } else {
- fail("Conflicts should be detected");
- }
- }
- catch (RuntimeException e) {
- if (success) {
- e.printStackTrace();
- fail("Conflicts should not appear");
- }
- }
- }
-
- private void doTest(boolean success) throws Exception {
- doTest(success, CommonClassNames.JAVA_LANG_OBJECT);
- }
-
- public void testListTypeArguments() throws Exception {
- doTest(true);
- }
-
- public void testFieldUsage() throws Exception {
- doTest(true);
- }
-
- public void testFieldUsage1() throws Exception {
- doTest(true);
- }
-
- public void testReturnType() throws Exception {
- doTest(true);
- }
-
- public void testReturnType1() throws Exception {
- doTest(true);
- }
-
- public void testReturnType2() throws Exception {
- doTest(true);
- }
-
- public void testPassedParameter() throws Exception {
- doTest(true);
- }
-
- public void testPassedParameter1() throws Exception {
- doTest(true, "java.lang.Integer");
- }
-
- public void testPassedParameter2() throws Exception {
- doTest(true);
- }
-
- public void testUsedInSuper() throws Exception {
- doTest(true);
- }
-
- public void testCompositeReturnType() throws Exception {
- doTest(true);
- }
-
- public void testTypeHierarchy() throws Exception {
- doTest(true);
- }
-
- public void testTypeHierarchy1() throws Exception {
- doTest(true);
- }
-
- public void testTypeHierarchy2() throws Exception {
- doTest(true);
- }
-
- public void testTypeHierarchyFieldUsage() throws Exception {
- doTest(true);
- }
-
- public void testTypeHierarchyFieldUsageConflict() throws Exception {
- doTest(true);
- }
-
- public void testParameterMigration() throws Exception {
- doTest(true);
- }
-
- public void testParameterMigration1() throws Exception {
- doTest(true, "java.lang.Integer");
- }
-
- public void testParameterMigration2() throws Exception {
- doTest(true, "java.lang.Integer");
- }
-
- public void testFieldTypeMigration() throws Exception {
- doTest(true, "java.lang.String");
- }
-
- public void testMethodReturnTypeMigration() throws Exception {
- doTest(true, "java.lang.Integer");
- }
-
- @Override
- protected boolean isRunInWriteAction() {
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java b/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java
deleted file mode 100644
index 7889306ed6f0..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * User: anna
- * Date: 30-Apr-2008
- */
-package com.intellij.refactoring;
-
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiEllipsisType;
-import com.intellij.psi.PsiType;
-import org.jetbrains.annotations.NotNull;
-
-public class MigrateTypeSignatureTest extends TypeMigrationTestBase {
- @NotNull
- @Override
- public String getTestRoot() {
- return "/refactoring/migrateTypeSignature/";
- }
-
- public void testExprAccess2Lvalue() throws Exception {
- doTestFieldType("myForAccess", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null));
- }
-
- public void testExprAccess2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassGrandChild", null));
- }
-
- public void testExprAccessParent2Lvalue() throws Exception {
- doTestFieldType("myForSuperAccess", "Ession",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null));
- }
-
- public void testExprAccessParent2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassGrandChild", null));
- }
-
- public void testExprArrayAccessNegative() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.DOUBLE);
- }
-
- public void testExprArrayAccessPositive() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.CHAR);
- }
-
- public void testExprCalcBooleanBoolean() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.BOOLEAN, PsiType.INT);
- }
-
- public void testExprCalcBooleanNumeric() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testExprCalcBooleanReference() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- PsiType.DOUBLE);
- }
-
- public void testExprCalcNumeric2Boolean() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.BOOLEAN);
- }
-
- public void testExprCalcNumeric2Floating() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.FLOAT);
- }
-
- public void testExprCalcNumeric2Int() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.LONG);
- }
-
- public void testExprCalcNumeric2String() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprCast2LvalueNeg() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.BYTE,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprCast2LvaluePos() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.BYTE, PsiType.INT);
- }
-
- public void testExprConcatNumeric2Reference() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testExprConcatNumeric2String() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprConcatString2Numeric() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- PsiType.INT);
- }
-
- public void testExprConcatString2Reference() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testExprInstanceofNeg() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null));
- }
-
- public void testExprInstanceofPos() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_MAP, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.AbstractMap", null));
- }
-
- public void testExprLiteralBoolean() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.BOOLEAN);
- }
-
- public void testExprLiteralByte() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.BYTE);
- }
-
- public void testExprLiteralChar() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.CHAR);
- }
-
- public void testExprLiteralClassExtends() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<? extends java.util.Collection[]>", null));
- }
-
- public void testExprLiteralClassPrimitive() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<Integer>", null));
- }
-
- public void testExprLiteralClassPrimitiveArray() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<int[]>", null));
- }
-
- public void testExprLiteralClassRaw() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class", null));
- }
-
- public void testExprLiteralClassReference() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<java.util.Set>", null));
- }
-
- public void testExprLiteralClassReferenceArray() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<java.util.Set[]>", null));
- }
-
- public void testExprLiteralClassSuper() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<? super java.util.AbstractSet[]>", null));
- }
-
- public void testExprLiteralDouble() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.DOUBLE);
- }
-
- public void testExprLiteralFloat() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.FLOAT);
- }
-
- public void testExprLiteralInt() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.INT);
- }
-
- public void testExprLiteralLong() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.LONG);
- }
-
- public void testExprLiteralShort() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- PsiType.SHORT);
- }
-
- public void testExprLiteralString() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprNewArrayArray2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null).createArrayType());
- }
-
- public void testExprNewArrayArray2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType().createArrayType().createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null).createArrayType().createArrayType().createArrayType());
- }
-
- public void testExprNewArrayGen2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<java.lang.Integer>", null).createArrayType());
- }
-
- public void testExprNewArrayPrimitive2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.BOOLEAN, PsiType.INT);
- }
-
- public void testExprNewArrayPrimitive2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- PsiType.BOOLEAN.createArrayType().createArrayType(),
- PsiType.INT.createArrayType().createArrayType());
- }
-
- public void testExprNewArrayReftype2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null));
- }
-
- public void testExprNewArrayReftype2Rvalue() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType().createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null).createArrayType().createArrayType());
- }
-
- public void testExprNewGen() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null));
- }
-
- public void testExprNewGenExtends() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends Subject>", null));
- }
-
- public void testExprNewGenSuper() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super Subject>", null));
- }
-
- public void testExprNewReference() throws Exception {
- doTestFieldType("myField", "Expr",
- myJavaFacade.getElementFactory().createTypeFromText("Expr.Ancestor", null),
- myJavaFacade.getElementFactory().createTypeFromText("Expr.Subject", null));
- }
-
- public void testExprReturn2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprReturn2Rvalue() throws Exception {
- doTestMethodType("meth", "Expr", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testExprTernary() throws Exception {
- doTestFirstParamType("meth", "Expr", PsiType.DOUBLE,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testOverridingDown() throws Exception {
- doTestMethodType("getInt", "Parent", PsiType.INT, PsiType.BYTE);
- }
-
- public void testOverridingUp() throws Exception {
- doTestMethodType("getInt", "Child", PsiType.INT, PsiType.BYTE);
- }
-
- public void testSpecJavadoc() throws Exception {
- doTestFirstParamType("meth", "Spec", PsiType.DOUBLE,
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null));
- }
-
- public void testSpecNotUsed() throws Exception {
- doTestFieldType("myField", "Spec", PsiType.INT, PsiType.BOOLEAN);
- }
-
- public void testTypeArrayReftype2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType());
- }
-
- public void testTypeArrayReftype2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType().createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType().createArrayType());
- }
-
- public void testTypeArrayRoots2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Holder", null),
- myJavaFacade.getElementFactory().createTypeFromText("Holder", null).createArrayType());
- }
-
- public void testTypeArrayVararg2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType(),
- new PsiEllipsisType(myJavaFacade.getElementFactory().createTypeFromText("Subject", null)));
- }
-
- public void testTypeArrayVararg2RvalueNeg() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType());
- }
-
- public void testTypeArrayVararg2RvaluePos() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType());
- }
-
- public void testTypeAutoboxBoolean2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BOOLEAN,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Boolean", null));
- }
-
- public void testTypeAutoboxBoolean2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Boolean", null),
- PsiType.BOOLEAN);
- }
-
- public void testTypeAutoboxByte2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Byte", null));
- }
-
- public void testTypeAutoboxByte2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Byte", null),
- PsiType.BYTE);
- }
-
- public void testTypeAutoboxChar2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.CHAR,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Character", null));
- }
-
- public void testTypeAutoboxChar2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Character", null),
- PsiType.CHAR);
- }
-
- public void testTypeAutoboxDouble2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.DOUBLE,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Double", null));
- }
-
- public void testTypeAutoboxDouble2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Double", null),
- PsiType.DOUBLE);
- }
-
- public void testTypeAutoboxFloat2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.FLOAT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Float", null));
- }
-
- public void testTypeAutoboxFloat2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Float", null),
- PsiType.FLOAT);
- }
-
- public void testTypeAutoboxInt2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.INT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null));
- }
-
- public void testTypeAutoboxInt2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null),
- PsiType.INT);
- }
-
- public void testTypeAutoboxLong2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.LONG,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Long", null));
- }
-
- public void testTypeAutoboxLong2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Long", null),
- PsiType.LONG);
- }
-
- public void testTypeAutoboxShort2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.SHORT,
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Short", null));
- }
-
- public void testTypeAutoboxShort2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Short", null),
- PsiType.SHORT);
- }
-
- public void testTypeGenAncestor2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null));
- }
-
- public void testTypeGenAncestorWildcard2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends Subject>", null));
- }
-
- public void testTypeGenDescendant2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null));
- }
-
- public void testTypeGenDescendantWildcard2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super Subject>", null));
- }
-
- public void testTypeGenRaw2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Any>", null),
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null));
- }
-
- public void testTypeGenRaw2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Any>", null),
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null));
- }
-
- public void testTypePrimsubBoolean2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.INT, PsiType.BOOLEAN);
- }
-
- public void testTypePrimsubBoolean2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.INT, PsiType.BOOLEAN);
- }
-
- public void testTypePrimsubByte2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.BYTE);
- }
-
- public void testTypePrimsubChar2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.CHAR);
- }
-
- public void testTypePrimsubChar2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.CHAR);
- }
-
- public void testTypePrimsubDouble2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.DOUBLE);
- }
-
- public void testTypePrimsubFloat2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.FLOAT);
- }
-
- public void testTypePrimsubFloat2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.FLOAT);
- }
-
- public void testTypePrimsubInt2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.INT);
- }
-
- public void testTypePrimsubInt2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.INT);
- }
-
- public void testTypePrimsubLong2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.LONG);
- }
-
- public void testTypePrimsubLong2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.LONG);
- }
-
- public void testTypePrimsubShort2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.SHORT);
- }
-
- public void testTypePrimsubShort2Rvalue() throws Exception {
- doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.SHORT);
- }
-
- public void testTypeRefClassChild2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null));
- }
-
- public void testTypeRefClassParent2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null));
- }
-
- public void testTypeRefClassParent2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null),
- myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null));
- }
-
- public void testTypeRefFaceChild2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null));
- }
-
- public void testTypeRefFaceChild2Rvalue() throws Exception {
- doTestFieldType("myField", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null),
- myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null));
- }
-
- public void testTypeRefFaceParent2Lvalue() throws Exception {
- doTestFirstParamType("meth", "Type",
- myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null),
- myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null));
- }
-}
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java
deleted file mode 100644
index 80658077e986..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * User: anna
- * Date: 19-Aug-2009
- */
-package com.intellij.refactoring;
-
-import com.intellij.psi.PsiType;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.concurrent.atomic.AtomicReferenceArray;
-import java.util.concurrent.atomic.AtomicIntegerArray;
-
-public class TypeMigrationByAtomicRuleTest extends TypeMigrationTestBase{
- @NotNull
- @Override
- protected String getTestRoot() {
- return "/refactoring/typeMigrationByAtomic/";
- }
-
- private void doTestDirectMigration() throws Exception {
- doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null));
- }
-
-
- public void testDirectIncrementDecrement() throws Exception {
- doTestDirectMigration();
- }
-
- public void testDirectAssignments() throws Exception {
- doTestDirectMigration();
- }
-
- public void testDirectConditions() throws Exception {
- doTestFieldType("b", PsiType.BOOLEAN, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null));
- }
-
-
- public void testDirectByte() throws Exception {
- doTestFieldType("b", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null));
- }
-
- public void testDirectString() throws Exception {
- doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null));
- }
-
- public void testDirectForeach() throws Exception {
- doTestFieldType("lst", myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.util.List<java.lang.String>>", null));
- }
-
- public void testDirectStringArray() throws Exception {
- doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText(AtomicReferenceArray.class.getName() + "<java.lang.String>", null));
- }
-
- public void testDirectIntArray() throws Exception {
- doTestFieldType("a", PsiType.INT.createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText(AtomicIntegerArray.class.getName(), null));
- }
-
- private void doTestReverseMigration() throws Exception {
- doTestFieldType("i", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null), PsiType.INT);
- }
-
-
- public void testReverseIncrementDecrement() throws Exception {
- doTestReverseMigration();
- }
-
- public void testReverseAssignments() throws Exception {
- doTestReverseMigration();
- }
-
- public void testReverseConditions() throws Exception {
- doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null), PsiType.BOOLEAN);
- }
-
- public void testReverseByte() throws Exception {
- doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null), PsiType.BYTE);
- }
-
- public void testReverseString() throws Exception {
- doTestFieldType("s",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null));
- }
-
- public void testReverseStringArray() throws Exception {
- doTestFieldType("s",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testReverseIntArray() throws Exception {
- doTestFieldType("a",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicIntegerArray", null),
- PsiType.INT.createArrayType());
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java
deleted file mode 100644
index 5d002d3fcced..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * User: anna
- * Date: 19-Aug-2009
- */
-package com.intellij.refactoring;
-
-import com.intellij.psi.PsiType;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import org.jetbrains.annotations.NotNull;
-
-public class TypeMigrationByThreadLocalRuleTest extends TypeMigrationTestBase{
- @NotNull
- @Override
- protected String getTestRoot() {
- return "/refactoring/typeMigrationByThreadLocal/";
- }
-
-
- public void testDirectInt() throws Exception {
- doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Integer>", null));
- }
-
- public void testDirectByte() throws Exception {
- doTestFieldType("i", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Byte>", null));
- }
-
- public void testDirectString() throws Exception {
- doTestFieldType("myS", PsiType.getJavaLangString(myPsiManager, GlobalSearchScope.allScope(myProject)), myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.String>", null));
- }
-
- public void testLanguageLevel() throws Exception {
- final LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(getProject());
- final LanguageLevel languageLevel = extension.getLanguageLevel();
- try {
- extension.setLanguageLevel(LanguageLevel.JDK_1_3);
- doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal", null));
- }
- finally {
- extension.setLanguageLevel(languageLevel);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java
deleted file mode 100644
index b3c36dca19f2..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java
+++ /dev/null
@@ -1,883 +0,0 @@
-package com.intellij.refactoring;
-
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.typeMigration.TypeMigrationRules;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author db
- * @since 22.07.2003
- */
-public class TypeMigrationTest extends TypeMigrationTestBase {
- private PsiElementFactory myFactory;
-
- @NotNull
- @Override
- public String getTestRoot() {
- return "/refactoring/typeMigration/";
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST);
- myFactory = myJavaFacade.getElementFactory();
- }
-
- public void testT07() {
- doTestFieldType("f",
- PsiType.INT.createArrayType(),
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType());
- }
-
- public void testT08() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT09() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT10() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- public void testT11() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Map<java.lang.Integer, java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.Integer>", null));
- }
-
- public void testT12() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- public void testT13() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null));
- }
-
- public void testT14() {
- doTestFieldType("f",
- myFactory.createTypeFromText("B", null),
- myFactory.createTypeFromText("A", null));
- }
-
- //do not touch javadoc refs etc
- public void testT15() {
- doTestFieldType("f",
- myFactory.createTypeFromText("B", null),
- myFactory.createTypeFromText("A", null));
- }
-
- //do not touch signature with method type parameters
- public void testT16() {
- doTestFieldType("f",
- myFactory.createTypeFromText("A", null),
- myFactory.createTypeFromText("B", null));
- }
-
- //change method signature inspired by call on parameters
- public void testT17() {
- doTestFieldType("f",
- myFactory.createTypeFromText("A", null),
- myFactory.createTypeFromText("B", null));
- }
-
- //extending iterable -> used in foreach statement
- public void testT18() {
- doTestFieldType("f",
- myFactory.createTypeFromText("A", null),
- myFactory.createTypeFromText("B", null));
- }
-
- public void testT19() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.String>", null),
- myFactory.createTypeFromText("java.util.HashMap<java.lang.Integer, java.lang.Integer>", null));
- }
-
- public void testT20() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.HashMap<java.lang.Integer, java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.String>", null));
- }
-
- public void testT21() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Map<java.lang.String, java.util.List<java.lang.String>>",
- null),
- myFactory.createTypeFromText("java.util.Map<java.lang.String, java.util.Set<java.lang.String>>",
- null)
- );
- }
-
- //varargs : removed after migration?!
- public void testT22() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.String", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- //substitution from super class: type params substitution needed
- public void testT23() {
- doTestFieldType("f",
- myFactory.createTypeFromText("HashMap<java.lang.String, java.util.Set<java.lang.String>>", null),
- myFactory.createTypeFromText("HashMap<java.lang.String, java.util.List<java.lang.String>>", null));
- }
-
- //check return type unchanged when it is possible
- public void testT24() {
- doTestFieldType("f",
- myFactory.createTypeFromText("C", null),
- myFactory.createTypeFromText("D", null));
- }
-
- public void testT25() {
- doTestFieldType("f",
- myFactory.createTypeFromText("C", null),
- myFactory.createTypeFromText("D", null));
- }
-
- //check param type change
- public void testT26() {
- doTestFieldType("f",
- myFactory.createTypeFromText("C", null),
- myFactory.createTypeFromText("D", null));
- }
-
- public void testT27() {
- doTestFieldType("f",
- myFactory.createTypeFromText("C", null),
- myFactory.createTypeFromText("D", null));
- }
-
- //list --> array
- public void testT28() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT29() {
- doTestMethodType("get",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- public void testT30() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
-
- public void testT31() {
- doTestFieldType("f",
- myFactory.createTypeFromText("Test", null),
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- //non code usages
- public void testT32() {
- doTestFirstParamType("bar",
- myFactory.createTypeFromText("long", null),
- myFactory.createTypeFromText("int", null));
- }
-
- //change type arguments for new expressions: l = new ArrayList<String>() -> l = new ArrayList<Integer>()
- public void testT33() {
- doTestFieldType("l",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null));
- }
-
- //new expression new ArrayList<String>() should be left without modifications
- public void testT34() {
- doTestFieldType("l",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.util.AbstractList<java.lang.String>", null));
- }
-
- public void testT35() {
- doTestFieldType("myParent",
- myFactory.createTypeFromText("Test", null),
- myFactory.createTypeFromText("TestImpl", null));
- }
-
- //co-variant/contra-variant positions for primitive types 36-39
- public void testT36() {
- doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE);
- }
-
- public void testT37() {
- doTestFirstParamType("foo", PsiType.SHORT, PsiType.INT);
- }
-
- public void testT38() {
- doTestFirstParamType("foo", PsiType.SHORT, PsiType.LONG);
- }
-
- public void testT39() {
- doTestFirstParamType("foo", PsiType.SHORT, PsiType.BYTE);
- }
-
- //Set s = new HashSet() -> HashSet s = new HashSet();
- public void testT40() {
- doTestFieldType("l",
- myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null),
- myFactory.createTypeFromText("java.util.ArrayList", null));
- }
-
- //Set s = new HashSet<String>() -> HashSet s = new HashSet<String>();
- public void testT41() {
- doTestFieldType("l",
- myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null),
- myFactory.createTypeFromText("java.util.ArrayList", null));
- }
-
- //Set s = new HashSet() -> HashSet<String> s = new HashSet();
- public void testT42() {
- doTestFieldType("l",
- myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null),
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.String>", null));
- }
-
- //long l; Object o = l -> long l; Long o = l;
- public void testT43() {
- doTestFieldType("o",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myFactory.createTypeFromText("java.lang.Long", null));
- }
-
- //long l; int i; l = i; -> long l; byte i; l = i;
- public void testT44() {
- doTestFieldType("i", PsiType.INT, PsiType.BYTE);
- }
-
- //long l; int i; l = i; -> byte l; -> byte i; l = i;
- public void testT45() {
- doTestFieldType("l", PsiType.LONG, PsiType.BYTE);
- }
-
- //byte i; long j = i; -> byte i; int j = i;
- public void testT46() {
- doTestFieldType("j", PsiType.LONG, PsiType.INT);
- }
-
- //o = null -? int o = null
- public void testT47() {
- doTestFieldType("o", myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), PsiType.INT);
- }
-
- //co-variant/contra-variant assignments: leave types if possible change generics signature only 48-49
- // foo(AbstractSet<String> s){Set<String> ss = s} -> foo(AbstractSet<Integer> s){Set<Integer> ss = s}
- public void testT48() {
- doTestFirstParamType("foo",
- myFactory.createTypeFromText("java.util.AbstractSet<A>", null),
- myFactory.createTypeFromText("java.util.AbstractSet<B>", null));
- }
-
- // Set<String> f; foo(AbstractSet<String> s){f = s} -> Set<Integer>f; foo(AbstractSet<Integer> s){f = s}
- public void testT49() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Set<A>", null),
- myFactory.createTypeFromText("java.util.Set<B>", null));
- }
-
- //captured wildcard: Set<? extends JComponent> s; Set<? extends JComponent> c1 = s; ->
- // Set<? extends JButton> s; Set<? extends JButton> c1 = s;
- public void testT50() {
- doTestFieldType("c1",
- myFactory.createTypeFromText("java.util.Set<? extends JComponent>", null),
- myFactory.createTypeFromText("java.util.Set<? extends JButton>", null));
- }
-
- //array initialization: 51-52
- public void testT51() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType());
- }
-
- public void testT52() {
- doTestFieldType("f",
- myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null).createArrayType(),
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType());
- }
-
- //generic type promotion to array initializer
- public void testT53() {
- doTestFieldType("f",
- PsiType.DOUBLE.createArrayType(),
- myFactory.createTypeFromText("java.util.Set<java.lang.String>", null).createArrayType());
- }
-
- //wildcard type promotion to expressions 54-55
- public void testT54() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Set<java.lang.Object>", null),
- myFactory.createTypeFromText("java.util.Set<? extends java.lang.Integer>", null));
- }
-
- public void testT55() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Set<java.lang.Object>", null),
- myFactory.createTypeFromText("java.util.Set<?>", null));
- }
-
- //array index should be integer 56-57
- public void testT56() {
- doTestFirstParamType("foo", PsiType.INT, PsiType.DOUBLE);
- }
-
- public void testT57() {
- doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE);
- }
-
- //Arrays can be assignable to Object/Serializable/Cloneable 58-59; ~ 60 varargs
- public void testT58() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testT59() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.lang.Cloneable", null));
- }
-
- public void testT60() {
- doTestFieldType("p",
- PsiType.INT.createArrayType(),
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- //change parameter type -> vararg; assignment changed to array
- public void testT61() {
- doTestFirstParamType("foo", PsiType.INT, new PsiEllipsisType(PsiType.INT));
- }
-
- //change field type -> change vararg parameter type due to assignment: 62-63
- public void testT62() {
- doTestFieldType("p", PsiType.INT.createArrayType(), myFactory.createTypeFromText(
- CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testT63() {
- doTestFieldType("p", PsiType.INT.createArrayType(), PsiType.DOUBLE.createArrayType());
- }
-
- //remove vararg type: 64-66
- public void testT64() {
- doTestFirstParamType("foo", new PsiEllipsisType(PsiType.INT), PsiType.INT);
- }
-
- public void testT65() {
- doTestFirstParamType("foo",
- new PsiEllipsisType(PsiType.INT),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT115() {
- doTestFirstParamType("foo",
- new PsiEllipsisType(myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null)));
- }
-
- public void testT66() {
- doTestFirstParamType("foo", new PsiEllipsisType(PsiType.INT), PsiType.INT);
- }
-
- public void testT67() {
- doTestFirstParamType("methMemAcc",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT68() {
- doTestFirstParamType("foo", PsiType.INT, PsiType.DOUBLE);
- }
-
- public void testT69() {
- doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE);
- }
-
- public void testT70() {
- doTestFieldType("a", PsiType.INT.createArrayType().createArrayType(), PsiType.FLOAT.createArrayType().createArrayType());
- }
-
- public void testT71() {
- doTestFieldType("f",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_CLASS, null),
- myFactory.createTypeFromText("java.lang.Class<? extends java.lang.Number>", null));
- }
-
- public void testT72() {
- doTestFieldType("f",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_CLASS, null),
- myFactory.createTypeFromText("java.lang.Class<java.lang.Integer>", null));
- }
-
- public void testT73() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Set<javax.swing.JComponent>", null).createArrayType().createArrayType(),
- myFactory.createTypeFromText("java.util.Set<java.awt.Component>", null).createArrayType().createArrayType());
- }
-
- //prefix/postfix expression; binary expressions 74-76
- public void testT74() {
- doTestFirstParamType("meth", PsiType.INT, PsiType.FLOAT);
- }
-
- public void testT75() {
- doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT76() {
- doTestFirstParamType("meth", PsiType.BYTE, PsiType.FLOAT);
- }
-
- //+= , etc 77-78
- public void testT77() {
- doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- public void testT78() {
- doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null));
- }
-
- //casts 79-80,83
- public void testT79() {
- doTestFirstParamType("meth", PsiType.INT, PsiType.BYTE);
- }
-
- public void testT80() {
- doTestFirstParamType("meth", PsiType.INT, PsiType.DOUBLE);
- }
-
- public void testT83() {
- doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null));
- }
-
- //instanceofs 81-82
- public void testT81() {
- doTestFirstParamType("foo",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myFactory.createTypeFromText("A", null));
- }
-
- public void testT82() {
- doTestFirstParamType("foo",
- myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null),
- myFactory.createTypeFromText("C", null));
- }
-
- public void testT84() {
- doTestFirstParamType("meth",
- myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null),
- myFactory.createTypeFromText("java.util.Set<? extends java.util.Set>", null));
- }
-
- public void testT85() {
- doTestFieldType("str",
- myFactory.createTypeFromText("java.lang.String", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- //array <-> list 86-89;94;95
- public void testT86() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- public void testT87() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT88() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- public void testT89() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT94() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- public void testT95() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
-
- public void testT90() {
- doTestFieldType("l",
- myFactory.createTypeFromText("java.util.List<B>", null),
- myFactory.createTypeFromText("java.util.List<A>", null));
- }
-
- //element type -> element type array
- public void testT91() {
- doTestMethodType("foo",
- myFactory.createTypeFromText("java.lang.String", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- //List<S>=new ArrayList<S>{}; -> List<I>=new ArrayList<I>{}; anonymous
- public void testT92() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null));
- }
-
- //generics signature do not support primitives: Map<Boolean, String> - Map<boolean, String>
- public void testT93() {
- doTestFirstParamType("foo", myFactory.createTypeFromText("java.lang.Boolean", null), PsiType.BOOLEAN);
- }
-
- //field initializers procession
- public void testT96() {
- doTestFieldType("f1",
- myFactory.createTypeFromText("java.lang.Integer", null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT97() {
- doTestFieldType("f1", myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(), PsiType.INT);
- }
-
- //list <-> array conversion in assignment statements
- public void testT98() {
- doTestMethodType("getArray",
- myFactory.createTypeFromText("java.lang.String", null).createArrayType(),
- myFactory.createTypeFromText("java.util.List<java.lang.String>", null));
- }
-
- //escape pattern from []
- public void testT99() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Set<java.util.List<char[]>>", null),
- myFactory.createTypeFromText("java.util.Set<java.util.List<int[]>>", null));
- }
-
- //non formatted type
- public void testT100() {
- doTestFieldType("f",
- myFactory.createTypeFromText("java.util.Map<java.lang.String,java.lang.String>", null),
- myFactory.createTypeFromText("java.util.Map<java.lang.String,java.lang.Integer>", null));
- }
-
- //param List -> Array[]
- public void testT101() {
- doTestFirstParamType("meth",
- myFactory.createTypeFromText("java.util.List<java.util.ArrayList<java.lang.Integer>>", null),
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.Integer>[]", null));
- }
-
- //param Set.add() -> Array[] with conflict
- public void testT102() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.Set<? extends java.lang.Object>", null),
- myFactory.createTypeFromText("java.lang.Object[]", null));
- }
-
- //set(1, "") should be assignment-checked over String
- public void testT103() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.String>", null),
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType());
- }
-
- //raw list type now should not be changed
- public void testT104() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.ArrayList", null),
- myFactory.createTypeFromText("java.lang.String", null).createArrayType());
- }
-
- //implicit type parameter change 105-107
- public void testT105() {
- doTestFieldType("t",
- myFactory.createTypeFromText("T", null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
-
- public void testT106() {
- doTestFieldType("t",
- myFactory.createTypeFromText("T", null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT107() {
- doTestFieldType("t",
- myFactory.createTypeFromText("T", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- //foreach && wildcards: 108-110
- public void testT108() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.List<? extends java.lang.Number>", null));
- }
-
- public void testT109() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.List<? super java.lang.Number>", null));
- }
-
- public void testT110() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null),
- myFactory.createTypeFromText("java.util.List<? extends java.lang.String>", null));
- }
-
- //wrap with array creation only literals and refs outside of binary/unary expressions
- public void testT111() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.lang.Integer", null),
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType());
- }
-
- public void testT112() {
- doTestMethodType("method",
- myFactory.createTypeFromText("java.lang.Integer", null),
- myFactory.createTypeFromText("java.lang.Integer", null).createArrayType());
- }
-
- //varargs
- public void testT113() {
- doTestFirstParamType("method",
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Number", null)));
- }
-
- public void testT114() {
- doTestFirstParamType("method",
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null)));
- }
-
- //varargs && ArrayList
- public void testT118() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.lang.Integer", null),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)));
- }
-
- //varargs && arrays
- public void testT119() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.lang.Integer", null),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)));
- }
-
- public void testT120() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.lang.Integer", null),
- new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null)));
- }
-
- //change parameter type in foreach statement: 116 - array, 117 - list
- public void testT116() {
- doTestFieldType("str",
- myFactory.createTypeFromText("java.lang.Number", null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT117() {
- doTestFieldType("str",
- myFactory.createTypeFromText("java.lang.Number", null),
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
-
- public void testT121() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.Number>", null),
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.Float>", null));
- }
-
- public void testT122() {
- doTestFirstParamType("method",
- myFactory.createTypeFromText("java.util.List<java.util.ArrayList<java.lang.Integer>>", null),
- myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null).createArrayType());
- }
-
- public void testT123() {
- doTestFieldType("n",
- myFactory.createTypeFromText("java.lang.Number", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- //124,125 - do not change formal method return type
- public void testT124() {
- doTestFirstParamType("meth",
- myFactory.createTypeFromText("T", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- public void testT125() {
- doTestFirstParamType("meth",
- myFactory.createTypeFromText("T", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- public void testT126() {
- doTestMethodType("meth",
- myFactory.createTypeFromText("java.lang.String", null),
- myFactory.createTypeFromText("T", null));
- }
-
- // Checking preserving method parameters alignment
- public void testT127() {
- getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true;
- getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
- doTestMethodType("test234",
- myFactory.createTypeFromText("int", null),
- myFactory.createTypeFromText("long", null));
- }
-
- // test type migration from disjunction type
- public void testT128() {
- doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null),
- myFactory.createTypeFromText("Test.E", null));
- }
-
- // test type migration to disjunction type
- public void testT129() {
- doTestCatchParameter(myFactory.createTypeFromText("Test.E", null),
- myFactory.createTypeFromText("Test.E1 | Test.E2", null));
- }
-
- // test type migration from disjunction type with interfaces
- public void testT130() {
- doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null),
- myFactory.createTypeFromText("Test.E", null));
- }
-
- // test type migration between disjunction types
- public void testT131() {
- doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null),
- myFactory.createTypeFromText("Test.E2 | Test.E1", null));
- }
-
- private void doTestCatchParameter(final PsiType rootType, final PsiType migrationType) {
- start(new RulesProvider() {
- @Override
- public TypeMigrationRules provide() {
- final TypeMigrationRules rules = new TypeMigrationRules(rootType);
- rules.setMigrationRootType(migrationType);
- return rules;
- }
-
- @Override
- public PsiElement victims(final PsiClass aClass) {
- final PsiCatchSection catchSection = PsiTreeUtil.findChildOfType(aClass, PsiCatchSection.class);
- assert catchSection != null : aClass.getText();
- final PsiParameter parameter = catchSection.getParameter();
- assert parameter != null : catchSection.getText();
- return parameter;
- }
- });
- }
-
- // IDEA-72420
- public void testT132() {
- doTestFirstParamType("h", "Test",
- myFactory.createTypeFromText("J", null),
- myFactory.createTypeFromText("I", null));
- }
-
- public void testT133() {
- doTestFirstParamType("h", "Test",
- myFactory.createTypeFromText("J", null),
- myFactory.createTypeFromText("I", null));
- }
-
- public void testT134() {
- doTestFirstParamType("buzz", "Test",
- PsiType.INT,
- myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT135() {
- doTestFieldType("foo", "Test", PsiType.LONG, PsiType.INT);
- }
-
- public void testT136() {
- final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject);
- doTestFirstParamType("foo", "Test",
- myFactory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_INTEGER, scope),
- PsiType.getJavaLangString(myPsiManager, scope));
- }
-
- public void testT137() {
- doTestFirstParamType("foo", "Test", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null));
- }
-
- public void testT138() {
- doTestFirstParamType("foo", "Test",
- myFactory.createTypeFromText("java.util.Set<java.lang.String>", null),
- myFactory.createTypeFromText("java.util.Collection<java.lang.String>", null));
- }
-
- public void testT139() {
- doTestForeachParameter(myFactory.createTypeFromText("java.lang.String", null),
- myFactory.createTypeFromText("java.lang.Integer", null));
- }
-
- private void doTestForeachParameter(final PsiType rootType, final PsiType migrationType) {
- start(new RulesProvider() {
- @Override
- public TypeMigrationRules provide() {
- final TypeMigrationRules rules = new TypeMigrationRules(rootType);
- rules.setMigrationRootType(migrationType);
- return rules;
- }
-
- @Override
- public PsiElement victims(final PsiClass aClass) {
- final PsiForeachStatement foreachStatement = PsiTreeUtil.findChildOfType(aClass, PsiForeachStatement.class);
- assert foreachStatement != null : aClass.getText();
- return foreachStatement.getIterationParameter();
- }
- });
- }
-
-
- public void testTypeAnno() {
- doTestFieldType("list", "Test",
- myFactory.createTypeFromText("java.util.ArrayList<java.lang.@TA Integer>", null),
- myFactory.createTypeFromText("java.util.Collection<java.lang.@TA Integer>", null));
- }
-}
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java
deleted file mode 100644
index 8f75c4921a1c..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java
+++ /dev/null
@@ -1,193 +0,0 @@
-package com.intellij.refactoring;
-
-import com.intellij.openapi.application.PluginPathManager;
-import com.intellij.openapi.command.WriteCommandAction;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiField;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.search.LocalSearchScope;
-import com.intellij.refactoring.typeMigration.TypeMigrationProcessor;
-import com.intellij.refactoring.typeMigration.TypeMigrationRules;
-import com.intellij.usageView.UsageInfo;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-
-/**
- * @author anna
- * Date: 30-Apr-2008
- */
-public abstract class TypeMigrationTestBase extends MultiFileTestCase {
- @Override
- protected String getTestDataPath() {
- return PluginPathManager.getPluginHomePath("typeMigration") + "/testData";
- }
-
- protected void doTestFieldType(@NonNls String fieldName, PsiType fromType, PsiType toType) {
- doTestFieldType(fieldName, "Test", fromType, toType);
- }
-
- protected void doTestFieldType(@NonNls final String fieldName, String className, final PsiType rootType, final PsiType migrationType) {
- final RulesProvider provider = new RulesProvider() {
- @Override
- public TypeMigrationRules provide() throws Exception {
- final TypeMigrationRules rules = new TypeMigrationRules(rootType);
- rules.setMigrationRootType(migrationType);
- return rules;
- }
-
- @Override
- public PsiElement victims(PsiClass aClass) {
- final PsiField field = aClass.findFieldByName(fieldName, false);
- assert field != null : fieldName + " not found in " + aClass;
- return field;
- }
- };
-
- start(provider, className);
- }
-
- protected void doTestMethodType(@NonNls final String methodName, final PsiType rootType, final PsiType migrationType) {
- doTestMethodType(methodName, "Test", rootType, migrationType);
- }
-
- protected void doTestMethodType(@NonNls final String methodName, @NonNls String className, final PsiType rootType, final PsiType migrationType) {
- final RulesProvider provider = new RulesProvider() {
- @Override
- public TypeMigrationRules provide() throws Exception {
- final TypeMigrationRules rules = new TypeMigrationRules(rootType);
- rules.setMigrationRootType(migrationType);
- return rules;
- }
-
- @Override
- public PsiElement victims(PsiClass aClass) {
- return aClass.findMethodsByName(methodName, false)[0];
- }
- };
-
- start(provider, className);
- }
-
- protected void doTestFirstParamType(@NonNls final String methodName, final PsiType rootType, final PsiType migrationType) {
- doTestFirstParamType(methodName, "Test", rootType, migrationType);
- }
-
- protected void doTestFirstParamType(@NonNls final String methodName, String className, final PsiType rootType, final PsiType migrationType) {
- final RulesProvider provider = new RulesProvider() {
- @Override
- public TypeMigrationRules provide() throws Exception {
- final TypeMigrationRules rules = new TypeMigrationRules(rootType);
- rules.setMigrationRootType(migrationType);
- return rules;
- }
-
- @Override
- public PsiElement victims(PsiClass aClass) {
- return aClass.findMethodsByName(methodName, false)[0].getParameterList().getParameters()[0];
- }
- };
-
- start(provider, className);
- }
-
- public void start(final RulesProvider provider) {
- start(provider, "Test");
- }
-
- public void start(final RulesProvider provider, final String className) {
- doTest(new PerformAction() {
- @Override
- public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
- TypeMigrationTestBase.this.performAction(className, rootDir.getName(), provider);
- }
- });
- }
-
- private void performAction(String className, String rootDir, RulesProvider provider) throws Exception {
- PsiClass aClass = myJavaFacade.findClass(className, GlobalSearchScope.allScope(getProject()));
-
- assertNotNull("Class " + className + " not found", aClass);
-
- final TypeMigrationRules rules = provider.provide();
- rules.setBoundScope(new LocalSearchScope(aClass.getContainingFile()));
- final TestTypeMigrationProcessor pr = new TestTypeMigrationProcessor(getProject(), provider.victims(aClass), rules);
-
- final UsageInfo[] usages = pr.findUsages();
- final String report = pr.getLabeler().getMigrationReport();
-
- WriteCommandAction.runWriteCommandAction(null, new Runnable() {
- public void run() {
- pr.performRefactoring(usages);
- }
- });
-
-
- String itemName = className + ".items";
- String patternName = getTestDataPath() + getTestRoot() + getTestName(true) + "/after/" + itemName;
-
- File patternFile = new File(patternName);
-
- if (!patternFile.exists()) {
- PrintWriter writer = new PrintWriter(new FileOutputStream(patternFile));
- try {
- writer.print(report);
- writer.close();
- }
- finally {
- writer.close();
- }
-
- System.out.println("Pattern not found, file " + patternName + " created.");
-
- LocalFileSystem.getInstance().refreshAndFindFileByIoFile(patternFile);
- }
-
- File graFile = new File(FileUtil.getTempDirectory() + File.separator + rootDir + File.separator + itemName);
-
- PrintWriter writer = new PrintWriter(new FileOutputStream(graFile));
- try {
- writer.print(report);
- writer.close();
- }
- finally {
- writer.close();
- }
-
- LocalFileSystem.getInstance().refreshAndFindFileByIoFile(graFile);
- FileDocumentManager.getInstance().saveAllDocuments();
- }
-
- interface RulesProvider {
- TypeMigrationRules provide() throws Exception;
-
- PsiElement victims(PsiClass aClass);
- }
-
- private static class TestTypeMigrationProcessor extends TypeMigrationProcessor {
- public TestTypeMigrationProcessor(final Project project, final PsiElement root, final TypeMigrationRules rules) {
- super(project, root, rules);
- }
-
- @NotNull
- @Override
- public UsageInfo[] findUsages() {
- return super.findUsages();
- }
-
- @Override
- public void performRefactoring(final UsageInfo[] usages) {
- super.performRefactoring(usages);
- }
- }
-} \ No newline at end of file
diff --git a/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java b/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java
deleted file mode 100644
index d66320623f83..000000000000
--- a/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * User: anna
- * Date: 19-Aug-2009
- */
-package com.intellij.refactoring;
-
-import com.intellij.psi.CommonClassNames;
-import org.jetbrains.annotations.NotNull;
-
-public class WildcardTypeMigrationTest extends TypeMigrationTestBase{
- @NotNull
- @Override
- protected String getTestRoot() {
- return "/refactoring/wildcard/";
- }
-
- public void testProducerExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null));
- }
-
- public void testProducerSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null));
- }
-
- public void testProducerUnbounded() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null));
- }
-
- public void testProducerCollectionChanged() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super java.lang.Integer>", null));
- }
-
- public void testProducerExtendsCollectionChanged() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends java.lang.Object>", null));
- }
-
- public void testProducerStopAtWildcard() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null));
- }
-
- public void testProducerFailToStopAtWildcard() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Integer>", null));
- }
-
- public void testProducerExtendsFailToStopAtWildcard() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? extends java.lang.Number>", null));
- }
-
-
- public void testConsumerExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null));
- }
-
- public void testConsumerSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null));
- }
-
- public void testConsumerUnbounded() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null));
- }
-
- // array -> list
- public void testAssignmentExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Integer>", null));
- }
-
- public void testAssignmentSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null));
- }
-
- public void testAssignmentUnbounded() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null));
- }
-
- public void testGetExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Integer>", null));
- }
-
- public void testGetSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null));
- }
-
- public void testGetUnbounded() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null));
-
- }
-
- public void testLengthSize() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(),
- myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null));
-
- }
-
- //list -> array
- public void testGetAssignmentExtendsToType() throws Exception {
- doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Number", null).createArrayType());
- }
-
- public void testGetAssignmentExtendsToSuperType() throws Exception {
- doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType());
- }
-
- public void testGetAssignmentExtendsToChildType() throws Exception {
- doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType());
- }
-
- // -> threadlocal with wildcard
- public void testThreadLocalProducerExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.util.List<? extends String>>", null));
- }
-
- //List<? super String> is not assignable to List<String> though it is possible to pass string where ? super String was
- public void _testThreadLocalProducerSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.util.List<? super String>>", null));
- }
-
- public void testThreadLocalConsumerSuper() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<? super String>", null));
- }
-
- public void testThreadLocalConsumerExtends() throws Exception {
- doTestFirstParamType("method",
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null),
- myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<? extends String>", null));
- }
-} \ No newline at end of file