@@ -10,7 +10,6 @@ module Ormolu.Printer.Meat.Declaration.Value
13−import Ormolu.Printer.Internal
14import Bag (bagToList)
13import Bag (bagToList)
15import BasicTypes
14import BasicTypes
16import Control.Monad
15import Control.Monad
@@ -847,7 +846,12 @@ p_hsSpliceTH isTyped expr = \case
848p_hsBracket :: HsBracket GhcPs -> R ()
847p_hsBracket :: HsBracket GhcPs -> R ()
849p_hsBracket = \case
848p_hsBracket = \case
849+ ExpBr NoExt expr -> do
850+ anns <- getEnclosingAnns
851+ let name = case anns of
850− ExpBr NoExt expr -> quote "e" (located expr p_hsExpr)
854+ quote name (located expr p_hsExpr)
851 PatBr NoExt pat -> quote "p" (located pat p_pat)
855 PatBr NoExt pat -> quote "p" (located pat p_pat)
852 DecBrL NoExt decls -> quote "d" (p_hsDecls Free decls)
856 DecBrL NoExt decls -> quote "d" (p_hsDecls Free decls)
853 DecBrG NoExt _ -> notImplemented "DecBrG" -- result of renamer
857 DecBrG NoExt _ -> notImplemented "DecBrG" -- result of renamer
@@ -967,3 +971,12 @@ withGuards = any (checkOne . unLoc)
967 checkOne :: GRHS GhcPs (Located body) -> Bool
971 checkOne :: GRHS GhcPs (Located body) -> Bool
968 checkOne (GRHS NoExt [] _) = False
972 checkOne (GRHS NoExt [] _) = False
969 checkOne _ = True
973 checkOne _ = True
975+-- | Get annotations for the enclosing element.
977+getEnclosingAnns :: R [AnnKeywordId]
978+getEnclosingAnns = do
979+ e <- getEnclosingSpan (const True)
981+ Nothing -> return []
982+ Just e' -> getAnns (RealSrcSpan e')