diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index ccb63678bd97..217045e35265 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -1788,8 +1788,6 @@ cast.conflicts.with.instanceof.quickfix1=Replace ''{0}'' with ''{1}'' in cast cast.conflicts.with.instanceof.quickfix2=Replace ''{0}'' with ''{1}'' in instanceof double.checked.locking.quickfix=Make ''{0}'' volatile double.literal.may.be.float.literal.display.name='double' literal cast to 'float' could be 'float' literal -double.literal.may.be.float.literal.problem.descriptor=#ref could be replaced with ''{0}'' #loc -double.literal.may.be.float.literal.quickfix=Replace with ''{0}'' multiple.declaration.option=Ignore 'for' loop declarations simplifiable.annotation.display.name=Simplifiable annotation simplifiable.annotation.problem.descriptor=Unnecessary #ref in annotation #loc diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/CastedLiteralMaybeJustLiteralInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/CastedLiteralMaybeJustLiteralInspection.java new file mode 100644 index 000000000000..8d20468d307b --- /dev/null +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/CastedLiteralMaybeJustLiteralInspection.java @@ -0,0 +1,134 @@ +// Copyright 2000-2017 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. +package com.siyeh.ig.numeric; + +import com.intellij.codeInspection.ProblemDescriptor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.PsiReplacementUtil; +import com.siyeh.ig.psiutils.ExpectedTypeUtils; +import org.jetbrains.annotations.NotNull; + +/** + * @author Bas Leijdekkers + */ +abstract class CastedLiteralMaybeJustLiteralInspection extends BaseInspection { + + @Override + @NotNull + protected final String buildErrorString(Object... infos) { + final PsiTypeCastExpression typeCastExpression = (PsiTypeCastExpression)infos[0]; + final StringBuilder replacementText = buildReplacementText(typeCastExpression, new StringBuilder()); + return InspectionGadgetsBundle.message("int.literal.may.be.long.literal.problem.descriptor", replacementText); + } + + @NotNull + abstract String getSuffix(); + + @NotNull + abstract PsiType getLiteralBeforeType(); + + @NotNull + abstract PsiType getCastType(); + + private StringBuilder buildReplacementText(PsiExpression expression, StringBuilder out) { + if (expression instanceof PsiLiteralExpression) { + out.append(expression.getText()).append(getSuffix()); + } + else if (expression instanceof PsiPrefixExpression) { + final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)expression; + out.append(prefixExpression.getOperationSign().getText()); + return buildReplacementText(prefixExpression.getOperand(), out); + } + else if (expression instanceof PsiParenthesizedExpression) { + final PsiParenthesizedExpression parenthesizedExpression = (PsiParenthesizedExpression)expression; + out.append('('); + buildReplacementText(parenthesizedExpression.getExpression(), out); + out.append(')'); + } + else if (expression instanceof PsiTypeCastExpression) { + final PsiTypeCastExpression typeCastExpression = (PsiTypeCastExpression)expression; + buildReplacementText(typeCastExpression.getOperand(), out); + } + else { + assert false; + } + return out; + } + + @Override + protected final InspectionGadgetsFix buildFix(Object... infos) { + final PsiTypeCastExpression typeCastExpression = (PsiTypeCastExpression)infos[0]; + final StringBuilder replacementText = buildReplacementText(typeCastExpression, new StringBuilder()); + return new ReplaceCastedLiteralWithJustLiteralFix(replacementText.toString()); + } + + private class ReplaceCastedLiteralWithJustLiteralFix extends InspectionGadgetsFix { + + private final String replacementString; + + public ReplaceCastedLiteralWithJustLiteralFix(String replacementString) { + this.replacementString = replacementString; + } + + @Override + @NotNull + public String getName() { + return InspectionGadgetsBundle.message("int.literal.may.be.long.literal.quickfix", replacementString); + } + + @NotNull + @Override + public String getFamilyName() { + return "Replace with " + getCastType().getPresentableText() + " literal"; + } + + @Override + protected void doFix(Project project, ProblemDescriptor descriptor) { + final PsiElement element = descriptor.getPsiElement(); + if (!(element instanceof PsiTypeCastExpression)) { + return; + } + final PsiTypeCastExpression typeCastExpression = (PsiTypeCastExpression)element; + PsiReplacementUtil.replaceExpression(typeCastExpression, replacementString); + } + } + + @Override + public final BaseInspectionVisitor buildVisitor() { + return new CastedLiteralMayBeJustLiteralVisitor(); + } + + private class CastedLiteralMayBeJustLiteralVisitor extends BaseInspectionVisitor { + + @Override + public void visitLiteralExpression(PsiLiteralExpression expression) { + super.visitLiteralExpression(expression); + final PsiType type = expression.getType(); + if (!getLiteralBeforeType().equals(type)) { + return; + } + PsiElement parent = expression.getParent(); + while (parent instanceof PsiPrefixExpression || parent instanceof PsiParenthesizedExpression) { + parent = parent.getParent(); + } + if (!(parent instanceof PsiTypeCastExpression)) { + return; + } + final PsiTypeCastExpression typeCastExpression = (PsiTypeCastExpression)parent; + final PsiType castType = typeCastExpression.getType(); + if (!getCastType().equals(castType)) { + return; + } + final PsiType expectedType = ExpectedTypeUtils.findExpectedType(typeCastExpression, false); + if (expectedType != null && !getCastType().equals(expectedType)) { + // don't warn on red code. + return; + } + registerError(typeCastExpression, typeCastExpression); + } + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspection.java index ed61e451ee62..f7e031268016 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspection.java @@ -1,162 +1,38 @@ -/* - * Copyright 2010 Bas Leijdekkers - * - * 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. - */ +// Copyright 2000-2017 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. package com.siyeh.ig.numeric; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.util.IncorrectOperationException; +import com.intellij.psi.PsiType; import com.siyeh.InspectionGadgetsBundle; -import com.siyeh.ig.BaseInspection; -import com.siyeh.ig.BaseInspectionVisitor; -import com.siyeh.ig.InspectionGadgetsFix; -import com.siyeh.ig.PsiReplacementUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -public class DoubleLiteralMayBeFloatLiteralInspection extends BaseInspection { +/** + * @author Bas Leijdekkers + */ +public class DoubleLiteralMayBeFloatLiteralInspection extends CastedLiteralMaybeJustLiteralInspection { @Override @Nls @NotNull public String getDisplayName() { - return InspectionGadgetsBundle.message( - "double.literal.may.be.float.literal.display.name"); + return InspectionGadgetsBundle.message("double.literal.may.be.float.literal.display.name"); } - @Override @NotNull - protected String buildErrorString(Object... infos) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)infos[0]; - final StringBuilder replacementText = - buildReplacementText(typeCastExpression, new StringBuilder()); - return InspectionGadgetsBundle.message( - "double.literal.may.be.float.literal.problem.descriptor", - replacementText); - } - @Override - protected InspectionGadgetsFix buildFix(Object... infos) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)infos[0]; - final StringBuilder replacementText = - buildReplacementText(typeCastExpression, new StringBuilder()); - return new DoubleLiteralMayBeFloatLiteralFix(replacementText.toString()); - } - - private static StringBuilder buildReplacementText( - PsiExpression expression, StringBuilder out) { - if (expression instanceof PsiLiteralExpression) { - out.append(expression.getText()); - out.append('f'); - } - else if (expression instanceof PsiPrefixExpression) { - final PsiPrefixExpression prefixExpression = - (PsiPrefixExpression)expression; - final PsiJavaToken sign = prefixExpression.getOperationSign(); - out.append(sign.getText()); - return buildReplacementText(prefixExpression.getOperand(), out); - } - else if (expression instanceof PsiParenthesizedExpression) { - final PsiParenthesizedExpression parenthesizedExpression = - (PsiParenthesizedExpression)expression; - out.append('('); - buildReplacementText(parenthesizedExpression.getExpression(), - out); - out.append(')'); - } - else if (expression instanceof PsiTypeCastExpression) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)expression; - final PsiExpression operand = typeCastExpression.getOperand(); - buildReplacementText(operand, out); - } - else { - assert false; - } - return out; - } - - private static class DoubleLiteralMayBeFloatLiteralFix - extends InspectionGadgetsFix { - - private final String replacementString; - - public DoubleLiteralMayBeFloatLiteralFix(String replacementString) { - this.replacementString = replacementString; - } - - @Override - @NotNull - public String getName() { - return InspectionGadgetsBundle.message( - "double.literal.may.be.float.literal.quickfix", - replacementString); - } - - @NotNull - @Override - public String getFamilyName() { - return "Replace with 'float'"; - } - - @Override - protected void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { - final PsiElement element = descriptor.getPsiElement(); - if (!(element instanceof PsiTypeCastExpression)) { - return; - } - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)element; - PsiReplacementUtil.replaceExpression(typeCastExpression, replacementString); - } + String getSuffix() { + return "f"; } + @NotNull @Override - public BaseInspectionVisitor buildVisitor() { - return new DoubleLiteralMayBeFloatLiteralVisitor(); + PsiType getLiteralBeforeType() { + return PsiType.DOUBLE; } - private static class DoubleLiteralMayBeFloatLiteralVisitor - extends BaseInspectionVisitor { - - @Override - public void visitLiteralExpression(PsiLiteralExpression expression) { - super.visitLiteralExpression(expression); - final PsiType type = expression.getType(); - if (!PsiType.DOUBLE.equals(type)) { - return; - } - PsiElement parent = expression.getParent(); - while (parent instanceof PsiPrefixExpression || - parent instanceof PsiParenthesizedExpression) { - parent = parent.getParent(); - } - if (!(parent instanceof PsiTypeCastExpression)) { - return; - } - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)parent; - final PsiType castType = typeCastExpression.getType(); - if (!PsiType.FLOAT.equals(castType)) { - return; - } - registerError(typeCastExpression, typeCastExpression); - } + @NotNull + @Override + PsiType getCastType() { + return PsiType.FLOAT; } } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspection.java index eb78377776c0..d36be5c68963 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspection.java @@ -1,162 +1,38 @@ -/* - * Copyright 2009-2010 Bas Leijdekkers - * - * 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. - */ +// Copyright 2000-2017 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. package com.siyeh.ig.numeric; -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.util.IncorrectOperationException; +import com.intellij.psi.PsiType; import com.siyeh.InspectionGadgetsBundle; -import com.siyeh.ig.BaseInspection; -import com.siyeh.ig.BaseInspectionVisitor; -import com.siyeh.ig.InspectionGadgetsFix; -import com.siyeh.ig.PsiReplacementUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; -public class IntLiteralMayBeLongLiteralInspection extends BaseInspection { +/** + * @author Bas Leijdekkers + */ +public class IntLiteralMayBeLongLiteralInspection extends CastedLiteralMaybeJustLiteralInspection { @Override @Nls @NotNull public String getDisplayName() { - return InspectionGadgetsBundle.message( - "int.literal.may.be.long.literal.display.name"); + return InspectionGadgetsBundle.message("int.literal.may.be.long.literal.display.name"); } - @Override @NotNull - protected String buildErrorString(Object... infos) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)infos[0]; - final StringBuilder replacementText = - buildReplacementText(typeCastExpression, new StringBuilder()); - return InspectionGadgetsBundle.message( - "int.literal.may.be.long.literal.problem.descriptor", - replacementText); - } - @Override - protected InspectionGadgetsFix buildFix(Object... infos) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)infos[0]; - final StringBuilder replacementText = - buildReplacementText(typeCastExpression, new StringBuilder()); - return new IntLiteralMayBeLongLiteralFix(replacementText.toString()); - } - - private static StringBuilder buildReplacementText( - PsiExpression expression, StringBuilder out) { - if (expression instanceof PsiLiteralExpression) { - out.append(expression.getText()); - out.append('L'); - } - else if (expression instanceof PsiPrefixExpression) { - final PsiPrefixExpression prefixExpression = - (PsiPrefixExpression)expression; - final PsiJavaToken sign = prefixExpression.getOperationSign(); - out.append(sign.getText()); - return buildReplacementText(prefixExpression.getOperand(), out); - } - else if (expression instanceof PsiParenthesizedExpression) { - final PsiParenthesizedExpression parenthesizedExpression = - (PsiParenthesizedExpression)expression; - out.append('('); - buildReplacementText(parenthesizedExpression.getExpression(), - out); - out.append(')'); - } - else if (expression instanceof PsiTypeCastExpression) { - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)expression; - final PsiExpression operand = typeCastExpression.getOperand(); - buildReplacementText(operand, out); - } - else { - assert false; - } - return out; - } - - private static class IntLiteralMayBeLongLiteralFix - extends InspectionGadgetsFix { - - private final String replacementString; - - public IntLiteralMayBeLongLiteralFix(String replacementString) { - this.replacementString = replacementString; - } - - @Override - @NotNull - public String getName() { - return InspectionGadgetsBundle.message( - "int.literal.may.be.long.literal.quickfix", - replacementString); - } - - @NotNull - @Override - public String getFamilyName() { - return "Replace with long literal"; - } - - @Override - protected void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { - final PsiElement element = descriptor.getPsiElement(); - if (!(element instanceof PsiTypeCastExpression)) { - return; - } - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)element; - PsiReplacementUtil.replaceExpression(typeCastExpression, replacementString); - } + String getSuffix() { + return "L"; } + @NotNull @Override - public BaseInspectionVisitor buildVisitor() { - return new IntLiteralMayBeLongLiteralVisitor(); + PsiType getLiteralBeforeType() { + return PsiType.INT; } - private static class IntLiteralMayBeLongLiteralVisitor - extends BaseInspectionVisitor { - - @Override - public void visitLiteralExpression(PsiLiteralExpression expression) { - super.visitLiteralExpression(expression); - final PsiType type = expression.getType(); - if (!PsiType.INT.equals(type)) { - return; - } - PsiElement parent = expression.getParent(); - while (parent instanceof PsiPrefixExpression || - parent instanceof PsiParenthesizedExpression) { - parent = parent.getParent(); - } - if (!(parent instanceof PsiTypeCastExpression)) { - return; - } - final PsiTypeCastExpression typeCastExpression = - (PsiTypeCastExpression)parent; - final PsiType castType = typeCastExpression.getType(); - if (!PsiType.LONG.equals(castType)) { - return; - } - registerError(typeCastExpression, typeCastExpression); - } + @NotNull + @Override + PsiType getCastType() { + return PsiType.LONG; } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/double_literal_may_be_float_literal/DoubleLiteralMayBeFloatLiteral.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/double_literal_may_be_float_literal/DoubleLiteralMayBeFloatLiteral.java new file mode 100644 index 000000000000..4f62d16f9a1c --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/double_literal_may_be_float_literal/DoubleLiteralMayBeFloatLiteral.java @@ -0,0 +1,12 @@ +class DoubleLiteralMayBeFloatLiteral { + + void literal() { + System.out.println((float)1.1); + System.out.println((float)-7.3); + System.out.println((float)-(-((4.2)))); + } + + void error() { + int i = (float)6.66; + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/IntLiteralMayBeLong.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/IntLiteralMayBeLong.java deleted file mode 100644 index 5fcd7f9e2116..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/IntLiteralMayBeLong.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.siyeh.igtest.numeric.int_literal_may_be_long; - -public class IntLiteralMayBeLong { - - void foo() { - System.out.println((long) 1); - System.out.println((long) -/*yes, minus*/1); - System.out.println((long)-(-(6))); - } -} diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/expected.xml deleted file mode 100644 index c91e4262b3d4..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long/expected.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - IntLiteralMayBeLong.java - 6 - int literal cast to long could be long literal - <code>(long) 1</code> could be replaced with '1L' #loc - - - IntLiteralMayBeLong.java - 7 - int literal cast to long could be long literal - <code>(long) -/*yes, minus*/1</code> could be replaced with '-/*yes, minus*/1L' #loc - - - IntLiteralMayBeLong.java - 8 - int literal cast to long could be long literal - <code>(long)-(-(6))</code> could be replaced with '-(-(6L))' #loc - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long_literal/IntLiteralMayBeLongLiteral.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long_literal/IntLiteralMayBeLongLiteral.java new file mode 100644 index 000000000000..cc3c68c81c6e --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/int_literal_may_be_long_literal/IntLiteralMayBeLongLiteral.java @@ -0,0 +1,14 @@ +package com.siyeh.igtest.numeric.int_literal_may_be_long; + +public class IntLiteralMayBeLongLiteral { + + void foo() { + System.out.println((long) 1); + System.out.println((long) -/*yes, minus*/1); + System.out.println((long)-(-(6))); + } + + void error() { + int answer = (long)42; + } +} diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspectionTest.java new file mode 100644 index 000000000000..b33efa05add5 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/DoubleLiteralMayBeFloatLiteralInspectionTest.java @@ -0,0 +1,22 @@ +// Copyright 2000-2017 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. +package com.siyeh.ig.numeric; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class DoubleLiteralMayBeFloatLiteralInspectionTest extends LightInspectionTestCase { + + public void testDoubleLiteralMayBeFloatLiteral() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new DoubleLiteralMayBeFloatLiteralInspection(); + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongInspectionTest.java deleted file mode 100644 index 3b1e1dbc63ff..000000000000 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongInspectionTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.siyeh.ig.numeric; - -import com.siyeh.ig.IGInspectionTestCase; - -public class IntLiteralMayBeLongInspectionTest extends IGInspectionTestCase { - - public void test() { - doTest("com/siyeh/igtest/numeric/int_literal_may_be_long", - new IntLiteralMayBeLongLiteralInspection()); - } -} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspectionTest.java new file mode 100644 index 000000000000..24bfedc5f870 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/numeric/IntLiteralMayBeLongLiteralInspectionTest.java @@ -0,0 +1,22 @@ +// Copyright 2000-2017 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. +package com.siyeh.ig.numeric; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class IntLiteralMayBeLongLiteralInspectionTest extends LightInspectionTestCase { + + public void testIntLiteralMayBeLongLiteral() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new IntLiteralMayBeLongLiteralInspection(); + } +} \ No newline at end of file