Allow multi line formatting of normal records
Only single line formatting of normal records was being supported. For records with long names we need multi line formatting. This also needs to support both multi and left indentation policies.pull/259/head
parent
a23ef696e8
commit
9494d6203a
|
@ -447,6 +447,24 @@ data Foo = Bar
|
||||||
ABC --g
|
ABC --g
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#test normal records on multi line indent policy left
|
||||||
|
-- brittany {lconfig_indentPolicy: IndentPolicyLeft }
|
||||||
|
data EnterpriseGrantsForCompanyResponse = EnterpriseGrantsForCompanyResponse
|
||||||
|
Types.Company
|
||||||
|
[EnterpriseGrantResponse]
|
||||||
|
|
||||||
|
#test normal records on multi line indent policy free
|
||||||
|
-- brittany {lconfig_indentPolicy: IndentPolicyFree }
|
||||||
|
data EnterpriseGrantsForCompanyResponse = EnterpriseGrantsForCompanyResponse
|
||||||
|
Types.Company
|
||||||
|
[EnterpriseGrantResponse]
|
||||||
|
|
||||||
|
#test normal records on multi line indent policy multiple
|
||||||
|
-- brittany {lconfig_indentPolicy: IndentPolicyMultiple }
|
||||||
|
data EnterpriseGrantsForCompanyResponse = EnterpriseGrantsForCompanyResponse
|
||||||
|
Types.Company
|
||||||
|
[EnterpriseGrantResponse]
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -266,11 +266,29 @@ docDeriving = docLit $ Text.pack "deriving"
|
||||||
createDetailsDoc
|
createDetailsDoc
|
||||||
:: Text -> HsConDeclDetails GhcPs -> (ToBriDocM BriDocNumbered)
|
:: Text -> HsConDeclDetails GhcPs -> (ToBriDocM BriDocNumbered)
|
||||||
createDetailsDoc consNameStr details = case details of
|
createDetailsDoc consNameStr details = case details of
|
||||||
PrefixCon args -> docSeq
|
PrefixCon args -> do
|
||||||
|
indentPolicy <- mAsk <&> _conf_layout .> _lconfig_indentPolicy .> confUnpack
|
||||||
|
let
|
||||||
|
singleLine = docSeq
|
||||||
[ docLit consNameStr
|
[ docLit consNameStr
|
||||||
, docSeparator
|
, docSeparator
|
||||||
, docSeq $ List.intersperse docSeparator $ args <&> layoutType
|
, docSeq $ List.intersperse docSeparator $ args <&> layoutType
|
||||||
]
|
]
|
||||||
|
leftIndented = docSetParSpacing
|
||||||
|
. docAddBaseY BrIndentRegular
|
||||||
|
. docPar (docLit consNameStr)
|
||||||
|
. docLines
|
||||||
|
$ layoutType <$> args
|
||||||
|
multiIndented = docSetParSpacing
|
||||||
|
. docSetBaseAndIndent
|
||||||
|
. docPar (docLit consNameStr)
|
||||||
|
. docLines
|
||||||
|
$ layoutType
|
||||||
|
<$> args
|
||||||
|
case indentPolicy of
|
||||||
|
IndentPolicyLeft -> docAlt [singleLine, leftIndented]
|
||||||
|
IndentPolicyMultiple -> docAlt [singleLine, multiIndented]
|
||||||
|
IndentPolicyFree -> docAlt [singleLine, multiIndented]
|
||||||
RecCon (L _ []) -> docEmpty
|
RecCon (L _ []) -> docEmpty
|
||||||
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
||||||
RecCon lRec@(L _ [lField@(L _ (ConDeclField _ext names t _))]) -> docSeq
|
RecCon lRec@(L _ [lField@(L _ (ConDeclField _ext names t _))]) -> docSeq
|
||||||
|
|
Loading…
Reference in New Issue