mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: avoid infinite loop when creating switch branches for enum with duplicate constants (IDEA-357561)
GitOrigin-RevId: e9c84396786baceb58501a56d5d7e529f5ae9276
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c983a3af19
commit
e2e6809274
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.fixes;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
@@ -25,7 +25,7 @@ public final class CreateEnumMissingSwitchBranchesFix extends CreateMissingSwitc
|
||||
|
||||
@Override
|
||||
protected @NotNull List<String> getAllNames(@NotNull PsiClass aClass, @NotNull PsiSwitchBlock switchBlock) {
|
||||
return StreamEx.of(aClass.getAllFields()).select(PsiEnumConstant.class).map(PsiField::getName).toList();
|
||||
return StreamEx.of(aClass.getFields()).select(PsiEnumConstant.class).map(PsiField::getName).distinct().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Create missing branches 'A', 'B', and 'C'" "true"
|
||||
class Main {
|
||||
enum E {A, B, C, C}
|
||||
|
||||
public void f(E e) {
|
||||
switch (e) {
|
||||
case A -> {
|
||||
}
|
||||
case B -> {
|
||||
}
|
||||
case C -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create missing branches 'A', 'B', and 'C'" "true"
|
||||
class Main {
|
||||
enum E {A, B, C, C}
|
||||
|
||||
public void f(E e) {
|
||||
switch<caret> (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user