quick fix for MagicConstantInspection which suggests to replace 1 with Font.BOLD

This commit is contained in:
Alexey Kudravtsev
2016-04-15 12:34:33 +03:00
parent ac5712ebbf
commit bfcb00fff6
9 changed files with 303 additions and 45 deletions

View File

@@ -35,6 +35,7 @@ import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.impl.JavaConstantExpressionEvaluator;
import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocTag;
@@ -53,6 +54,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.stream.Collectors;
public class MagicConstantInspection extends BaseJavaLocalInspectionTool {
private static final Key<Boolean> NO_ANNOTATIONS_FOUND = Key.create("REPORTED_NO_ANNOTATIONS_FOUND");
@@ -517,7 +519,73 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool {
}
return value.getText();
}, ", ");
holder.registerProblem(argument, "Must be one of: " + values);
String message = "Should be one of: " + values + (allowedValues.canBeOred ? " or their combination" : "");
holder.registerProblem(argument, message, suggestMagicConstant(argument, allowedValues));
}
@Nullable // null means no quickfix available
private static LocalQuickFix suggestMagicConstant(@NotNull PsiExpression argument,
@NotNull AllowedValues allowedValues) {
Object argumentValue = JavaConstantExpressionEvaluator.computeConstantExpression(argument, null, false);
if (argumentValue == null) return null;
if (!allowedValues.canBeOred) {
for (PsiAnnotationMemberValue value : allowedValues.values) {
if (value instanceof PsiExpression) {
Object constantValue = JavaConstantExpressionEvaluator.computeConstantExpression((PsiExpression)value, null, false);
if (constantValue != null && constantValue.equals(argumentValue)) {
return new ReplaceWithMagicConstantFix(argument, value);
}
}
}
}
else {
Long longArgument = evaluateLongConstant(argument);
if (longArgument == null) { return null; }
// try to find ored flags
long remainingFlags = longArgument.longValue();
List<PsiAnnotationMemberValue> flags = new ArrayList<>();
for (PsiAnnotationMemberValue value : allowedValues.values) {
if (value instanceof PsiExpression) {
Long constantValue = evaluateLongConstant((PsiExpression)value);
if (constantValue == null) {
continue;
}
if ((remainingFlags & constantValue) == constantValue) {
flags.add(value);
remainingFlags &= ~constantValue;
}
}
}
if (remainingFlags == 0) {
// found flags to combine with OR, suggest the fix
if (flags.size() > 1) {
for (int i = flags.size() - 1; i >= 0; i--) {
PsiAnnotationMemberValue flag = flags.get(i);
if (evaluateLongConstant((PsiExpression)flag) == 0) {
// no sense in ORing with '0'
flags.remove(i);
}
}
}
if (!flags.isEmpty()) {
return new ReplaceWithMagicConstantFix(argument, flags.toArray(PsiAnnotationMemberValue.EMPTY_ARRAY));
}
}
}
return null;
}
private static Long evaluateLongConstant(@NotNull PsiExpression expression) {
Object constantValue = JavaConstantExpressionEvaluator.computeConstantExpression(expression, null, false);
if (constantValue instanceof Long ||
constantValue instanceof Integer ||
constantValue instanceof Short ||
constantValue instanceof Byte) {
return ((Number)constantValue).longValue();
}
return null;
}
private static boolean isAllowed(@NotNull final PsiElement scope,
@@ -648,4 +716,75 @@ public class MagicConstantInspection extends BaseJavaLocalInspectionTool {
return !children.isEmpty();
}
private static class ReplaceWithMagicConstantFix extends LocalQuickFixOnPsiElement {
private final List<SmartPsiElementPointer<PsiAnnotationMemberValue>> myMemberValuePointers;
ReplaceWithMagicConstantFix(@NotNull PsiExpression argument, @NotNull PsiAnnotationMemberValue... values) {
super(argument);
myMemberValuePointers = Arrays.stream(values).map(
value -> SmartPointerManager.getInstance(argument.getProject()).createSmartPsiElementPointer(value)).collect(Collectors.toList());
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return "Replace with magic constant";
}
@NotNull
@Override
public String getText() {
List<String> names = myMemberValuePointers.stream().map(SmartPsiElementPointer::getElement).map(PsiElement::getText).collect(Collectors.toList());
String expression = StringUtil.join(names, " | ");
return "Replace with '" + expression + "'";
}
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
List<PsiAnnotationMemberValue> values = myMemberValuePointers.stream().map(SmartPsiElementPointer::getElement).collect(Collectors.toList());
String text = StringUtil.join(Collections.nCopies(values.size(), "0"), " | ");
PsiExpression concatExp = PsiElementFactory.SERVICE.getInstance(project).createExpressionFromText(text, startElement);
List<PsiLiteralExpression> expressionsToReplace = new ArrayList<>(values.size());
concatExp.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitLiteralExpression(PsiLiteralExpression expression) {
super.visitLiteralExpression(expression);
if (Integer.valueOf(0).equals(expression.getValue())) {
expressionsToReplace.add(expression);
}
}
});
Iterator<PsiAnnotationMemberValue> iterator = values.iterator();
List<PsiElement> resolved = new ArrayList<>();
for (PsiLiteralExpression toReplace : expressionsToReplace) {
PsiAnnotationMemberValue value = iterator.next();
resolved.add(((PsiReference)value).resolve());
PsiExpression replaced = (PsiExpression)toReplace.replace(value);
if (toReplace == concatExp) {
concatExp = replaced;
}
}
PsiElement newStartElement = startElement.replace(concatExp);
Iterator<PsiElement> resolvedValuesIterator = resolved.iterator();
newStartElement.accept(new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
PsiElement bound = expression.bindToElement(resolvedValuesIterator.next());
JavaCodeStyleManager.getInstance(project).shortenClassReferences(bound);
}
});
}
@Override
public boolean isAvailable(@NotNull Project project,
@NotNull PsiFile file,
@NotNull PsiElement startElement,
@NotNull PsiElement endElement) {
boolean allValid = !myMemberValuePointers.stream().map(SmartPsiElementPointer::getElement).anyMatch(p -> p == null || !p.isValid());
return allValid && super.isAvailable(project, file, startElement, endElement);
}
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'FontType.PLAIN'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
}
void font(@MagicConstant(flags = {FontType.PLAIN, FontType.BOLD, FontType.ITALIC}) int x) {
// 0 is not allowed despite the fact that it's flags parameter
font(<caret>FontType.PLAIN);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'FontType.ITALIC'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
}
private static final int UNDER = 2;
void font(@MagicConstant(flags = {FontType.PLAIN, FontType.BOLD, FontType.ITALIC}) int x) {
font(<caret>FontType.ITALIC);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'D.FontType.BOLD | D.FontType.ITALIC | D.FontType.WEIRD'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
public static final int WEIRD = 4;
}
void font(@MagicConstant(flagsFromClass = FontType.class) int x) {
font(<caret>FontType.BOLD | FontType.ITALIC | FontType.WEIRD);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'FontType.PLAIN'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
}
void font(@MagicConstant(flags = {FontType.PLAIN, FontType.BOLD, FontType.ITALIC}) int x) {
// 0 is not allowed despite the fact that it's flags parameter
font(<caret>0);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'FontType.ITALIC'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
}
private static final int UNDER = 2;
void font(@MagicConstant(flags = {FontType.PLAIN, FontType.BOLD, FontType.ITALIC}) int x) {
font(<caret>UNDER);
}
}

View File

@@ -0,0 +1,14 @@
// "Replace with 'D.FontType.BOLD | D.FontType.ITALIC | D.FontType.WEIRD'" "true"
import org.intellij.lang.annotations.MagicConstant;
class D {
static class FontType {
public static final int PLAIN = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
public static final int WEIRD = 4;
}
void font(@MagicConstant(flagsFromClass = FontType.class) int x) {
font(<caret>7);
}
}

View File

@@ -14,7 +14,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -26,7 +26,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -38,7 +38,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -50,7 +50,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -62,7 +62,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -74,7 +74,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -86,7 +86,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -98,7 +98,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -110,7 +110,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -122,7 +122,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -134,7 +134,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -146,7 +146,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -158,7 +158,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -170,7 +170,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -178,7 +178,7 @@
<file>X.java</file>
<line>81</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -189,7 +189,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -201,7 +201,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -213,7 +213,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -225,7 +225,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -237,7 +237,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -249,7 +249,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -257,14 +257,14 @@
<file>X.java</file>
<line>118</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
<problem>
<file>X.java</file>
<line>119</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -276,7 +276,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -288,7 +288,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -300,7 +300,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -312,7 +312,7 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z or their combination</description>
</problem>
@@ -322,7 +322,7 @@
<file>X.java</file>
<line>173</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -331,7 +331,7 @@
<file>X.java</file>
<line>174</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -340,7 +340,7 @@
<file>X.java</file>
<line>175</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -349,7 +349,7 @@
<file>X.java</file>
<line>177</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -357,7 +357,7 @@
<file>X.java</file>
<line>178</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -366,7 +366,7 @@
<file>X.java</file>
<line>179</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -375,7 +375,7 @@
<file>X.java</file>
<line>180</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y, Const.Z</description>
<description>Should be one of: Const.X, Const.Y, Const.Z</description>
</problem>
@@ -383,7 +383,7 @@
<file>X.java</file>
<line>193</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
@@ -391,14 +391,14 @@
<file>X.java</file>
<line>195</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
<problem>
<file>X.java</file>
<line>227</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
@@ -406,7 +406,7 @@
<file>X.java</file>
<line>228</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
@@ -414,7 +414,7 @@
<file>X.java</file>
<line>229</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
@@ -422,34 +422,34 @@
<file>X.java</file>
<line>230</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
<problem>
<file>X.java</file>
<line>231</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">magic constant</problem_class>
<description>Must be one of: Const.X, Const.Y</description>
<description>Should be one of: Const.X, Const.Y</description>
</problem>
<problem>
<file>X.java</file>
<line>238</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
<description>Must be one of: Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER</description>
<description>Should be one of: Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER</description>
</problem>
<problem>
<file>X.java</file>
<line>239</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
<description>Must be one of: SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, SwingConstants.LEADING, SwingConstants.TRAILING</description>
<description>Should be one of: SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, SwingConstants.LEADING, SwingConstants.TRAILING</description>
</problem>
<problem>
<file>X.java</file>
<line>268</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
<description>Must be one of: FontType.PLAIN, FontType.BOLD, FontType.ITALIC</description>
<description>Should be one of: FontType.PLAIN, FontType.BOLD, FontType.ITALIC or their combination</description>
</problem>
</problems>

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.magicConstant.MagicConstantInspection;
import org.jetbrains.annotations.NotNull;
public class MagicConstantQuickFixTest extends LightQuickFixTestCase {
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/magicConstant";
}
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[]{new MagicConstantInspection()};
}
public void test() throws Exception { doAllTests(); }
}