Refactoring: extract method for applying codestyle from string (KT-23400)
This commit is contained in:
@@ -12,6 +12,20 @@ import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemesImpl
|
||||
|
||||
object ProjectCodeStyleImporter {
|
||||
fun apply(project: Project, codeStyleStr: String?): Boolean {
|
||||
return when (codeStyleStr) {
|
||||
KotlinObsoleteCodeStyle.CODE_STYLE_SETTING -> {
|
||||
ProjectCodeStyleImporter.apply(project, KotlinObsoleteCodeStyle.INSTANCE)
|
||||
true
|
||||
}
|
||||
KotlinStyleGuideCodeStyle.CODE_STYLE_SETTING -> {
|
||||
ProjectCodeStyleImporter.apply(project, KotlinStyleGuideCodeStyle.INSTANCE)
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun apply(project: Project, codeStyle: KotlinPredefinedCodeStyle) {
|
||||
val schemeManager = CodeStyleSettingsManager.getInstance(project)
|
||||
val schemesModel = CodeStyleSchemesModel(project)
|
||||
|
||||
+2
-8
@@ -149,14 +149,8 @@ class KotlinGradleProjectDataService : AbstractProjectDataService<ModuleData, Vo
|
||||
GradleProjectImportHandler.getInstances(project).forEach { it.importByModule(kotlinFacet, moduleNode) }
|
||||
}
|
||||
|
||||
val property = GradlePropertiesFileUtils.readProperty(project, GradlePropertiesFileUtils.KOTLIN_CODE_STYLE_GRADLE_SETTING)
|
||||
when (property) {
|
||||
KotlinObsoleteCodeStyle.CODE_STYLE_SETTING ->
|
||||
ProjectCodeStyleImporter.apply(project, KotlinObsoleteCodeStyle.INSTANCE)
|
||||
KotlinStyleGuideCodeStyle.CODE_STYLE_SETTING ->
|
||||
ProjectCodeStyleImporter.apply(project, KotlinStyleGuideCodeStyle.INSTANCE)
|
||||
else -> return
|
||||
}
|
||||
val codeStyleStr = GradlePropertiesFileUtils.readProperty(project, GradlePropertiesFileUtils.KOTLIN_CODE_STYLE_GRADLE_SETTING)
|
||||
ProjectCodeStyleImporter.apply(project, codeStyleStr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user