Fix comment/eof space handling (fixes #22)
parent
505ad99f35
commit
cbeab39b2d
|
@ -202,13 +202,17 @@ ppModule lmod@(L loc m@(HsModule _name _exports _imports decls _ _)) = do
|
||||||
ppmMoveToExactLoc l
|
ppmMoveToExactLoc l
|
||||||
mTell $ Text.Builder.fromString cmStr
|
mTell $ Text.Builder.fromString cmStr
|
||||||
(ExactPrint.Types.G AnnEofPos, (ExactPrint.Types.DP (eofX, eofY))) ->
|
(ExactPrint.Types.G AnnEofPos, (ExactPrint.Types.DP (eofX, eofY))) ->
|
||||||
let folder acc (kw, ExactPrint.Types.DP (x, _)) = case kw of
|
let
|
||||||
ExactPrint.Types.AnnComment cm
|
folder (acc, _) (kw, ExactPrint.Types.DP (x, y)) = case kw of
|
||||||
| GHC.RealSrcSpan span <- ExactPrint.Types.commentIdentifier cm
|
ExactPrint.Types.AnnComment cm
|
||||||
-> acc + x + GHC.srcSpanEndLine span - GHC.srcSpanStartLine span
|
| GHC.RealSrcSpan span <- ExactPrint.Types.commentIdentifier cm
|
||||||
_ -> acc + x
|
-> ( acc + x + GHC.srcSpanEndLine span - GHC.srcSpanStartLine span
|
||||||
cmX = foldl' folder 0 finalComments
|
, y + GHC.srcSpanEndCol span - GHC.srcSpanStartCol span
|
||||||
in ppmMoveToExactLoc $ ExactPrint.Types.DP (eofX - cmX, eofY)
|
)
|
||||||
|
_ -> (acc + x, y)
|
||||||
|
(cmX, cmY) = foldl' folder (0, 0) finalComments
|
||||||
|
in
|
||||||
|
ppmMoveToExactLoc $ ExactPrint.Types.DP (eofX - cmX, eofY - cmY)
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
withTransformedAnns :: SYB.Data ast => ast -> PPM () -> PPM ()
|
withTransformedAnns :: SYB.Data ast => ast -> PPM () -> PPM ()
|
||||||
|
@ -224,7 +228,7 @@ withTransformedAnns ast m = do
|
||||||
ExactPrint.runTransform anns (commentAnnFixTransformGlob ast)
|
ExactPrint.runTransform anns (commentAnnFixTransformGlob ast)
|
||||||
in annsBalanced
|
in annsBalanced
|
||||||
|
|
||||||
|
|
||||||
ppDecl :: LHsDecl RdrName -> PPM ()
|
ppDecl :: LHsDecl RdrName -> PPM ()
|
||||||
ppDecl d@(L loc decl) = case decl of
|
ppDecl d@(L loc decl) = case decl of
|
||||||
SigD sig -> -- trace (_sigHead sig) $
|
SigD sig -> -- trace (_sigHead sig) $
|
||||||
|
|
Loading…
Reference in New Issue