mirror of
https://github.com/ilyakooo0/ormolu.git
synced 2024-10-27 03:28:33 +03:00
Tweak formatting of warning pragmas
This commit is contained in:
parent
93271b2551
commit
c2b32da3b5
@ -3,3 +3,9 @@
|
||||
{-# WARNING test "This is a warning" #-}
|
||||
test :: IO ()
|
||||
test = pure ()
|
||||
|
||||
bar = 3
|
||||
{-# DEPRECATED bar "Bar is deprecated" #-}
|
||||
|
||||
{-# DEPRECATED baz "Baz is also deprecated" #-}
|
||||
baz = 5
|
||||
|
@ -3,3 +3,11 @@
|
||||
{-# WARNING test ["This is a warning" ] #-}
|
||||
test :: IO ()
|
||||
test = pure ()
|
||||
|
||||
bar = 3
|
||||
|
||||
{-# Deprecated bar "Bar is deprecated" #-}
|
||||
|
||||
{-# DEPRECATED baz "Baz is also deprecated" #-}
|
||||
baz = 5
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
module Test {-# DEPRECATED "This module is unstable" #-}
|
||||
module Test
|
||||
{-# DEPRECATED "This module is unstable" #-}
|
||||
( foo,
|
||||
bar,
|
||||
baz
|
||||
|
@ -1 +1,3 @@
|
||||
module Test {-# WARNING "This module is very internal" #-} where
|
||||
module Test
|
||||
{-# WARNING "This module is very internal" #-}
|
||||
where
|
||||
|
@ -103,6 +103,7 @@ separatedDecls
|
||||
-> HsDecl GhcPs
|
||||
-> Bool
|
||||
separatedDecls (TypeSignature n) (FunctionBody n') = n /= n'
|
||||
separatedDecls x (FunctionBody n) | Just n' <- isPragma x = n /= n'
|
||||
separatedDecls (FunctionBody n) x | Just n' <- isPragma x = n /= n'
|
||||
separatedDecls x y | Just n <- isPragma x, Just n' <- isPragma y = n /= n'
|
||||
separatedDecls x (TypeSignature n') | Just n <- isPragma x = n /= n'
|
||||
|
@ -29,7 +29,6 @@ p_moduleWarning :: WarningTxt -> R ()
|
||||
p_moduleWarning wtxt = do
|
||||
let (pragmaText, lits) = warningText wtxt
|
||||
switchLayout (getLoc <$> lits) $ do
|
||||
breakpoint
|
||||
inci $ pragma pragmaText (inci $ p_lits lits)
|
||||
|
||||
p_topLevelWarning :: [Located RdrName] -> WarningTxt -> R ()
|
||||
|
@ -27,9 +27,9 @@ p_hsModule exts (L moduleSpan HsModule {..}) = do
|
||||
-- NOTE If span of exports in multiline, the whole thing is multiline.
|
||||
-- This is especially important because span of module itself always seems
|
||||
-- to have length zero, so it's not reliable for layout selection.
|
||||
let spans' = case hsmodExports of
|
||||
Nothing -> [moduleSpan]
|
||||
Just (L exportsSpan _) -> moduleSpan : [exportsSpan]
|
||||
let exportSpans = maybe [] (\(L s _) -> [s]) hsmodExports
|
||||
deprecSpan = maybe [] (\(L s _) -> [s]) hsmodDeprecMessage
|
||||
spans' = exportSpans ++ deprecSpan ++ [moduleSpan]
|
||||
switchLayout spans' $ do
|
||||
let hasLangPragmas = not (null exts)
|
||||
hasModuleHeader = isJust hsmodName
|
||||
@ -43,7 +43,9 @@ p_hsModule exts (L moduleSpan HsModule {..}) = do
|
||||
Nothing -> pure ()
|
||||
Just hsmodName' -> line $ do
|
||||
located hsmodName' p_hsmodName
|
||||
forM_ hsmodDeprecMessage (located' p_moduleWarning)
|
||||
forM_ hsmodDeprecMessage $ \w -> do
|
||||
breakpoint
|
||||
located' p_moduleWarning w
|
||||
case hsmodExports of
|
||||
Nothing -> return ()
|
||||
Just hsmodExports' -> do
|
||||
|
Loading…
Reference in New Issue
Block a user