From 36b626c2118f42a56e4011281996c4d4b8ac19cf Mon Sep 17 00:00:00 2001 From: Kyle Bashour Date: Wed, 20 Nov 2024 15:32:29 -0800 Subject: [PATCH] Prettier kotlin deprecations --- .golden/kotlinDeprecatedFieldSpec/golden | 4 ++-- src/Moat/Pretty/Kotlin.hs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.golden/kotlinDeprecatedFieldSpec/golden b/.golden/kotlinDeprecatedFieldSpec/golden index 01dd78a..a89c950 100644 --- a/.golden/kotlinDeprecatedFieldSpec/golden +++ b/.golden/kotlinDeprecatedFieldSpec/golden @@ -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, ) \ No newline at end of file diff --git a/src/Moat/Pretty/Kotlin.hs b/src/Moat/Pretty/Kotlin.hs index a4fc0e7..9392463 100644 --- a/src/Moat/Pretty/Kotlin.hs +++ b/src/Moat/Pretty/Kotlin.hs @@ -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 @@ -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