Reset inspection options in Settings isn't saved IDEA-194226

This commit is contained in:
Dmitry Batkovich
2018-10-01 17:47:19 +03:00
parent fc66905163
commit 3dafef6aee
2 changed files with 15 additions and 6 deletions
@@ -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) {
@@ -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)