on master help sign in
Group deprecation declarations with data types as well
commit825171a16d755707129c6023ec5fa5912c53c8ff authormrkkrp <mark.karpov@tweag.io> dateSun 11 Aug 2019, 21:34 (7 years ago) parent0233f6d
3 files changed+13−1
data/examples/declaration/warning/warning-single-line-out.hs+3 data/examples/declaration/warning/warning-single-line.hs+2 src/Ormolu/Printer/Meat/Declaration.hs+8−1
data/examples/declaration/warning/warning-single-line-out.hs+3
@@ -9,3 +9,6 @@ bar = 3
99
1010{-# DEPRECATED baz "Baz is also deprecated" #-}
1111baz = 5
12+
13+data Number = Number Dobule
14+{-# DEPRECATED Number "Use Scientific instead." #-}
data/examples/declaration/warning/warning-single-line.hs+2
@@ -11,3 +11,5 @@ bar = 3
1111{-# DEPRECATED baz "Baz is also deprecated" #-}
1212baz = 5
1313
14+data Number = Number Dobule
15+{-# DEPRECATED Number "Use Scientific instead." #-}
src/Ormolu/Printer/Meat/Declaration.hs+8−1
@@ -12,6 +12,7 @@ where
1212
1313import Control.Monad (forM_)
1414import GHC
15+import OccName (occNameFS)
1516import Ormolu.Printer.Combinators
1617import Ormolu.Printer.Meat.Common
1718import Ormolu.Printer.Meat.Declaration.Annotation
@@ -30,6 +31,7 @@ import Ormolu.Printer.Meat.Declaration.Value
3031import Ormolu.Printer.Meat.Declaration.Warning
3132import Ormolu.Printer.Meat.Type
3233import Ormolu.Utils
34+import RdrName (rdrNameOcc)
3335
3436p_hsDecls :: FamilyStyle -> [LHsDecl GhcPs] -> R ()
3537p_hsDecls style decls =
@@ -105,6 +107,9 @@ separatedDecls
105107separatedDecls (TypeSignature n) (FunctionBody n') = n /= n'
106108separatedDecls x (FunctionBody n) | Just n' <- isPragma x = n /= n'
107109separatedDecls (FunctionBody n) x | Just n' <- isPragma x = n /= n'
110+separatedDecls x (DataDeclaration n) | Just n' <- isPragma x = n /= n'
111+separatedDecls (DataDeclaration n) x | Just n' <- isPragma x =
112+ let f = occNameFS . rdrNameOcc in f n /= f n'
108113separatedDecls x y | Just n <- isPragma x, Just n' <- isPragma y = n /= n'
109114separatedDecls x (TypeSignature n') | Just n <- isPragma x = n /= n'
110115separatedDecls (PatternSignature n) (Pattern n') = n /= n'
@@ -131,7 +136,8 @@ pattern TypeSignature
131136 , AnnValuePragma
132137 , PatternSignature
133138 , Pattern
134− , WarningPragma :: RdrName -> HsDecl GhcPs
139+ , WarningPragma
140+ , DataDeclaration :: RdrName -> HsDecl GhcPs
135141pattern TypeSignature n <- (sigRdrName -> Just n)
136142pattern FunctionBody n <- ValD NoExt (FunBind NoExt (L _ n) _ _ _)
137143pattern InlinePragma n <- SigD NoExt (InlineSig NoExt (L _ n) _)
@@ -142,6 +148,7 @@ pattern AnnValuePragma n <- AnnD NoExt (HsAnnotation NoExt _ (ValueAnnProvenance
142148pattern PatternSignature n <- SigD NoExt (PatSynSig NoExt ((L _ n):_) _)
143149pattern Pattern n <- ValD NoExt (PatSynBind NoExt (PSB _ (L _ n) _ _ _))
144150pattern WarningPragma n <- WarningD NoExt (Warnings NoExt _ [(L _ (Warning NoExt [(L _ n)] _))])
151+pattern DataDeclaration n <- TyClD NoExt (DataDecl NoExt (L _ n) _ _ _)
145152
146153sigRdrName :: HsDecl GhcPs -> Maybe RdrName
147154sigRdrName (SigD NoExt (TypeSig NoExt ((L _ n):_) _)) = Just n