on master help sign in
Handle comments inside of import statements better
commitc9c38764107dcd3b64661826fb70f4bacb455965 authormrkkrp <mark.karpov@tweag.io> dateThu 12 Sep 2019, 21:49 (7 years ago) parent5c923a2
3 files changed+36−20
data/examples/import/comments-inside-imports-out.hs+6 data/examples/import/comments-inside-imports.hs+9 src/Ormolu/Printer/Meat/ImportExport.hs+21−20
data/examples/import/comments-inside-imports-out.hsnew file+6
@@ -0,0 +1,6 @@
1+-- x
2+import qualified -- x
3+ Bar
4+import qualified -- x
5+ Baz
6+import Foo
data/examples/import/comments-inside-imports.hsnew file+9
@@ -0,0 +1,9 @@
1+import -- x
2+ Foo
3+
4+import -- x
5+ qualified Bar
6+
7+import qualified
8+ -- x
9+ Baz
src/Ormolu/Printer/Meat/ImportExport.hs+21−20
@@ -39,26 +39,27 @@ p_hsmodImport ImportDecl {..} = do
3939 Nothing -> return ()
4040 Just slit -> atom slit
4141 space
42− located ideclName atom
43− case ideclAs of
44− Nothing -> return ()
45− Just l -> do
46− space
47− txt "as"
48− space
49− located l atom
50− space
51− case ideclHiding of
52− Nothing -> return ()
53− Just (hiding, _) ->
54− when hiding (txt "hiding")
55− case ideclHiding of
56− Nothing -> return ()
57− Just (_, (L _ a)) -> do
58− breakpoint
59− inci . parens . sitcc $
60− sep (comma >> breakpoint) (sitcc . located' p_lie) a
61− newline
42+ inci $ do
43+ located ideclName atom
44+ case ideclAs of
45+ Nothing -> return ()
46+ Just l -> do
47+ space
48+ txt "as"
49+ space
50+ located l atom
51+ space
52+ case ideclHiding of
53+ Nothing -> return ()
54+ Just (hiding, _) ->
55+ when hiding (txt "hiding")
56+ case ideclHiding of
57+ Nothing -> return ()
58+ Just (_, (L _ a)) -> do
59+ breakpoint
60+ parens . sitcc $
61+ sep (comma >> breakpoint) (sitcc . located' p_lie) a
62+ newline
6263p_hsmodImport (XImportDecl NoExt) = notImplemented "XImportDecl"
6364
6465p_lie :: IE GhcPs -> R ()