mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java: Add code block and break-with-value when wrapping result expression of a switch expression (IDEA-204012)
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>{ break "a"; }</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
if () {
|
||||
break "a";
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>"a".substring(1);</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
if () {
|
||||
break "a".substring(1);
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> /*0*/<selection>/*1*/"a" +/*2*/ "b"/*3*/;</selection>/*4*/
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> /*0*/{
|
||||
synchronized () {
|
||||
/*1*/
|
||||
"a" +/*2*/ "b"/*3*/;
|
||||
}
|
||||
}/*4*/
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>throw new RuntimeException();</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>throw new RuntimeException();</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
if () {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> /*0*/<selection>/*1*/throw new /*2*/RuntimeException("a")/*3*/;</selection>/*4*/
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> /*0*/{
|
||||
try {
|
||||
/*1*/
|
||||
throw new /*2*/RuntimeException("a")/*3*/;/*4*/
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>{ break "a"; }</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
for () {
|
||||
break "a";
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> <selection>"a".substring(1);</selection>
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> {
|
||||
for () {
|
||||
"a".substring(1);
|
||||
}
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> <selection>{ break "a".substring(1); }</selection>;
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> {
|
||||
do {
|
||||
break "a".substring(1);
|
||||
} while (true);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> /*0*/<selection>{/*1*/break /*2*/"a";/*3*/}</selection>/*4*/
|
||||
};
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> /*0*/{
|
||||
try {
|
||||
/*1*/
|
||||
break /*2*/"a";/*3*/
|
||||
} finally {
|
||||
<caret>
|
||||
}
|
||||
}/*4*/
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> /*0*/<selection>/*1*/"a" + "b"/*2*/;</selection>/*3*/
|
||||
};
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> /*0*/{
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
/*1*/
|
||||
"a" + "b"/*2*/;
|
||||
}
|
||||
};
|
||||
}/*3*/
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> <selection>"a" + "b";</selection>;
|
||||
};
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> {
|
||||
try {
|
||||
break "a" + "b";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
;
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> <selection>"a" + "b";</selection>
|
||||
};
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> {
|
||||
while (true) {
|
||||
"a" + "b";
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> <selection>throw new RuntimeException("a");</selection>
|
||||
};
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
class C {
|
||||
void test(int n) {
|
||||
String s = switch (n) {
|
||||
case 1 -> "";
|
||||
default -> {
|
||||
if () {
|
||||
throw new RuntimeException("a");
|
||||
} else {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user