mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[remote-dev] [kotlin] register KotlinLanguageCodeStyleSettingsProvider in JBClient
^GTW-7553 fixed GitOrigin-RevId: aafee179747513bcef9b9346eb30c3b17f26761c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6474f8eea8
commit
d67523619a
@@ -17,5 +17,8 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
<orderEntry type="module" module-name="kotlin.base.frontend-agnostic" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="kotlin.base.resources" />
|
||||
<orderEntry type="module" module-name="intellij.platform.core.ui" />
|
||||
<orderEntry type="module" module-name="kotlin.highlighting.minimal" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
import com.intellij.application.options.codeStyle.properties.CodeStyleChoiceList
|
||||
import com.intellij.application.options.codeStyle.properties.CodeStylePropertyAccessor
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||
import org.jetbrains.kotlin.idea.util.applyKotlinCodeStyle
|
||||
|
||||
class KotlinCodeStylePropertyAccessor(private val kotlinCodeStyle: KotlinCodeStyleSettings) :
|
||||
CodeStylePropertyAccessor<String>(),
|
||||
@@ -16,4 +16,14 @@ class KotlinCodeStylePropertyAccessor(private val kotlinCodeStyle: KotlinCodeSty
|
||||
override fun valueToString(value: String): String = value
|
||||
override fun getChoices(): List<String> = listOf(KotlinOfficialStyleGuide.CODE_STYLE_ID, KotlinObsoleteStyleGuide.CODE_STYLE_ID)
|
||||
override fun getPropertyName(): String = "code_style_defaults"
|
||||
}
|
||||
|
||||
private fun applyKotlinCodeStyle(codeStyleId: String?, codeStyleSettings: CodeStyleSettings): Boolean {
|
||||
when (codeStyleId) {
|
||||
KotlinOfficialStyleGuide.CODE_STYLE_ID -> KotlinOfficialStyleGuide.apply(codeStyleSettings)
|
||||
KotlinObsoleteStyleGuide.CODE_STYLE_ID -> KotlinObsoleteStyleGuide.apply(codeStyleSettings)
|
||||
else -> return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.formatter
|
||||
|
||||
@@ -61,12 +61,3 @@ fun PsiElement.containsLineBreakInChild(globalStartOffset: Int, globalEndOffset:
|
||||
.takeWhile { it.endOffset <= globalEndOffset }
|
||||
.any { it.textContains('\n') || it.textContains('\r') }
|
||||
|
||||
fun applyKotlinCodeStyle(codeStyleId: String?, codeStyleSettings: CodeStyleSettings): Boolean {
|
||||
when (codeStyleId) {
|
||||
KotlinOfficialStyleGuide.CODE_STYLE_ID -> KotlinOfficialStyleGuide.apply(codeStyleSettings)
|
||||
KotlinObsoleteStyleGuide.CODE_STYLE_ID -> KotlinObsoleteStyleGuide.apply(codeStyleSettings)
|
||||
else -> return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user