Skip to content

Commit

Permalink
Prettier kotlin deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebshr committed Nov 20, 2024
1 parent fa9d21b commit 36b626c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .golden/kotlinDeprecatedFieldSpec/golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data class Data(
val field0: Int,
// Deprecated since build 500
// val field1: Int? = null,
// Deprecated since build 500
// val field1: Int? = null,
)
11 changes: 6 additions & 5 deletions src/Moat/Pretty/Kotlin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ prettyStructFields indents fields deprecatedFields = go fields
where
deprecatedFieldsMap = Map.fromList deprecatedFields
prettyField (Field fieldName ty _) =
indents
++ "val "
"val "
++ fieldName
++ ": "
++ prettyMoatType ty
Expand All @@ -84,11 +83,13 @@ prettyStructFields indents fields deprecatedFields = go fields
go (field@(Field fieldName _ _) : fs) =
case Map.lookup fieldName deprecatedFieldsMap of
Just mComment ->
maybe "" (\comment -> "// " ++ comment ++ "\n") mComment
++ "//"
indents
++ maybe "" (\comment -> "// " ++ comment ++ "\n") mComment
++ indents
++ "// "
++ prettyField field
++ go fs
Nothing -> prettyField field ++ go fs
Nothing -> indents ++ prettyField field ++ go fs

prettyEnumCases :: String -> [EnumCase] -> String
prettyEnumCases indents = go
Expand Down

0 comments on commit 36b626c

Please sign in to comment.