mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
drop "ignore empty 'catch' blocks in tests" and use "suppress for 'Tests' scope" quickfix
This commit is contained in:
+1
-1
@@ -1229,7 +1229,7 @@ string.format.class.method.name=Additional formatter methods
|
||||
exception.class.column.name=Exception class
|
||||
bad.exception.thrown.problem.descriptor=Prohibited exception ''{0}'' thrown #loc
|
||||
empty.catch.block.comments.option=Comments count as content
|
||||
empty.catch.block.ignore.ignore.option=Ignore for 'catch' parameters named 'ignore' or 'ignored'
|
||||
empty.catch.block.ignore.ignore.option=Ignore when 'catch' parameter is named 'ignore' or 'ignored'
|
||||
too.broad.catch.problem.descriptor=''catch'' of <code>#ref</code> is too broad, masking exception ''{0}'' #loc
|
||||
too.broad.catch.problem.descriptor1=''catch'' of <code>#ref</code> is too broad, masking exceptions ''{0}'' and ''{1}'' #loc
|
||||
unused.catch.parameter.ignore.catch.option=Ignore for 'catch' blocks containing comments
|
||||
|
||||
+4
-8
@@ -19,12 +19,12 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
import com.siyeh.ig.BaseInspectionVisitor;
|
||||
import com.siyeh.ig.InspectionGadgetsFix;
|
||||
import com.intellij.psi.util.FileTypeUtils;
|
||||
import com.siyeh.ig.psiutils.TestUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class EmptyCatchBlockInspection extends BaseInspection {
|
||||
public class EmptyCatchBlockInspectionBase extends BaseInspection {
|
||||
|
||||
/**
|
||||
* @noinspection PublicField
|
||||
@@ -41,7 +41,7 @@ public class EmptyCatchBlockInspection extends BaseInspection {
|
||||
/**
|
||||
* @noinspection PublicField
|
||||
*/
|
||||
public boolean m_ignoreTestCases = true;
|
||||
public boolean m_ignoreTestCases = true; // keep for compatibility
|
||||
/**
|
||||
* @noinspection PublicField
|
||||
*/
|
||||
@@ -68,7 +68,6 @@ public class EmptyCatchBlockInspection extends BaseInspection {
|
||||
public JComponent createOptionsPanel() {
|
||||
final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
|
||||
optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.comments.option"), "m_includeComments");
|
||||
optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.ignore.option"), "m_ignoreTestCases");
|
||||
optionsPanel.addCheckbox(InspectionGadgetsBundle.message("empty.catch.block.ignore.ignore.option"), "m_ignoreIgnoreParameter");
|
||||
return optionsPanel;
|
||||
}
|
||||
@@ -127,9 +126,6 @@ public class EmptyCatchBlockInspection extends BaseInspection {
|
||||
if (FileTypeUtils.isInServerPageFile(statement.getContainingFile())) {
|
||||
return;
|
||||
}
|
||||
if (m_ignoreTestCases && TestUtils.isInTestCode(statement)) {
|
||||
return;
|
||||
}
|
||||
final PsiCatchSection[] catchSections = statement.getCatchSections();
|
||||
for (final PsiCatchSection section : catchSections) {
|
||||
checkCatchSection(section);
|
||||
@@ -157,7 +153,7 @@ public class EmptyCatchBlockInspection extends BaseInspection {
|
||||
if (catchToken == null) {
|
||||
return;
|
||||
}
|
||||
registerError(catchToken);
|
||||
registerError(catchToken, catchToken);
|
||||
}
|
||||
|
||||
private boolean isEmpty(PsiElement element) {
|
||||
+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 EmptyCatchBlockInspection extends EmptyCatchBlockInspectionBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected InspectionGadgetsFix[] buildFixes(Object... infos) {
|
||||
final PsiElement context = (PsiElement)infos[0];
|
||||
final SuppressForTestsScopeFix fix = SuppressForTestsScopeFix.build(this, context);
|
||||
if (fix == null) {
|
||||
return new InspectionGadgetsFix[] {buildFix(infos)};
|
||||
}
|
||||
return new InspectionGadgetsFix[] {buildFix(infos), fix};
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports empty <b>catch</b> blocks. While occasionally intended, this
|
||||
Reports empty <b>catch</b> blocks. While occasionally intended,
|
||||
empty <b>catch</b> blocks can make debugging extremely difficult.
|
||||
<p>
|
||||
At present, this inspection is disabled in JSP files.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the controls below to indicate whether catch blocks containing only comments,
|
||||
empty catch blocks in JUnit tests should be reported and whether to ignore empty
|
||||
catch blocks if the parameter is named 'ignore' or 'ignored'.
|
||||
Use the controls below to indicate whether catch blocks containing only comments should be reported,
|
||||
and whether to ignore empty catch blocks if the parameter is named 'ignore' or 'ignored'.
|
||||
<p>
|
||||
|
||||
</body>
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class EmptyCatchBlockInspectionTest extends LightInspectionTestCase {
|
||||
public void testTest() {
|
||||
doTest("import junit.framework.TestCase;\n" +
|
||||
"class C extends TestCase {\n" +
|
||||
" void m() {\n" +
|
||||
" public void testM() {\n" +
|
||||
" try {\n" +
|
||||
" throw new Exception();\n" +
|
||||
" } catch (Exception e) {}\n" +
|
||||
|
||||
Reference in New Issue
Block a user