diff --git a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java index e7bbbb754520..b73f5ff92491 100644 --- a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java +++ b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java @@ -54,6 +54,7 @@ public class KotlinCodeStyleSettings extends CustomCodeStyleSettings { public int WRAP_ELVIS_EXPRESSIONS = 1; public boolean IF_RPAREN_ON_NEW_LINE = false; public boolean ALLOW_TRAILING_COMMA = false; + public int BLANK_LINES_BEFORE_DECLARATION_WITH_COMMENT_OR_ANNOTATION_ON_SEPARATE_LINE = 1; @ReflectionUtil.SkipInEquals public String CODE_STYLE_DEFAULTS = null; diff --git a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 3b9863243bae..8e56896103d3 100644 --- a/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/plugins/kotlin/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -114,7 +114,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing node.text.subSequence(0, elementStart.startOffset - node.startOffset).trimStart() ) ) - createSpacing(0, minLineFeeds = 2) + createSpacing(0, minLineFeeds = 1 + kotlinCustomSettings.BLANK_LINES_BEFORE_DECLARATION_WITH_COMMENT_OR_ANNOTATION_ON_SEPARATE_LINE) else null }) @@ -131,7 +131,6 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing // Case left for alternative constructors inPosition(left = FUN, right = CLASS).emptyLinesIfLineBreakInLeft(1) - inPosition(left = ENUM_ENTRY, right = ENUM_ENTRY).emptyLinesIfLineBreakInLeft( emptyLines = 0, numberOfLineFeedsOtherwise = 0, numSpacesOtherwise = 1 ) @@ -139,7 +138,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing inPosition(parent = CLASS_BODY, left = SEMICOLON).customRule { parent, _, right -> val klass = parent.requireNode().treeParent.psi as? KtClass ?: return@customRule null if (klass.isEnum() && right.requireNode().elementType in DECLARATIONS) { - createSpacing(0, minLineFeeds = 2, keepBlankLines = settings.KEEP_BLANK_LINES_IN_DECLARATIONS) + createSpacing(0, minLineFeeds = 2, keepBlankLines = kotlinCommonSettings.KEEP_BLANK_LINES_IN_DECLARATIONS) } else null } diff --git a/plugins/kotlin/idea/resources-en/messages/KotlinBundle.properties b/plugins/kotlin/idea/resources-en/messages/KotlinBundle.properties index 11d6bf8474ca..468d0c2aa33a 100644 --- a/plugins/kotlin/idea/resources-en/messages/KotlinBundle.properties +++ b/plugins/kotlin/idea/resources-en/messages/KotlinBundle.properties @@ -519,6 +519,7 @@ formatter.title.align.when.branches.in.columns=Align 'when' branches in columns formatter.title.around.arrow.in.function.types=Around arrow in function types formatter.title.around.arrow.in=Around arrow in "when" clause formatter.title.around.when.branches.with=Around 'when' branches with {} +formatter.title.before.declaration.with.comment.or.annotation=Before declaration with comment or annotation formatter.title.before.colon.after.declaration.name=Before colon, after declaration name formatter.title.before.colon.in.new.type.definition=Before colon in new type definition formatter.title.before.lambda.arrow=Before lambda arrow @@ -2211,4 +2212,4 @@ inspection.logger.initialized.with.foreign.class.display.name=Logger initialized logger.initialized.with.foreign.class=Logger initialized with foreign class ''{0}'' logger.factory.method.name=Logger factory method name logger.factory.class.name=Logger factory class name -choose.logger.factory.class=Choose logger factory class \ No newline at end of file +choose.logger.factory.class=Choose logger factory class diff --git a/plugins/kotlin/idea/resources-en/search/searchableOptions.xml b/plugins/kotlin/idea/resources-en/search/searchableOptions.xml index d1e03083c41a..663837242d9b 100644 --- a/plugins/kotlin/idea/resources-en/search/searchableOptions.xml +++ b/plugins/kotlin/idea/resources-en/search/searchableOptions.xml @@ -598,6 +598,12 @@