diff --git a/ChangeLog.md b/ChangeLog.md index 99729bddf44..e2d7f88abac 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,12 @@ ## 1.0.4 +### IDE + +###### Issues fixed + +- [`KT-12830`](https://youtrack.jetbrains.com/issue/KT-12830) Remove spaces before *?* in nullable types + ## 1.0.3 ### Compiler 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 bae9f249b9c..311597bce6e 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -223,6 +223,8 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing beforeInside(INITIALIZER_LIST, ENUM_ENTRY).spaces(0) + beforeInside(QUEST, NULLABLE_TYPE).spaces(0) + 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/NullableType.after.kt b/idea/testData/formatter/NullableType.after.kt new file mode 100644 index 00000000000..b6dc86f8720 --- /dev/null +++ b/idea/testData/formatter/NullableType.after.kt @@ -0,0 +1 @@ +fun foo(): String? = "" \ No newline at end of file diff --git a/idea/testData/formatter/NullableType.kt b/idea/testData/formatter/NullableType.kt new file mode 100644 index 00000000000..5f9c4145a06 --- /dev/null +++ b/idea/testData/formatter/NullableType.kt @@ -0,0 +1 @@ +fun foo(): String ? = "" \ 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 6cd4317427c..f5cda8f3bf3 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -433,6 +433,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest { doTest(fileName); } + @TestMetadata("NullableType.after.kt") + public void testNullableType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/NullableType.after.kt"); + doTest(fileName); + } + @TestMetadata("ObjectInBody.after.kt") public void testObjectInBody() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/ObjectInBody.after.kt");