Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove // fall out comments, which are sometimes used to document an empty default: statement group #4519

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public final class StatementSwitchToExpressionSwitch extends BugChecker
ImmutableSet.of(THROW, EXPRESSION_STATEMENT);
private static final ImmutableSet<Kind> KINDS_RETURN_OR_THROW = ImmutableSet.of(THROW, RETURN);
private static final Pattern FALL_THROUGH_PATTERN =
Pattern.compile("\\bfalls?.?through\\b", Pattern.CASE_INSENSITIVE);
Pattern.compile("\\bfalls?.?(through|out)\\b", Pattern.CASE_INSENSITIVE);
// Default (negative) result for assignment switch conversion analysis. Note that the value is
// immutable.
private static final AssignmentSwitchAnalysisResult DEFAULT_ASSIGNMENT_SWITCH_ANALYSIS_RESULT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3657,4 +3657,36 @@ public void unnecessaryBreaks() {
.setArgs("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion=true")
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
public void fallOutComment() {
assumeTrue(RuntimeVersion.isAtLeast14());
refactoringHelper
.addInputLines(
"Test.java",
"public class Test {",
" void f(int x) {",
" switch (x) {",
" case 0:",
" System.err.println(\"ZERO\");",
" break;",
" default:",
" // fall out",
" }",
" }",
"}")
.addOutputLines(
"Test.java",
"public class Test {",
" void f(int x) {",
" switch (x) {",
" case 0 -> System.err.println(\"ZERO\");",
" default -> {}",
" }",
" }",
"}")
.setArgs(
ImmutableList.of("-XepOpt:StatementSwitchToExpressionSwitch:EnableDirectConversion"))
.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}
}
Loading