drop "ignore exceptions declared in test" and use "suppress for 'Tests' scope" quickfix

This commit is contained in:
Bas Leijdekkers
2013-11-28 16:00:34 +01:00
parent 166d33a827
commit 3c85c6960e
3 changed files with 14 additions and 12 deletions
@@ -45,7 +45,7 @@ public class BadExceptionDeclaredInspectionBase extends BaseInspection {
);
@SuppressWarnings("PublicField")
public boolean ignoreTestCases = false;
public boolean ignoreTestCases = false; // keep for compatibility
@SuppressWarnings("PublicField")
public boolean ignoreLibraryOverrides = false;
@@ -109,7 +109,7 @@ public class BadExceptionDeclaredInspectionBase extends BaseInspection {
final PsiClass thrownClass = (PsiClass)element;
final String qualifiedName = thrownClass.getQualifiedName();
if (qualifiedName != null && exceptions.contains(qualifiedName)) {
registerError(reference);
registerError(reference, reference);
}
}
}
@@ -17,8 +17,11 @@ package com.siyeh.ig.errorhandling;
import com.intellij.codeInspection.ui.ListTable;
import com.intellij.codeInspection.ui.ListWrappingTableModel;
import com.intellij.psi.PsiElement;
import com.intellij.util.ui.CheckBox;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.InspectionGadgetsFix;
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
import com.siyeh.ig.ui.UiUtils;
import javax.swing.*;
@@ -26,6 +29,12 @@ import java.awt.*;
public class BadExceptionDeclaredInspection extends BadExceptionDeclaredInspectionBase {
@Override
protected InspectionGadgetsFix buildFix(Object... infos) {
final PsiElement context = (PsiElement)infos[0];
return SuppressForTestsScopeFix.build(this, context);
}
@Override
public JComponent createOptionsPanel() {
final JComponent panel = new JPanel(new GridBagLayout());
@@ -41,17 +50,12 @@ public class BadExceptionDeclaredInspection extends BadExceptionDeclaredInspecti
constraints.fill = GridBagConstraints.BOTH;
panel.add(tablePanel, constraints);
final CheckBox checkBox1 =
new CheckBox(InspectionGadgetsBundle.message("ignore.exceptions.declared.in.tests.option"), this,
"ignoreTestCases");
constraints.gridy = 1;
constraints.weighty = 0.0;
panel.add(checkBox1, constraints);
final CheckBox checkBox2 =
new CheckBox(InspectionGadgetsBundle.message("ignore.exceptions.declared.on.library.override.option"), this,
"ignoreLibraryOverrides");
constraints.gridy = 2;
constraints.weighty = 0.0;
constraints.gridy = 1;
panel.add(checkBox2, constraints);
return panel;
}
@@ -6,9 +6,7 @@ Reports inappropriate exceptions declared by methods. One use of this inspection
<p>
Use the list below to specify which exceptions should be flagged by this inspection.
<p>
Use the first checkbox below to ignore exceptions declared on test methods.
<p>
Use the second checkbox below to ignore exceptions declared on methods which override a library method.
Use the checkbox below to ignore exceptions declared on methods which override a library method.
<p>
</body>