Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
c9694cff
Commit
c9694cff
authored
6 years ago
by
Roman Shevchenko
Browse files
Options
Download
Email Patches
Plain Diff
Cleanup (formatting)
parent
200f4f4f
Branches unavailable
Tags unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/java-tests/testSrc/com/intellij/java/refactoring/MockIntroduceVariableHandler.java
+17
-21
...tellij/java/refactoring/MockIntroduceVariableHandler.java
with
17 additions
and
21 deletions
+17
-21
java/java-tests/testSrc/com/intellij/java/refactoring/MockIntroduceVariableHandler.java
+
17
-
21
View file @
c9694cff
...
...
@@ -10,7 +10,6 @@ import com.intellij.refactoring.introduceVariable.InputValidator;
import
com.intellij.refactoring.introduceVariable.IntroduceVariableBase
;
import
com.intellij.refactoring.introduceVariable.IntroduceVariableSettings
;
import
com.intellij.refactoring.ui.TypeSelectorManagerImpl
;
import
org.jetbrains.annotations.NonNls
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
@@ -23,38 +22,35 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
private
final
boolean
myReplaceAll
;
private
final
boolean
myDeclareFinal
;
private
final
boolean
myReplaceLValues
;
private
final
String
myExpectedType
CanonicalName
;
private
final
String
myExpectedType
Text
;
private
final
boolean
myLookForType
;
MockIntroduceVariableHandler
(
@NonNls
final
String
name
,
final
boolean
replaceAll
,
final
boolean
declareFinal
,
final
boolean
replaceLValues
,
@NonNls
final
String
expectedTypeCanonicalName
)
{
this
(
name
,
replaceAll
,
declareFinal
,
replaceLValues
,
expectedTypeCanonicalName
,
false
);
MockIntroduceVariableHandler
(
String
name
,
boolean
replaceAll
,
boolean
declareFinal
,
boolean
replaceLValues
,
String
expectedTypeText
)
{
this
(
name
,
replaceAll
,
declareFinal
,
replaceLValues
,
expectedTypeText
,
false
);
}
MockIntroduceVariableHandler
(
@NonNls
final
String
name
,
final
boolean
replaceAll
,
final
boolean
declareFinal
,
final
boolean
replaceLValues
,
@NonNls
final
String
expectedTypeCanonicalName
,
boolean
lookForType
)
{
MockIntroduceVariableHandler
(
String
name
,
boolean
replaceAll
,
boolean
declareFinal
,
boolean
replaceLValues
,
String
expectedTypeText
,
boolean
lookForType
)
{
myName
=
name
;
myReplaceAll
=
replaceAll
;
myDeclareFinal
=
declareFinal
;
myReplaceLValues
=
replaceLValues
;
myExpectedType
CanonicalName
=
expectedType
CanonicalName
;
myExpectedType
Text
=
expectedType
Text
;
myLookForType
=
lookForType
;
}
@Override
public
IntroduceVariableSettings
getSettings
(
Project
project
,
Editor
editor
,
PsiExpression
expr
,
final
PsiExpression
[]
occurrences
,
PsiExpression
expr
,
PsiExpression
[]
occurrences
,
TypeSelectorManagerImpl
typeSelectorManager
,
final
boolean
declareFinalIfAll
,
boolean
declareFinalIfAll
,
boolean
anyAssignmentLHS
,
InputValidator
validator
,
PsiElement
anchor
,
final
JavaReplaceChoice
replaceChoice
)
{
final
PsiType
type
=
myLookForType
?
findType
(
typeSelectorManager
.
getTypesForAll
(),
typeSelectorManager
.
getDefaultType
())
:
typeSelectorManager
.
getDefaultType
();
assertEquals
(
type
.
getInternalCanonicalText
(),
myExpectedTypeCanonicalName
);
PsiElement
anchor
,
JavaReplaceChoice
replaceChoice
)
{
PsiType
defaultType
=
typeSelectorManager
.
getDefaultType
();
PsiType
type
=
myLookForType
?
findType
(
typeSelectorManager
.
getTypesForAll
(),
defaultType
)
:
defaultType
;
assertEquals
(
type
.
getInternalCanonicalText
(),
myExpectedTypeText
);
IntroduceVariableSettings
introduceVariableSettings
=
new
IntroduceVariableSettings
()
{
@Override
public
String
getEnteredName
()
{
...
...
@@ -86,12 +82,12 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
return
true
;
}
};
final
boolean
validationResult
=
validator
.
isOK
(
introduceVariableSettings
);
boolean
validationResult
=
validator
.
isOK
(
introduceVariableSettings
);
assertValidationResult
(
validationResult
);
return
introduceVariableSettings
;
}
protected
void
assertValidationResult
(
final
boolean
validationResult
)
{
protected
void
assertValidationResult
(
boolean
validationResult
)
{
assertTrue
(
validationResult
);
}
...
...
@@ -102,8 +98,8 @@ class MockIntroduceVariableHandler extends IntroduceVariableBase {
private
PsiType
findType
(
final
PsiType
[]
candidates
,
PsiType
defaultType
)
{
for
(
PsiType
candidate
:
candidates
)
{
if
(
candidate
.
equalsToText
(
myExpectedType
CanonicalName
))
return
candidate
;
if
(
candidate
.
equalsToText
(
myExpectedType
Text
))
return
candidate
;
}
return
defaultType
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help