extract method: don't skip vars from the exit statements if nullable checks would be added (IDEA-141562)

This commit is contained in:
Anna Kozlova
2015-06-17 20:12:16 +03:00
parent 483df7b174
commit f2cddf7201
6 changed files with 51 additions and 7 deletions
@@ -0,0 +1,12 @@
class X {
static String guessTestDataName(String method, String testName, String[] methods) {
for (String psiMethod : methods) {
<selection>String strings = method;
if (strings != null && !strings.isEmpty()) {
return strings.substring(0) + testName;
}
</selection>
}
return null;
}
}
@@ -0,0 +1,21 @@
import org.jetbrains.annotations.Nullable;
class X {
static String guessTestDataName(String method, String testName, String[] methods) {
for (String psiMethod : methods) {
String strings = newMethod(method, testName);
if (strings != null) return strings;
}
return null;
}
@Nullable
private static String newMethod(String method, String testName) {
String strings = method;
if (strings != null && !strings.isEmpty()) {
return strings.substring(0) + testName;
}
return null;
}
}
@@ -7,7 +7,6 @@ public class Test {
}
private boolean newMethod() {
Object result;
if (test1()) return true;
if (test2()) return true;
return false;