Skip to content

Commit

Permalink
Merge pull request #123 from disneystreaming/dfrancoeur/121-missing-c…
Browse files Browse the repository at this point in the history
…omment
  • Loading branch information
kubukoz authored Apr 26, 2023
2 parents 57fb9e7 + 469d074 commit ba2b197
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/formatter/src/writer/ShapeWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ object ShapeWriter {
members
) =>
val content =
if (members.members.isEmpty) "{}"
if (members.members.isEmpty && !Comment.hasComment(members.ws0)) "{}"
else s"{\n${indent(members.write, "\n", 4)}\n}"
s"structure ${identifier.write}${resource.write}${mixins.write}${whitespace.write} $content"

Expand Down
20 changes: 20 additions & 0 deletions modules/formatter/tests/src/FormatterSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,26 @@ final class FormatterSpec extends munit.FunSuite {
formatTest(src, expected)
}

test("#121 - comment in empty structure") {
val src = """|$version: "2"
|
|namespace demo
|
|structure MyOpOutput {
| //hello
|}
|""".stripMargin
val expected = """|$version: "2"
|
|namespace demo
|
|structure MyOpOutput {
| // hello
|}
|""".stripMargin
formatTest(src, expected)
}

test("format test - support inline structure") {
val src = s"""|$$version: "2.0"
|
Expand Down

0 comments on commit ba2b197

Please sign in to comment.