summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java')
-rw-r--r--java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java210
1 files changed, 103 insertions, 107 deletions
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
index fcadcd170588..34745372977e 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/IntroduceVariableTest.java
@@ -28,7 +28,6 @@ import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import com.intellij.testFramework.LightCodeInsightTestCase;
import com.intellij.util.containers.MultiMap;
-import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -37,66 +36,65 @@ import java.util.Collection;
* @author dsl
*/
public class IntroduceVariableTest extends LightCodeInsightTestCase {
-
@NotNull
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
- public void testSimpleExpression() throws Exception {
+ public void testSimpleExpression() {
doTest(new MockIntroduceVariableHandler("i", false, false, true, "int"));
}
- public void testInsideFor() throws Exception {
+ public void testInsideFor() {
doTest(new MockIntroduceVariableHandler("temp", false, false, true, "int"));
}
- public void testReplaceAll() throws Exception {
- doTest(new MockIntroduceVariableHandler("s", true, true, true, "java.lang.String"));
+ public void testReplaceAll() {
+ doTest(new MockIntroduceVariableHandler("s", true, true, true, CommonClassNames.JAVA_LANG_STRING));
}
- public void testIDEADEV3678() throws Exception {
+ public void testIDEADEV3678() {
doTest(new MockIntroduceVariableHandler("component", true, true, true, CommonClassNames.JAVA_LANG_OBJECT));
}
- public void testIDEADEV13369() throws Exception {
+ public void testIDEADEV13369() {
doTest(new MockIntroduceVariableHandler("ints", true, true, true, "int[]"));
}
- public void testAnonymousClass() throws Exception {
+ public void testAnonymousClass() {
doTest(new MockIntroduceVariableHandler("temp", true, false, true, "int"));
}
- public void testAnonymousClass1() throws Exception {
+ public void testAnonymousClass1() {
doTest(new MockIntroduceVariableHandler("runnable", false, false, false, CommonClassNames.JAVA_LANG_RUNNABLE));
}
- public void testAnonymousClass2() throws Exception {
+ public void testAnonymousClass2() {
doTest(new MockIntroduceVariableHandler("j", true, false, false, "int"));
}
- public void testAnonymousClass3() throws Exception {
+ public void testAnonymousClass3() {
doTest(new MockIntroduceVariableHandler("j", true, false, false, "Foo"));
}
- public void testAnonymousClass4() throws Exception {
+ public void testAnonymousClass4() {
doTest(new MockIntroduceVariableHandler("j", true, false, false, "int"));
}
- public void testAnonymousClass5() throws Exception {
+ public void testAnonymousClass5() {
doTest(new MockIntroduceVariableHandler("j", true, false, false, "int"));
}
- public void testLambda() throws Exception {
+ public void testLambda() {
doTest(new MockIntroduceVariableHandler("j", true, false, false, "int"));
}
- public void testParenthized() throws Exception {
+ public void testParenthized() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "int"));
}
- public void testExpectedType8Inference() throws Exception {
+ public void testExpectedType8Inference() {
final PsiResolveHelperImpl helper = (PsiResolveHelperImpl)JavaPsiFacade.getInstance(getProject()).getResolveHelper();
helper.setTestHelper(new PsiGraphInferenceHelper(getPsiManager()));
try {
@@ -108,64 +106,64 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
}
}
- public void testMethodCall() throws Exception {
+ public void testMethodCall() {
doTest(new MockIntroduceVariableHandler("temp", true, true, true, CommonClassNames.JAVA_LANG_OBJECT));
}
- public void testMethodCallInSwitch() throws Exception {
+ public void testMethodCallInSwitch() {
doTest(new MockIntroduceVariableHandler("i", true, true, true, "int"));
}
- public void testParenthizedOccurence() throws Exception {
+ public void testParenthizedOccurence() {
doTest(new MockIntroduceVariableHandler("empty", true, true, true, "boolean"));
}
- public void testParenthizedOccurence1() throws Exception {
- doTest(new MockIntroduceVariableHandler("s", true, true, true, "java.lang.String"));
+ public void testParenthizedOccurence1() {
+ doTest(new MockIntroduceVariableHandler("s", true, true, true, CommonClassNames.JAVA_LANG_STRING));
}
- public void testConflictingField() throws Exception {
- doTest(new MockIntroduceVariableHandler("name", true, false, true, "java.lang.String"));
+ public void testConflictingField() {
+ doTest(new MockIntroduceVariableHandler("name", true, false, true, CommonClassNames.JAVA_LANG_STRING));
}
- public void testConflictingFieldInExpression() throws Exception {
+ public void testConflictingFieldInExpression() {
doTest(new MockIntroduceVariableHandler("name", false, false, true, "int"));
}
- public void testStaticConflictingField() throws Exception {
+ public void testStaticConflictingField() {
doTest(new MockIntroduceVariableHandler("name", false, false, true, "int"));
}
- public void testNonConflictingField() throws Exception {
+ public void testNonConflictingField() {
doTest(new MockIntroduceVariableHandler("name", false, false, true, "int"));
}
- public void testScr16910() throws Exception {
+ public void testScr16910() {
doTest(new MockIntroduceVariableHandler("i", true, true, false, "int"));
}
- public void testSCR18295() throws Exception {
- doTest(new MockIntroduceVariableHandler("it", true, false, false, "java.lang.String"));
+ public void testSCR18295() {
+ doTest(new MockIntroduceVariableHandler("it", true, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSCR18295a() throws Exception {
- doTest(new MockIntroduceVariableHandler("it", false, false, false, "java.lang.String"));
+ public void testSCR18295a() {
+ doTest(new MockIntroduceVariableHandler("it", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testFromInjected() throws Exception {
- doTest(new MockIntroduceVariableHandler("regexp", false, false, false, "java.lang.String"));
+ public void testFromInjected() {
+ doTest(new MockIntroduceVariableHandler("regexp", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSCR10412() throws Exception {
+ public void testSCR10412() {
doTest(new MockIntroduceVariableHandler("newVar", false, false, false, "java.lang.String[]"));
}
- public void testSCR22718() throws Exception {
+ public void testSCR22718() {
doTest(new MockIntroduceVariableHandler("object", true, true, false, CommonClassNames.JAVA_LANG_OBJECT));
}
- public void testSCR26075() throws Exception {
- doTest(new MockIntroduceVariableHandler("wrong", false, false, false, "java.lang.String") {
+ public void testSCR26075() {
+ doTest(new MockIntroduceVariableHandler("wrong", false, false, false, CommonClassNames.JAVA_LANG_STRING) {
@Override
protected void assertValidationResult(boolean validationResult) {
assertFalse(validationResult);
@@ -182,59 +180,59 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
});
}
- public void testConflictingFieldInOuterClass() throws Exception {
- doTest(new MockIntroduceVariableHandler("text", true, true, false, "java.lang.String"));
+ public void testConflictingFieldInOuterClass() {
+ doTest(new MockIntroduceVariableHandler("text", true, true, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSkipSemicolon() throws Exception {
+ public void testSkipSemicolon() {
doTest(new MockIntroduceVariableHandler("mi5", false, false, false, "int"));
}
- public void testInsideIf() throws Exception {
- doTest(new MockIntroduceVariableHandler("s1", false, false, false, "java.lang.String"));
+ public void testInsideIf() {
+ doTest(new MockIntroduceVariableHandler("s1", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testInsideElse() throws Exception {
- doTest(new MockIntroduceVariableHandler("s1", false, false, false, "java.lang.String"));
+ public void testInsideElse() {
+ doTest(new MockIntroduceVariableHandler("s1", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testInsideWhile() throws Exception {
+ public void testInsideWhile() {
doTest(new MockIntroduceVariableHandler("temp", false, false, false, "int"));
}
- public void testSCR40281() throws Exception {
+ public void testSCR40281() {
doTest(new MockIntroduceVariableHandler("temp", false, false, false, "Set<? extends Map<?,java.lang.String>.Entry<?,java.lang.String>>"));
}
- public void testWithIfBranches() throws Exception {
+ public void testWithIfBranches() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "int"));
}
- public void testInsideForLoop() throws Exception {
+ public void testInsideForLoop() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "int"));
}
- public void testDuplicateGenericExpressions() throws Exception {
+ public void testDuplicateGenericExpressions() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2<? extends java.lang.Runnable>"));
}
- public void testStaticImport() throws Exception {
+ public void testStaticImport() {
doTest(new MockIntroduceVariableHandler("i", true, true, false, "int"));
}
- public void testThisQualifier() throws Exception {
+ public void testThisQualifier() {
doTest(new MockIntroduceVariableHandler("count", true, true, false, "int"));
}
- public void testSubLiteral() throws Exception {
- doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
+ public void testSubLiteral() {
+ doTest(new MockIntroduceVariableHandler("str", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSubLiteral1() throws Exception {
- doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
+ public void testSubLiteral1() {
+ doTest(new MockIntroduceVariableHandler("str", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSubLiteralFailure() throws Exception {
+ public void testSubLiteralFailure() {
try {
doTest(new MockIntroduceVariableHandler("str", false, false, false, "int"));
}
@@ -246,35 +244,35 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
fail("Should not be able to perform refactoring");
}
- public void testSubLiteralFromExpression() throws Exception {
- doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
+ public void testSubLiteralFromExpression() {
+ doTest(new MockIntroduceVariableHandler("str", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSubExpressionFromIntellijidearulezzz() throws Exception {
- doTest(new MockIntroduceVariableHandler("str", false, false, false, "java.lang.String"));
+ public void testSubExpressionFromIntellijidearulezzz() {
+ doTest(new MockIntroduceVariableHandler("str", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testSubPrimitiveLiteral() throws Exception {
+ public void testSubPrimitiveLiteral() {
doTest(new MockIntroduceVariableHandler("str", false, false, false, "boolean"));
}
- public void testArrayFromVarargs() throws Exception {
+ public void testArrayFromVarargs() {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
- public void testArrayFromVarargs1() throws Exception {
+ public void testArrayFromVarargs1() {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
- public void testEnumArrayFromVarargs() throws Exception {
+ public void testEnumArrayFromVarargs() {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "E[]"));
}
- public void testFromFinalFieldOnAssignment() throws Exception {
- doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String"));
+ public void testFromFinalFieldOnAssignment() {
+ doTest(new MockIntroduceVariableHandler("strs", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testNoArrayFromVarargs() throws Exception {
+ public void testNoArrayFromVarargs() {
try {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
@@ -286,7 +284,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
fail("Should not be able to perform refactoring");
}
- public void testNoArrayFromVarargs1() throws Exception {
+ public void testNoArrayFromVarargs1() {
try {
doTest(new MockIntroduceVariableHandler("strs", false, false, false, "java.lang.String[]"));
}
@@ -298,59 +296,59 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
fail("Should not be able to perform refactoring");
}
- public void testNonExpression() throws Exception {
+ public void testNonExpression() {
doTest(new MockIntroduceVariableHandler("sum", true, true, false, "int"));
}
- public void testTypeAnnotations() throws Exception {
+ public void testTypeAnnotations() {
doTest(new MockIntroduceVariableHandler("y1", true, false, false, "@TA C"));
}
- public void testReturnStatementWithoutSemicolon() throws Exception {
- doTest(new MockIntroduceVariableHandler("b", true, true, false, "java.lang.String"));
+ public void testReturnStatementWithoutSemicolon() {
+ doTest(new MockIntroduceVariableHandler("b", true, true, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testAndAndSubexpression() throws Exception {
+ public void testAndAndSubexpression() {
doTest(new MockIntroduceVariableHandler("ab", true, true, false, "boolean"));
}
- public void testSubexpressionWithSpacesInSelection() throws Exception {
+ public void testSubexpressionWithSpacesInSelection() {
doTest(new MockIntroduceVariableHandler("ab", true, true, false, "boolean"));
}
- public void testDuplicatesAnonymousClassCreationWithSimilarParameters () throws Exception {
+ public void testDuplicatesAnonymousClassCreationWithSimilarParameters () {
doTest(new MockIntroduceVariableHandler("foo1", true, true, false, "Foo"));
}
- public void testDifferentForeachParameters () throws Exception {
- doTest(new MockIntroduceVariableHandler("tostr", true, true, false, "java.lang.String"));
+ public void testDifferentForeachParameters () {
+ doTest(new MockIntroduceVariableHandler("tostr", true, true, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testCollapsedToDiamond() throws Exception {
+ public void testCollapsedToDiamond() {
doTest(new MockIntroduceVariableHandler("a", true, true, true, "java.util.ArrayList<java.lang.String>"));
}
- public void testCantCollapsedToDiamond() throws Exception {
+ public void testCantCollapsedToDiamond() {
doTest(new MockIntroduceVariableHandler("a", true, true, true, "Foo<java.lang.Number>"));
}
- public void testFromForInitializer() throws Exception {
+ public void testFromForInitializer() {
doTest(new MockIntroduceVariableHandler("list", true, true, true, "java.util.List"));
}
- public void testInvalidPostfixExpr() throws Exception {
+ public void testInvalidPostfixExpr() {
doTest(new MockIntroduceVariableHandler("a1", true, false, true, "int[]"));
}
- public void testPolyadic() throws Exception {
+ public void testPolyadic() {
doTest(new MockIntroduceVariableHandler("b1", true, true, true, "boolean"));
}
- public void testAssignmentToUnresolvedReference() throws Exception {
+ public void testAssignmentToUnresolvedReference() {
doTest(new MockIntroduceVariableHandler("collection", true, true, true, "java.util.List<? extends java.util.Collection<?>>"));
}
- public void testNameSuggestion() throws Exception {
+ public void testNameSuggestion() {
final String expectedTypeName = "Path";
doTest(new MockIntroduceVariableHandler("path", true, false, false, expectedTypeName) {
@Override
@@ -370,7 +368,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
});
}
- public void testSiblingInnerClassType() throws Exception {
+ public void testSiblingInnerClassType() {
doTest(new MockIntroduceVariableHandler("vari", true, false, false, "A.B") {
@Override
public IntroduceVariableSettings getSettings(Project project, Editor editor,
@@ -388,7 +386,7 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
});
}
- public void testNonExpressionPriorityFailure() throws Exception {
+ public void testNonExpressionPriorityFailure() {
doTest(new MockIntroduceVariableHandler("sum", true, true, false, "int"){
@Override
protected void showErrorMessage(Project project, Editor editor, String message) {
@@ -398,10 +396,9 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
});
}
-
- public void testIncorrectExpressionSelected() throws Exception {
+ public void testIncorrectExpressionSelected() {
try {
- doTest(new MockIntroduceVariableHandler("toString", false, false, false, "java.lang.String"));
+ doTest(new MockIntroduceVariableHandler("toString", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
catch (Exception e) {
assertEquals(e.getMessage(), "Error message:Cannot perform refactoring.\n" +
@@ -411,51 +408,50 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
fail("Should not be able to perform refactoring");
}
- public void testMultiCatchSimple() throws Exception {
+ public void testMultiCatchSimple() {
doTest(new MockIntroduceVariableHandler("e", true, true, false, "java.lang.Exception", true));
}
- public void testMultiCatchTyped() throws Exception {
+ public void testMultiCatchTyped() {
doTest(new MockIntroduceVariableHandler("b", true, true, false, "java.lang.Exception", true));
}
- public void testBeforeVoidStatement() throws Exception {
+ public void testBeforeVoidStatement() {
doTest(new MockIntroduceVariableHandler("c", false, false, false, CommonClassNames.JAVA_LANG_OBJECT));
}
- public void testWriteUsages() throws Exception {
+ public void testWriteUsages() {
doTest(new MockIntroduceVariableHandler("c", true, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testLambdaExpr() throws Exception {
-
+ public void testLambdaExpr() {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
}
- public void testMethodRef() throws Exception {
+ public void testMethodRef() {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "Test.Bar"));
}
- public void testLambdaExprNotAccepted() throws Exception {
- doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<X>"));
+ public void testLambdaExprNotAccepted() {
+ doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
}
- public void testOneLineLambdaVoidCompatible() throws Exception {
- doTest(new MockIntroduceVariableHandler("c", false, false, false, "java.lang.String"));
+ public void testOneLineLambdaVoidCompatible() {
+ doTest(new MockIntroduceVariableHandler("c", false, false, false, CommonClassNames.JAVA_LANG_STRING));
}
- public void testOneLineLambdaValueCompatible() throws Exception {
+ public void testOneLineLambdaValueCompatible() {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "int"));
}
- public void testNormalizeDeclarations() throws Exception {
+ public void testNormalizeDeclarations() {
doTest(new MockIntroduceVariableHandler("i3", false, false, false, "int"));
}
- public void testMethodReferenceExpr() throws Exception {
+ public void testMethodReferenceExpr() {
doTest(new MockIntroduceVariableHandler("m", false, false, false, "Foo.I"));
}
- public void testReturnNonExportedArray() throws Exception {
+ public void testReturnNonExportedArray() {
doTest(new MockIntroduceVariableHandler("i", false, false, false, "java.io.File[]") {
@Override
protected boolean isInplaceAvailableInTestMode() {
@@ -464,8 +460,8 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
});
}
- private void doTest(IntroduceVariableBase testMe) throws Exception {
- @NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false);
+ private void doTest(IntroduceVariableBase testMe) {
+ String baseName = "/refactoring/introduceVariable/" + getTestName(false);
configureByFile(baseName + ".java");
testMe.invoke(getProject(), getEditor(), getFile(), null);
checkResultByFile(baseName + ".after.java");