File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
main/java/com/google/errorprone/bugpatterns
test/java/com/google/errorprone/bugpatterns Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public final class StatementSwitchToExpressionSwitch extends BugChecker
94
94
ImmutableSet .of (THROW , EXPRESSION_STATEMENT );
95
95
private static final ImmutableSet <Kind > KINDS_RETURN_OR_THROW = ImmutableSet .of (THROW , RETURN );
96
96
private static final Pattern FALL_THROUGH_PATTERN =
97
- Pattern .compile ("\\ bfalls?.?through\\ b" , Pattern .CASE_INSENSITIVE );
97
+ Pattern .compile ("\\ bfalls?.?( through|out) \\ b" , Pattern .CASE_INSENSITIVE );
98
98
// Default (negative) result for assignment switch conversion analysis. Note that the value is
99
99
// immutable.
100
100
private static final AssignmentSwitchAnalysisResult DEFAULT_ASSIGNMENT_SWITCH_ANALYSIS_RESULT =
Original file line number Diff line number Diff line change @@ -3657,4 +3657,36 @@ public void unnecessaryBreaks() {
3657
3657
.setArgs ("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true" )
3658
3658
.doTest (BugCheckerRefactoringTestHelper .TestMode .TEXT_MATCH );
3659
3659
}
3660
+
3661
+ @ Test
3662
+ public void fallOutComment () {
3663
+ assumeTrue (RuntimeVersion .isAtLeast14 ());
3664
+ refactoringHelper
3665
+ .addInputLines (
3666
+ "Test.java" ,
3667
+ "public class Test {" ,
3668
+ " void f(int x) {" ,
3669
+ " switch (x) {" ,
3670
+ " case 0:" ,
3671
+ " System.err.println(\" ZERO\" );" ,
3672
+ " break;" ,
3673
+ " default:" ,
3674
+ " // fall out" ,
3675
+ " }" ,
3676
+ " }" ,
3677
+ "}" )
3678
+ .addOutputLines (
3679
+ "Test.java" ,
3680
+ "public class Test {" ,
3681
+ " void f(int x) {" ,
3682
+ " switch (x) {" ,
3683
+ " case 0 -> System.err.println(\" ZERO\" );" ,
3684
+ " default -> {}" ,
3685
+ " }" ,
3686
+ " }" ,
3687
+ "}" )
3688
+ .setArgs (
3689
+ ImmutableList .of ("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion" ))
3690
+ .doTest (BugCheckerRefactoringTestHelper .TestMode .TEXT_MATCH );
3691
+ }
3660
3692
}
You can’t perform that action at this time.
0 commit comments