mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
DeleteSwitchLabelFix: delete unreachable switch branch
Fixes IDEA-199692 Quickfix to delete unreachable switch branch reported by "constant conditions & exceptions"
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
// "Remove switch branch '"baz"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "qux":
|
||||
case "bar":
|
||||
class Foo {}
|
||||
int i;
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Remove switch label '"qux"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
int i = 1;
|
||||
class Foo {}
|
||||
System.out.println(i);
|
||||
break;
|
||||
/*comment*/
|
||||
case "bar":
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Remove switch label '"bar"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
int i = 1;
|
||||
class Foo {}
|
||||
System.out.println(i);
|
||||
break;
|
||||
case "qux":
|
||||
// comment
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Remove switch branch '"bar"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
System.out.println("foo");
|
||||
break;
|
||||
//oops
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Remove switch branch '"baz"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "<caret>baz":
|
||||
int i = 1;
|
||||
class Foo {}
|
||||
System.out.println(i);
|
||||
break;
|
||||
case "qux":
|
||||
case "bar":
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Remove switch label '"qux"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
int i = 1;
|
||||
class Foo {}
|
||||
System.out.println(i);
|
||||
break;
|
||||
case "<caret>qux" /*comment*/:
|
||||
case "bar":
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// "Remove switch label '"bar"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
int i = 1;
|
||||
class Foo {}
|
||||
System.out.println(i);
|
||||
break;
|
||||
case "qux":
|
||||
case "<caret>bar" // comment
|
||||
:
|
||||
i = 2;
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
default:
|
||||
System.out.println("oops");
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Remove switch branch '"bar"'" "true"
|
||||
class Main {
|
||||
public void test() {
|
||||
switch ("foo") {
|
||||
case "baz":
|
||||
System.out.println("foo");
|
||||
break;
|
||||
case "<caret>bar":
|
||||
int i = 2;
|
||||
class Foo {}
|
||||
System.out.println("hello"+new Foo()+i);
|
||||
//oops
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user