Kotlin Facet: Avoid excessive validation
#KT-17293 Fixed
This commit is contained in:
@@ -227,6 +227,8 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
private val versionValidator = VersionValidator()
|
private val versionValidator = VersionValidator()
|
||||||
private val coroutineValidator = ArgumentConsistencyValidator()
|
private val coroutineValidator = ArgumentConsistencyValidator()
|
||||||
|
|
||||||
|
private var enableValidation = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
libraryValidator = FrameworkLibraryValidatorWithDynamicDescription(
|
libraryValidator = FrameworkLibraryValidatorWithDynamicDescription(
|
||||||
DelegatingLibrariesValidatorContext(editorContext),
|
DelegatingLibrariesValidatorContext(editorContext),
|
||||||
@@ -254,8 +256,6 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
editor.targetPlatformComboBox.validateOnChange()
|
editor.targetPlatformComboBox.validateOnChange()
|
||||||
|
|
||||||
editor.updateCompilerConfigurable()
|
editor.updateCompilerConfigurable()
|
||||||
|
|
||||||
reset()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun JTextField.validateOnChange() {
|
private fun JTextField.validateOnChange() {
|
||||||
@@ -276,8 +276,17 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
addActionListener { doValidate() }
|
addActionListener { doValidate() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun validateOnce(body: () -> Unit) {
|
||||||
|
enableValidation = false
|
||||||
|
body()
|
||||||
|
enableValidation = true
|
||||||
|
doValidate()
|
||||||
|
}
|
||||||
|
|
||||||
private fun doValidate() {
|
private fun doValidate() {
|
||||||
validatorsManager.validate()
|
if (enableValidation) {
|
||||||
|
validatorsManager.validate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isModified(): Boolean {
|
override fun isModified(): Boolean {
|
||||||
@@ -287,29 +296,33 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() {
|
override fun reset() {
|
||||||
editor.useProjectSettingsCheckBox.isSelected = configuration.settings.useProjectSettings
|
validateOnce {
|
||||||
editor.targetPlatformComboBox.selectedItem = configuration.settings.targetPlatformKind
|
editor.useProjectSettingsCheckBox.isSelected = configuration.settings.useProjectSettings
|
||||||
editor.compilerConfigurable.reset()
|
editor.targetPlatformComboBox.selectedItem = configuration.settings.targetPlatformKind
|
||||||
editor.updateCompilerConfigurable()
|
editor.compilerConfigurable.reset()
|
||||||
|
editor.updateCompilerConfigurable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply() {
|
override fun apply() {
|
||||||
editor.compilerConfigurable.apply()
|
validateOnce {
|
||||||
with(configuration.settings) {
|
editor.compilerConfigurable.apply()
|
||||||
useProjectSettings = editor.useProjectSettingsCheckBox.isSelected
|
with(configuration.settings) {
|
||||||
(editor.targetPlatformComboBox.selectedItem as TargetPlatformKind<*>?)?.let {
|
useProjectSettings = editor.useProjectSettingsCheckBox.isSelected
|
||||||
if (it != targetPlatformKind) {
|
(editor.targetPlatformComboBox.selectedItem as TargetPlatformKind<*>?)?.let {
|
||||||
val newCompilerArguments = it.createCompilerArguments()
|
if (it != targetPlatformKind) {
|
||||||
val platformArguments = when (it) {
|
val newCompilerArguments = it.createCompilerArguments()
|
||||||
is TargetPlatformKind.Jvm -> editor.compilerConfigurable.k2jvmCompilerArguments
|
val platformArguments = when (it) {
|
||||||
is TargetPlatformKind.JavaScript -> editor.compilerConfigurable.k2jsCompilerArguments
|
is TargetPlatformKind.Jvm -> editor.compilerConfigurable.k2jvmCompilerArguments
|
||||||
else -> null
|
is TargetPlatformKind.JavaScript -> editor.compilerConfigurable.k2jsCompilerArguments
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (platformArguments != null) {
|
||||||
|
mergeBeans(platformArguments, newCompilerArguments)
|
||||||
|
}
|
||||||
|
copyInheritedFields(compilerArguments!!, newCompilerArguments)
|
||||||
|
compilerArguments = newCompilerArguments
|
||||||
}
|
}
|
||||||
if (platformArguments != null) {
|
|
||||||
mergeBeans(platformArguments, newCompilerArguments)
|
|
||||||
}
|
|
||||||
copyInheritedFields(compilerArguments!!, newCompilerArguments)
|
|
||||||
compilerArguments = newCompilerArguments
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user