mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
[java-highlighting] Don't provide the "Move switch branch '...' before '...'" quick-fix when labels dominate each other
(IDEA-27229) GitOrigin-RevId: 12445a0a68c4a4d3f99a92cdabbb8a6288c16c6f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
23fbe72cac
commit
94d6143fef
@@ -688,7 +688,11 @@ public class SwitchBlockHighlightingModel {
|
||||
}
|
||||
alreadyDominatedLabels.forEach((overWhom, who) -> {
|
||||
HighlightInfo info = createError(overWhom, JavaErrorBundle.message("switch.dominance.of.preceding.label", who.getText()));
|
||||
QuickFixAction.registerQuickFixAction(info, getFixFactory().createMoveSwitchBranchUpFix(who, overWhom));
|
||||
PsiPattern overWhomPattern = ObjectUtils.tryCast(overWhom, PsiPattern.class);
|
||||
PsiPattern whoPattern = ObjectUtils.tryCast(who, PsiPattern.class);
|
||||
if (whoPattern == null || !JavaPsiPatternUtil.dominates(overWhomPattern, whoPattern)) {
|
||||
QuickFixAction.registerQuickFixAction(info, getFixFactory().createMoveSwitchBranchUpFix(who, overWhom));
|
||||
}
|
||||
QuickFixAction.registerQuickFixAction(info, getFixFactory().createDeleteSwitchLabelFix(overWhom));
|
||||
results.add(info);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Move switch branch 'List i' before 'List n'" "false"
|
||||
import java.util.List;
|
||||
|
||||
class Main {
|
||||
void test(Object o) {
|
||||
String str = switch (o) {
|
||||
case List n -> "List";
|
||||
case List i<caret> -> "List";
|
||||
default -> "default";
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Move switch branch 'List n && 42 == 42' before 'List n'" "false"
|
||||
import java.util.List;
|
||||
|
||||
class Main {
|
||||
void test(Object o) {
|
||||
String str = switch (o) {
|
||||
case List n -> "List";
|
||||
case List n && 42 == 42<caret> -> "List n && 42 == 42";
|
||||
default -> "default";
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user