diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java b/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java index e7bbbb75452..b73f5ff9249 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java +++ b/idea/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/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 3b9863243ba..8e56896103d 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/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/idea/resources-en/messages/KotlinBundle.properties b/idea/resources-en/messages/KotlinBundle.properties index 11d6bf8474c..b4440042213 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/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 diff --git a/idea/resources-en/search/searchableOptions.xml b/idea/resources-en/search/searchableOptions.xml index d1e03083c41..663837242d9 100644 --- a/idea/resources-en/search/searchableOptions.xml +++ b/idea/resources-en/search/searchableOptions.xml @@ -598,6 +598,12 @@