mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[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:
committed by
intellij-monorepo-bot
parent
65edb4852c
commit
a961fa6ae8
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user