@@ -510,13 +510,7 @@ public void testIncDecReading230408() throws Exception {
510
510
}
511
511
512
512
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" );
520
514
performTest ("Record" ,
521
515
"public record Test(String s) {}\n " +
522
516
"class T {\n " +
@@ -538,13 +532,7 @@ public void testRecord1() throws Exception {
538
532
}
539
533
540
534
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" );
548
536
performTest ("Records" ,
549
537
"public class Records {\n " +
550
538
" public interface Super {}\n " +
@@ -578,13 +566,7 @@ public void testRecord2() throws Exception {
578
566
}
579
567
580
568
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" );
588
570
performTest ("SealedTest" ,
589
571
"sealed class Test{}\n "
590
572
+ "non-sealed class Child extends Test{}\n " ,
@@ -597,13 +579,7 @@ public void testSealed() throws Exception {
597
579
}
598
580
599
581
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" );
607
583
performTest ("SealedTest" ,
608
584
"sealed class Test permits Child{}\n "
609
585
+ "non-sealed class Child extends Test{}\n " ,
@@ -618,13 +594,7 @@ public void testSealed2() throws Exception {
618
594
}
619
595
620
596
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" );
628
598
performTest ("TestSwitchPattern.java" ,
629
599
"public class TestSwitchPattern {\n "
630
600
+ " String strColor = \" color\" ;\n "
@@ -643,6 +613,8 @@ public void testSwitchPattern() throws Exception {
643
613
+ "[PUBLIC, CLASS], 3:8-3:14\n "
644
614
+ "[LOCAL_VARIABLE, DECLARATION], 3:15-3:18\n "
645
615
+ "[LOCAL_VARIABLE], 4:16-4:19\n "
616
+ + "[PUBLIC, CLASS], 5:17-5:23\n "
617
+ + "[LOCAL_VARIABLE, DECLARATION], 5:24-5:25\n "
646
618
+ "[KEYWORD], 5:26-5:30\n "
647
619
+ "[LOCAL_VARIABLE], 5:31-5:32\n "
648
620
+ "[PUBLIC, METHOD], 5:33-5:39\n "
@@ -656,13 +628,7 @@ public void testSwitchPattern() throws Exception {
656
628
}
657
629
658
630
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" );
666
632
performTest ("TestRecordPattern.java" ,
667
633
"public class TestRecordPattern {\n "
668
634
+ " record Person(int name, int a){}\n "
@@ -684,7 +650,11 @@ public void testRecordPattern() throws Exception {
684
650
+ "[LOCAL_VARIABLE, DECLARATION], 3:15-3:18\n "
685
651
+ "[PACKAGE_PRIVATE, CONSTRUCTOR], 3:25-3:31\n "
686
652
+ "[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 "
687
656
+ "[KEYWORD], 5:38-5:42\n "
657
+ + "[LOCAL_VARIABLE], 5:43-5:44\n "
688
658
+ "[PUBLIC, CLASS], 5:52-5:58\n "
689
659
+ "[STATIC, PUBLIC, FIELD], 5:59-5:62\n "
690
660
+ "[PUBLIC, METHOD], 5:63-5:70\n "
@@ -694,7 +664,7 @@ public void testRecordPattern() throws Exception {
694
664
}
695
665
696
666
public void testYield () throws Exception {
697
- enablePreview ( );
667
+ setSourceLevel ( "17" );
698
668
performTest ("YieldTest.java" ,
699
669
"public class YieldTest {\n " +
700
670
" private int map(int i) {\n " +
@@ -709,12 +679,6 @@ public void testYield() throws Exception {
709
679
}
710
680
711
681
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
- }
718
682
setSourceLevel ("15" );
719
683
performTest ("RawStringLiteral" ,
720
684
"public class RawStringLiteral {\n " +
@@ -739,12 +703,6 @@ public void testRawStringLiteral() throws Exception {
739
703
}
740
704
741
705
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
- }
748
706
setSourceLevel ("16" );
749
707
performTest ("BindingPattern" ,
750
708
"public class BindingPattern {\n " +
@@ -1070,12 +1028,6 @@ public void testChainTypes4() throws Exception {
1070
1028
}
1071
1029
1072
1030
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
- }
1079
1031
setSourceLevel ("15" );
1080
1032
performTest ("RawStringLiteral" ,
1081
1033
"public class RawStringLiteral {\n " +
@@ -1115,6 +1067,29 @@ public void testVar() throws Exception {
1115
1067
"[ABSTRACT, PUBLIC, METHOD], 2:19-2:27" );
1116
1068
}
1117
1069
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
+
1118
1093
private void performTest (String fileName ) throws Exception {
1119
1094
performTest (fileName , new Performer () {
1120
1095
public void compute (CompilationController parameter , Document doc , final ErrorDescriptionSetter setter ) {
0 commit comments