[property tests] IDEA-271659 Property test for pattern matching for switch

Add a new action on file for invoking IfCanBeSwitchInspection

GitOrigin-RevId: 0673fca2d4583e6909ecab6716a998c257785f99
This commit is contained in:
Nikita Eshkeev
2021-06-30 19:48:26 +00:00
committed by intellij-monorepo-bot
parent 65edb4852c
commit a961fa6ae8
2 changed files with 28 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.propertyBased;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiIfStatement;
import com.siyeh.InspectionGadgetsBundle;
import org.jetbrains.annotations.NotNull;
import java.util.function.Function;
public final class IfCanBeSwitchActionOnFile extends InvokeIntentionAtElement {
public IfCanBeSwitchActionOnFile(@NotNull PsiFile file) {
super(file, new IfCanBeSwitchPolicy(), PsiIfStatement.class, Function.identity());
}
private static final class IfCanBeSwitchPolicy extends JavaIntentionPolicy {
@Override
protected boolean shouldSkipIntention(@NotNull String actionText) {
return !actionText.equals(InspectionGadgetsBundle.message("if.can.be.switch.problem.descriptor"));
}
}
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.propertyBased;
import com.intellij.application.options.CodeStyle;
@@ -55,7 +55,7 @@ public class JavaCodeInsightSanityTest extends LightJavaCodeInsightFixtureTestCa
@Override
protected @NotNull LightProjectDescriptor getProjectDescriptor() {
return JAVA_15;
return JAVA_17;
}
public void testRandomActivity() {
@@ -65,7 +65,9 @@ public class JavaCodeInsightSanityTest extends LightJavaCodeInsightFixtureTestCa
new InvokeCompletion(file, new JavaCompletionPolicy()),
new StripTestDataMarkup(file),
new DeleteRange(file),
new IntroduceVariableActionOnFile(file));
new IntroduceVariableActionOnFile(file),
new IfCanBeSwitchActionOnFile(file)
);
PropertyChecker
.checkScenarios(actionsOnJavaFiles(fileActions));
}