Skip to content

Commit

Permalink
FORCE on check
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 645227800
  • Loading branch information
java-team-github-bot authored and Error Prone Team committed Jun 21, 2024
1 parent 3e4aa1d commit 7841a33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.google.errorprone.matchers.Matchers;
import com.google.errorprone.util.ASTHelpers;
import com.google.errorprone.util.Reachability;
import com.google.errorprone.util.SourceVersion;
import com.sun.source.tree.AssignmentTree;
import com.sun.source.tree.BlockTree;
import com.sun.source.tree.BreakTree;
Expand Down Expand Up @@ -135,7 +134,10 @@ static enum CaseQualifications {
@Inject
StatementSwitchToExpressionSwitch(ErrorProneFlags flags) {
this.enableDirectConversion =
flags.getBoolean("StatementSwitchToExpressionSwitch:EnableDirectConversion").orElse(false);
true
|| flags
.getBoolean("StatementSwitchToExpressionSwitch:EnableDirectConversion")
.orElse(false);
this.enableReturnSwitchConversion =
flags
.getBoolean("StatementSwitchToExpressionSwitch:EnableReturnSwitchConversion")
Expand All @@ -148,9 +150,9 @@ static enum CaseQualifications {

@Override
public Description matchSwitch(SwitchTree switchTree, VisitorState state) {
if (!SourceVersion.supportsSwitchExpressions(state.context)) {
return NO_MATCH;
}
// if (!SourceVersion.supportsSwitchExpressions(state.context)) {
// return NO_MATCH;
// }

AnalysisResult analysisResult = analyzeSwitchTree(switchTree, state);

Expand Down Expand Up @@ -568,7 +570,7 @@ private static SuggestedFix convertDirectlyToExpressionSwitch(
|| trimmedTransformedBlockSource.equals("break;")) {
replacementCodeBuilder.append("{}");
} else {
replacementCodeBuilder.append("{").append(transformedBlockSource).append("\n}");
replacementCodeBuilder.append("{\n").append(transformedBlockSource).append("\n}");
}
} else {
// Transformed block has code
Expand All @@ -585,7 +587,7 @@ private static SuggestedFix convertDirectlyToExpressionSwitch(
replacementCodeBuilder.append(transformedBlockSource);
} else {
// Use braces on the rhs
replacementCodeBuilder.append("{").append(transformedBlockSource).append("\n}");
replacementCodeBuilder.append("{\n").append(transformedBlockSource).append("\n}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public void switchByEnum_removesRedundantBreak_error() {
" ",
" public void foo(Side side) { ",
" switch(side) {",
" case OBVERSE -> { /* left comment */",
" case OBVERSE -> {",
" /* left comment */",
" /* and there is more: */",
" // to end of line",
" // Explanatory comment",
Expand Down

0 comments on commit 7841a33

Please sign in to comment.