Cleanup (dead code; pointless exceptions; constants; formatting)

This commit is contained in:
Roman Shevchenko
2014-03-13 14:13:05 +01:00
parent 5dda96836e
commit 3ba792a845
4 changed files with 165 additions and 159 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* created at Sep 17, 2001
* @author Jeka
*/
package com.intellij.refactoring.changeSignature;
import com.intellij.openapi.application.ApplicationManager;
@@ -36,6 +31,7 @@ import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewDescriptor;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.VisibilityUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
@@ -43,6 +39,12 @@ import org.jetbrains.annotations.Nullable;
import java.util.*;
import static com.intellij.util.ObjectUtils.assertNotNull;
/**
* @author Jeka
* @since Sep 17, 2001
*/
public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.changeSignature.ChangeSignatureProcessor");
@@ -99,18 +101,22 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
ThrownExceptionInfo[] thrownExceptions,
Set<PsiMethod> propagateParametersMethods,
Set<PsiMethod> propagateExceptionsMethods) {
Set<PsiMethod> myPropagateParametersMethods =
propagateParametersMethods != null ? propagateParametersMethods : new HashSet<PsiMethod>();
Set<PsiMethod> myPropagateExceptionsMethods =
propagateExceptionsMethods != null ? propagateExceptionsMethods : new HashSet<PsiMethod>();
LOG.assertTrue(method.isValid());
if (propagateParametersMethods == null) {
propagateParametersMethods = ContainerUtil.newHashSet();
}
if (propagateExceptionsMethods == null) {
propagateExceptionsMethods = ContainerUtil.newHashSet();
}
if (newVisibility == null) {
newVisibility = VisibilityUtil.getVisibilityModifier(method.getModifierList());
}
return new JavaChangeInfoImpl(newVisibility, method, newName, newType, parameterInfo, thrownExceptions, generateDelegate,
myPropagateParametersMethods, myPropagateExceptionsMethods);
propagateParametersMethods, propagateExceptionsMethods);
}
@NotNull
@@ -177,7 +183,7 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
for (UsageInfo usageInfo : usages) {
if (usageInfo instanceof OverriderUsageInfo) {
final OverriderUsageInfo info = (OverriderUsageInfo)usageInfo;
PsiMethod overrider = info.getElement();
PsiMethod overrider = assertNotNull(info.getElement());
PsiMethod baseMethod = info.getBaseMethod();
PsiSubstitutor substitutor = calculateSubstitutor(overrider, baseMethod);
PsiType type;
@@ -212,9 +218,8 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
}
protected boolean isProcessCovariantOverriders() {
return Messages
.showYesNoDialog(myProject, RefactoringBundle.message("do.you.want.to.process.overriding.methods.with.covariant.return.type"),
JavaChangeSignatureHandler.REFACTORING_NAME, Messages.getQuestionIcon()) == Messages.YES;
String message = RefactoringBundle.message("do.you.want.to.process.overriding.methods.with.covariant.return.type");
return Messages.showYesNoDialog(myProject, message, ChangeSignatureHandler.REFACTORING_NAME, Messages.getQuestionIcon()) == Messages.YES;
}
public static void makeEmptyBody(final PsiElementFactory factory, final PsiMethod delegate) throws IncorrectOperationException {
@@ -229,7 +234,7 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
}
@Nullable
public static PsiCallExpression addDelegatingCallTemplate(final PsiMethod delegate, final String newName) throws IncorrectOperationException {
public static PsiCallExpression addDelegatingCallTemplate(PsiMethod delegate, String newName) throws IncorrectOperationException {
Project project = delegate.getProject();
PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory();
PsiCodeBlock body = delegate.getBody();
@@ -240,7 +245,8 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
callStatement = CodeStyleManager.getInstance(project).reformat(callStatement);
callStatement = body.add(callStatement);
callExpression = (PsiCallExpression)((PsiExpressionStatement) callStatement).getExpression();
} else {
}
else {
if (PsiType.VOID.equals(delegate.getReturnType())) {
PsiElement callStatement = factory.createStatementFromText(newName + "();", null);
callStatement = CodeStyleManager.getInstance(project).reformat(callStatement);
@@ -261,16 +267,18 @@ public class ChangeSignatureProcessor extends ChangeSignatureProcessorBase {
PsiSubstitutor substitutor;
if (derivedMethod.getManager().areElementsEquivalent(derivedMethod, baseMethod)) {
substitutor = PsiSubstitutor.EMPTY;
} else {
final PsiClass baseClass = baseMethod.getContainingClass();
final PsiClass derivedClass = derivedMethod.getContainingClass();
if(baseClass != null && derivedClass != null && InheritanceUtil.isInheritorOrSelf(derivedClass, baseClass, true)) {
final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, derivedClass, PsiSubstitutor.EMPTY);
final MethodSignature superMethodSignature = baseMethod.getSignature(superClassSubstitutor);
final MethodSignature methodSignature = derivedMethod.getSignature(PsiSubstitutor.EMPTY);
final PsiSubstitutor superMethodSubstitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superMethodSignature);
}
else {
PsiClass baseClass = baseMethod.getContainingClass();
PsiClass derivedClass = derivedMethod.getContainingClass();
if (baseClass != null && derivedClass != null && InheritanceUtil.isInheritorOrSelf(derivedClass, baseClass, true)) {
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, derivedClass, PsiSubstitutor.EMPTY);
MethodSignature superMethodSignature = baseMethod.getSignature(superClassSubstitutor);
MethodSignature methodSignature = derivedMethod.getSignature(PsiSubstitutor.EMPTY);
PsiSubstitutor superMethodSubstitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superMethodSignature);
substitutor = superMethodSubstitutor != null ? superMethodSubstitutor : superClassSubstitutor;
} else {
}
else {
substitutor = PsiSubstitutor.EMPTY;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,8 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.impl.source.tree.Factory;
import com.intellij.psi.impl.source.tree.SharedImplUtil;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.CharTable;
import com.intellij.util.IncorrectOperationException;
import java.util.ArrayList;
@@ -32,16 +33,19 @@ import java.util.List;
* @author dsl
*/
public class ChangeSignatureUtil {
private ChangeSignatureUtil() {
private ChangeSignatureUtil() { }
public interface ChildrenGenerator<Parent extends PsiElement, Child extends PsiElement> {
List<Child> getChildren(Parent parent);
}
public static <Parent extends PsiElement, Child extends PsiElement> void synchronizeList(Parent list,
final List<Child> newElements,
ChildrenGenerator<Parent, Child> generator,
final boolean[] shouldRemoveChild)
throws IncorrectOperationException {
ArrayList<Child> elementsToRemove = null;
public static <Parent extends PsiElement, Child extends PsiElement> void synchronizeList(
Parent list,
List<Child> newElements,
ChildrenGenerator<Parent, Child> generator,
boolean[] shouldRemoveChild) throws IncorrectOperationException
{
List<Child> elementsToRemove = null;
List<Child> elements;
int index = 0;
@@ -67,33 +71,36 @@ public class ChangeSignatureUtil {
index--;
}
else {
assert list.isWritable() : PsiUtilBase.getVirtualFile(list);
assert list.isWritable() : PsiUtilCore.getVirtualFile(list);
list.addBefore(newElement, oldElement);
if (list.equals(newElement.getParent())) {
newElement.delete();
}
}
}
} else {
}
else {
if (newElements.size() > 1 && (!elements.isEmpty() || index < newElements.size() - 1)) {
PsiElement anchor;
if (index == 0) {
anchor = list.getFirstChild();
} else {
}
else {
anchor = index - 1 < elements.size() ? elements.get(index - 1) : null;
}
final PsiElement psi = Factory
.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, SharedImplUtil.findCharTableByTree(list.getNode()), list.getManager())
.getPsi();
CharTable charTable = SharedImplUtil.findCharTableByTree(list.getNode());
PsiElement psi = Factory.createSingleLeafElement(JavaTokenType.COMMA, ",", 0, 1, charTable, list.getManager()).getPsi();
if (anchor != null) {
list.addAfter(psi, anchor);
} else {
}
else {
list.add(psi);
}
}
}
index++;
}
for (int i = newElements.size(); i < elements.size(); i++) {
Child element = elements.get(i);
element.delete();
@@ -101,12 +108,9 @@ public class ChangeSignatureUtil {
}
public static void invokeChangeSignatureOn(PsiMethod method, Project project) {
final ChangeSignatureHandler handler =
LanguageRefactoringSupport.INSTANCE.forLanguage(method.getLanguage()).getChangeSignatureHandler();
handler.invoke(project, new PsiElement[]{method}, null);
}
public interface ChildrenGenerator<Parent extends PsiElement, Child extends PsiElement> {
List<Child> getChildren(Parent parent);
ChangeSignatureHandler handler = LanguageRefactoringSupport.INSTANCE.forLanguage(method.getLanguage()).getChangeSignatureHandler();
if (handler != null) {
handler.invoke(project, new PsiElement[]{method}, null);
}
}
}
@@ -33,8 +33,6 @@ import java.util.ArrayList;
import java.util.List;
public class ParameterInfoImpl implements JavaParameterInfo {
public static final ParameterInfoImpl[] EMPTY_ARRAY = {};
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.changeSignature.ParameterInfoImpl");
public int oldParameterIndex;
@@ -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 {
public void testLambdaExprNotAccepted() {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<X>"));
}
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");