mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-324641 Allow fallthrough for empty block
GitOrigin-RevId: e60d99c7c4e142d0df91601e9bcee02f4ff4cd7e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
51ab1f234c
commit
aeb1714a62
+6
@@ -925,6 +925,12 @@ public class SwitchBlockHighlightingModel {
|
||||
addIllegalFallThroughError(problem.element(), problem.message(), holder, alreadyFallThroughElements);
|
||||
}
|
||||
else if (JavaPsiPatternUtil.containsPatternVariable(first)) {
|
||||
PsiElement nextNotLabel = PsiTreeUtil.skipSiblingsForward(switchLabelElement, PsiWhiteSpace.class, PsiComment.class,
|
||||
PsiSwitchLabelStatement.class);
|
||||
//there is no statement, it is allowed to go through (14.11.1 JEP 440-441)
|
||||
if (!(nextNotLabel instanceof PsiStatement)) {
|
||||
continue;
|
||||
}
|
||||
if (PsiTreeUtil.skipWhitespacesAndCommentsForward(switchLabelElement) instanceof PsiSwitchLabelStatement) {
|
||||
addIllegalFallThroughError(first, "multiple.switch.labels", holder, alreadyFallThroughElements);
|
||||
}
|
||||
|
||||
+7
@@ -187,4 +187,11 @@ class IllegalFallthroughIn21Java {
|
||||
}
|
||||
|
||||
}
|
||||
void emptyCase(Object o) {
|
||||
switch (o) {
|
||||
case Integer a1:
|
||||
case Object a222:
|
||||
// System.out.println("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ public class LightPatternsForSwitchHighlightingTest extends LightJavaCodeInsight
|
||||
}
|
||||
|
||||
public void testIllegalFallthroughIn20Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_20_PREVIEW, this::doTest);
|
||||
//there are no changes in 20->21
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
}
|
||||
public void testIllegalFallthroughIn21Java() {
|
||||
IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_21, this::doTest);
|
||||
|
||||
Reference in New Issue
Block a user