suppress inspection for switch backward migration when not -> used: IDEA-204207

This commit is contained in:
Roman.Ivanov
2018-12-14 16:18:33 +07:00
parent 956a9f16ce
commit f3ff9a02c3
2 changed files with 15 additions and 1 deletions
@@ -34,6 +34,7 @@ public class EnhancedSwitchBackwardMigrationInspection extends AbstractBaseJavaL
return new JavaElementVisitor() {
@Override
public void visitSwitchExpression(PsiSwitchExpression expression) {
if (!SwitchUtils.isRuleFormatSwitch(expression)) return;
if (findReplacer(expression) == null) return;
String message = InspectionsBundle.message("inspection.switch.expression.backward.expression.migration.inspection.name");
holder.registerProblem(expression.getFirstChild(), message, new ReplaceWithOldStyleSwitchFix());
@@ -41,8 +42,8 @@ public class EnhancedSwitchBackwardMigrationInspection extends AbstractBaseJavaL
@Override
public void visitSwitchStatement(PsiSwitchStatement statement) {
if (findReplacer(statement) == null) return;
if (!SwitchUtils.isRuleFormatSwitch(statement)) return;
if (findReplacer(statement) == null) return;
String message = InspectionsBundle.message("inspection.switch.expression.backward.statement.migration.inspection.name");
holder.registerProblem(statement.getFirstChild(), message, new ReplaceWithOldStyleSwitchFix());
}
@@ -0,0 +1,13 @@
// "Replace with old style 'switch' statement" "false"
import java.util.*;
class SwitchExpressionMigration {
int foo(int n) {
return switch<caret> (n) {
case 1:
break 1;
default:
break 0;
};
}
}