Fix handling of comment before data-decl
`docWrapNodePrior` caused duplication of offset of `data` keyword and of comments connected to it.pull/259/head
parent
ea9d3bb5b3
commit
48490a7110
|
@ -385,6 +385,11 @@ data Foo = forall a b . (Show a, Eq b) => Bar
|
|||
, bars :: b
|
||||
}
|
||||
|
||||
#test plain comment simple
|
||||
-- before
|
||||
data MyData = MyData Int
|
||||
-- after
|
||||
|
||||
#test record comments simple
|
||||
data Foo = Bar -- a
|
||||
{ foo :: Baz -- b
|
||||
|
|
|
@ -46,6 +46,7 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs) defn = case defn of
|
|||
#else
|
||||
layoutDataDecl ltycl name (HsQTvs _ bndrs _) defn = case defn of
|
||||
#endif
|
||||
-- newtype MyType a b = MyType ..
|
||||
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
||||
HsDataDefn _ext NewType (L _ []) _ctype Nothing [cons] mDerivs -> case cons of
|
||||
(L _ (ConDeclH98 _ext consName (L _ False) _qvars (Just (L _ [])) details _conDoc)) ->
|
||||
|
@ -74,6 +75,9 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs _) defn = case defn of
|
|||
]
|
||||
_ -> briDocByExactNoComment ltycl
|
||||
|
||||
|
||||
-- data MyData a b
|
||||
-- (zero constructors)
|
||||
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
||||
HsDataDefn _ext DataType (L _ lhsContext) _ctype Nothing [] mDerivs ->
|
||||
#else
|
||||
|
@ -90,6 +94,8 @@ layoutDataDecl ltycl name (HsQTvs _ bndrs _) defn = case defn of
|
|||
, appSep tyVarLine
|
||||
]
|
||||
|
||||
-- data MyData = MyData ..
|
||||
-- data MyData = MyData { .. }
|
||||
#if MIN_VERSION_ghc(8,6,0) /* ghc-8.6 */
|
||||
HsDataDefn _ext DataType (L _ lhsContext) _ctype Nothing [cons] mDerivs ->
|
||||
#else
|
||||
|
|
|
@ -748,7 +748,6 @@ layoutTyCl ltycl@(L _loc tycl) = case tycl of
|
|||
#else
|
||||
DataDecl name tyVars dataDefn _ _ ->
|
||||
#endif
|
||||
docWrapNodePrior ltycl $
|
||||
layoutDataDecl ltycl name tyVars dataDefn
|
||||
_ -> briDocByExactNoComment ltycl
|
||||
|
||||
|
|
Loading…
Reference in New Issue