diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java index f3295fcd50e6..a929d9e76632 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -905,7 +905,7 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel, getTools(toolId, project).removeScope(scopeIdx); } - private void removeScope(@NotNull String toolId, @NotNull String scopeName, Project project) { + public void removeScope(@NotNull String toolId, @NotNull String scopeName, Project project) { getTools(toolId, project).removeScope(scopeName); } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspectionBase.java similarity index 91% rename from plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java rename to plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspectionBase.java index 86ade7c861fc..6471277153c9 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspectionBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 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. @@ -23,7 +23,7 @@ import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; import org.jetbrains.annotations.NotNull; -public class ResultOfObjectAllocationIgnoredInspection extends BaseInspection { +public class ResultOfObjectAllocationIgnoredInspectionBase extends BaseInspection { @Override @NotNull @@ -59,7 +59,7 @@ public class ResultOfObjectAllocationIgnoredInspection extends BaseInspection { if (newExpression.getArrayInitializer() != null) { return; } - registerNewExpressionError(newExpression); + registerNewExpressionError(newExpression, newExpression); } } } \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java new file mode 100644 index 000000000000..d31cd55a8e34 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ResultOfObjectAllocationIgnoredInspection.java @@ -0,0 +1,34 @@ +/* + * 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.bugs; + +import com.intellij.psi.PsiElement; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.SuppressForTestsScopeFix; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class ResultOfObjectAllocationIgnoredInspection extends ResultOfObjectAllocationIgnoredInspectionBase { + + @Nullable + @Override + protected InspectionGadgetsFix buildFix(Object... infos) { + final PsiElement context = (PsiElement)infos[0]; + return SuppressForTestsScopeFix.build(this, context); + } +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/SuppressForTestsScopeFix.java b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/SuppressForTestsScopeFix.java index aa8c592ff3ef..70f7fef4e8cb 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/SuppressForTestsScopeFix.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/SuppressForTestsScopeFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * 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. @@ -97,14 +97,14 @@ public class SuppressForTestsScopeFix extends InspectionGadgetsFix { if (tool == null) { return; } - final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests"); - final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); - final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project); if (add) { + final NamedScope namedScope = NamedScopesHolder.getScope(project, "Tests"); + final HighlightDisplayKey key = HighlightDisplayKey.find(shortName); + final HighlightDisplayLevel level = profile.getErrorLevel(key, namedScope, project); profile.addScope(tool, namedScope, level, false, project); } else { - profile.removeScope(shortName, 0, project); + profile.removeScope(shortName, "Tests", project); } profile.scopesChanged(); }