mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EnhancedSwitchMigrationInspection: proper condition for non-exhaustive switch
GitOrigin-RevId: 7e0310220f13821a87cc0e231d12f403af65b4e1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c186cba88
commit
620b2c353f
+4
-3
@@ -480,11 +480,12 @@ public class EnhancedSwitchMigrationInspection extends AbstractBaseJavaLocalInsp
|
||||
}
|
||||
if (assignedVariable == null || !hasAssignedBranch) return null;
|
||||
boolean isRightAfterDeclaration = isRightAfterDeclaration(anchor, assignedVariable);
|
||||
if (!wasDefault || !isExhaustive) {
|
||||
if (!wasDefault) {
|
||||
SwitchExpressionBranch defaultBranch = getVariableAssigningDefaultBranch(assignedVariable, isRightAfterDeclaration, statement);
|
||||
if (defaultBranch == null) {
|
||||
} else {
|
||||
if (defaultBranch != null) {
|
||||
newBranches.add(defaultBranch);
|
||||
} else if (!isExhaustive) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new SwitchExistingVariableReplacer(assignedVariable, statement, expressionBeingSwitched, newBranches, isRightAfterDeclaration);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
import java.util.*;
|
||||
|
||||
class SwitchExpressionMigration {
|
||||
private static void m() {
|
||||
private static void m(String s) {
|
||||
int result = switch (s) {
|
||||
case "a" -> 1;
|
||||
case "b" -> 2;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
import java.util.*;
|
||||
|
||||
class SwitchExpressionMigration {
|
||||
private static void m() {
|
||||
private static void m(String s) {
|
||||
int result = 0;
|
||||
switch<caret>(s) {
|
||||
case "a": result = 1; break;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
import java.util.*;
|
||||
|
||||
class SwitchExpressionMigration {
|
||||
private static void m() {
|
||||
private static void m(String s) {
|
||||
int result;
|
||||
switch<caret>(s) {
|
||||
case "a": result = 1; break;
|
||||
|
||||
Reference in New Issue
Block a user