ProjectCodeStyleImporter: fix deprecated elements

This commit is contained in:
Dmitry Gridin
2019-10-31 18:42:20 +07:00
parent f2289c216c
commit 196dd25637
@@ -1,10 +1,11 @@
/* /*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.idea.formatter package org.jetbrains.kotlin.idea.formatter
import com.intellij.application.options.CodeStyle
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.psi.codeStyle.CodeStyleSettings import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsManager import com.intellij.psi.codeStyle.CodeStyleSettingsManager
@@ -27,14 +28,14 @@ object ProjectCodeStyleImporter {
fun apply(project: Project, predefinedCodeStyle: KotlinPredefinedCodeStyle) { fun apply(project: Project, predefinedCodeStyle: KotlinPredefinedCodeStyle) {
val settingsManager = CodeStyleSettingsManager.getInstance(project) val settingsManager = CodeStyleSettingsManager.getInstance(project)
val currentSettings = settingsManager.currentSettings val customSettings = CodeStyle.getSettings(project)
if (predefinedCodeStyle.codeStyleId == currentSettings.kotlinCodeStyleDefaults()) { if (predefinedCodeStyle.codeStyleId == customSettings.kotlinCodeStyleDefaults()) {
// Don't bother user that already have correct code style // Don't bother user that already have correct code style
return return
} }
val projectSettingsUpdated: CodeStyleSettings = if (settingsManager.USE_PER_PROJECT_SETTINGS) { val projectSettingsUpdated: CodeStyleSettings = if (settingsManager.USE_PER_PROJECT_SETTINGS) {
settingsManager.currentSettings.clone() customSettings.clone()
} else { } else {
CodeStyleSettings() CodeStyleSettings()
} }