[java-inspections] IJ-CR-125834 EA-1063946 more filters for yield statements

- more tests

GitOrigin-RevId: da9cb8318212633c8ee6eae92f7c43f3f3167036
This commit is contained in:
Mikhail Pyltsin
2024-03-20 11:14:13 +00:00
committed by intellij-monorepo-bot
parent 9ca3db69b4
commit 855a23bf6e
3 changed files with 39 additions and 1 deletions
@@ -0,0 +1,18 @@
// "Replace with 'switch' expression" "true"
class NestedReturn {
public static int parse(String value) {
return switch (value) {
case "string" -> 1;
case "boolean" -> 1;
default -> {
String trimmed = value.trim();
if (trimmed.endsWith("2113[]")) {
byte ops = 1;
yield ~ops;
}
throw new IllegalArgumentException(trimmed);
}
};
}
}
@@ -1,7 +1,7 @@
// "Replace with 'switch' expression" "false"
import java.util.*;
class NestedPatterns {
class NestedReturn {
public static List<Class<?>> parse(String value) {
switc<caret>h (value) {
case "string":
@@ -0,0 +1,20 @@
// "Replace with 'switch' expression" "true"
class NestedReturn {
public static int parse(String value) {
switc<caret>h (value) {
case "string":
return 1;
case "boolean":
return 1;
default: {
String trimmed = value.trim();
if (trimmed.endsWith("2113[]")) {
byte ops = 1;
return ~ops;
}
throw new IllegalArgumentException(trimmed);
}
}
}
}