RedundantCastInspection: IGNORE_ANNOTATED_METHODS option removed

After change 3c9c050b4 it's always on anyways
This commit is contained in:
Tagir Valeev
2017-09-18 14:14:47 +07:00
parent 5fc31e62f1
commit 2b46ed04c9
2 changed files with 2 additions and 24 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.codeInspection.redundantCast;
import com.intellij.codeInsight.NullableNotNullManager;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.miscGenerics.GenericsInspectionToolBase;
@@ -45,7 +44,6 @@ public class RedundantCastInspection extends GenericsInspectionToolBase {
private static final String DISPLAY_NAME = InspectionsBundle.message("inspection.redundant.cast.display.name");
@NonNls private static final String SHORT_NAME = "RedundantCast";
public boolean IGNORE_ANNOTATED_METHODS;
public boolean IGNORE_SUSPICIOUS_METHOD_CALLS;
@@ -71,7 +69,7 @@ public class RedundantCastInspection extends GenericsInspectionToolBase {
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
if (IGNORE_ANNOTATED_METHODS || IGNORE_SUSPICIOUS_METHOD_CALLS) {
if (IGNORE_SUSPICIOUS_METHOD_CALLS) {
super.writeSettings(node);
}
}
@@ -80,7 +78,6 @@ public class RedundantCastInspection extends GenericsInspectionToolBase {
public JComponent createOptionsPanel() {
final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
optionsPanel.addCheckbox("Ignore casts in suspicious collections method calls", "IGNORE_SUSPICIOUS_METHOD_CALLS");
optionsPanel.addCheckbox("Ignore casts to invoke @NotNull method which overrides @Nullable", "IGNORE_ANNOTATED_METHODS");
return optionsPanel;
}
@@ -90,25 +87,7 @@ public class RedundantCastInspection extends GenericsInspectionToolBase {
PsiTypeElement castType = cast.getCastType();
if (operand == null || castType == null) return null;
PsiElement parent = PsiUtil.skipParenthesizedExprUp(cast.getParent());
if (parent instanceof PsiReferenceExpression) {
if (IGNORE_ANNOTATED_METHODS) {
final PsiElement gParent = parent.getParent();
if (gParent instanceof PsiMethodCallExpression) {
final PsiMethod psiMethod = ((PsiMethodCallExpression)gParent).resolveMethod();
if (psiMethod != null && NullableNotNullManager.isNotNull(psiMethod)) {
final PsiClass superClass = PsiUtil.resolveClassInType(operand.getType());
final PsiClass containingClass = psiMethod.getContainingClass();
if (containingClass != null && superClass != null && containingClass.isInheritor(superClass, true)) {
for (PsiMethod method : psiMethod.findSuperMethods(superClass)) {
if (NullableNotNullManager.isNullable(method)) {
return null;
}
}
}
}
}
}
} else if (parent instanceof PsiExpressionList) {
if (parent instanceof PsiExpressionList) {
final PsiElement gParent = parent.getParent();
if (gParent instanceof PsiMethodCallExpression && IGNORE_SUSPICIOUS_METHOD_CALLS) {
final String message = SuspiciousMethodCallUtil
@@ -87,7 +87,6 @@ public class RedundantCast15Test extends InspectionTestCase {
public void testIgnore() {
final RedundantCastInspection castInspection = new RedundantCastInspection();
castInspection.IGNORE_ANNOTATED_METHODS = true;
castInspection.IGNORE_SUSPICIOUS_METHOD_CALLS = true;
final LocalInspectionToolWrapper tool = new LocalInspectionToolWrapper(castInspection);
doTest("redundantCast/generics/" + getTestName(false), tool, "java 1.5");