mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 18:50:54 +07:00
[java-inspections] IDEA-357323 Propose case null during adding all cases
GitOrigin-RevId: 6d7ffccc28d64ed0f52db0235c41796d1d81284e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0f5aa949cb
commit
cb37003541
@@ -0,0 +1,20 @@
|
||||
// "Create missing switch branches with null branch" "true-preview"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
test(true);
|
||||
}
|
||||
|
||||
public void test(@Nullable Boolean b) {
|
||||
switch (b) {
|
||||
case true -> {
|
||||
}
|
||||
case false -> {
|
||||
}
|
||||
case null -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Create missing switch branches with null branch" "true-preview"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
test(true);
|
||||
}
|
||||
|
||||
public void test(@Nullable Boolean b) {
|
||||
switch (b<caret>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Create missing switch branches with null branch" "false"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
test(true);
|
||||
}
|
||||
|
||||
public void test(@Nullable Boolean b) {
|
||||
switch (b<caret>) {
|
||||
case null -> System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// "Create missing switch branches with null branch" "true-preview"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Test {
|
||||
sealed interface SA permits R1, R2 {
|
||||
}
|
||||
|
||||
record R1() implements SA {
|
||||
}
|
||||
|
||||
record R2() implements SA {
|
||||
}
|
||||
|
||||
|
||||
public void test(@Nullable SA sa) {
|
||||
switch (sa) {
|
||||
case R1 r1 -> {
|
||||
}
|
||||
case R2 r2 -> {
|
||||
}
|
||||
case null -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Create missing switch branches with null branch" "false"
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Test {
|
||||
sealed interface SA permits R1, R2 {
|
||||
}
|
||||
|
||||
record R1() implements SA {
|
||||
}
|
||||
|
||||
record R2() implements SA {
|
||||
}
|
||||
|
||||
|
||||
public void test(@NotNull SA sa) {
|
||||
switch (sa<caret>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Create missing switch branches with null branch" "true-preview"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class Test {
|
||||
sealed interface SA permits R1, R2 {
|
||||
}
|
||||
|
||||
record R1() implements SA {
|
||||
}
|
||||
|
||||
record R2() implements SA {
|
||||
}
|
||||
|
||||
|
||||
public void test(@Nullable SA sa) {
|
||||
switch (sa<caret>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user