diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspection.java index 098ba559e869..6998c06666b9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,19 +44,11 @@ public class UncheckedExceptionClassInspection extends BaseInspection { return new UncheckedExceptionClassVisitor(); } - private static class UncheckedExceptionClassVisitor - extends BaseInspectionVisitor { + private static class UncheckedExceptionClassVisitor extends BaseInspectionVisitor { @Override public void visitClass(@NotNull PsiClass aClass) { - if (!InheritanceUtil.isInheritor(aClass, - CommonClassNames.JAVA_LANG_THROWABLE)) { - return; - } - if (InheritanceUtil.isInheritor(aClass, - CommonClassNames.JAVA_LANG_EXCEPTION) && - !InheritanceUtil.isInheritor(aClass, - CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) { + if (!InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION)) { return; } registerClassError(aClass); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/unchecked_exception_class/UncheckedExceptionClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/unchecked_exception_class/UncheckedExceptionClass.java new file mode 100644 index 000000000000..abfb775a1533 --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/errorhandling/unchecked_exception_class/UncheckedExceptionClass.java @@ -0,0 +1,5 @@ +public class UncheckedExceptionClass extends RuntimeException { + +} +class E1 extends Throwable {} +class E2 extends Exception {} \ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspectionTest.java new file mode 100644 index 000000000000..c5a7d031c627 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UncheckedExceptionClassInspectionTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2015 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.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import junit.framework.TestCase; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class UncheckedExceptionClassInspectionTest extends LightInspectionTestCase { + + public void testUncheckedExceptionClass() { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new UncheckedExceptionClassInspection(); + } +} \ No newline at end of file