[java-highlighting] IDEA-324445 IJ-CR-110332 offer when after TypePattern

GitOrigin-RevId: e83a11865b073e51f26361121a739d4977abf17b
This commit is contained in:
Mikhail Pyltsin
2023-07-08 13:44:56 +00:00
committed by intellij-monorepo-bot
parent fb5e591040
commit 424001aef5
4 changed files with 17 additions and 3 deletions
@@ -318,8 +318,7 @@ public class JavaKeywordCompletion {
}
private void addWhen() {
LanguageLevel level = PsiUtil.getLanguageLevel(myPosition);
if (!(level == LanguageLevel.JDK_20_PREVIEW || level.isAtLeast(LanguageLevel.JDK_21))) {
if (!HighlightingFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(myPosition)) {
return;
}
PsiElement element = PsiTreeUtil.skipWhitespacesAndCommentsForward(myPrevLeaf);
@@ -0,0 +1,7 @@
class Main {
void f(Object o) {
switch (o) {
case String s whe<caret>
}
}
}
@@ -0,0 +1,7 @@
class Main {
void f(Object o) {
switch (o) {
case String s when <caret>
}
}
}
@@ -10,7 +10,7 @@ public class NormalSwitchCompletionTest extends NormalCompletionTestCase {
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
return JAVA_20;
return JAVA_21;
}
public void testDefaultInRuleSwitch() { doTest(); }
@@ -81,6 +81,7 @@ public class NormalSwitchCompletionTest extends NormalCompletionTestCase {
public void testCompleteFinalInsideSwitch() { doTest("\n"); }
public void testCompleteYieldInsideSwitch() { doTest(); }
public void testWhenInSwitchRule() { doTest(); }
private void doTestPostfixCompletion() {
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable());