inspections:

1. add @NotNull scope parameter of ToolsImpl#enableTool() and replace callers respectively
2. InspectionProfileImpl#enableTool() always enables default tool
This commit is contained in:
Dmitry Batkovich
2017-01-10 16:23:22 +03:00
parent 8b6cbc4552
commit aa95159f3c
4 changed files with 6 additions and 14 deletions
@@ -129,7 +129,7 @@ public class InspectionProfileConvertor {
//set up tools for default profile
if (level != HighlightDisplayLevel.DO_NOT_SHOW) {
profile.enableTool(shortName, null, null);
profile.enableTool(shortName, null);
}
if (level == null || level == HighlightDisplayLevel.DO_NOT_SHOW) {
@@ -660,13 +660,11 @@ public class InspectionProfileImpl extends NewInspectionProfile {
public void enableTool(@NotNull String toolId, Project project) {
final ToolsImpl tools = getTools(toolId, project);
tools.setEnabled(true);
if (tools.getNonDefaultTools() == null) {
tools.getDefaultState().setEnabled(true);
}
tools.getDefaultState().setEnabled(true);
schemeState = SchemeState.POSSIBLY_CHANGED;
}
public void enableTool(@NotNull String inspectionTool, NamedScope namedScope, Project project) {
public void enableTool(@NotNull String inspectionTool, @NotNull NamedScope namedScope, Project project) {
getTools(inspectionTool, project).enableTool(namedScope, project);
schemeState = SchemeState.POSSIBLY_CHANGED;
}
@@ -394,10 +394,10 @@ public class ToolsImpl implements Tools {
myEnabled = enabled;
}
public void enableTool(NamedScope namedScope, Project project) {
public void enableTool(@NotNull NamedScope namedScope, Project project) {
if (myTools != null) {
for (ScopeToolState state : myTools) {
if (Comparing.equal(state.getScope(project), namedScope)) {
if (namedScope.equals(state.getScope(project))) {
state.setEnabled(true);
}
}
@@ -234,13 +234,7 @@ public class PyCompatibilityInspectionAdvertiser implements Annotator {
final InspectionProfileImpl profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
final InspectionToolWrapper tool = profile.getInspectionTool(getCompatibilityInspectionShortName(), project);
if (tool != null) {
// Partially copied from JSLinterInspection
final InspectionProfileImpl inspectionProfileImpl = as(profile, InspectionProfileImpl.class);
if (inspectionProfileImpl != null) {
final ScopeToolState state = inspectionProfileImpl.getToolDefaultState(tool.getShortName(), project);
state.setEnabled(true);
}
profile.modifyProfile(model -> model.enableTool(tool.getShortName(), null, project));
profile.modifyProfile(model -> model.enableTool(tool.getShortName(), project));
EditInspectionToolsSettingsAction.editToolSettings(project, profile, getCompatibilityInspectionShortName());
}
}