mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
drop "ignore exceptions declared in tests" checkbox and use "suppress for 'Tests' scope" quickfix
This commit is contained in:
+5
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2012 Bas Leijdekkers
|
||||
* Copyright 2010-2013 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,19 +27,18 @@ import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.psiutils.ExceptionUtils;
|
||||
import com.siyeh.ig.psiutils.LibraryUtil;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public class TooBroadThrowsInspection extends BaseInspection {
|
||||
public class TooBroadThrowsInspectionBase extends BaseInspection {
|
||||
|
||||
@SuppressWarnings({"PublicField"})
|
||||
public boolean onlyWarnOnRootExceptions = false;
|
||||
|
||||
@SuppressWarnings("PublicField")
|
||||
public boolean ignoreInTestCode = false;
|
||||
@SuppressWarnings({"PublicField", "UnusedDeclaration"})
|
||||
public boolean ignoreInTestCode = false; // keep for compatibility
|
||||
|
||||
@SuppressWarnings("PublicField")
|
||||
public boolean ignoreLibraryOverrides = false;
|
||||
@@ -89,7 +88,6 @@ public class TooBroadThrowsInspection extends BaseInspection {
|
||||
public JComponent createOptionsPanel() {
|
||||
final MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("too.broad.catch.option"), "onlyWarnOnRootExceptions");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("ignore.exceptions.declared.in.tests.option"), "ignoreInTestCode");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("ignore.exceptions.declared.on.library.override.option"), "ignoreLibraryOverrides");
|
||||
panel.addCheckbox(InspectionGadgetsBundle.message("overly.broad.throws.clause.ignore.thrown.option"), "ignoreThrown");
|
||||
return panel;
|
||||
@@ -174,9 +172,6 @@ public class TooBroadThrowsInspection extends BaseInspection {
|
||||
if (body == null) {
|
||||
return;
|
||||
}
|
||||
if (ignoreInTestCode && TestUtils.isInTestCode(method)) {
|
||||
return;
|
||||
}
|
||||
if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
|
||||
return;
|
||||
}
|
||||
@@ -206,7 +201,7 @@ public class TooBroadThrowsInspection extends BaseInspection {
|
||||
if (ignoreThrown && originalNeeded) {
|
||||
continue;
|
||||
}
|
||||
registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded));
|
||||
registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded), throwsReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.siyeh.ig.errorhandling;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.siyeh.ig.fixes.SuppressForTestsScopeFix;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
*/
|
||||
public class TooBroadThrowsInspection extends TooBroadThrowsInspectionBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final PsiElement context = (PsiElement)infos[2];
|
||||
final SuppressForTestsScopeFix suppressFix = SuppressForTestsScopeFix.build(this, context);
|
||||
if (suppressFix == null) {
|
||||
return new InspectionGadgetsFix[] {buildFix(infos)};
|
||||
}
|
||||
return new InspectionGadgetsFix[] {buildFix(infos), suppressFix};
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,9 @@ exceptions actually thrown by the method.
|
||||
<p>
|
||||
Use the first checkbox below to have this inspection only warn on the most generic exceptions.
|
||||
<p>
|
||||
Use the second checkbox below to ignore overly broad <b>throws</b> clauses in test code.
|
||||
Use the second checkbox below to ignore overly broad <b>throws</b> clauses in methods which override a library method.
|
||||
<p>
|
||||
Use the third checkbox below to ignore overly broad <b>throws</b> clauses in methods which override a library method.
|
||||
<p>
|
||||
Use the fourth checkbox below to ignore any exceptions which hide other exceptions, but which may be thrown from the method body and thus
|
||||
Use the third checkbox below to ignore any exceptions which hide other exceptions, but which may be thrown from the method body and thus
|
||||
are technically not overly broad.
|
||||
<p>
|
||||
<small>New in 10</small>
|
||||
|
||||
Reference in New Issue
Block a user