File tree Expand file tree Collapse file tree
main/java/com/facebook/ktfmt/format
test/java/com/facebook/ktfmt/format Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1515### Added
1616- Support ` ij_kotlin_indent_size ` in editorconfig. (https://github.com/facebook/ktfmt/pull/604 )
1717- Support for lists within quoted blocks in KDoc comments (https://github.com/facebook/ktfmt/commit/68fa1585b759ad4b12ca4802bccd297f6a33b0f3 )
18- - Fix ` ONLY_ADD ` trailing commas strategy causing lines over MAX_WIDTH length (https://github.com/facebook/ktfmt/issues/610 )
18+ - Fix ` ONLY_ADD ` trailing commas strategy causing lines over MAX_WIDTH length (https://github.com/facebook/ktfmt/issues/610 )
19+ - Remove forced breaking of ` context ` function types (https://github.com/facebook/ktfmt/pull/613 )
1920
2021## [ 0.62]
2122### Added
Original file line number Diff line number Diff line change @@ -1820,9 +1820,9 @@ class KotlinInputAstVisitor(
18201820 * Example `context(logger: Logger, raise: Raise<Error>)`
18211821 *
18221822 * Note this also supports the legacy receiver format of `context(Logger, Raise<Error>)` for
1823- * backward compatibility.
1823+ * backward compatibility and for function types
18241824 */
1825- override fun visitContextReceiverList (contextReceiverList : KtContextReceiverList ) {
1825+ private fun handleContextReceiverList (contextReceiverList : KtContextReceiverList ) {
18261826 builder.sync(contextReceiverList)
18271827 builder.token(" context" )
18281828 visitEachCommaSeparated(
@@ -1832,6 +1832,10 @@ class KotlinInputAstVisitor(
18321832 breakAfterPrefix = false ,
18331833 breakBeforePostfix = false ,
18341834 )
1835+ }
1836+
1837+ override fun visitContextReceiverList (contextReceiverList : KtContextReceiverList ) {
1838+ handleContextReceiverList(contextReceiverList)
18351839 builder.forcedBreak()
18361840 }
18371841
@@ -2465,7 +2469,10 @@ class KotlinInputAstVisitor(
24652469 override fun visitFunctionType (type : KtFunctionType ) {
24662470 builder.sync(type)
24672471
2468- type.contextReceiverList?.let { visitContextReceiverList(it) }
2472+ type.contextReceiverList?.let {
2473+ handleContextReceiverList(it)
2474+ builder.space()
2475+ }
24692476
24702477 val receiver = type.receiver
24712478 if (receiver != null ) {
Original file line number Diff line number Diff line change @@ -8571,9 +8571,7 @@ class FormatterTest {
85718571 |
85728572 | fun <T> testSuspend(
85738573 | mock: T,
8574- | block:
8575- | suspend context(SomeContext)
8576- | T.() -> Unit,
8574+ | block: suspend context(SomeContext) T.() -> Unit,
85778575 | ) = startCoroutine { T.block() }
85788576 |}
85798577 |"""
@@ -8629,9 +8627,7 @@ class FormatterTest {
86298627 |
86308628 | fun <T> testSuspend(
86318629 | mock: T,
8632- | block:
8633- | suspend context(someContext: SomeContext)
8634- | T.() -> Unit,
8630+ | block: suspend context(someContext: SomeContext) T.() -> Unit,
86358631 | ) = startCoroutine { T.block() }
86368632 |}
86378633 |"""
You can’t perform that action at this time.
0 commit comments