mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
move test for fix in IJ-CR-4970 away from SuppressLIIJspTest because it has nothing to do with jsp
GitOrigin-RevId: 84111526ca761cc9b4cb468371e4455ef5b0fead
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f1ad635d96
commit
a2233e727f
+7
@@ -0,0 +1,7 @@
|
||||
// "Suppress for statement" "true"
|
||||
class X {
|
||||
{
|
||||
//noinspection MyLocalInspectionTool
|
||||
String s = String.format("foo");
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Suppress for statement" "true"
|
||||
class X {
|
||||
{
|
||||
String s = String.form<caret>at("foo");
|
||||
}
|
||||
}
|
||||
+47
-1
@@ -16,11 +16,21 @@
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.IntentionAndQuickFixAction;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal;
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName;
|
||||
import com.intellij.codeInspection.util.IntentionName;
|
||||
import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.ig.psiutils.MethodCallUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SuppressLocalInspectionTest extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
@@ -30,7 +40,7 @@ public class SuppressLocalInspectionTest extends LightQuickFixParameterizedTestC
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool @NotNull [] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new LocalCanBeFinal(), new FieldCanBeLocalInspection()};
|
||||
return new LocalInspectionTool[]{new LocalCanBeFinal(), new FieldCanBeLocalInspection(), new MyLocalInspectionTool()};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,5 +48,41 @@ public class SuppressLocalInspectionTest extends LightQuickFixParameterizedTestC
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/suppressLocalInspection";
|
||||
}
|
||||
|
||||
|
||||
static class DummyUnavailableQuickFix extends IntentionAndQuickFixAction {
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, @Nullable Editor editor, PsiFile file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @IntentionName @NotNull String getName() {
|
||||
return getFamilyName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @IntentionFamilyName @NotNull String getFamilyName() {
|
||||
return "Dummy fix";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, PsiFile file, @Nullable Editor editor) {
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
if (MethodCallUtils.isCallToMethod(expression, CommonClassNames.JAVA_LANG_STRING, null, "format", (PsiType[]) null)) {
|
||||
holder.registerProblem(expression, "I am a dummy problem with unavailable fix", new DummyUnavailableQuickFix());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user