mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add "Suppress for 'Tests' scope" quickfix to "Result of object allocation ignored" inspection (IDEA-144404)
This commit is contained in:
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user