Respect and Fix disable-next-binding/decl
parent
fe876ea0b0
commit
84e703d7f3
|
@ -22,7 +22,6 @@ import GHC.Parser.Annotation ( EpaCommentTok
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
import qualified UI.Butcher.Monadic as Butcher
|
import qualified UI.Butcher.Monadic as Butcher
|
||||||
-- import qualified Language.Haskell.GHC.ExactPrint.Utils as ExactPrint.Utils
|
|
||||||
import Control.Monad.Trans.Except
|
import Control.Monad.Trans.Except
|
||||||
|
|
||||||
import Language.Haskell.Brittany.Internal.Config.Config
|
import Language.Haskell.Brittany.Internal.Config.Config
|
||||||
|
@ -31,6 +30,8 @@ import Language.Haskell.Brittany.Internal.Util.AST
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types.Instances1 ()
|
import Language.Haskell.Brittany.Internal.Config.Types.Instances1 ()
|
||||||
import Language.Haskell.Brittany.Internal.Config.Types.Instances2 ()
|
import Language.Haskell.Brittany.Internal.Config.Types.Instances2 ()
|
||||||
-- import Language.Haskell.Brittany.Internal.Utils
|
-- import Language.Haskell.Brittany.Internal.Utils
|
||||||
|
-- import qualified Language.Haskell.GHC.ExactPrint.Utils as ExactPrint.Utils
|
||||||
|
-- import Data.Data(toConstr)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ data InlineConfigTarget
|
||||||
| InlineConfigTargetNextDecl -- really only next in module
|
| InlineConfigTargetNextDecl -- really only next in module
|
||||||
| InlineConfigTargetNextBinding -- by name
|
| InlineConfigTargetNextBinding -- by name
|
||||||
| InlineConfigTargetBinding String
|
| InlineConfigTargetBinding String
|
||||||
|
deriving Show
|
||||||
|
|
||||||
extractCommentConfigs
|
extractCommentConfigs
|
||||||
:: (String -> IO ())
|
:: (String -> IO ())
|
||||||
|
@ -116,13 +118,13 @@ extractCommentConfigs _putErrorLn modul = do
|
||||||
]
|
]
|
||||||
let perSpan = Map.fromListWith
|
let perSpan = Map.fromListWith
|
||||||
(<>)
|
(<>)
|
||||||
[ (srcSpan, conf)
|
[ (declSpan, conf)
|
||||||
| (srcSpan, target, conf) <- lineConfigs
|
| (srcSpan, target, conf) <- lineConfigs
|
||||||
, let perBindRes = Map.lookupGT srcSpan declMap
|
, Just (declSpan, names) <- [Map.lookupGT srcSpan declMap]
|
||||||
, case target of
|
, case target of
|
||||||
InlineConfigTargetNextDecl -> True
|
InlineConfigTargetNextDecl -> True
|
||||||
InlineConfigTargetNextBinding | Nothing <- perBindRes -> True
|
InlineConfigTargetNextBinding -> null names
|
||||||
_ -> False
|
_ -> False
|
||||||
]
|
]
|
||||||
|
|
||||||
pure
|
pure
|
||||||
|
|
|
@ -218,7 +218,8 @@ ppToplevelDecl decl immediateAfterComms = do
|
||||||
declConfig & _conf_roundtrip_exactprint_only & confUnpack
|
declConfig & _conf_roundtrip_exactprint_only & confUnpack
|
||||||
bd <- fmap fst $ if exactprintOnly
|
bd <- fmap fst $ if exactprintOnly
|
||||||
then briDocMToPPM layouters
|
then briDocMToPPM layouters
|
||||||
$ docSeq (briDocByExact decl : map commentToDoc immediateAfterComms)
|
$ docSeq
|
||||||
|
(briDocByExactNoComment decl : map commentToDoc immediateAfterComms)
|
||||||
else do
|
else do
|
||||||
let innerDoc = case decl of
|
let innerDoc = case decl of
|
||||||
L (SrcSpanAnn _ (GHC.RealSrcSpan s _)) _ ->
|
L (SrcSpanAnn _ (GHC.RealSrcSpan s _)) _ ->
|
||||||
|
|
Loading…
Reference in New Issue