From 4068b3d9b99ab3109e6bef2f7f2238c148d1a51c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 17 Nov 2017 13:35:26 +0100 Subject: [PATCH] Add continuation indent for wrapped type aliases #KT-21078 Fixed fixup type alias --- .../jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt | 7 ++++++- idea/testData/formatter/TypeAliasSpacing.after.kt | 8 +++++--- idea/testData/formatter/TypeAliasSpacing.kt | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt index cb0a4a048ab..10ded6b351e 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -539,7 +539,12 @@ private val INDENT_RULES = arrayOf( strategy("Array literals") .within(KtNodeTypes.COLLECTION_LITERAL_EXPRESSION) .notForType(LBRACKET, RBRACKET) - .set(Indent.getNormalIndent()) + .set(Indent.getNormalIndent()), + + strategy("Type aliases") + .within(KtNodeTypes.TYPEALIAS) + .notForType(KtTokens.TYPE_ALIAS_KEYWORD, KtTokens.EOL_COMMENT, KtNodeTypes.MODIFIER_LIST) + .set(Indent.getContinuationIndent()) ) diff --git a/idea/testData/formatter/TypeAliasSpacing.after.kt b/idea/testData/formatter/TypeAliasSpacing.after.kt index 783de15b31c..c2307e0ace9 100644 --- a/idea/testData/formatter/TypeAliasSpacing.after.kt +++ b/idea/testData/formatter/TypeAliasSpacing.after.kt @@ -4,11 +4,11 @@ typealias B = Int typealias C = Int typealias D = -Int + Int // typealias E = -Int + Int typealias F = Int // @@ -33,4 +33,6 @@ typealias K = Int // object OO -typealias L = Int \ No newline at end of file +typealias L = Int + +internal typealias M = Int diff --git a/idea/testData/formatter/TypeAliasSpacing.kt b/idea/testData/formatter/TypeAliasSpacing.kt index 8cbf3ece17a..ff073922b78 100644 --- a/idea/testData/formatter/TypeAliasSpacing.kt +++ b/idea/testData/formatter/TypeAliasSpacing.kt @@ -25,4 +25,6 @@ class Y typealias K = Int // object OO -typealias L = Int \ No newline at end of file +typealias L = Int + +internal typealias M = Int