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 1f89181068a..8e80ac294d7 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -217,6 +217,8 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing after(LONG_TEMPLATE_ENTRY_START).spaces(0) before(LONG_TEMPLATE_ENTRY_END).spaces(0) + afterInside(ANNOTATION_ENTRY, ANNOTATED_EXPRESSION).spaces(1) + val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, DESTRUCTURING_DECLARATION_ENTRY, FUNCTION_LITERAL) beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_TYPE_COLON) } afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_TYPE_COLON) } diff --git a/idea/testData/formatter/AnnotationBeforeExpression.after.kt b/idea/testData/formatter/AnnotationBeforeExpression.after.kt new file mode 100644 index 00000000000..43e92df5ee6 --- /dev/null +++ b/idea/testData/formatter/AnnotationBeforeExpression.after.kt @@ -0,0 +1,3 @@ +fun foo() { + @Suppress("all") "" +} \ No newline at end of file diff --git a/idea/testData/formatter/AnnotationBeforeExpression.kt b/idea/testData/formatter/AnnotationBeforeExpression.kt new file mode 100644 index 00000000000..647aa1c58d9 --- /dev/null +++ b/idea/testData/formatter/AnnotationBeforeExpression.kt @@ -0,0 +1,3 @@ +fun foo() { + @Suppress("all") "" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java index ea745c1bbe0..981106d5189 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -43,6 +43,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/formatter"), Pattern.compile("^([^\\.]+)\\.after\\.kt.*$"), true); } + @TestMetadata("AnnotationBeforeExpression.after.kt") + public void testAnnotationBeforeExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/AnnotationBeforeExpression.after.kt"); + doTest(fileName); + } + @TestMetadata("AnonymousInitializers.after.kt") public void testAnonymousInitializers() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/AnonymousInitializers.after.kt");