Avoid persisting default anchor configuration

#KT-24309 In Progress
This commit is contained in:
Pavel Kirpichenkov
2020-06-05 20:31:50 +03:00
parent b8cbfcbe7e
commit 8216e5cd72
@@ -32,16 +32,31 @@ class KotlinLibraryToSourceAnalysisStateComponent : PersistentStateComponent<Kot
@OptionTag(converter = AtomicBooleanXmlbConverter::class)
var isEnabled: AtomicBoolean = AtomicBoolean(false)
override fun getState(): KotlinLibraryToSourceAnalysisStateComponent? = this
private var shouldPersist: Boolean = true
override fun getState(): KotlinLibraryToSourceAnalysisStateComponent? =
if (shouldPersist) this else null
override fun loadState(state: KotlinLibraryToSourceAnalysisStateComponent) {
XmlSerializerUtil.copyBean(state, this)
}
override fun noStateLoaded() {
shouldPersist = false
}
fun setEnabled(newState: Boolean) {
isEnabled.getAndSet(newState)
}
override fun equals(other: Any?): Boolean {
return other is KotlinLibraryToSourceAnalysisStateComponent && other.isEnabled.get() == isEnabled.get()
}
override fun hashCode(): Int {
return isEnabled.get().hashCode()
}
companion object {
fun getInstance(project: Project): KotlinLibraryToSourceAnalysisStateComponent =
ServiceManager.getService(project, KotlinLibraryToSourceAnalysisStateComponent::class.java)