From 3dafef6aee13c7855d6de56e330bb134e94d1a80 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 1 Oct 2018 17:45:51 +0300 Subject: [PATCH] Reset inspection options in Settings isn't saved IDEA-194226 --- .../codeInspection/ex/InspectionProfileImpl.java | 9 +++++++++ .../ex/InspectionProfileModifiableModel.kt | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) 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 0f3a71f74584..eef2e018990f 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileImpl.java @@ -689,6 +689,15 @@ public class InspectionProfileImpl extends NewInspectionProfile { schemeState = SchemeState.POSSIBLY_CHANGED; } + public void resetToBase(String toolId, NamedScope scope, Project project) { + ToolsImpl tools = myBaseProfile.getToolsOrNull(toolId, null); + if (tools == null) return; + InspectionToolWrapper baseDefaultWrapper = tools.getDefaultState().getTool(); + ScopeToolState state = myTools.get(toolId).getTools().stream().filter(s -> scope == s.getScope(project)).findFirst().orElseThrow(IllegalStateException::new); + state.setTool(copyToolSettings(baseDefaultWrapper)); + schemeState = SchemeState.POSSIBLY_CHANGED; + } + public void convert(@NotNull Element element, @NotNull Project project) { final Element scopes = element.getChild("scopes"); if (scopes == null) { diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileModifiableModel.kt b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileModifiableModel.kt index 5dac3864626c..dba9d722fbf9 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileModifiableModel.kt +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/InspectionProfileModifiableModel.kt @@ -3,6 +3,7 @@ package com.intellij.codeInspection.ex import com.intellij.codeInspection.InspectionEP import com.intellij.codeInspection.InspectionProfileEntry +import com.intellij.openapi.options.SchemeState import com.intellij.openapi.project.Project import com.intellij.openapi.util.InvalidDataException import com.intellij.openapi.util.WriteExternalException @@ -27,6 +28,11 @@ open class InspectionProfileModifiableModel(val source: InspectionProfileImpl) : modified = value } + override fun resetToBase(toolId: String?, scope: NamedScope?, project: Project?) { + super.resetToBase(toolId, scope, project) + setModified(true) + } + override fun copyToolsConfigurations(project: Project?) { copyToolsConfigurations(source, project) } @@ -90,12 +96,6 @@ open class InspectionProfileModifiableModel(val source: InspectionProfileImpl) : myUninitializedSettings.clear() } - fun resetToBase(toolId: String, scope: NamedScope, project: Project?) { - val baseDefaultWrapper = myBaseProfile.getToolsOrNull(toolId, null)?.defaultState?.tool!! - val state = myTools[toolId]?.tools?.first { s -> scope == s.getScope(project) }!! - state.tool = copyToolSettings(baseDefaultWrapper) - } - //invoke when isChanged() == true fun commit() { source.commit(this)