mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-209056 Switch, try-catch, synchronized support; avoid conflicting var names; fix reads of uninitialized vars
This commit is contained in:
+1
-1
@@ -6,8 +6,8 @@ class Test {
|
||||
if (strings.length > 2) {
|
||||
String string = strings[0];
|
||||
if (string.equals(strings[1])) {
|
||||
finished = true;
|
||||
res = foo(string);
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
if (!finished) {
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ class Test {
|
||||
if (strings.length > 2) {
|
||||
String string = strings[0];
|
||||
if (string.equals(strings[1])) {
|
||||
finished = true;
|
||||
result = foo(string);
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
if (!finished) {
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ class Test {
|
||||
for (String s : list) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (s.length() == i) {
|
||||
finished = true;
|
||||
result = foo;
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String test(int x) {
|
||||
String result = "foo";
|
||||
switch (x) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
result = "bar";
|
||||
break;
|
||||
case 3:
|
||||
result = "baz";
|
||||
break;
|
||||
default:
|
||||
result = "qux";
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String test(int x) {
|
||||
String result = "foo";
|
||||
synchronized (this) {
|
||||
if (x != 0) {
|
||||
if (x == 1) {
|
||||
result = "bar";
|
||||
} else {
|
||||
result = "baz";
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String test(int x) {
|
||||
String result = null;
|
||||
synchronized (this) {
|
||||
if (x == 0) {
|
||||
result = "foo";
|
||||
} else {
|
||||
if (x == 1) {
|
||||
result = "bar";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result == null) {
|
||||
result = "baz";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
int test(String s) {
|
||||
int result = -1;
|
||||
try {
|
||||
result = Integer.parseInt(s);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
int test(String s) {
|
||||
int res = -1;
|
||||
boolean finished = false;
|
||||
try {
|
||||
res = Integer.parseInt(s);
|
||||
finished = true;
|
||||
} catch (NumberFormatException ex) {
|
||||
boolean result = s.isEmpty();
|
||||
if (result) {
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
if (!finished) {
|
||||
System.out.println("oops");
|
||||
res = -2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
void test(String s) {
|
||||
boolean finished = false;
|
||||
if (s != null) {
|
||||
int a = 0;
|
||||
synchronized (this) {
|
||||
if (s.isEmpty()) {
|
||||
finished = true;
|
||||
} else {
|
||||
a = s.length();
|
||||
}
|
||||
}
|
||||
if (!finished) {
|
||||
System.out.println(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String <caret>test(int x) {
|
||||
switch (x) {
|
||||
case 1:return "foo";
|
||||
case 2:return "bar";
|
||||
case 3:return "baz";
|
||||
default:return "qux";
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String <caret>test(int x) {
|
||||
synchronized(this) {
|
||||
if(x == 0) return "foo";
|
||||
if(x == 1) return "bar";
|
||||
return "baz";
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
String <caret>test(int x) {
|
||||
synchronized(this) {
|
||||
if(x == 0) return "foo";
|
||||
if(x == 1) return "bar";
|
||||
}
|
||||
return "baz";
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
int <caret>test(String s) {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
catch(NumberFormatException ex) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
int <caret>test(String s) {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
catch(NumberFormatException ex) {
|
||||
boolean result = s.isEmpty();
|
||||
if (result) return -1;
|
||||
}
|
||||
System.out.println("oops");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Transform body to single exit-point form" "true"
|
||||
class Test {
|
||||
void <caret>test(String s) {
|
||||
if (s != null) {
|
||||
int a;
|
||||
synchronized (this) {
|
||||
if (s.isEmpty()) return;
|
||||
a = s.length();
|
||||
}
|
||||
System.out.println(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user