diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaKeywordCompletion.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaKeywordCompletion.java index a902aee97b30..fb2283e2f475 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaKeywordCompletion.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaKeywordCompletion.java @@ -775,8 +775,9 @@ public class JavaKeywordCompletion { addKeyword(br); } else if (psiElement().inside(PsiSwitchExpression.class).accepts(myPosition)) { - addKeyword(TailTypeDecorator.withTail(br, TailType.INSERT_SPACE)); - addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.YIELD), TailType.INSERT_SPACE)); + addKeyword(TailTypeDecorator.withTail(PsiUtil.getLanguageLevel(myPosition) == LanguageLevel.JDK_12_PREVIEW + ? createKeyword(PsiKeyword.BREAK) + : createKeyword(PsiKeyword.YIELD), TailType.INSERT_SPACE)); } for (PsiLabeledStatement labeled : psiApi().parents(myPosition).takeWhile(notInstanceOf(PsiMember.class)).filter(PsiLabeledStatement.class)) { diff --git a/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression.java b/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression.java index 34e868eddf43..78e4228d6137 100644 --- a/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression.java +++ b/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression.java @@ -2,7 +2,7 @@ public class ConstConfig { int test(int x) { return switch (x) { case 1: - if (Math.random() > 0.5) br + if (Math.random() > 0.5) yi }; } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression_after.java b/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression_after.java index 4c8d79f05912..b9e3d78231f8 100644 --- a/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression_after.java +++ b/java/java-tests/testData/codeInsight/completion/normal/BreakInSwitchExpression_after.java @@ -2,7 +2,7 @@ public class ConstConfig { int test(int x) { return switch (x) { case 1: - if (Math.random() > 0.5) break + if (Math.random() > 0.5) yield }; } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression.java b/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression.java index bec68a0583c1..907421f65e25 100644 --- a/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression.java +++ b/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression.java @@ -3,9 +3,9 @@ public class ConstConfig { Boolean b; if ((b = switch (0) { case 1: { - break aaaa; + yield aaaa; } - default: break false; + default: yield false; })); } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression_after.java b/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression_after.java index a52917e6b3f3..bbc7a6cafac5 100644 --- a/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression_after.java +++ b/java/java-tests/testData/codeInsight/completion/normal/InsideBreakInSwitchExpression_after.java @@ -3,9 +3,9 @@ public class ConstConfig { Boolean b; if ((b = switch (0) { case 1: { - break aaaaaaaa; + yield aaaaaaaa; } - default: break false; + default: yield false; })); } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/Normal12CompletionTest.groovy b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/Normal12CompletionTest.groovy index 076d20944ed7..414fca5bf796 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/Normal12CompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/completion/Normal12CompletionTest.groovy @@ -12,7 +12,7 @@ class Normal12CompletionTest extends NormalCompletionTestCase { @NotNull @Override protected LightProjectDescriptor getProjectDescriptor() { - return JAVA_12 + return JAVA_13 } void testDefaultInRuleSwitch() throws Throwable { doTest() }