Merge KotlinCodeStyleSettingsProvider to KotlinLanguageCodeStyleSettingsProvider
This commit is contained in:
@@ -415,9 +415,8 @@
|
|||||||
<additionalTextAttributes scheme="Default" file="colorScheme/Default_Kotlin.xml"/>
|
<additionalTextAttributes scheme="Default" file="colorScheme/Default_Kotlin.xml"/>
|
||||||
<additionalTextAttributes scheme="Darcula" file="colorScheme/Darcula_Kotlin.xml"/>
|
<additionalTextAttributes scheme="Darcula" file="colorScheme/Darcula_Kotlin.xml"/>
|
||||||
|
|
||||||
<codeStyleSettingsProvider implementation="org.jetbrains.kotlin.idea.formatter.KotlinGenerationSettingsProvider"/>
|
|
||||||
<codeStyleSettingsProvider implementation="org.jetbrains.kotlin.idea.formatter.KotlinCodeStyleSettingsProvider"/>
|
|
||||||
<langCodeStyleSettingsProvider implementation="org.jetbrains.kotlin.idea.formatter.KotlinLanguageCodeStyleSettingsProvider"/>
|
<langCodeStyleSettingsProvider implementation="org.jetbrains.kotlin.idea.formatter.KotlinLanguageCodeStyleSettingsProvider"/>
|
||||||
|
<codeStyleSettingsProvider implementation="org.jetbrains.kotlin.idea.formatter.KotlinGenerationSettingsProvider"/>
|
||||||
<predefinedCodeStyle implementation="org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle"/>
|
<predefinedCodeStyle implementation="org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle"/>
|
||||||
<predefinedCodeStyle implementation="org.jetbrains.kotlin.idea.formatter.KotlinObsoleteCodeStyle"/>
|
<predefinedCodeStyle implementation="org.jetbrains.kotlin.idea.formatter.KotlinObsoleteCodeStyle"/>
|
||||||
|
|
||||||
|
|||||||
@@ -2194,4 +2194,5 @@ fix.move.file.to.package.dir.name.text=source root
|
|||||||
move.refactoring.error.text.cannot.perform.refactoring.since.the.following.files.already.exist=Cannot perform refactoring since the following files already exist:\n\n
|
move.refactoring.error.text.cannot.perform.refactoring.since.the.following.files.already.exist=Cannot perform refactoring since the following files already exist:\n\n
|
||||||
kotlin.script.definitions.model.name.is.enabled=Is Enabled
|
kotlin.script.definitions.model.name.is.enabled=Is Enabled
|
||||||
kotlin.script.definitions.model.name.pattern.extension=Pattern/Extension
|
kotlin.script.definitions.model.name.pattern.extension=Pattern/Extension
|
||||||
kotlin.script.definitions.model.name.name=Name
|
kotlin.script.definitions.model.name.name=Name
|
||||||
|
codestyle.name.kotlin=Kotlin
|
||||||
@@ -15,6 +15,7 @@ import com.intellij.psi.codeStyle.PackageEntryTable
|
|||||||
import com.intellij.ui.OptionGroup
|
import com.intellij.ui.OptionGroup
|
||||||
import com.intellij.ui.components.JBScrollPane
|
import com.intellij.ui.components.JBScrollPane
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.GridBagConstraints
|
import java.awt.GridBagConstraints
|
||||||
@@ -23,7 +24,7 @@ import java.awt.Insets
|
|||||||
import javax.swing.*
|
import javax.swing.*
|
||||||
import javax.swing.table.AbstractTableModel
|
import javax.swing.table.AbstractTableModel
|
||||||
|
|
||||||
class ImportSettingsPanelWrapper(settings: CodeStyleSettings) : CodeStyleAbstractPanel(settings) {
|
class ImportSettingsPanelWrapper(settings: CodeStyleSettings) : CodeStyleAbstractPanel(KotlinLanguage.INSTANCE, null, settings) {
|
||||||
private val importsPanel = ImportSettingsPanel(settings)
|
private val importsPanel = ImportSettingsPanel(settings)
|
||||||
|
|
||||||
private fun CodeStyleSettings.kotlinSettings() = getCustomSettings(KotlinCodeStyleSettings::class.java)
|
private fun CodeStyleSettings.kotlinSettings() = getCustomSettings(KotlinCodeStyleSettings::class.java)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.formatter
|
||||||
|
|
||||||
|
import com.intellij.application.options.TabbedLanguageCodeStylePanel
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
|
|
||||||
|
class KotlinCodeStylePanel(currentSettings: CodeStyleSettings, settings: CodeStyleSettings) :
|
||||||
|
TabbedLanguageCodeStylePanel(KotlinLanguage.INSTANCE, currentSettings, settings) {
|
||||||
|
override fun initTabs(settings: CodeStyleSettings) {
|
||||||
|
super.initTabs(settings)
|
||||||
|
|
||||||
|
addTab(ImportSettingsPanelWrapper(settings))
|
||||||
|
for (provider in CodeStyleSettingsProvider.EXTENSION_POINT_NAME.extensions) {
|
||||||
|
if (provider.language == KotlinLanguage.INSTANCE && !provider.hasSettingsPage()) {
|
||||||
|
createTab(provider)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addTab(KotlinSaveStylePanel(settings))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.formatter;
|
|
||||||
|
|
||||||
import com.intellij.application.options.CodeStyleAbstractConfigurable;
|
|
||||||
import com.intellij.application.options.CodeStyleAbstractPanel;
|
|
||||||
import com.intellij.application.options.TabbedLanguageCodeStylePanel;
|
|
||||||
import com.intellij.lang.Language;
|
|
||||||
import com.intellij.psi.codeStyle.CodeStyleConfigurable;
|
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
|
|
||||||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
|
|
||||||
|
|
||||||
public class KotlinCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getConfigurableDisplayName() {
|
|
||||||
return KotlinLanguage.NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Language getLanguage() {
|
|
||||||
return KotlinLanguage.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
|
|
||||||
return new KotlinCodeStyleSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings settings, @NotNull CodeStyleSettings modelSettings) {
|
|
||||||
return new CodeStyleAbstractConfigurable(settings, modelSettings, KotlinLanguage.NAME) {
|
|
||||||
@Override
|
|
||||||
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
|
|
||||||
return new TabbedLanguageCodeStylePanel(KotlinLanguage.INSTANCE, getCurrentSettings(), settings) {
|
|
||||||
@Override
|
|
||||||
protected void initTabs(CodeStyleSettings settings) {
|
|
||||||
// TODO: activate all parent tabs
|
|
||||||
addIndentOptionsTab(settings);
|
|
||||||
addSpacesTab(settings);
|
|
||||||
addWrappingAndBracesTab(settings);
|
|
||||||
addBlankLinesTab(settings);
|
|
||||||
addTab(new ImportSettingsPanelWrapper(settings));
|
|
||||||
|
|
||||||
for (CodeStyleSettingsProvider provider : CodeStyleSettingsProvider.EXTENSION_POINT_NAME.getExtensions()) {
|
|
||||||
if (provider.getLanguage() == KotlinLanguage.INSTANCE && !provider.hasSettingsPage()) {
|
|
||||||
createTab(provider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addTab(new KotlinSaveStylePanel(settings));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getHelpTopic() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+259
-242
@@ -1,23 +1,276 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 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.CodeStyleAbstractConfigurable
|
||||||
|
import com.intellij.application.options.CodeStyleAbstractPanel
|
||||||
import com.intellij.application.options.IndentOptionsEditor
|
import com.intellij.application.options.IndentOptionsEditor
|
||||||
import com.intellij.application.options.SmartIndentOptionsEditor
|
import com.intellij.application.options.SmartIndentOptionsEditor
|
||||||
|
import com.intellij.lang.Language
|
||||||
import com.intellij.openapi.application.ApplicationBundle
|
import com.intellij.openapi.application.ApplicationBundle
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable
|
import com.intellij.psi.codeStyle.*
|
||||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
|
|
||||||
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
|
class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
|
||||||
override fun getLanguage() = KotlinLanguage.INSTANCE
|
override fun getLanguage(): Language = KotlinLanguage.INSTANCE
|
||||||
|
override fun getConfigurableDisplayName(): String = KotlinBundle.message("codestyle.name.kotlin")
|
||||||
|
override fun getDisplayPriority(): DisplayPriority = DisplayPriority.COMMON_SETTINGS
|
||||||
|
override fun createConfigurable(settings: CodeStyleSettings, modelSettings: CodeStyleSettings): CodeStyleConfigurable =
|
||||||
|
object : CodeStyleAbstractConfigurable(settings, modelSettings, KotlinLanguage.NAME) {
|
||||||
|
override fun createPanel(settings: CodeStyleSettings): CodeStyleAbstractPanel =
|
||||||
|
KotlinCodeStylePanel(currentSettings, settings)
|
||||||
|
|
||||||
|
override fun getHelpTopic(): String = "reference.settingsdialog.codestyle.kotlin"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getIndentOptionsEditor(): IndentOptionsEditor = SmartIndentOptionsEditor()
|
||||||
|
|
||||||
|
override fun getDefaultCommonSettings(): CommonCodeStyleSettings = KotlinCommonCodeStyleSettings().apply {
|
||||||
|
initIndentOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createCustomSettings(settings: CodeStyleSettings?): CustomCodeStyleSettings = KotlinCodeStyleSettings(settings)
|
||||||
|
|
||||||
|
override fun customizeSettings(consumer: CodeStyleSettingsCustomizable, settingsType: SettingsType) {
|
||||||
|
fun showCustomOption(field: KProperty<*>, title: String, groupName: String? = null, vararg options: Any) {
|
||||||
|
consumer.showCustomOption(KotlinCodeStyleSettings::class.java, field.name, title, groupName, *options)
|
||||||
|
}
|
||||||
|
|
||||||
|
when (settingsType) {
|
||||||
|
SettingsType.SPACING_SETTINGS -> {
|
||||||
|
consumer.showStandardOptions(
|
||||||
|
"SPACE_AROUND_ASSIGNMENT_OPERATORS",
|
||||||
|
"SPACE_AROUND_LOGICAL_OPERATORS",
|
||||||
|
"SPACE_AROUND_EQUALITY_OPERATORS",
|
||||||
|
"SPACE_AROUND_RELATIONAL_OPERATORS",
|
||||||
|
"SPACE_AROUND_ADDITIVE_OPERATORS",
|
||||||
|
"SPACE_AROUND_MULTIPLICATIVE_OPERATORS",
|
||||||
|
"SPACE_AROUND_UNARY_OPERATOR",
|
||||||
|
"SPACE_AFTER_COMMA",
|
||||||
|
"SPACE_BEFORE_COMMA",
|
||||||
|
"SPACE_BEFORE_IF_PARENTHESES",
|
||||||
|
"SPACE_BEFORE_WHILE_PARENTHESES",
|
||||||
|
"SPACE_BEFORE_FOR_PARENTHESES",
|
||||||
|
"SPACE_BEFORE_CATCH_PARENTHESES"
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_AROUND_RANGE,
|
||||||
|
KotlinBundle.message("formatter.title.range.operator"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_AROUND_OPERATORS
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_BEFORE_TYPE_COLON,
|
||||||
|
KotlinBundle.message("formatter.title.before.colon.after.declaration.name"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_AFTER_TYPE_COLON,
|
||||||
|
KotlinBundle.message("formatter.title.after.colon.before.declaration.type"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_BEFORE_EXTEND_COLON,
|
||||||
|
KotlinBundle.message("formatter.title.before.colon.in.new.type.definition"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_AFTER_EXTEND_COLON,
|
||||||
|
KotlinBundle.message("formatter.title.after.colon.in.new.type.definition"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD,
|
||||||
|
KotlinBundle.message("formatter.title.in.simple.one.line.methods"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_AROUND_FUNCTION_TYPE_ARROW,
|
||||||
|
KotlinBundle.message("formatter.title.around.arrow.in.function.types"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_AROUND_WHEN_ARROW,
|
||||||
|
KotlinBundle.message("formatter.title.around.arrow.in"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_BEFORE_LAMBDA_ARROW,
|
||||||
|
KotlinBundle.message("formatter.title.before.lambda.arrow"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_OTHER
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::SPACE_BEFORE_WHEN_PARENTHESES,
|
||||||
|
KotlinBundle.message("formatter.title.when.parentheses"),
|
||||||
|
CodeStyleSettingsCustomizable.SPACES_BEFORE_PARENTHESES
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SettingsType.WRAPPING_AND_BRACES_SETTINGS -> {
|
||||||
|
consumer.showStandardOptions(
|
||||||
|
// "ALIGN_MULTILINE_CHAINED_METHODS",
|
||||||
|
"RIGHT_MARGIN",
|
||||||
|
"WRAP_ON_TYPING",
|
||||||
|
"KEEP_FIRST_COLUMN_COMMENT",
|
||||||
|
"KEEP_LINE_BREAKS",
|
||||||
|
"ALIGN_MULTILINE_EXTENDS_LIST",
|
||||||
|
"ALIGN_MULTILINE_PARAMETERS",
|
||||||
|
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
|
||||||
|
"ALIGN_MULTILINE_METHOD_BRACKETS",
|
||||||
|
"ALIGN_MULTILINE_BINARY_OPERATION",
|
||||||
|
"ELSE_ON_NEW_LINE",
|
||||||
|
"WHILE_ON_NEW_LINE",
|
||||||
|
"CATCH_ON_NEW_LINE",
|
||||||
|
"FINALLY_ON_NEW_LINE",
|
||||||
|
"CALL_PARAMETERS_WRAP",
|
||||||
|
"METHOD_PARAMETERS_WRAP",
|
||||||
|
"EXTENDS_LIST_WRAP",
|
||||||
|
"METHOD_ANNOTATION_WRAP",
|
||||||
|
"CLASS_ANNOTATION_WRAP",
|
||||||
|
"PARAMETER_ANNOTATION_WRAP",
|
||||||
|
"VARIABLE_ANNOTATION_WRAP",
|
||||||
|
"FIELD_ANNOTATION_WRAP",
|
||||||
|
"METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
||||||
|
"METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
|
||||||
|
"CALL_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
||||||
|
"CALL_PARAMETERS_RPAREN_ON_NEXT_LINE",
|
||||||
|
"ENUM_CONSTANTS_WRAP",
|
||||||
|
"METHOD_CALL_CHAIN_WRAP",
|
||||||
|
"WRAP_FIRST_METHOD_IN_CALL_CHAIN",
|
||||||
|
"ASSIGNMENT_WRAP",
|
||||||
|
)
|
||||||
|
|
||||||
|
consumer.renameStandardOption(
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT,
|
||||||
|
KotlinBundle.message("formatter.title.when.statements")
|
||||||
|
)
|
||||||
|
|
||||||
|
consumer.renameStandardOption("FIELD_ANNOTATION_WRAP", KotlinBundle.message("formatter.title.property.annotations"))
|
||||||
|
consumer.renameStandardOption(
|
||||||
|
"METHOD_PARAMETERS_WRAP",
|
||||||
|
KotlinBundle.message("formatter.title.function.declaration.parameters")
|
||||||
|
)
|
||||||
|
|
||||||
|
consumer.renameStandardOption("CALL_PARAMETERS_WRAP", KotlinBundle.message("formatter.title.function.call.arguments"))
|
||||||
|
consumer.renameStandardOption("METHOD_CALL_CHAIN_WRAP", KotlinBundle.message("formatter.title.chained.function.calls"))
|
||||||
|
consumer.renameStandardOption("METHOD_ANNOTATION_WRAP", KotlinBundle.message("formatter.title.function.annotations"))
|
||||||
|
consumer.renameStandardOption(
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_METHOD_PARENTHESES,
|
||||||
|
KotlinBundle.message("formatter.title.function.parentheses")
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(KotlinCodeStyleSettings::ALLOW_TRAILING_COMMA, "Use trailing comma")
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::ALIGN_IN_COLUMNS_CASE_BRANCH,
|
||||||
|
KotlinBundle.message("formatter.title.align.when.branches.in.columns"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::LBRACE_ON_NEXT_LINE,
|
||||||
|
KotlinBundle.message("formatter.title.put.left.brace.on.new.line"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_BRACES
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_PARAMETER_LISTS,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_METHOD_PARAMETERS
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_ARGUMENT_LISTS,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_METHOD_ARGUMENTS_WRAPPING
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_CHAINED_CALLS,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_CALL_CHAIN
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_EXTENDS_LIST
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::WRAP_EXPRESSION_BODY_FUNCTIONS,
|
||||||
|
KotlinBundle.message("formatter.title.expression.body.functions"),
|
||||||
|
options = *arrayOf(
|
||||||
|
CodeStyleSettingsCustomizable.WRAP_OPTIONS_FOR_SINGLETON,
|
||||||
|
CodeStyleSettingsCustomizable.WRAP_VALUES_FOR_SINGLETON
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
KotlinBundle.message("formatter.title.expression.body.functions")
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::WRAP_ELVIS_EXPRESSIONS,
|
||||||
|
KotlinBundle.message("formatter.title.elvis.expressions"),
|
||||||
|
options = *arrayOf(
|
||||||
|
CodeStyleSettingsCustomizable.WRAP_OPTIONS_FOR_SINGLETON,
|
||||||
|
CodeStyleSettingsCustomizable.WRAP_VALUES_FOR_SINGLETON
|
||||||
|
)
|
||||||
|
)
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_ELVIS,
|
||||||
|
title = KotlinBundle.message("formatter.title.use.continuation.indent"),
|
||||||
|
groupName = KotlinBundle.message("formatter.title.elvis.expressions")
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::IF_RPAREN_ON_NEW_LINE,
|
||||||
|
ApplicationBundle.message("wrapping.rpar.on.new.line"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_IF_STATEMENT
|
||||||
|
)
|
||||||
|
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_IF_CONDITIONS,
|
||||||
|
KotlinBundle.message("formatter.title.use.continuation.indent.in.conditions"),
|
||||||
|
CodeStyleSettingsCustomizable.WRAPPING_IF_STATEMENT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SettingsType.BLANK_LINES_SETTINGS -> {
|
||||||
|
consumer.showStandardOptions(
|
||||||
|
"KEEP_BLANK_LINES_IN_CODE",
|
||||||
|
"KEEP_BLANK_LINES_IN_DECLARATIONS",
|
||||||
|
"KEEP_BLANK_LINES_BEFORE_RBRACE",
|
||||||
|
"BLANK_LINES_AFTER_CLASS_HEADER"
|
||||||
|
)
|
||||||
|
showCustomOption(
|
||||||
|
KotlinCodeStyleSettings::BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES,
|
||||||
|
KotlinBundle.message("formatter.title.around.when.branches.with"),
|
||||||
|
CodeStyleSettingsCustomizable.BLANK_LINES
|
||||||
|
)
|
||||||
|
}
|
||||||
|
SettingsType.COMMENTER_SETTINGS -> {
|
||||||
|
consumer.showAllStandardOptions()
|
||||||
|
}
|
||||||
|
else -> consumer.showStandardOptions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getCodeSample(settingsType: SettingsType): String = when (settingsType) {
|
override fun getCodeSample(settingsType: SettingsType): String = when (settingsType) {
|
||||||
SettingsType.WRAPPING_AND_BRACES_SETTINGS ->
|
SettingsType.WRAPPING_AND_BRACES_SETTINGS ->
|
||||||
@@ -167,240 +420,4 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide
|
|||||||
class AnotherClass<T : Any> : Some()
|
class AnotherClass<T : Any> : Some()
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
override fun getLanguageName(): String = KotlinLanguage.NAME
|
|
||||||
|
|
||||||
override fun customizeSettings(consumer: CodeStyleSettingsCustomizable, settingsType: SettingsType) {
|
|
||||||
fun showCustomOption(field: KProperty<*>, title: String, groupName: String? = null, vararg options: Any) {
|
|
||||||
consumer.showCustomOption(KotlinCodeStyleSettings::class.java, field.name, title, groupName, *options)
|
|
||||||
}
|
|
||||||
|
|
||||||
when (settingsType) {
|
|
||||||
SettingsType.SPACING_SETTINGS -> {
|
|
||||||
consumer.showStandardOptions(
|
|
||||||
"SPACE_AROUND_ASSIGNMENT_OPERATORS",
|
|
||||||
"SPACE_AROUND_LOGICAL_OPERATORS",
|
|
||||||
"SPACE_AROUND_EQUALITY_OPERATORS",
|
|
||||||
"SPACE_AROUND_RELATIONAL_OPERATORS",
|
|
||||||
"SPACE_AROUND_ADDITIVE_OPERATORS",
|
|
||||||
"SPACE_AROUND_MULTIPLICATIVE_OPERATORS",
|
|
||||||
"SPACE_AROUND_UNARY_OPERATOR",
|
|
||||||
"SPACE_AFTER_COMMA",
|
|
||||||
"SPACE_BEFORE_COMMA",
|
|
||||||
"SPACE_BEFORE_IF_PARENTHESES",
|
|
||||||
"SPACE_BEFORE_WHILE_PARENTHESES",
|
|
||||||
"SPACE_BEFORE_FOR_PARENTHESES",
|
|
||||||
"SPACE_BEFORE_CATCH_PARENTHESES"
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_AROUND_RANGE,
|
|
||||||
KotlinBundle.message("formatter.title.range.operator"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_AROUND_OPERATORS
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_BEFORE_TYPE_COLON,
|
|
||||||
KotlinBundle.message("formatter.title.before.colon.after.declaration.name"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_AFTER_TYPE_COLON,
|
|
||||||
KotlinBundle.message("formatter.title.after.colon.before.declaration.type"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_BEFORE_EXTEND_COLON,
|
|
||||||
KotlinBundle.message("formatter.title.before.colon.in.new.type.definition"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_AFTER_EXTEND_COLON,
|
|
||||||
KotlinBundle.message("formatter.title.after.colon.in.new.type.definition"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD,
|
|
||||||
KotlinBundle.message("formatter.title.in.simple.one.line.methods"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_AROUND_FUNCTION_TYPE_ARROW,
|
|
||||||
KotlinBundle.message("formatter.title.around.arrow.in.function.types"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_AROUND_WHEN_ARROW,
|
|
||||||
KotlinBundle.message("formatter.title.around.arrow.in"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_BEFORE_LAMBDA_ARROW,
|
|
||||||
KotlinBundle.message("formatter.title.before.lambda.arrow"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_OTHER
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::SPACE_BEFORE_WHEN_PARENTHESES,
|
|
||||||
KotlinBundle.message("formatter.title.when.parentheses"),
|
|
||||||
CodeStyleSettingsCustomizable.SPACES_BEFORE_PARENTHESES
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SettingsType.WRAPPING_AND_BRACES_SETTINGS -> {
|
|
||||||
consumer.showStandardOptions(
|
|
||||||
// "ALIGN_MULTILINE_CHAINED_METHODS",
|
|
||||||
"RIGHT_MARGIN",
|
|
||||||
"WRAP_ON_TYPING",
|
|
||||||
"KEEP_FIRST_COLUMN_COMMENT",
|
|
||||||
"KEEP_LINE_BREAKS",
|
|
||||||
"ALIGN_MULTILINE_EXTENDS_LIST",
|
|
||||||
"ALIGN_MULTILINE_PARAMETERS",
|
|
||||||
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
|
|
||||||
"ALIGN_MULTILINE_METHOD_BRACKETS",
|
|
||||||
"ALIGN_MULTILINE_BINARY_OPERATION",
|
|
||||||
"ELSE_ON_NEW_LINE",
|
|
||||||
"WHILE_ON_NEW_LINE",
|
|
||||||
"CATCH_ON_NEW_LINE",
|
|
||||||
"FINALLY_ON_NEW_LINE",
|
|
||||||
"CALL_PARAMETERS_WRAP",
|
|
||||||
"METHOD_PARAMETERS_WRAP",
|
|
||||||
"EXTENDS_LIST_WRAP",
|
|
||||||
"METHOD_ANNOTATION_WRAP",
|
|
||||||
"CLASS_ANNOTATION_WRAP",
|
|
||||||
"PARAMETER_ANNOTATION_WRAP",
|
|
||||||
"VARIABLE_ANNOTATION_WRAP",
|
|
||||||
"FIELD_ANNOTATION_WRAP",
|
|
||||||
"METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
|
||||||
"METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
|
|
||||||
"CALL_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
|
||||||
"CALL_PARAMETERS_RPAREN_ON_NEXT_LINE",
|
|
||||||
"ENUM_CONSTANTS_WRAP",
|
|
||||||
"METHOD_CALL_CHAIN_WRAP",
|
|
||||||
"WRAP_FIRST_METHOD_IN_CALL_CHAIN",
|
|
||||||
"ASSIGNMENT_WRAP"
|
|
||||||
)
|
|
||||||
consumer.renameStandardOption(
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT,
|
|
||||||
KotlinBundle.message("formatter.title.when.statements")
|
|
||||||
)
|
|
||||||
consumer.renameStandardOption("FIELD_ANNOTATION_WRAP", KotlinBundle.message("formatter.title.property.annotations"))
|
|
||||||
consumer.renameStandardOption(
|
|
||||||
"METHOD_PARAMETERS_WRAP",
|
|
||||||
KotlinBundle.message("formatter.title.function.declaration.parameters")
|
|
||||||
)
|
|
||||||
consumer.renameStandardOption("CALL_PARAMETERS_WRAP", KotlinBundle.message("formatter.title.function.call.arguments"))
|
|
||||||
consumer.renameStandardOption("METHOD_CALL_CHAIN_WRAP", KotlinBundle.message("formatter.title.chained.function.calls"))
|
|
||||||
consumer.renameStandardOption("METHOD_ANNOTATION_WRAP", KotlinBundle.message("formatter.title.function.annotations"))
|
|
||||||
consumer.renameStandardOption(
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_METHOD_PARENTHESES,
|
|
||||||
KotlinBundle.message("formatter.title.function.parentheses")
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(KotlinCodeStyleSettings::ALLOW_TRAILING_COMMA, "Use trailing comma")
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::ALIGN_IN_COLUMNS_CASE_BRANCH,
|
|
||||||
KotlinBundle.message("formatter.title.align.when.branches.in.columns"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_SWITCH_STATEMENT
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::LBRACE_ON_NEXT_LINE,
|
|
||||||
KotlinBundle.message("formatter.title.put.left.brace.on.new.line"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_BRACES
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_PARAMETER_LISTS,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_METHOD_PARAMETERS
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_ARGUMENT_LISTS,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_METHOD_ARGUMENTS_WRAPPING
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_CHAINED_CALLS,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_CALL_CHAIN
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_EXTENDS_LIST
|
|
||||||
)
|
|
||||||
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::WRAP_EXPRESSION_BODY_FUNCTIONS,
|
|
||||||
KotlinBundle.message("formatter.title.expression.body.functions"),
|
|
||||||
options = *arrayOf(
|
|
||||||
CodeStyleSettingsCustomizable.WRAP_OPTIONS_FOR_SINGLETON,
|
|
||||||
CodeStyleSettingsCustomizable.WRAP_VALUES_FOR_SINGLETON
|
|
||||||
)
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
KotlinBundle.message("formatter.title.expression.body.functions")
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::WRAP_ELVIS_EXPRESSIONS,
|
|
||||||
KotlinBundle.message("formatter.title.elvis.expressions"),
|
|
||||||
options = *arrayOf(
|
|
||||||
CodeStyleSettingsCustomizable.WRAP_OPTIONS_FOR_SINGLETON,
|
|
||||||
CodeStyleSettingsCustomizable.WRAP_VALUES_FOR_SINGLETON
|
|
||||||
)
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_ELVIS,
|
|
||||||
title = KotlinBundle.message("formatter.title.use.continuation.indent"),
|
|
||||||
groupName = KotlinBundle.message("formatter.title.elvis.expressions")
|
|
||||||
)
|
|
||||||
@Suppress("InvalidBundleOrProperty")
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::IF_RPAREN_ON_NEW_LINE,
|
|
||||||
ApplicationBundle.message("wrapping.rpar.on.new.line"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_IF_STATEMENT
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_IF_CONDITIONS,
|
|
||||||
KotlinBundle.message("formatter.title.use.continuation.indent.in.conditions"),
|
|
||||||
CodeStyleSettingsCustomizable.WRAPPING_IF_STATEMENT
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SettingsType.BLANK_LINES_SETTINGS -> {
|
|
||||||
consumer.showStandardOptions(
|
|
||||||
"KEEP_BLANK_LINES_IN_CODE",
|
|
||||||
"KEEP_BLANK_LINES_IN_DECLARATIONS",
|
|
||||||
"KEEP_BLANK_LINES_BEFORE_RBRACE",
|
|
||||||
"BLANK_LINES_AFTER_CLASS_HEADER"
|
|
||||||
)
|
|
||||||
showCustomOption(
|
|
||||||
KotlinCodeStyleSettings::BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES,
|
|
||||||
KotlinBundle.message("formatter.title.around.when.branches.with"),
|
|
||||||
CodeStyleSettingsCustomizable.BLANK_LINES
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SettingsType.COMMENTER_SETTINGS -> {
|
|
||||||
consumer.showAllStandardOptions()
|
|
||||||
}
|
|
||||||
else -> consumer.showStandardOptions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getIndentOptionsEditor(): IndentOptionsEditor = SmartIndentOptionsEditor()
|
|
||||||
|
|
||||||
override fun getDefaultCommonSettings(): CommonCodeStyleSettings {
|
|
||||||
return KotlinCommonCodeStyleSettings().apply {
|
|
||||||
initIndentOptions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,13 +16,14 @@ import com.intellij.ui.components.panels.VerticalLayout
|
|||||||
import com.intellij.util.ui.JBUI
|
import com.intellij.util.ui.JBUI
|
||||||
import com.intellij.util.ui.UIUtil
|
import com.intellij.util.ui.UIUtil
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
import org.jetbrains.kotlin.idea.KotlinBundle
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import javax.swing.BorderFactory
|
import javax.swing.BorderFactory
|
||||||
import javax.swing.JLabel
|
import javax.swing.JLabel
|
||||||
import javax.swing.JList
|
import javax.swing.JList
|
||||||
import javax.swing.JPanel
|
import javax.swing.JPanel
|
||||||
|
|
||||||
class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(settings) {
|
class KotlinSaveStylePanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(KotlinLanguage.INSTANCE, null, settings) {
|
||||||
override fun getRightMargin() = throw UnsupportedOperationException()
|
override fun getRightMargin() = throw UnsupportedOperationException()
|
||||||
override fun createHighlighter(scheme: EditorColorsScheme) = throw UnsupportedOperationException()
|
override fun createHighlighter(scheme: EditorColorsScheme) = throw UnsupportedOperationException()
|
||||||
override fun getFileType() = throw UnsupportedOperationException()
|
override fun getFileType() = throw UnsupportedOperationException()
|
||||||
|
|||||||
Reference in New Issue
Block a user