diff --git a/java/java-syntax/src/com/intellij/pom/java/JavaFeature.kt b/java/java-syntax/src/com/intellij/pom/java/JavaFeature.kt index 0ea4879436ee..3ed7e5ddda47 100644 --- a/java/java-syntax/src/com/intellij/pom/java/JavaFeature.kt +++ b/java/java-syntax/src/com/intellij/pom/java/JavaFeature.kt @@ -119,6 +119,7 @@ enum class JavaFeature { //jep 463,477 INHERITED_STATIC_MAIN_METHOD(LanguageLevel.JDK_22_PREVIEW, "feature.inherited.static.main.method"), IMPLICIT_IMPORT_IN_IMPLICIT_CLASSES(LanguageLevel.JDK_23_PREVIEW, "feature.implicit.import.in.implicit.classes"), + //JEP 507 PRIMITIVE_TYPES_IN_PATTERNS(LanguageLevel.JDK_23_PREVIEW, "feature.primitive.types.in.patterns"), //see together with PACKAGE_IMPORTS_SHADOW_MODULE_IMPORTS and TRANSITIVE_DEPENDENCY_ON_JAVA_BASE diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25.java new file mode 100644 index 000000000000..39d875c8cf04 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25.java @@ -0,0 +1,11 @@ +package test.something; + +public class SwitchRecordPrimitiveJava25 { + static void main(String[] args) { + Integer a = 1; + switch (a) { + case int _ -> System.out.println("1"); + default -> throw new IllegalStateException("Unexpected value: " + a); + } + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25Preview.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25Preview.java new file mode 100644 index 000000000000..f80533c23690 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsWithPrimitives/SwitchRecordPrimitiveJava25Preview.java @@ -0,0 +1,11 @@ +package test.something; + +public class SwitchRecordPrimitiveJava25Preview { + static void main(String[] args) { + Integer a = 1; + switch (a) { + case int _ -> System.out.println("1"); + default -> throw new IllegalStateException("Unexpected value: " + a); + } + } +} diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightPrimitivePatternsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightPrimitivePatternsHighlightingTest.java index 8aae13f42a58..df1df1805b9e 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightPrimitivePatternsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/LightPrimitivePatternsHighlightingTest.java @@ -2,6 +2,8 @@ package com.intellij.java.codeInsight.daemon; import com.intellij.JavaTestUtil; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.LightProjectDescriptor; import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase; import org.jetbrains.annotations.NotNull; @@ -48,4 +50,12 @@ public class LightPrimitivePatternsHighlightingTest extends LightJavaCodeInsight myFixture.configureByFile(getTestName(false) + ".java"); myFixture.checkHighlighting(); } + + public void testSwitchRecordPrimitiveJava25Preview() { + IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_25_PREVIEW, this::doTest); + } + + public void testSwitchRecordPrimitiveJava25() { + IdeaTestUtil.withLevel(getModule(), LanguageLevel.JDK_25, this::doTest); + } } \ No newline at end of file