Commit c9694cff authored by Roman Shevchenko's avatar Roman Shevchenko
Browse files

Cleanup (formatting)

parent 200f4f4f
Branches unavailable Tags unavailable
Showing with 17 additions and 21 deletions
+17 -21
...@@ -10,7 +10,6 @@ import com.intellij.refactoring.introduceVariable.InputValidator; ...@@ -10,7 +10,6 @@ import com.intellij.refactoring.introduceVariable.InputValidator;
import com.intellij.refactoring.introduceVariable.IntroduceVariableBase; import com.intellij.refactoring.introduceVariable.IntroduceVariableBase;
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings; import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
import com.intellij.refactoring.ui.TypeSelectorManagerImpl; import com.intellij.refactoring.ui.TypeSelectorManagerImpl;
import org.jetbrains.annotations.NonNls;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
...@@ -23,38 +22,35 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase { ...@@ -23,38 +22,35 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
private final boolean myReplaceAll; private final boolean myReplaceAll;
private final boolean myDeclareFinal; private final boolean myDeclareFinal;
private final boolean myReplaceLValues; private final boolean myReplaceLValues;
private final String myExpectedTypeCanonicalName; private final String myExpectedTypeText;
private final boolean myLookForType; private final boolean myLookForType;
MockIntroduceVariableHandler(@NonNls final String name, final boolean replaceAll, MockIntroduceVariableHandler(String name, boolean replaceAll, boolean declareFinal, boolean replaceLValues, String expectedTypeText) {
final boolean declareFinal, final boolean replaceLValues, this(name, replaceAll, declareFinal, replaceLValues, expectedTypeText, false);
@NonNls final String expectedTypeCanonicalName) {
this(name, replaceAll, declareFinal, replaceLValues, expectedTypeCanonicalName, false);
} }
MockIntroduceVariableHandler(@NonNls final String name, final boolean replaceAll, MockIntroduceVariableHandler(String name, boolean replaceAll, boolean declareFinal, boolean replaceLValues, String expectedTypeText, boolean lookForType) {
final boolean declareFinal, final boolean replaceLValues,
@NonNls final String expectedTypeCanonicalName, boolean lookForType) {
myName = name; myName = name;
myReplaceAll = replaceAll; myReplaceAll = replaceAll;
myDeclareFinal = declareFinal; myDeclareFinal = declareFinal;
myReplaceLValues = replaceLValues; myReplaceLValues = replaceLValues;
myExpectedTypeCanonicalName = expectedTypeCanonicalName; myExpectedTypeText = expectedTypeText;
myLookForType = lookForType; myLookForType = lookForType;
} }
@Override @Override
public IntroduceVariableSettings getSettings(Project project, Editor editor, public IntroduceVariableSettings getSettings(Project project, Editor editor,
PsiExpression expr, final PsiExpression[] occurrences, PsiExpression expr,
PsiExpression[] occurrences,
TypeSelectorManagerImpl typeSelectorManager, TypeSelectorManagerImpl typeSelectorManager,
final boolean declareFinalIfAll, boolean declareFinalIfAll,
boolean anyAssignmentLHS, boolean anyAssignmentLHS,
InputValidator validator, InputValidator validator,
PsiElement anchor, final JavaReplaceChoice replaceChoice) { PsiElement anchor,
final PsiType type = myLookForType ? findType(typeSelectorManager.getTypesForAll(), typeSelectorManager.getDefaultType()) JavaReplaceChoice replaceChoice) {
: typeSelectorManager.getDefaultType(); PsiType defaultType = typeSelectorManager.getDefaultType();
assertEquals(type.getInternalCanonicalText(), myExpectedTypeCanonicalName); PsiType type = myLookForType ? findType(typeSelectorManager.getTypesForAll(), defaultType) : defaultType;
assertEquals(type.getInternalCanonicalText(), myExpectedTypeText);
IntroduceVariableSettings introduceVariableSettings = new IntroduceVariableSettings() { IntroduceVariableSettings introduceVariableSettings = new IntroduceVariableSettings() {
@Override @Override
public String getEnteredName() { public String getEnteredName() {
...@@ -86,12 +82,12 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase { ...@@ -86,12 +82,12 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
return true; return true;
} }
}; };
final boolean validationResult = validator.isOK(introduceVariableSettings); boolean validationResult = validator.isOK(introduceVariableSettings);
assertValidationResult(validationResult); assertValidationResult(validationResult);
return introduceVariableSettings; return introduceVariableSettings;
} }
protected void assertValidationResult(final boolean validationResult) { protected void assertValidationResult(boolean validationResult) {
assertTrue(validationResult); assertTrue(validationResult);
} }
...@@ -102,8 +98,8 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase { ...@@ -102,8 +98,8 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
private PsiType findType(final PsiType[] candidates, PsiType defaultType) { private PsiType findType(final PsiType[] candidates, PsiType defaultType) {
for (PsiType candidate : candidates) { for (PsiType candidate : candidates) {
if (candidate.equalsToText(myExpectedTypeCanonicalName)) return candidate; if (candidate.equalsToText(myExpectedTypeText)) return candidate;
} }
return defaultType; return defaultType;
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment