diff --git a/ChangeLog.md b/ChangeLog.md index 295403ec58d..86e1c6cda60 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -196,6 +196,7 @@ These artifacts include extensions for the types available in the latter JDKs, s #### Formatter - [`KT-12830`](https://youtrack.jetbrains.com/issue/KT-12830) Remove spaces before *?* in nullable types +- [`KT-13314`](https://youtrack.jetbrains.com/issue/KT-13314) Format spaces around !is and !in #### Intention actions, inspections and quickfixes 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 311597bce6e..4f19a7a7936 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -167,7 +167,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing around(AS_KEYWORD).spaces(1) around(IS_KEYWORD).spaces(1) + around(NOT_IS).spaces(1) around(IN_KEYWORD).spaces(1) + around(NOT_IN).spaces(1) aroundInside(IDENTIFIER, BINARY_EXPRESSION).spaces(1) // before LPAR in constructor(): this() {} diff --git a/idea/testData/formatter/NotIn.after.kt b/idea/testData/formatter/NotIn.after.kt new file mode 100644 index 00000000000..5cd22d0952a --- /dev/null +++ b/idea/testData/formatter/NotIn.after.kt @@ -0,0 +1,5 @@ +fun f() { + if (1 !in intArrayOf()) { + + } +} \ No newline at end of file diff --git a/idea/testData/formatter/NotIn.kt b/idea/testData/formatter/NotIn.kt new file mode 100644 index 00000000000..224c0cd9faa --- /dev/null +++ b/idea/testData/formatter/NotIn.kt @@ -0,0 +1,5 @@ +fun f() { + if (1 !in intArrayOf()) { + + } +} \ No newline at end of file diff --git a/idea/testData/formatter/NotIs.after.kt b/idea/testData/formatter/NotIs.after.kt new file mode 100644 index 00000000000..d0e0c2d3b26 --- /dev/null +++ b/idea/testData/formatter/NotIs.after.kt @@ -0,0 +1,5 @@ +fun f() { + if (1 !is Int) { + + } +} \ No newline at end of file diff --git a/idea/testData/formatter/NotIs.kt b/idea/testData/formatter/NotIs.kt new file mode 100644 index 00000000000..893cef99561 --- /dev/null +++ b/idea/testData/formatter/NotIs.kt @@ -0,0 +1,5 @@ +fun f() { + if (1 !is Int) { + + } +} \ 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 f5cda8f3bf3..4e0d507980b 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -433,6 +433,18 @@ public class FormatterTestGenerated extends AbstractFormatterTest { doTest(fileName); } + @TestMetadata("NotIn.after.kt") + public void testNotIn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/NotIn.after.kt"); + doTest(fileName); + } + + @TestMetadata("NotIs.after.kt") + public void testNotIs() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/NotIs.after.kt"); + doTest(fileName); + } + @TestMetadata("NullableType.after.kt") public void testNullableType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/NullableType.after.kt");