[java] drops value break keyword completion

GitOrigin-RevId: b713ae661f06245ae400d6aa20ec14d2fa2f20ef
This commit is contained in:
Roman Shevchenko
2019-07-05 01:10:36 +03:00
committed by intellij-monorepo-bot
parent 60e3e2280b
commit 1baaa93702
4 changed files with 28 additions and 7 deletions
@@ -773,13 +773,9 @@ public class JavaKeywordCompletion {
if (psiElement().inside(PsiSwitchStatement.class).accepts(myPosition)) {
addKeyword(br);
}
else if (psiElement().inside(PsiSwitchExpression.class).accepts(myPosition)) {
if (PsiUtil.getLanguageLevel(myPosition) == LanguageLevel.JDK_12_PREVIEW) {
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.BREAK), TailType.INSERT_SPACE));
}
else if (PsiUtil.getLanguageLevel(myPosition).isAtLeast(LanguageLevel.JDK_13_PREVIEW)) {
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.YIELD), TailType.INSERT_SPACE));
}
else if (psiElement().inside(PsiSwitchExpression.class).accepts(myPosition) &&
PsiUtil.getLanguageLevel(myPosition).isAtLeast(LanguageLevel.JDK_13_PREVIEW)) {
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.YIELD), TailType.INSERT_SPACE));
}
for (PsiLabeledStatement labeled : psiApi().parents(myPosition).takeWhile(notInstanceOf(PsiMember.class)).filter(PsiLabeledStatement.class)) {
@@ -0,0 +1,12 @@
class BreakDeepInsideSwitchExpression {
int test(int i) {
return switch (i) {
default -> {
while (true) {
if (--i < 8) br<caret>
}
yield i;
};
};
}
}
@@ -0,0 +1,12 @@
class BreakDeepInsideSwitchExpression {
int test(int i) {
return switch (i) {
default -> {
while (true) {
if (--i < 8) break;
}
yield i;
};
};
}
}
@@ -21,4 +21,5 @@ class Normal13CompletionTest extends NormalCompletionTestCase {
void testYieldInSwitchExpression() { doTest() }
void testInsideYieldInSwitchExpression() { doTest() }
void testInsideRuleInSwitchExpression() { doTest() }
void testBreakDeepInsideSwitchExpression() { doTest() }
}