@@ -510,13 +510,7 @@ public void testIncDecReading230408() throws Exception {
510510 }
511511
512512 public void testRecord1 () throws Exception {
513- try {
514- SourceVersion .valueOf ("RELEASE_14" ); //NOI18N
515- } catch (IllegalArgumentException ex ) {
516- //OK, no RELEASE_14, skip tests
517- return ;
518- }
519- enablePreview ();
513+ setSourceLevel ("16" );
520514 performTest ("Record" ,
521515 "public record Test(String s) {}\n " +
522516 "class T {\n " +
@@ -538,13 +532,7 @@ public void testRecord1() throws Exception {
538532 }
539533
540534 public void testRecord2 () throws Exception {
541- try {
542- SourceVersion .valueOf ("RELEASE_14" ); //NOI18N
543- } catch (IllegalArgumentException ex ) {
544- //OK, no RELEASE_14, skip tests
545- return ;
546- }
547- enablePreview ();
535+ setSourceLevel ("16" );
548536 performTest ("Records" ,
549537 "public class Records {\n " +
550538 " public interface Super {}\n " +
@@ -578,13 +566,7 @@ public void testRecord2() throws Exception {
578566 }
579567
580568 public void testSealed () throws Exception {
581- try {
582- SourceVersion .valueOf ("RELEASE_15" ); //NOI18N
583- } catch (IllegalArgumentException ex ) {
584- //OK, no RELEASE_14, skip tests
585- return ;
586- }
587- enablePreview ();
569+ setSourceLevel ("17" );
588570 performTest ("SealedTest" ,
589571 "sealed class Test{}\n "
590572 + "non-sealed class Child extends Test{}\n " ,
@@ -597,13 +579,7 @@ public void testSealed() throws Exception {
597579 }
598580
599581 public void testSealed2 () throws Exception {
600- try {
601- SourceVersion .valueOf ("RELEASE_15" ); //NOI18N
602- } catch (IllegalArgumentException ex ) {
603- //OK, no RELEASE_14, skip tests
604- return ;
605- }
606- enablePreview ();
582+ setSourceLevel ("17" );
607583 performTest ("SealedTest" ,
608584 "sealed class Test permits Child{}\n "
609585 + "non-sealed class Child extends Test{}\n " ,
@@ -618,13 +594,7 @@ public void testSealed2() throws Exception {
618594 }
619595
620596 public void testSwitchPattern () throws Exception {
621- try {
622- SourceVersion .valueOf ("RELEASE_19" ); //NOI18N
623- } catch (IllegalArgumentException ex ) {
624- //OK, no RELEASE_19, skip tests
625- return ;
626- }
627- enablePreview ();
597+ setSourceLevel ("21" );
628598 performTest ("TestSwitchPattern.java" ,
629599 "public class TestSwitchPattern {\n "
630600 + " String strColor = \" color\" ;\n "
@@ -643,6 +613,8 @@ public void testSwitchPattern() throws Exception {
643613 + "[PUBLIC, CLASS], 3:8-3:14\n "
644614 + "[LOCAL_VARIABLE, DECLARATION], 3:15-3:18\n "
645615 + "[LOCAL_VARIABLE], 4:16-4:19\n "
616+ + "[PUBLIC, CLASS], 5:17-5:23\n "
617+ + "[LOCAL_VARIABLE, DECLARATION], 5:24-5:25\n "
646618 + "[KEYWORD], 5:26-5:30\n "
647619 + "[LOCAL_VARIABLE], 5:31-5:32\n "
648620 + "[PUBLIC, METHOD], 5:33-5:39\n "
@@ -656,13 +628,7 @@ public void testSwitchPattern() throws Exception {
656628 }
657629
658630 public void testRecordPattern () throws Exception {
659- try {
660- SourceVersion .valueOf ("RELEASE_19" ); //NOI18N
661- } catch (IllegalArgumentException ex ) {
662- //OK, no RELEASE_19, skip tests
663- return ;
664- }
665- enablePreview ();
631+ setSourceLevel ("21" );
666632 performTest ("TestRecordPattern.java" ,
667633 "public class TestRecordPattern {\n "
668634 + " record Person(int name, int a){}\n "
@@ -684,7 +650,11 @@ public void testRecordPattern() throws Exception {
684650 + "[LOCAL_VARIABLE, DECLARATION], 3:15-3:18\n "
685651 + "[PACKAGE_PRIVATE, CONSTRUCTOR], 3:25-3:31\n "
686652 + "[LOCAL_VARIABLE], 4:16-4:19\n "
653+ + "[STATIC, PACKAGE_PRIVATE, RECORD], 5:17-5:23\n "
654+ + "[LOCAL_VARIABLE, DECLARATION], 5:28-5:29\n "
655+ + "[LOCAL_VARIABLE, UNUSED, DECLARATION], 5:35-5:36\n "
687656 + "[KEYWORD], 5:38-5:42\n "
657+ + "[LOCAL_VARIABLE], 5:43-5:44\n "
688658 + "[PUBLIC, CLASS], 5:52-5:58\n "
689659 + "[STATIC, PUBLIC, FIELD], 5:59-5:62\n "
690660 + "[PUBLIC, METHOD], 5:63-5:70\n "
@@ -694,7 +664,7 @@ public void testRecordPattern() throws Exception {
694664 }
695665
696666 public void testYield () throws Exception {
697- enablePreview ( );
667+ setSourceLevel ( "17" );
698668 performTest ("YieldTest.java" ,
699669 "public class YieldTest {\n " +
700670 " private int map(int i) {\n " +
@@ -709,12 +679,6 @@ public void testYield() throws Exception {
709679 }
710680
711681 public void testRawStringLiteral () throws Exception {
712- try {
713- SourceVersion .valueOf ("RELEASE_15" );
714- } catch (IllegalArgumentException iae ) {
715- //OK, presumably no support for raw string literals
716- return ;
717- }
718682 setSourceLevel ("15" );
719683 performTest ("RawStringLiteral" ,
720684 "public class RawStringLiteral {\n " +
@@ -739,12 +703,6 @@ public void testRawStringLiteral() throws Exception {
739703 }
740704
741705 public void testBindingPattern () throws Exception {
742- try {
743- SourceVersion .valueOf ("RELEASE_16" );
744- } catch (IllegalArgumentException iae ) {
745- //OK, presumably no support for pattern matching
746- return ;
747- }
748706 setSourceLevel ("16" );
749707 performTest ("BindingPattern" ,
750708 "public class BindingPattern {\n " +
@@ -1070,12 +1028,6 @@ public void testChainTypes4() throws Exception {
10701028 }
10711029
10721030 public void testRawStringLiteralNETBEANS_5118 () throws Exception {
1073- try {
1074- SourceVersion .valueOf ("RELEASE_15" );
1075- } catch (IllegalArgumentException iae ) {
1076- //OK, presumably no support for raw string literals
1077- return ;
1078- }
10791031 setSourceLevel ("15" );
10801032 performTest ("RawStringLiteral" ,
10811033 "public class RawStringLiteral {\n " +
@@ -1115,6 +1067,29 @@ public void testVar() throws Exception {
11151067 "[ABSTRACT, PUBLIC, METHOD], 2:19-2:27" );
11161068 }
11171069
1070+ public void testCaseRuleBodyHighlight () throws Exception {
1071+ performTest ("CaseTest" ,
1072+ """
1073+ public class CaseTest {
1074+ private void t(Object o) {
1075+ switch (o) {
1076+ case Object oo -> {
1077+ o = null;
1078+ }
1079+ }
1080+ }
1081+ }
1082+ """ ,
1083+ "[PUBLIC, CLASS, DECLARATION], 0:13-0:21" ,
1084+ "[PRIVATE, METHOD, UNUSED, DECLARATION], 1:17-1:18" ,
1085+ "[PUBLIC, CLASS], 1:19-1:25" ,
1086+ "[PARAMETER, DECLARATION], 1:26-1:27" ,
1087+ "[PARAMETER], 2:16-2:17" ,
1088+ "[PUBLIC, CLASS], 3:17-3:23" ,
1089+ "[LOCAL_VARIABLE, UNUSED, DECLARATION], 3:24-3:26" ,
1090+ "[PARAMETER], 4:16-4:17" );
1091+ }
1092+
11181093 private void performTest (String fileName ) throws Exception {
11191094 performTest (fileName , new Performer () {
11201095 public void compute (CompilationController parameter , Document doc , final ErrorDescriptionSetter setter ) {
0 commit comments