{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ViewPatterns #-}
module Language.Haskell.GHC.ExactPrint.Annotater
(
annotate
, AnnotationF(..)
, Annotated
, Annotate(..)
, withSortKeyContextsHelper
) where
import Language.Haskell.GHC.ExactPrint.AnnotateTypes
import Language.Haskell.GHC.ExactPrint.Types
import Language.Haskell.GHC.ExactPrint.Utils
import qualified Bag as GHC
import qualified BasicTypes as GHC
import qualified BooleanFormula as GHC
import qualified Class as GHC
import qualified CoAxiom as GHC
import qualified FastString as GHC
import qualified ForeignCall as GHC
import qualified GHC as GHC
import qualified Name as GHC
import qualified RdrName as GHC
import qualified Outputable as GHC
import qualified SrcLoc as GHC
import Control.Monad.Identity
import Data.Data
import Data.Maybe
import qualified Data.Set as Set
import Debug.Trace
{-# ANN module "HLint: ignore Eta reduce" #-}
{-# ANN module "HLint: ignore Redundant do" #-}
{-# ANN module "HLint: ignore Reduce duplication" #-}
class Data ast => Annotate ast where
markAST :: GHC.SrcSpan -> ast -> Annotated ()
annotate :: (Annotate ast, Data (GHC.SrcSpanLess ast), GHC.HasSrcSpan ast) => ast -> Annotated ()
annotate :: ast -> Annotated ()
annotate = ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated
instance (Data ast, Annotate ast) => Annotate (GHC.Located ast) where
markAST :: SrcSpan -> Located ast -> Annotated ()
markAST SrcSpan
l (GHC.L SrcSpan
_ ast
ast) = SrcSpan -> ast -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l ast
ast
markLocated :: (Data (GHC.SrcSpanLess ast), Annotate ast, GHC.HasSrcSpan ast)
=> ast -> Annotated ()
markLocated :: ast -> Annotated ()
markLocated ast
ast =
case ast -> Maybe (LHsDecl GhcPs)
forall a b. (Typeable a, Typeable b) => a -> Maybe b
cast ast
ast :: Maybe (GHC.LHsDecl GHC.GhcPs) of
Just LHsDecl GhcPs
d -> LHsDecl GhcPs -> Annotated ()
markLHsDecl LHsDecl GhcPs
d
Maybe (LHsDecl GhcPs)
Nothing -> ast -> (SrcSpan -> ast -> Annotated ()) -> Annotated ()
forall a.
(Data a, Data (SrcSpanLess a), HasSrcSpan a) =>
a -> (SrcSpan -> a -> Annotated ()) -> Annotated ()
withLocated ast
ast SrcSpan -> ast -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST
markListNoPrecedingSpace :: (Data (GHC.SrcSpanLess ast), Annotate ast, GHC.HasSrcSpan ast)
=> Bool -> [ast] -> Annotated ()
markListNoPrecedingSpace :: Bool -> [ast] -> Annotated ()
markListNoPrecedingSpace Bool
intercal [ast]
ls =
case [ast]
ls of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
(ast
l:[ast]
ls') -> do
if Bool
intercal
then do
if [ast] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ast]
ls'
then Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
NoPrecedingSpace ]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ast
l
else Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
NoPrecedingSpace,AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ast
l
[ast] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [ast]
ls'
else do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
NoPrecedingSpace) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ast
l
(ast -> Annotated ()) -> [ast] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [ast]
ls'
markListIntercalate :: (Data (GHC.SrcSpanLess ast), Annotate ast, GHC.HasSrcSpan ast)
=> [ast] -> Annotated ()
markListIntercalate :: [ast] -> Annotated ()
markListIntercalate [ast]
ls = (ast -> Annotated ()) -> [ast] -> Annotated ()
forall t. (t -> Annotated ()) -> [t] -> Annotated ()
markListIntercalateWithFun ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [ast]
ls
markListWithContexts :: Annotate ast
=> Set.Set AstContext -> Set.Set AstContext -> [GHC.Located ast] -> Annotated ()
markListWithContexts :: Set AstContext -> Set AstContext -> [Located ast] -> Annotated ()
markListWithContexts Set AstContext
ctxInitial Set AstContext
ctxRest [Located ast]
ls =
case [Located ast]
ls of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
[Located ast
x] -> Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxInitial Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
(Located ast
x:[Located ast]
xs) -> do
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxInitial Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxRest Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (Located ast -> Annotated ()) -> [Located ast] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located ast]
xs
markListWithContexts' :: Annotate ast
=> ListContexts
-> [GHC.Located ast] -> Annotated ()
markListWithContexts' :: ListContexts -> [Located ast] -> Annotated ()
markListWithContexts' (LC Set AstContext
ctxOnly Set AstContext
ctxInitial Set AstContext
ctxMiddle Set AstContext
ctxLast) [Located ast]
ls =
case [Located ast]
ls of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
[Located ast
x] -> Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxOnly Int
level (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
(Located ast
x:[Located ast]
xs) -> do
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxInitial Int
level (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
[Located ast] -> Annotated ()
go [Located ast]
xs
where
level :: Int
level = Int
2
go :: [Located ast] -> Annotated ()
go [] = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
go [Located ast
x] = Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxLast Int
level (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
go (Located ast
x:[Located ast]
xs) = do
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel Set AstContext
ctxMiddle Int
level (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
x
[Located ast] -> Annotated ()
go [Located ast]
xs
markListWithLayout :: Annotate ast => [GHC.Located ast] -> Annotated ()
markListWithLayout :: [Located ast] -> Annotated ()
markListWithLayout [Located ast]
ls =
Annotated () -> Annotated ()
setLayoutFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [Located ast] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markList [Located ast]
ls
markList :: Annotate ast => [GHC.Located ast] -> Annotated ()
markList :: [Located ast] -> Annotated ()
markList [Located ast]
ls =
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
NoPrecedingSpace)
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ ListContexts -> [Located ast] -> Annotated ()
forall ast.
Annotate ast =>
ListContexts -> [Located ast] -> Annotated ()
markListWithContexts' ListContexts
listContexts' [Located ast]
ls
markLocalBindsWithLayout :: GHC.HsLocalBinds GHC.GhcPs -> Annotated ()
markLocalBindsWithLayout :: HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
binds = HsLocalBinds GhcPs -> Annotated ()
markHsLocalBinds HsLocalBinds GhcPs
binds
markLocatedFromKw :: (Annotate ast) => GHC.AnnKeywordId -> GHC.Located ast -> Annotated ()
markLocatedFromKw :: AnnKeywordId -> Located ast -> Annotated ()
markLocatedFromKw AnnKeywordId
kw (GHC.L SrcSpan
l ast
a) = do
SrcSpan
ss <- SrcSpan -> AnnKeywordId -> FreeT AnnotationF Identity SrcSpan
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> m SrcSpan
getSrcSpanForKw SrcSpan
l AnnKeywordId
kw
AnnKey SrcSpan
ss' AnnConName
_ <- SrcSpan -> AnnKey -> FreeT AnnotationF Identity AnnKey
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKey -> m AnnKey
storeOriginalSrcSpan SrcSpan
l (Located ast -> AnnKey
forall a. Constraints a => a -> AnnKey
mkAnnKey (SrcSpan -> ast -> Located ast
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
ss ast
a))
Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> ast -> Located ast
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
ss' ast
a)
markMaybe :: (Annotate ast) => Maybe (GHC.Located ast) -> Annotated ()
markMaybe :: Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located ast)
Nothing = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markMaybe (Just Located ast
ast) = Located ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ast
ast
prepareListAnnotation :: Annotate a => [GHC.Located a] -> [(GHC.SrcSpan,Annotated ())]
prepareListAnnotation :: [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [Located a]
ls = (Located a -> (SrcSpan, Annotated ()))
-> [Located a] -> [(SrcSpan, Annotated ())]
forall a b. (a -> b) -> [a] -> [b]
map (\Located a
b -> (Located a -> SrcSpan
forall a. HasSrcSpan a => a -> SrcSpan
GHC.getLoc Located a
b,Located a -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located a
b)) [Located a]
ls
instance Annotate (GHC.HsModule GHC.GhcPs) where
markAST :: SrcSpan -> HsModule GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsModule Maybe (Located ModuleName)
mmn Maybe (Located [LIE GhcPs])
mexp [LImportDecl GhcPs]
imps [LHsDecl GhcPs]
decs Maybe (Located WarningTxt)
mdepr Maybe LHsDocString
_haddock) = do
case Maybe (Located ModuleName)
mmn of
Maybe (Located ModuleName)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (GHC.L SrcSpan
ln ModuleName
mn) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnModule
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
ln AnnKeywordId
GHC.AnnVal (ModuleName -> String
GHC.moduleNameString ModuleName
mn)
Maybe (Located WarningTxt)
-> (Located WarningTxt -> Annotated ()) -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ Maybe (Located WarningTxt)
mdepr Located WarningTxt -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated
Maybe (Located [LIE GhcPs])
-> (Located [LIE GhcPs] -> Annotated ()) -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ Maybe (Located [LIE GhcPs])
mexp Located [LIE GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
GHC.AnnSemi
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
TopLevel) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LImportDecl GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LImportDecl GhcPs]
imps
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
TopLevel) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LHsDecl GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LHsDecl GhcPs]
decs
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Annotated ()
forall (m :: * -> *). MonadFree AnnotationF m => m ()
markEOF
instance Annotate GHC.WarningTxt where
markAST :: SrcSpan -> WarningTxt -> Annotated ()
markAST SrcSpan
_ (GHC.WarningTxt (GHC.L SrcSpan
_ SourceText
txt) [Located StringLiteral]
lss) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
txt String
"{-# WARNING"
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
[Located StringLiteral] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located StringLiteral]
lss
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.DeprecatedTxt (GHC.L SrcSpan
_ SourceText
txt) [Located StringLiteral]
lss) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
txt String
"{-# DEPRECATED"
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
[Located StringLiteral] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located StringLiteral]
lss
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
instance Annotate GHC.StringLiteral where
markAST :: SrcSpan -> StringLiteral -> Annotated ()
markAST SrcSpan
l (GHC.StringLiteral SourceText
src FastString
fs) = do
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
l SourceText
src (String -> String
forall a. Show a => a -> String
show (FastString -> String
GHC.unpackFS FastString
fs))
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.SourceText,GHC.FastString) where
markAST :: SrcSpan -> (SourceText, FastString) -> Annotated ()
markAST SrcSpan
l (SourceText
src,FastString
fs) = do
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
l SourceText
src (String -> String
forall a. Show a => a -> String
show (FastString -> String
GHC.unpackFS FastString
fs))
instance Annotate [GHC.LIE GHC.GhcPs] where
markAST :: SrcSpan -> [LIE GhcPs] -> Annotated ()
markAST SrcSpan
_ [LIE GhcPs]
ls = do
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
HasHiding) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnHiding
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
(LIE GhcPs -> Annotated ()) -> Int -> [LIE GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LIE GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LIE GhcPs]
ls
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
instance Annotate (GHC.IE GHC.GhcPs) where
markAST :: SrcSpan -> IE GhcPs -> Annotated ()
markAST SrcSpan
_ IE GhcPs
ie = do
case IE GhcPs
ie of
GHC.IEVar XIEVar GhcPs
_ LIEWrappedName (IdP GhcPs)
ln -> LIEWrappedName RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LIEWrappedName (IdP GhcPs)
LIEWrappedName RdrName
ln
GHC.IEThingAbs XIEThingAbs GhcPs
_ LIEWrappedName (IdP GhcPs)
ln -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LIEWrappedName RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LIEWrappedName (IdP GhcPs)
LIEWrappedName RdrName
ln
GHC.IEThingWith XIEThingWith GhcPs
_ LIEWrappedName (IdP GhcPs)
ln IEWildcard
wc [LIEWrappedName (IdP GhcPs)]
ns [Located (FieldLbl (IdP GhcPs))]
_lfs -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LIEWrappedName RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LIEWrappedName (IdP GhcPs)
LIEWrappedName RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
case IEWildcard
wc of
IEWildcard
GHC.NoIEWildcard ->
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp])
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LIEWrappedName RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LIEWrappedName (IdP GhcPs)]
[LIEWrappedName RdrName]
ns
GHC.IEWildcard Int
n -> do
Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp,AstContext
Intercalate])
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LIEWrappedName RdrName -> Annotated ())
-> [LIEWrappedName RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LIEWrappedName RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (Int -> [LIEWrappedName RdrName] -> [LIEWrappedName RdrName]
forall a. Int -> [a] -> [a]
take Int
n [LIEWrappedName (IdP GhcPs)]
[LIEWrappedName RdrName]
ns)
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
case Int -> [LIEWrappedName RdrName] -> [LIEWrappedName RdrName]
forall a. Int -> [a] -> [a]
drop Int
n [LIEWrappedName (IdP GhcPs)]
[LIEWrappedName RdrName]
ns of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
[LIEWrappedName RdrName]
ns' -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp])
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LIEWrappedName RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LIEWrappedName RdrName]
ns'
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
(GHC.IEThingAll XIEThingAll GhcPs
_ LIEWrappedName (IdP GhcPs)
ln) -> do
Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LIEWrappedName RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LIEWrappedName (IdP GhcPs)
LIEWrappedName RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
(GHC.IEModuleContents XIEModuleContents GhcPs
_ (GHC.L SrcSpan
lm ModuleName
mn)) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnModule
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
lm AnnKeywordId
GHC.AnnVal (ModuleName -> String
GHC.moduleNameString ModuleName
mn)
(GHC.IEGroup {}) -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
(GHC.IEDoc {}) -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
(GHC.IEDocNamed {}) -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
GHC.XIE XXIE GhcPs
x -> String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XIE for :" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXIE GhcPs
x
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate])
(AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma)
(AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnComma)
instance Annotate (GHC.IEWrappedName GHC.RdrName) where
markAST :: SrcSpan -> IEWrappedName RdrName -> Annotated ()
markAST SrcSpan
_ (GHC.IEName Located RdrName
ln) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp])
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.IEPattern Located RdrName
ln) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnPattern
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.IEType Located RdrName
ln) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
isSymRdr :: GHC.RdrName -> Bool
isSymRdr :: RdrName -> Bool
isSymRdr RdrName
n = OccName -> Bool
GHC.isSymOcc (RdrName -> OccName
GHC.rdrNameOcc RdrName
n) Bool -> Bool -> Bool
|| RdrName -> String
rdrName2String RdrName
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"."
instance Annotate GHC.RdrName where
markAST :: SrcSpan -> RdrName -> Annotated ()
markAST SrcSpan
l RdrName
n = do
let
str :: String
str = RdrName -> String
rdrName2String RdrName
n
isSym :: Bool
isSym = RdrName -> Bool
isSymRdr RdrName
n
doNormalRdrName :: Annotated ()
doNormalRdrName = do
let str' :: String
str' = case String
str of
String
"forall" -> if SrcSpan -> Int
spanLength SrcSpan
l Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 then String
"∀" else String
str
String
_ -> String
str
let
markParen :: GHC.AnnKeywordId -> Annotated ()
markParen :: AnnKeywordId -> Annotated ()
markParen AnnKeywordId
pa = do
if Bool
isSym
then Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
PrefixOp,AstContext
PrefixOpDollar])
(AnnKeywordId -> Annotated ()
mark AnnKeywordId
pa)
(AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
pa)
else AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
pa
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnSimpleQuote
AnnKeywordId -> Annotated ()
markParen AnnKeywordId
GHC.AnnOpenP
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
isSym (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InfixOp]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnBackquote Int
0
Int
cnt <- AnnKeywordId -> FreeT AnnotationF Identity Int
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m Int
countAnns AnnKeywordId
GHC.AnnVal
case Int
cnt of
Int
0 -> SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
str'
Int
1 -> AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnVal String
str'
Int
_ -> String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"Printing RdrName, more than 1 AnnVal:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (SrcSpan, RdrName) -> String
forall a. Outputable a => a -> String
showGhc (SrcSpan
l,RdrName
n)
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
isSym (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InfixOp]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnBackquote Int
1
AnnKeywordId -> Annotated ()
markParen AnnKeywordId
GHC.AnnCloseP
case RdrName
n of
GHC.Unqual OccName
_ -> Annotated ()
doNormalRdrName
GHC.Qual ModuleName
_ OccName
_ -> Annotated ()
doNormalRdrName
GHC.Orig Module
_ OccName
_ -> if String
str String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"~"
then Annotated ()
doNormalRdrName
else SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
str
GHC.Exact Name
n' -> do
case String
str of
String
"[]" -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
String
"()" -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
(Char
'(':Char
'#':String
_) -> do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
let cnt :: Int
cnt = String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
filter (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
',') String
str
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
cnt (AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCommaTuple)
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
String
"[::]" -> do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"[:"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
":]"
String
"->" -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
String
"~" -> do
Annotated ()
doNormalRdrName
String
"*" -> do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
str
String
"★" -> do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
str
String
":" -> do
Annotated ()
doNormalRdrName
(Char
'(':Char
',':String
_) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
let cnt :: Int
cnt = String -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (String -> Int) -> String -> Int
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
filter (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
',') String
str
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ Int
cnt (AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCommaTuple)
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
String
_ -> do
let isSym' :: Bool
isSym' = RdrName -> Bool
isSymRdr (Name -> RdrName
GHC.nameRdrName Name
n')
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isSym' (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnVal String
str
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isSym (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma Annotated () -> String -> Annotated ()
forall c. c -> String -> c
`debug` (String
"AnnComma in RdrName")
instance Annotate (GHC.ImportDecl GHC.GhcPs) where
markAST :: SrcSpan -> ImportDecl GhcPs -> Annotated ()
markAST SrcSpan
_ imp :: ImportDecl GhcPs
imp@(GHC.ImportDecl XCImportDecl GhcPs
_ SourceText
msrc Located ModuleName
modname Maybe StringLiteral
mpkg Bool
_src Bool
safeflag ImportDeclQualifiedStyle
qualFlag Bool
_impl Maybe (Located ModuleName)
_as Maybe (Bool, Located [LIE GhcPs])
hiding) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnImport
case SourceText
msrc of
GHC.SourceText String
_txt -> do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
msrc String
"{-# SOURCE"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
SourceText
GHC.NoSourceText -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
safeflag (AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSafe)
case ImportDeclQualifiedStyle
qualFlag of
ImportDeclQualifiedStyle
GHC.QualifiedPre
-> (AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
TopLevel (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnQualified)
ImportDeclQualifiedStyle
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
case Maybe StringLiteral
mpkg of
Just (GHC.StringLiteral (GHC.SourceText String
srcPkg) FastString
_) ->
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnPackageName String
srcPkg
Maybe StringLiteral
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Located ModuleName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ModuleName
modname
case ImportDeclQualifiedStyle
qualFlag of
ImportDeclQualifiedStyle
GHC.QualifiedPost
-> (AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
TopLevel (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnQualified)
ImportDeclQualifiedStyle
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
case ImportDecl GhcPs -> Maybe (Located ModuleName)
forall pass. ImportDecl pass -> Maybe (Located ModuleName)
GHC.ideclAs ImportDecl GhcPs
imp of
Maybe (Located ModuleName)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just Located ModuleName
mn -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnAs
Located ModuleName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located ModuleName
mn
case Maybe (Bool, Located [LIE GhcPs])
hiding of
Maybe (Bool, Located [LIE GhcPs])
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (Bool
isHiding,Located [LIE GhcPs]
lie) -> do
if Bool
isHiding
then Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
HasHiding) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$
Located [LIE GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LIE GhcPs]
lie
else Located [LIE GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LIE GhcPs]
lie
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XImportDecl XXImportDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XImportDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXImportDecl GhcPs
x
instance Annotate GHC.ModuleName where
markAST :: SrcSpan -> ModuleName -> Annotated ()
markAST SrcSpan
l ModuleName
mname =
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (ModuleName -> String
GHC.moduleNameString ModuleName
mname)
markLHsDecl :: GHC.LHsDecl GHC.GhcPs -> Annotated ()
markLHsDecl :: LHsDecl GhcPs -> Annotated ()
markLHsDecl (GHC.L SrcSpan
l HsDecl GhcPs
decl) =
case HsDecl GhcPs
decl of
GHC.TyClD XTyClD GhcPs
_ TyClDecl GhcPs
d -> GenLocated SrcSpan (TyClDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> TyClDecl GhcPs -> GenLocated SrcSpan (TyClDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l TyClDecl GhcPs
d)
GHC.InstD XInstD GhcPs
_ InstDecl GhcPs
d -> GenLocated SrcSpan (InstDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> InstDecl GhcPs -> GenLocated SrcSpan (InstDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l InstDecl GhcPs
d)
GHC.DerivD XDerivD GhcPs
_ DerivDecl GhcPs
d -> GenLocated SrcSpan (DerivDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> DerivDecl GhcPs -> GenLocated SrcSpan (DerivDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l DerivDecl GhcPs
d)
GHC.ValD XValD GhcPs
_ HsBind GhcPs
d -> GenLocated SrcSpan (HsBind GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> HsBind GhcPs -> GenLocated SrcSpan (HsBind GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l HsBind GhcPs
d)
GHC.SigD XSigD GhcPs
_ Sig GhcPs
d -> GenLocated SrcSpan (Sig GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> Sig GhcPs -> GenLocated SrcSpan (Sig GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l Sig GhcPs
d)
GHC.KindSigD XKindSigD GhcPs
_ StandaloneKindSig GhcPs
d -> GenLocated SrcSpan (StandaloneKindSig GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan
-> StandaloneKindSig GhcPs
-> GenLocated SrcSpan (StandaloneKindSig GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l StandaloneKindSig GhcPs
d)
GHC.DefD XDefD GhcPs
_ DefaultDecl GhcPs
d -> GenLocated SrcSpan (DefaultDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan
-> DefaultDecl GhcPs -> GenLocated SrcSpan (DefaultDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l DefaultDecl GhcPs
d)
GHC.ForD XForD GhcPs
_ ForeignDecl GhcPs
d -> GenLocated SrcSpan (ForeignDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan
-> ForeignDecl GhcPs -> GenLocated SrcSpan (ForeignDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l ForeignDecl GhcPs
d)
GHC.WarningD XWarningD GhcPs
_ WarnDecls GhcPs
d -> GenLocated SrcSpan (WarnDecls GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> WarnDecls GhcPs -> GenLocated SrcSpan (WarnDecls GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l WarnDecls GhcPs
d)
GHC.AnnD XAnnD GhcPs
_ AnnDecl GhcPs
d -> GenLocated SrcSpan (AnnDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> AnnDecl GhcPs -> GenLocated SrcSpan (AnnDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l AnnDecl GhcPs
d)
GHC.RuleD XRuleD GhcPs
_ RuleDecls GhcPs
d -> GenLocated SrcSpan (RuleDecls GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> RuleDecls GhcPs -> GenLocated SrcSpan (RuleDecls GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l RuleDecls GhcPs
d)
GHC.SpliceD XSpliceD GhcPs
_ SpliceDecl GhcPs
d -> GenLocated SrcSpan (SpliceDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan
-> SpliceDecl GhcPs -> GenLocated SrcSpan (SpliceDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l SpliceDecl GhcPs
d)
GHC.DocD XDocD GhcPs
_ DocDecl
d -> GenLocated SrcSpan DocDecl -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> DocDecl -> GenLocated SrcSpan DocDecl
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l DocDecl
d)
GHC.RoleAnnotD XRoleAnnotD GhcPs
_ RoleAnnotDecl GhcPs
d -> GenLocated SrcSpan (RoleAnnotDecl GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan
-> RoleAnnotDecl GhcPs -> GenLocated SrcSpan (RoleAnnotDecl GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l RoleAnnotDecl GhcPs
d)
GHC.XHsDecl XXHsDecl GhcPs
x -> String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsDecl GhcPs
x
instance Annotate (GHC.HsDecl GHC.GhcPs) where
markAST :: SrcSpan -> HsDecl GhcPs -> Annotated ()
markAST SrcSpan
l HsDecl GhcPs
d = LHsDecl GhcPs -> Annotated ()
markLHsDecl (SrcSpan -> HsDecl GhcPs -> LHsDecl GhcPs
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l HsDecl GhcPs
d)
instance Annotate (GHC.RoleAnnotDecl GHC.GhcPs) where
markAST :: SrcSpan -> RoleAnnotDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.RoleAnnotDecl XCRoleAnnotDecl GhcPs
_ Located (IdP GhcPs)
ln [Located (Maybe Role)]
mr) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRole
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
(Located (Maybe Role) -> Annotated ())
-> [Located (Maybe Role)] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located (Maybe Role) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located (Maybe Role)]
mr
markAST SrcSpan
_ (GHC.XRoleAnnotDecl XXRoleAnnotDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XRoleAnnotDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXRoleAnnotDecl GhcPs
x
instance Annotate (Maybe GHC.Role) where
markAST :: SrcSpan -> Maybe Role -> Annotated ()
markAST SrcSpan
l Maybe Role
Nothing = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"_"
markAST SrcSpan
l (Just Role
r) = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (FastString -> String
GHC.unpackFS (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ Role -> FastString
GHC.fsFromRole Role
r)
instance Annotate (GHC.SpliceDecl GHC.GhcPs) where
markAST :: SrcSpan -> SpliceDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.SpliceDecl XSpliceDecl GhcPs
_ e :: Located (HsSplice GhcPs)
e@(GHC.L SrcSpan
_ (GHC.HsQuasiQuote{})) SpliceExplicitFlag
_flag) = do
Located (HsSplice GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsSplice GhcPs)
e
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.SpliceDecl XSpliceDecl GhcPs
_ Located (HsSplice GhcPs)
e SpliceExplicitFlag
_flag) = do
Located (HsSplice GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsSplice GhcPs)
e
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XSpliceDecl XXSpliceDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XSpliceDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXSpliceDecl GhcPs
x
instance Annotate (GHC.RuleDecls GHC.GhcPs) where
markAST :: SrcSpan -> RuleDecls GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsRules XCRuleDecls GhcPs
_ SourceText
src [LRuleDecl GhcPs]
rules) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# RULES"
Annotated () -> Annotated ()
setLayoutFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LRuleDecl GhcPs -> Annotated ())
-> Int -> [LRuleDecl GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LRuleDecl GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LRuleDecl GhcPs]
rules
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XRuleDecls XXRuleDecls GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XRuleDecls for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXRuleDecls GhcPs
x
instance Annotate (GHC.RuleDecl GHC.GhcPs) where
markAST :: SrcSpan -> RuleDecl GhcPs -> Annotated ()
markAST SrcSpan
l (GHC.HsRule XHsRule GhcPs
_ Located (SourceText, FastString)
ln Activation
act Maybe [LHsTyVarBndr (NoGhcTc GhcPs)]
mtybndrs [LRuleBndr GhcPs]
termbndrs Located (HsExpr GhcPs)
lhs Located (HsExpr GhcPs)
rhs) = do
Located (SourceText, FastString) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (SourceText, FastString)
ln
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
ExplicitNeverActive) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ SrcSpan -> Activation -> Annotated ()
markActivation SrcSpan
l Activation
act
case Maybe [LHsTyVarBndr (NoGhcTc GhcPs)]
mtybndrs of
Maybe [LHsTyVarBndr (NoGhcTc GhcPs)]
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just [LHsTyVarBndr (NoGhcTc GhcPs)]
bndrs -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LHsTyVarBndr GhcPs -> Annotated ())
-> [LHsTyVarBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsTyVarBndr GhcPs]
[LHsTyVarBndr (NoGhcTc GhcPs)]
bndrs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LRuleBndr GhcPs -> Annotated ())
-> [LRuleBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LRuleBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LRuleBndr GhcPs]
termbndrs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
lhs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
rhs
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSemi
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XRuleDecl XXRuleDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XRuleDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXRuleDecl GhcPs
x
markActivation :: GHC.SrcSpan -> GHC.Activation -> Annotated ()
markActivation :: SrcSpan -> Activation -> Annotated ()
markActivation SrcSpan
_ Activation
act = do
case Activation
act of
GHC.ActiveBefore SourceText
src Int
phase -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnTilde
SourceText -> String -> Annotated ()
markSourceText SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
phase)
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
GHC.ActiveAfter SourceText
src Int
phase -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
SourceText -> String -> Annotated ()
markSourceText SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
phase)
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
Activation
GHC.NeverActive -> do
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
ExplicitNeverActive) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnTilde
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
Activation
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
instance Annotate (GHC.RuleBndr GHC.GhcPs) where
markAST :: SrcSpan -> RuleBndr GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.RuleBndr XCRuleBndr GhcPs
_ Located (IdP GhcPs)
ln) = Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
markAST SrcSpan
_ (GHC.RuleBndrSig XRuleBndrSig GhcPs
_ Located (IdP GhcPs)
ln LHsSigWcType GhcPs
st) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsSigWcType GhcPs -> Annotated ()
markLHsSigWcType LHsSigWcType GhcPs
st
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markAST SrcSpan
_ (GHC.XRuleBndr XXRuleBndr GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XRuleBndr for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXRuleBndr GhcPs
x
markLHsSigWcType :: GHC.LHsSigWcType GHC.GhcPs -> Annotated ()
markLHsSigWcType :: LHsSigWcType GhcPs -> Annotated ()
markLHsSigWcType (GHC.HsWC XHsWC GhcPs (LHsSigType GhcPs)
_ (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
ty)) = do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
ty
markLHsSigWcType (GHC.HsWC XHsWC GhcPs (LHsSigType GhcPs)
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_)) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markLHsSigWcType extension hit"
markLHsSigWcType (GHC.XHsWildCardBndrs XXHsWildCardBndrs GhcPs (LHsSigType GhcPs)
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markLHsSigWcType extension hit"
instance Annotate (GHC.AnnDecl GHC.GhcPs) where
markAST :: SrcSpan -> AnnDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsAnnotation XHsAnnotation GhcPs
_ SourceText
src AnnProvenance (IdP GhcPs)
prov Located (HsExpr GhcPs)
e) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# ANN"
case AnnProvenance (IdP GhcPs)
prov of
(GHC.ValueAnnProvenance Located (IdP GhcPs)
n) -> Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n
(GHC.TypeAnnProvenance Located (IdP GhcPs)
n) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n
AnnProvenance (IdP GhcPs)
GHC.ModuleAnnProvenance -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnModule
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XAnnDecl XXAnnDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XAnnDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXAnnDecl GhcPs
x
instance Annotate (GHC.WarnDecls GHC.GhcPs) where
markAST :: SrcSpan -> WarnDecls GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.Warnings XWarnings GhcPs
_ SourceText
src [LWarnDecl GhcPs]
warns) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# WARNING"
(LWarnDecl GhcPs -> Annotated ())
-> [LWarnDecl GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LWarnDecl GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LWarnDecl GhcPs]
warns
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.XWarnDecls XXWarnDecls GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XWarnDecls for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXWarnDecls GhcPs
x
instance Annotate (GHC.WarnDecl GHC.GhcPs) where
markAST :: SrcSpan -> WarnDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.Warning XWarning GhcPs
_ [Located (IdP GhcPs)]
lns WarningTxt
txt) = do
[Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
lns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
case WarningTxt
txt of
GHC.WarningTxt GenLocated SrcSpan SourceText
_src [Located StringLiteral]
ls -> [Located StringLiteral] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located StringLiteral]
ls
GHC.DeprecatedTxt GenLocated SrcSpan SourceText
_src [Located StringLiteral]
ls -> [Located StringLiteral] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located StringLiteral]
ls
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markAST SrcSpan
_ (GHC.XWarnDecl XXWarnDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XWarnDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXWarnDecl GhcPs
x
instance Annotate GHC.FastString where
markAST :: SrcSpan -> FastString -> Annotated ()
markAST SrcSpan
l FastString
fs = do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (String -> String
forall a. Show a => a -> String
show (FastString -> String
GHC.unpackFS FastString
fs))
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.ForeignDecl GHC.GhcPs) where
markAST :: SrcSpan -> ForeignDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.ForeignImport XForeignImport GhcPs
_ Located (IdP GhcPs)
ln (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ)
(GHC.CImport Located CCallConv
cconv safety :: Located Safety
safety@(GHC.L SrcSpan
ll Safety
_) Maybe Header
_mh CImportSpec
_imp (GHC.L SrcSpan
ls SourceText
src))) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForeign
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnImport
Located CCallConv -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located CCallConv
cconv
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (SrcSpan
ll SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
GHC.noSrcSpan) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located Safety -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located Safety
safety
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
ls SourceText
src String
""
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
Annotated ()
markTrailingSemi
markAST SrcSpan
_l (GHC.ForeignExport XForeignExport GhcPs
_ Located (IdP GhcPs)
ln (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ) (GHC.CExport Located CExportSpec
spec (GHC.L SrcSpan
ls SourceText
src))) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForeign
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnExport
Located CExportSpec -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located CExportSpec
spec
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
ls AnnKeywordId
GHC.AnnVal (SourceText -> String -> String
sourceTextToString SourceText
src String
"")
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
markAST SrcSpan
_ (GHC.ForeignImport XForeignImport GhcPs
_ Located (IdP GhcPs)
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_) ForeignImport
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST ForeignDecl hit extenstion"
markAST SrcSpan
_ (GHC.ForeignExport XForeignExport GhcPs
_ Located (IdP GhcPs)
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_) ForeignExport
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST ForeignDecl hit extenstion"
markAST SrcSpan
_ (GHC.XForeignDecl XXForeignDecl GhcPs
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST ForeignDecl hit extenstion"
instance (Annotate GHC.CExportSpec) where
markAST :: SrcSpan -> CExportSpec -> Annotated ()
markAST SrcSpan
l (GHC.CExportStatic SourceText
_src FastString
_ CCallConv
cconv) = SrcSpan -> CCallConv -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l CCallConv
cconv
instance (Annotate GHC.CCallConv) where
markAST :: SrcSpan -> CCallConv -> Annotated ()
markAST SrcSpan
l CCallConv
GHC.StdCallConv = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"stdcall"
markAST SrcSpan
l CCallConv
GHC.CCallConv = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"ccall"
markAST SrcSpan
l CCallConv
GHC.CApiConv = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"capi"
markAST SrcSpan
l CCallConv
GHC.PrimCallConv = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"prim"
markAST SrcSpan
l CCallConv
GHC.JavaScriptCallConv = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"javascript"
instance (Annotate GHC.Safety) where
markAST :: SrcSpan -> Safety -> Annotated ()
markAST SrcSpan
l Safety
GHC.PlayRisky = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"unsafe"
markAST SrcSpan
l Safety
GHC.PlaySafe = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"safe"
markAST SrcSpan
l Safety
GHC.PlayInterruptible = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"interruptible"
instance Annotate (GHC.DerivDecl GHC.GhcPs) where
markAST :: SrcSpan -> DerivDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.DerivDecl XCDerivDecl GhcPs
_ (GHC.HsWC XHsWC GhcPs (LHsSigType GhcPs)
_ (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ)) Maybe (LDerivStrategy GhcPs)
ms Maybe (Located OverlapMode)
mov) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDeriving
Maybe (LDerivStrategy GhcPs) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (LDerivStrategy GhcPs)
ms
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnInstance
Maybe (Located OverlapMode) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located OverlapMode)
mov
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.DerivDecl XCDerivDecl GhcPs
_ (GHC.HsWC XHsWC GhcPs (LHsSigType GhcPs)
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_)) Maybe (LDerivStrategy GhcPs)
_ Maybe (Located OverlapMode)
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST DerivDecl hit extension"
markAST SrcSpan
_ (GHC.DerivDecl XCDerivDecl GhcPs
_ (GHC.XHsWildCardBndrs XXHsWildCardBndrs GhcPs (LHsSigType GhcPs)
_) Maybe (LDerivStrategy GhcPs)
_ Maybe (Located OverlapMode)
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST DerivDecl hit extension"
markAST SrcSpan
_ (GHC.XDerivDecl XXDerivDecl GhcPs
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markAST DerivDecl hit extension"
instance Annotate (GHC.DerivStrategy GHC.GhcPs) where
markAST :: SrcSpan -> DerivStrategy GhcPs -> Annotated ()
markAST SrcSpan
_ DerivStrategy GhcPs
GHC.StockStrategy = AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnStock
markAST SrcSpan
_ DerivStrategy GhcPs
GHC.AnyclassStrategy = AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnAnyclass
markAST SrcSpan
_ DerivStrategy GhcPs
GHC.NewtypeStrategy = AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnNewtype
markAST SrcSpan
_ (GHC.ViaStrategy (GHC.HsIB _ ty)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVia
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
ty
markAST SrcSpan
_ (GHC.ViaStrategy (GHC.XHsImplicitBndrs _))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsImplicitBndrs in AnnDerivStrategy"
instance Annotate (GHC.DefaultDecl GHC.GhcPs) where
markAST :: SrcSpan -> DefaultDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.DefaultDecl XCDefaultDecl GhcPs
_ [LHsType GhcPs]
typs) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDefault
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
[LHsType GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LHsType GhcPs]
typs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XDefaultDecl XXDefaultDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XDefaultDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXDefaultDecl GhcPs
x
instance Annotate (GHC.InstDecl GHC.GhcPs) where
markAST :: SrcSpan -> InstDecl GhcPs -> Annotated ()
markAST SrcSpan
l (GHC.ClsInstD XClsInstD GhcPs
_ ClsInstDecl GhcPs
cid) = SrcSpan -> ClsInstDecl GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l ClsInstDecl GhcPs
cid
markAST SrcSpan
l (GHC.DataFamInstD XDataFamInstD GhcPs
_ DataFamInstDecl GhcPs
dfid) = SrcSpan -> DataFamInstDecl GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l DataFamInstDecl GhcPs
dfid
markAST SrcSpan
l (GHC.TyFamInstD XTyFamInstD GhcPs
_ TyFamInstDecl GhcPs
tfid) = SrcSpan -> TyFamInstDecl GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l TyFamInstDecl GhcPs
tfid
markAST SrcSpan
_ (GHC.XInstDecl XXInstDecl GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XInstDecl for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXInstDecl GhcPs
x
instance Annotate GHC.OverlapMode where
markAST :: SrcSpan -> OverlapMode -> Annotated ()
markAST SrcSpan
_ (GHC.NoOverlap SourceText
src) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# NO_OVERLAP"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.Overlappable SourceText
src) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# OVERLAPPABLE"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.Overlapping SourceText
src) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# OVERLAPPING"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.Overlaps SourceText
src) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# OVERLAPS"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
markAST SrcSpan
_ (GHC.Incoherent SourceText
src) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# INCOHERENT"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
instance Annotate (GHC.ClsInstDecl GHC.GhcPs) where
markAST :: SrcSpan -> ClsInstDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.ClsInstDecl XCClsInstDecl GhcPs
_ (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
poly) LHsBinds GhcPs
binds [GenLocated SrcSpan (Sig GhcPs)]
sigs [LTyFamInstDecl GhcPs]
tyfams [LDataFamInstDecl GhcPs]
datafams Maybe (Located OverlapMode)
mov) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnInstance
Maybe (Located OverlapMode) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located OverlapMode)
mov
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
poly
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
[(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsLayout ([GenLocated SrcSpan (HsBind GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation (LHsBinds GhcPs -> [GenLocated SrcSpan (HsBind GhcPs)]
forall a. Bag a -> [a]
GHC.bagToList LHsBinds GhcPs
binds)
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpan (Sig GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [GenLocated SrcSpan (Sig GhcPs)]
sigs
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [LTyFamInstDecl GhcPs] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [LTyFamInstDecl GhcPs]
tyfams
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [LDataFamInstDecl GhcPs] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [LDataFamInstDecl GhcPs]
datafams
)
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.ClsInstDecl XCClsInstDecl GhcPs
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_) LHsBinds GhcPs
_ [GenLocated SrcSpan (Sig GhcPs)]
_ [LTyFamInstDecl GhcPs]
_ [LDataFamInstDecl GhcPs]
_ Maybe (Located OverlapMode)
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for ClsInstDecl"
markAST SrcSpan
_ (GHC.XClsInstDecl XXClsInstDecl GhcPs
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for ClsInstDecl"
instance Annotate (GHC.TyFamInstDecl GHC.GhcPs) where
markAST :: SrcSpan -> TyFamInstDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.TyFamInstDecl (GHC.HsIB XHsIB GhcPs (FamEqn GhcPs (LHsType GhcPs))
_ FamEqn GhcPs (LHsType GhcPs)
eqn)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnInstance
FamEqn GhcPs (LHsType GhcPs) -> Annotated ()
markFamEqn FamEqn GhcPs (LHsType GhcPs)
eqn
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.TyFamInstDecl (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (FamEqn GhcPs (LHsType GhcPs))
_)) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyFamInstDecl"
markFamEqn :: GHC.FamEqn GhcPs (GHC.LHsType GHC.GhcPs)
-> Annotated ()
markFamEqn :: FamEqn GhcPs (LHsType GhcPs) -> Annotated ()
markFamEqn (GHC.FamEqn XCFamEqn GhcPs (LHsType GhcPs)
_ Located (IdP GhcPs)
ln Maybe [LHsTyVarBndr GhcPs]
bndrs HsTyPats GhcPs
pats LexicalFixity
fixity LHsType GhcPs
rhs) = do
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> HsTyPats GhcPs
-> Annotated ()
forall a.
Annotate a =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> HsTyPats GhcPs -> Annotated ()
markTyClassArgs Maybe [LHsTyVarBndr GhcPs]
bndrs LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln HsTyPats GhcPs
pats
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
rhs
markFamEqn (GHC.XFamEqn XXFamEqn GhcPs (LHsType GhcPs)
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"got XFamEqn"
instance Annotate (GHC.DataFamInstDecl GHC.GhcPs) where
markAST :: SrcSpan -> DataFamInstDecl GhcPs -> Annotated ()
markAST SrcSpan
l (GHC.DataFamInstDecl (GHC.HsIB XHsIB GhcPs (FamEqn GhcPs (HsDataDefn GhcPs))
_ (GHC.FamEqn XCFamEqn GhcPs (HsDataDefn GhcPs)
_ Located (IdP GhcPs)
ln Maybe [LHsTyVarBndr GhcPs]
bndrs HsTyPats GhcPs
pats LexicalFixity
fixity
defn :: HsDataDefn GhcPs
defn@(GHC.HsDataDefn XCHsDataDefn GhcPs
_ NewOrData
nd LHsContext GhcPs
ctx Maybe (Located CType)
typ Maybe (LHsType GhcPs)
_mk [LConDecl GhcPs]
cons HsDeriving GhcPs
mderivs) ))) = do
case HsDataDefn GhcPs -> NewOrData
forall pass. HsDataDefn pass -> NewOrData
GHC.dd_ND HsDataDefn GhcPs
defn of
NewOrData
GHC.NewType -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnNewtype
NewOrData
GHC.DataType -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnData
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnInstance
LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
ctx
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> HsTyPats GhcPs
-> Annotated ()
forall a.
Annotate a =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> HsTyPats GhcPs -> Annotated ()
markTyClassArgs Maybe [LHsTyVarBndr GhcPs]
bndrs LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln HsTyPats GhcPs
pats
case (HsDataDefn GhcPs -> Maybe (LHsType GhcPs)
forall pass. HsDataDefn pass -> Maybe (LHsKind pass)
GHC.dd_kindSig HsDataDefn GhcPs
defn) of
Just LHsType GhcPs
s -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
s
Maybe (LHsType GhcPs)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
if [LConDecl GhcPs] -> Bool
forall name. [LConDecl name] -> Bool
isGadt ([LConDecl GhcPs] -> Bool) -> [LConDecl GhcPs] -> Bool
forall a b. (a -> b) -> a -> b
$ HsDataDefn GhcPs -> [LConDecl GhcPs]
forall pass. HsDataDefn pass -> [LConDecl pass]
GHC.dd_cons HsDataDefn GhcPs
defn
then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
else Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([LConDecl GhcPs] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LConDecl GhcPs]
cons) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
SrcSpan -> HsDataDefn GhcPs -> Annotated ()
markDataDefn SrcSpan
l (XCHsDataDefn GhcPs
-> NewOrData
-> LHsContext GhcPs
-> Maybe (Located CType)
-> Maybe (LHsType GhcPs)
-> [LConDecl GhcPs]
-> HsDeriving GhcPs
-> HsDataDefn GhcPs
forall pass.
XCHsDataDefn pass
-> NewOrData
-> LHsContext pass
-> Maybe (Located CType)
-> Maybe (LHsKind pass)
-> [LConDecl pass]
-> HsDeriving pass
-> HsDataDefn pass
GHC.HsDataDefn NoExtField
XCHsDataDefn GhcPs
GHC.NoExtField NewOrData
nd (SrcSpanLess (LHsContext GhcPs) -> LHsContext GhcPs
forall a. HasSrcSpan a => SrcSpanLess a -> a
GHC.noLoc []) Maybe (Located CType)
typ Maybe (LHsType GhcPs)
_mk [LConDecl GhcPs]
cons HsDeriving GhcPs
mderivs)
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnWhere
Annotated ()
markTrailingSemi
markAST SrcSpan
_
(GHC.DataFamInstDecl
(GHC.HsIB XHsIB GhcPs (FamEqn GhcPs (HsDataDefn GhcPs))
_ (GHC.FamEqn XCFamEqn GhcPs (HsDataDefn GhcPs)
_ Located (IdP GhcPs)
_ Maybe [LHsTyVarBndr GhcPs]
_ HsTyPats GhcPs
_ LexicalFixity
_ (GHC.XHsDataDefn XXHsDataDefn GhcPs
_))))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for DataFamInstDecl"
markAST SrcSpan
_ (GHC.DataFamInstDecl (GHC.HsIB XHsIB GhcPs (FamEqn GhcPs (HsDataDefn GhcPs))
_ (GHC.XFamEqn XXFamEqn GhcPs (HsDataDefn GhcPs)
_)))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for DataFamInstDecl"
markAST SrcSpan
_ (GHC.DataFamInstDecl (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (FamEqn GhcPs (HsDataDefn GhcPs))
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for DataFamInstDecl"
instance Annotate (GHC.HsBind GHC.GhcPs) where
markAST :: SrcSpan -> HsBind GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.FunBind XFunBind GhcPs GhcPs
_ Located (IdP GhcPs)
_ (GHC.MG XMG GhcPs (Located (HsExpr GhcPs))
_ (GHC.L SrcSpan
_ [LMatch GhcPs (Located (HsExpr GhcPs))]
matches) Origin
_) HsWrapper
_ [Tickish Id]
_) = do
let
tlFun :: Annotated ()
tlFun =
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
CtxOnly,AstContext
CtxFirst])
(ListContexts
-> [LMatch GhcPs (Located (HsExpr GhcPs))] -> Annotated ()
forall ast.
Annotate ast =>
ListContexts -> [Located ast] -> Annotated ()
markListWithContexts' ListContexts
listContexts [LMatch GhcPs (Located (HsExpr GhcPs))]
matches)
(Set AstContext
-> Set AstContext
-> [LMatch GhcPs (Located (HsExpr GhcPs))]
-> Annotated ()
forall ast.
Annotate ast =>
Set AstContext -> Set AstContext -> [Located ast] -> Annotated ()
markListWithContexts (ListContexts -> Set AstContext
lcMiddle ListContexts
listContexts) (ListContexts -> Set AstContext
lcLast ListContexts
listContexts) [LMatch GhcPs (Located (HsExpr GhcPs))]
matches)
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
TopLevel)
(Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
TopLevel) Int
2 Annotated ()
tlFun)
Annotated ()
tlFun
markAST SrcSpan
_ (GHC.PatBind XPatBind GhcPs GhcPs
_ LPat GhcPs
lhs (GHC.GRHSs XCGRHSs GhcPs (Located (HsExpr GhcPs))
_ [LGRHS GhcPs (Located (HsExpr GhcPs))]
grhs (GHC.L SrcSpan
_ HsLocalBinds GhcPs
lb)) ([Tickish Id], [[Tickish Id]])
_ticks) = do
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
lhs
case [LGRHS GhcPs (Located (HsExpr GhcPs))]
grhs of
(GHC.L SrcSpan
_ (GHC.GRHS XCGRHS GhcPs (Located (HsExpr GhcPs))
_ [] Located (HsExpr GhcPs)
_):[LGRHS GhcPs (Located (HsExpr GhcPs))]
_) -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
[LGRHS GhcPs (Located (HsExpr GhcPs))]
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
(LGRHS GhcPs (Located (HsExpr GhcPs)) -> Annotated ())
-> Int -> [LGRHS GhcPs (Located (HsExpr GhcPs))] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LGRHS GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LGRHS GhcPs (Located (HsExpr GhcPs))]
grhs
case HsLocalBinds GhcPs
lb of
GHC.EmptyLocalBinds{} -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
HsLocalBinds GhcPs
_ -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
lb
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.VarBind XVarBind GhcPs GhcPs
_ IdP GhcPs
_n Located (HsExpr GhcPs)
rhse Bool
_) =
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
rhse
markAST SrcSpan
_ (GHC.AbsBinds {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: AbsBinds introduced after renaming"
markAST SrcSpan
l (GHC.PatSynBind XPatSynBind GhcPs GhcPs
_ (GHC.PSB XPSB GhcPs GhcPs
_ Located (IdP GhcPs)
ln HsPatSynDetails (Located (IdP GhcPs))
args LPat GhcPs
def HsPatSynDir GhcPs
dir)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnPattern
case HsPatSynDetails (Located (IdP GhcPs))
args of
GHC.InfixCon Located (IdP GhcPs)
la Located (IdP GhcPs)
lb -> do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
la
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
lb
GHC.PrefixCon [Located (IdP GhcPs)]
ns -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
(Located RdrName -> Annotated ())
-> [Located RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located (IdP GhcPs)]
[Located RdrName]
ns
GHC.RecCon [RecordPatSynField (Located (IdP GhcPs))]
fs -> do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
(RecordPatSynField (Located RdrName) -> Annotated ())
-> [RecordPatSynField (Located RdrName)] -> Annotated ()
forall t. (t -> Annotated ()) -> [t] -> Annotated ()
markListIntercalateWithFun (Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (Located RdrName -> Annotated ())
-> (RecordPatSynField (Located RdrName) -> Located RdrName)
-> RecordPatSynField (Located RdrName)
-> Annotated ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RecordPatSynField (Located RdrName) -> Located RdrName
forall a. RecordPatSynField a -> a
GHC.recordPatSynSelectorId) [RecordPatSynField (Located (IdP GhcPs))]
[RecordPatSynField (Located RdrName)]
fs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
case HsPatSynDir GhcPs
dir of
HsPatSynDir GhcPs
GHC.ImplicitBidirectional -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
HsPatSynDir GhcPs
_ -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLarrow
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
def
case HsPatSynDir GhcPs
dir of
HsPatSynDir GhcPs
GHC.Unidirectional -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
HsPatSynDir GhcPs
GHC.ImplicitBidirectional -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
GHC.ExplicitBidirectional MatchGroup GhcPs (Located (HsExpr GhcPs))
mg -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
SrcSpan
-> MatchGroup GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall body.
Annotate body =>
SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
l MatchGroup GhcPs (Located (HsExpr GhcPs))
mg
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.FunBind XFunBind GhcPs GhcPs
_ Located (IdP GhcPs)
_ (GHC.XMatchGroup XXMatchGroup GhcPs (Located (HsExpr GhcPs))
_) HsWrapper
_ [Tickish Id]
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for HsBind"
markAST SrcSpan
_ (GHC.PatBind XPatBind GhcPs GhcPs
_ LPat GhcPs
_ (GHC.XGRHSs XXGRHSs GhcPs (Located (HsExpr GhcPs))
_) ([Tickish Id], [[Tickish Id]])
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for HsBind"
markAST SrcSpan
_ (GHC.PatSynBind XPatSynBind GhcPs GhcPs
_ (GHC.XPatSynBind XXPatSynBind GhcPs GhcPs
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for HsBind"
markAST SrcSpan
_ (GHC.XHsBindsLR XXHsBindsLR GhcPs GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for HsBind"
instance Annotate (GHC.IPBind GHC.GhcPs) where
markAST :: SrcSpan -> IPBind GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.IPBind XCIPBind GhcPs
_ Either (Located HsIPName) (IdP GhcPs)
en Located (HsExpr GhcPs)
e) = do
case Either (Located HsIPName) (IdP GhcPs)
en of
Left Located HsIPName
n -> Located HsIPName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located HsIPName
n
Right IdP GhcPs
_i -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XIPBind XXIPBind GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XIPBind for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXIPBind GhcPs
x
instance Annotate GHC.HsIPName where
markAST :: SrcSpan -> HsIPName -> Annotated ()
markAST SrcSpan
l (GHC.HsIPName FastString
n) = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (String
"?" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FastString -> String
GHC.unpackFS FastString
n)
instance (Annotate body)
=> Annotate (GHC.Match GHC.GhcPs (GHC.Located body)) where
markAST :: SrcSpan -> Match GhcPs (Located body) -> Annotated ()
markAST SrcSpan
_ (GHC.Match XCMatch GhcPs (Located body)
_ HsMatchContext (NameOrRdrName (IdP GhcPs))
mln [LPat GhcPs]
pats (GHC.GRHSs XCGRHSs GhcPs (Located body)
_ [LGRHS GhcPs (Located body)]
grhs (GHC.L SrcSpan
_ HsLocalBinds GhcPs
lb))) = do
let
get_infix :: HsMatchContext id -> LexicalFixity
get_infix (GHC.FunRhs Located id
_ LexicalFixity
f SrcStrictness
_) = LexicalFixity
f
get_infix HsMatchContext id
_ = LexicalFixity
GHC.Prefix
isFunBind :: HsMatchContext id -> Bool
isFunBind GHC.FunRhs{} = Bool
True
isFunBind HsMatchContext id
_ = Bool
False
case (HsMatchContext RdrName -> LexicalFixity
forall id. HsMatchContext id -> LexicalFixity
get_infix HsMatchContext (NameOrRdrName (IdP GhcPs))
HsMatchContext RdrName
mln,[LPat GhcPs]
[Located (Pat GhcPs)]
pats) of
(LexicalFixity
GHC.Infix, Located (Pat GhcPs)
a:Located (Pat GhcPs)
b:[Located (Pat GhcPs)]
xs) -> do
if [Located (Pat GhcPs)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Located (Pat GhcPs)]
xs
then AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenP
else AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (Pat GhcPs)
a
case HsMatchContext (NameOrRdrName (IdP GhcPs))
mln of
GHC.FunRhs Located (NameOrRdrName (IdP GhcPs))
n LexicalFixity
_ SrcStrictness
_ -> Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (NameOrRdrName (IdP GhcPs))
Located RdrName
n
HsMatchContext (NameOrRdrName (IdP GhcPs))
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (Pat GhcPs)
b
if [Located (Pat GhcPs)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Located (Pat GhcPs)]
xs
then AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseP
else AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
(Located (Pat GhcPs) -> Annotated ())
-> [Located (Pat GhcPs)] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located (Pat GhcPs)]
xs
(LexicalFixity, [Located (Pat GhcPs)])
_ -> do
[AnnKeywordId] -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
[AnnKeywordId] -> m ()
annotationsToComments [AnnKeywordId
GHC.AnnOpenP,AnnKeywordId
GHC.AnnCloseP]
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LambdaExpr]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLam
case HsMatchContext (NameOrRdrName (IdP GhcPs))
mln of
GHC.FunRhs Located (NameOrRdrName (IdP GhcPs))
n LexicalFixity
_ SrcStrictness
s -> do
Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
NoPrecedingSpace,AstContext
PrefixOp]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SrcStrictness
s SrcStrictness -> SrcStrictness -> Bool
forall a. Eq a => a -> a -> Bool
== SrcStrictness
GHC.SrcStrict) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBang
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (NameOrRdrName (IdP GhcPs))
Located RdrName
n
(Located (Pat GhcPs) -> Annotated ())
-> [Located (Pat GhcPs)] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LPat GhcPs]
[Located (Pat GhcPs)]
pats
HsMatchContext (NameOrRdrName (IdP GhcPs))
_ -> Bool -> [Located (Pat GhcPs)] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
Bool -> [ast] -> Annotated ()
markListNoPrecedingSpace Bool
False [LPat GhcPs]
[Located (Pat GhcPs)]
pats
case [LGRHS GhcPs (Located body)]
grhs of
(GHC.L SrcSpan
_ (GHC.GRHS XCGRHS GhcPs (Located body)
_ [] Located body
_):[LGRHS GhcPs (Located body)]
_) -> Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (HsMatchContext RdrName -> Bool
forall id. HsMatchContext id -> Bool
isFunBind HsMatchContext (NameOrRdrName (IdP GhcPs))
HsMatchContext RdrName
mln) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
[LGRHS GhcPs (Located body)]
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LambdaExpr]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
(LGRHS GhcPs (Located body) -> Annotated ())
-> [LGRHS GhcPs (Located body)] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LGRHS GhcPs (Located body) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LGRHS GhcPs (Located body)]
grhs
case HsLocalBinds GhcPs
lb of
GHC.EmptyLocalBinds{} -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
HsLocalBinds GhcPs
_ -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
lb
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.Match XCMatch GhcPs (Located body)
_ HsMatchContext (NameOrRdrName (IdP GhcPs))
_ [LPat GhcPs]
_ (GHC.XGRHSs XXGRHSs GhcPs (Located body)
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Match"
markAST SrcSpan
_ (GHC.XMatch XXMatch GhcPs (Located body)
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Match"
instance (Annotate body)
=> Annotate (GHC.GRHS GHC.GhcPs (GHC.Located body)) where
markAST :: SrcSpan -> GRHS GhcPs (Located body) -> Annotated ()
markAST SrcSpan
_ (GHC.GRHS XCGRHS GhcPs (Located body)
_ [GuardLStmt GhcPs]
guards Located body
expr) = do
case [GuardLStmt GhcPs]
guards of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
(GuardLStmt GhcPs
_:[GuardLStmt GhcPs]
_) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LeftMost,AstContext
PrefixOp])
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [GuardLStmt GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [GuardLStmt GhcPs]
guards
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
CaseAlt])
(() -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
(AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual)
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnEqual
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
CaseAlt]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LeftMost,AstContext
PrefixOp]) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located body -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located body
expr
markAST SrcSpan
_ (GHC.XGRHS XXGRHS GhcPs (Located body)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XGRHS for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXGRHS GhcPs (Located body)
x
instance Annotate (GHC.Sig GHC.GhcPs) where
markAST :: SrcSpan -> Sig GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.TypeSig XTypeSig GhcPs
_ [Located (IdP GhcPs)]
lns LHsSigWcType GhcPs
st) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Bool -> [Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
Bool -> [ast] -> Annotated ()
markListNoPrecedingSpace Bool
True [Located (IdP GhcPs)]
[Located RdrName]
lns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsSigWcType GhcPs -> Annotated ()
markLHsSigWcType LHsSigWcType GhcPs
st
Annotated ()
markTrailingSemi
Set AstContext -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> m ()
tellContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
FollowingLine)
markAST SrcSpan
_ (GHC.PatSynSig XPatSynSig GhcPs
_ [Located (IdP GhcPs)]
lns (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnPattern
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
lns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.ClassOpSig XClassOpSig GhcPs
_ Bool
isDefault [Located (IdP GhcPs)]
ns (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ)) = do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isDefault (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDefault
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
ns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.IdSig {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: Introduced after renaming"
markAST SrcSpan
_ (GHC.FixSig XFixSig GhcPs
_ (GHC.FixitySig XFixitySig GhcPs
_ [Located (IdP GhcPs)]
lns (GHC.Fixity SourceText
src Int
v FixityDirection
fdir))) = do
let fixstr :: String
fixstr = case FixityDirection
fdir of
FixityDirection
GHC.InfixL -> String
"infixl"
FixityDirection
GHC.InfixR -> String
"infixr"
FixityDirection
GHC.InfixN -> String
"infix"
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnInfix String
fixstr
SourceText -> String -> Annotated ()
markSourceText SourceText
src (Int -> String
forall a. Show a => a -> String
show Int
v)
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
lns
Annotated ()
markTrailingSemi
markAST SrcSpan
l (GHC.InlineSig XInlineSig GhcPs
_ Located (IdP GhcPs)
ln InlinePragma
inl) = do
SourceText -> String -> Annotated ()
markAnnOpen (InlinePragma -> SourceText
GHC.inl_src InlinePragma
inl) String
"{-# INLINE"
SrcSpan -> Activation -> Annotated ()
markActivation SrcSpan
l (InlinePragma -> Activation
GHC.inl_act InlinePragma
inl)
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
l (GHC.SpecSig XSpecSig GhcPs
_ Located (IdP GhcPs)
ln [LHsSigType GhcPs]
typs InlinePragma
inl) = do
SourceText -> String -> Annotated ()
markAnnOpen (InlinePragma -> SourceText
GHC.inl_src InlinePragma
inl) String
"{-# SPECIALISE"
SrcSpan -> Activation -> Annotated ()
markActivation SrcSpan
l (InlinePragma -> Activation
GHC.inl_act InlinePragma
inl)
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
(LHsSigType GhcPs -> Annotated ())
-> Int -> [LHsSigType GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LHsSigType GhcPs -> Annotated ()
markLHsSigType Int
2 [LHsSigType GhcPs]
typs
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.SpecInstSig XSpecInstSig GhcPs
_ SourceText
src LHsSigType GhcPs
typ) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# SPECIALISE"
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnInstance
LHsSigType GhcPs -> Annotated ()
markLHsSigType LHsSigType GhcPs
typ
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.MinimalSig XMinimalSig GhcPs
_ SourceText
src LBooleanFormula (Located (IdP GhcPs))
formula) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# MINIMAL"
LBooleanFormula (Located RdrName) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LBooleanFormula (Located (IdP GhcPs))
LBooleanFormula (Located RdrName)
formula
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.SCCFunSig XSCCFunSig GhcPs
_ SourceText
src Located (IdP GhcPs)
ln Maybe (Located StringLiteral)
ml) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# SCC"
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
Maybe (Located StringLiteral) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located StringLiteral)
ml
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.CompleteMatchSig XCompleteMatchSig GhcPs
_ SourceText
src (GHC.L SrcSpan
_ [Located (IdP GhcPs)]
ns) Maybe (Located (IdP GhcPs))
mlns) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# COMPLETE"
[Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
ns
case Maybe (Located (IdP GhcPs))
mlns of
Maybe (Located (IdP GhcPs))
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just Located (IdP GhcPs)
_ -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
Maybe (Located RdrName) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located (IdP GhcPs))
Maybe (Located RdrName)
mlns
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.PatSynSig XPatSynSig GhcPs
_ [Located (IdP GhcPs)]
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Sig"
markAST SrcSpan
_ (GHC.ClassOpSig XClassOpSig GhcPs
_ Bool
_ [Located (IdP GhcPs)]
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Sig"
markAST SrcSpan
_ (GHC.FixSig XFixSig GhcPs
_ (GHC.XFixitySig XXFixitySig GhcPs
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Sig"
markAST SrcSpan
_ (GHC.XSig XXSig GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for Sig"
instance Annotate (GHC.StandaloneKindSig GHC.GhcPs) where
markAST :: SrcSpan -> StandaloneKindSig GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.StandaloneKindSig XStandaloneKindSig GhcPs
_ Located (IdP GhcPs)
ln LHsSigType GhcPs
st) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsSigType GhcPs -> Annotated ()
markLHsSigType LHsSigType GhcPs
st
Annotated ()
markTrailingSemi
Set AstContext -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> m ()
tellContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
FollowingLine)
markAST SrcSpan
_ (GHC.XStandaloneKindSig XXStandaloneKindSig GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension for StandaloneKindSig"
markLHsSigType :: GHC.LHsSigType GHC.GhcPs -> Annotated ()
markLHsSigType :: LHsSigType GhcPs -> Annotated ()
markLHsSigType (GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
typ) = LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
markLHsSigType (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (LHsType GhcPs)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsImplicitBndrs for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsImplicitBndrs GhcPs (LHsType GhcPs)
x
instance Annotate [GHC.LHsSigType GHC.GhcPs] where
markAST :: SrcSpan -> [LHsSigType GhcPs] -> Annotated ()
markAST SrcSpan
_ [LHsSigType GhcPs]
ls = do
let marker :: AnnKeywordId -> Annotated ()
marker = case [LHsSigType GhcPs]
ls of
[] -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional
[GHC.HsIB XHsIB GhcPs (LHsType GhcPs)
_ LHsType GhcPs
t] -> if PprPrec -> HsType GhcPs -> Bool
forall pass. PprPrec -> HsType pass -> Bool
GHC.hsTypeNeedsParens PprPrec
GHC.appPrec (LHsType GhcPs -> SrcSpanLess (LHsType GhcPs)
forall a. HasSrcSpan a => a -> SrcSpanLess a
GHC.unLoc LHsType GhcPs
t)
then AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany
else AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional
[LHsSigType GhcPs]
_ -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany
AnnKeywordId -> Annotated ()
marker AnnKeywordId
GHC.AnnOpenP
(LHsSigType GhcPs -> Annotated ())
-> [LHsSigType GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> [t] -> Annotated ()
markListIntercalateWithFun LHsSigType GhcPs -> Annotated ()
markLHsSigType [LHsSigType GhcPs]
ls
AnnKeywordId -> Annotated ()
marker AnnKeywordId
GHC.AnnCloseP
instance (Annotate name) => Annotate (GHC.BooleanFormula (GHC.Located name)) where
markAST :: SrcSpan -> BooleanFormula (Located name) -> Annotated ()
markAST SrcSpan
_ (GHC.Var Located name
x) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located name -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located name
x
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
AddVbar]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.Or [LBooleanFormula (Located name)]
ls) = (LBooleanFormula (Located name) -> Annotated ())
-> Int
-> AstContext
-> [LBooleanFormula (Located name)]
-> Annotated ()
forall t.
(t -> Annotated ()) -> Int -> AstContext -> [t] -> Annotated ()
markListIntercalateWithFunLevelCtx LBooleanFormula (Located name) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 AstContext
AddVbar [LBooleanFormula (Located name)]
ls
markAST SrcSpan
_ (GHC.And [LBooleanFormula (Located name)]
ls) = do
(LBooleanFormula (Located name) -> Annotated ())
-> Int -> [LBooleanFormula (Located name)] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LBooleanFormula (Located name) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LBooleanFormula (Located name)]
ls
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
AddVbar]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.Parens LBooleanFormula (Located name)
x) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
LBooleanFormula (Located name) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LBooleanFormula (Located name)
x
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
AddVbar]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.HsTyVarBndr GHC.GhcPs) where
markAST :: SrcSpan -> HsTyVarBndr GhcPs -> Annotated ()
markAST SrcSpan
_l (GHC.UserTyVar XUserTyVar GhcPs
_ Located (IdP GhcPs)
n) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n
markAST SrcSpan
_ (GHC.KindedTyVar XKindedTyVar GhcPs
_ Located (IdP GhcPs)
n LHsType GhcPs
ty) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
ty
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markAST SrcSpan
_l (GHC.XTyVarBndr XXTyVarBndr GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XTyVarBndr for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXTyVarBndr GhcPs
x
instance Annotate (GHC.HsType GHC.GhcPs) where
markAST :: SrcSpan -> HsType GhcPs -> Annotated ()
markAST SrcSpan
loc HsType GhcPs
ty = do
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InTypeApp]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnAt
SrcSpan -> HsType GhcPs -> Annotated ()
markType SrcSpan
loc HsType GhcPs
ty
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
(Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar)
where
markType :: GHC.SrcSpan -> (GHC.HsType GHC.GhcPs) -> Annotated ()
markType :: SrcSpan -> HsType GhcPs -> Annotated ()
markType SrcSpan
_ (GHC.HsForAllTy XForAllTy GhcPs
_ ForallVisFlag
fvf [LHsTyVarBndr GhcPs]
tvs LHsType GhcPs
typ) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LHsTyVarBndr GhcPs -> Annotated ())
-> [LHsTyVarBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsTyVarBndr GhcPs]
tvs
case ForallVisFlag
fvf of
ForallVisFlag
GHC.ForallInvis -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
ForallVisFlag
GHC.ForallVis -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
markType SrcSpan
_ (GHC.HsQualTy XQualTy GhcPs
_ LHsContext GhcPs
cxt LHsType GhcPs
typ) = do
LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
cxt
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
markType SrcSpan
_ (GHC.HsTyVar XTyVar GhcPs
_ PromotionFlag
promoted Located (IdP GhcPs)
name) = do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (PromotionFlag
promoted PromotionFlag -> PromotionFlag -> Bool
forall a. Eq a => a -> a -> Bool
== PromotionFlag
GHC.IsPromoted) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSimpleQuote
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
InfixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
name
markType SrcSpan
_ (GHC.HsAppTy XAppTy GhcPs
_ LHsType GhcPs
t1 LHsType GhcPs
t2) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t1
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t2
markType SrcSpan
_ (GHC.HsAppKindTy XAppKindTy GhcPs
l LHsType GhcPs
t LHsType GhcPs
k) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
SrcSpan -> Annotated ()
markTypeApp XAppKindTy GhcPs
SrcSpan
l
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
k
markType SrcSpan
_ (GHC.HsFunTy XFunTy GhcPs
_ LHsType GhcPs
t1 LHsType GhcPs
t2) = do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t2
markType SrcSpan
_ (GHC.HsListTy XListTy GhcPs
_ LHsType GhcPs
t) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markType SrcSpan
_ (GHC.HsTupleTy XTupleTy GhcPs
_ HsTupleSort
tt [LHsType GhcPs]
ts) = do
case HsTupleSort
tt of
HsTupleSort
GHC.HsBoxedOrConstraintTuple -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
HsTupleSort
_ -> AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
(LHsType GhcPs -> Annotated ())
-> Int -> [LHsType GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LHsType GhcPs]
ts
case HsTupleSort
tt of
HsTupleSort
GHC.HsBoxedOrConstraintTuple -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
HsTupleSort
_ -> AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markType SrcSpan
_ (GHC.HsSumTy XSumTy GhcPs
_ [LHsType GhcPs]
tys) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
(LHsType GhcPs -> Annotated ())
-> Int -> AstContext -> [LHsType GhcPs] -> Annotated ()
forall t.
(t -> Annotated ()) -> Int -> AstContext -> [t] -> Annotated ()
markListIntercalateWithFunLevelCtx LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 AstContext
AddVbar [LHsType GhcPs]
tys
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markType SrcSpan
_ (GHC.HsOpTy XOpTy GhcPs
_ LHsType GhcPs
t1 Located (IdP GhcPs)
lo LHsType GhcPs
t2) = do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t1
if (OccName -> Bool
GHC.isTcOcc (OccName -> Bool) -> OccName -> Bool
forall a b. (a -> b) -> a -> b
$ RdrName -> OccName
forall name. HasOccName name => name -> OccName
GHC.occName (RdrName -> OccName) -> RdrName -> OccName
forall a b. (a -> b) -> a -> b
$ Located RdrName -> SrcSpanLess (Located RdrName)
forall a. HasSrcSpan a => a -> SrcSpanLess a
GHC.unLoc Located (IdP GhcPs)
Located RdrName
lo)
then do
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnSimpleQuote
else do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSimpleQuote
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
PrefixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
lo
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t2
markType SrcSpan
_ (GHC.HsParTy XParTy GhcPs
_ LHsType GhcPs
t) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markType SrcSpan
_ (GHC.HsIParamTy XIParamTy GhcPs
_ Located HsIPName
n LHsType GhcPs
t) = do
Located HsIPName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located HsIPName
n
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
markType SrcSpan
l (GHC.HsStarTy XStarTy GhcPs
_ Bool
isUnicode) = do
if Bool
isUnicode
then SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"\x2605"
else SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"*"
markType SrcSpan
_ (GHC.HsKindSig XKindSig GhcPs
_ LHsType GhcPs
t LHsType GhcPs
k) = do
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenP
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
k
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseP
markType SrcSpan
l (GHC.HsSpliceTy XSpliceTy GhcPs
_ HsSplice GhcPs
s) = do
SrcSpan -> HsSplice GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsSplice GhcPs
s
markType SrcSpan
_ (GHC.HsDocTy XDocTy GhcPs
_ LHsType GhcPs
t LHsDocString
ds) = do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
LHsDocString -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsDocString
ds
markType SrcSpan
_ (GHC.HsBangTy XBangTy GhcPs
_ (GHC.HsSrcBang SourceText
mt SrcUnpackedness
_up SrcStrictness
str) LHsType GhcPs
t) = do
case SourceText
mt of
SourceText
GHC.NoSourceText -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
GHC.SourceText String
src -> do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
src
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
case SrcStrictness
str of
SrcStrictness
GHC.SrcLazy -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnTilde
SrcStrictness
GHC.SrcStrict -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBang
SrcStrictness
GHC.NoSrcStrict -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
t
markType SrcSpan
_ (GHC.HsRecTy XRecTy GhcPs
_ [LConDeclField GhcPs]
cons) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
[LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LConDeclField GhcPs]
cons
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
markType SrcSpan
_ (GHC.HsExplicitListTy XExplicitListTy GhcPs
_ PromotionFlag
promoted [LHsType GhcPs]
ts) = do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (PromotionFlag
promoted PromotionFlag -> PromotionFlag -> Bool
forall a. Eq a => a -> a -> Bool
== PromotionFlag
GHC.IsPromoted) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSimpleQuote
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
[LHsType GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LHsType GhcPs]
ts
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markType SrcSpan
_ (GHC.HsExplicitTupleTy XExplicitTupleTy GhcPs
_ [LHsType GhcPs]
ts) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSimpleQuote
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
[LHsType GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LHsType GhcPs]
ts
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markType SrcSpan
l (GHC.HsTyLit XTyLit GhcPs
_ HsTyLit
lit) = do
case HsTyLit
lit of
(GHC.HsNumTy SourceText
s Integer
v) ->
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
l SourceText
s (Integer -> String
forall a. Show a => a -> String
show Integer
v)
(GHC.HsStrTy SourceText
s FastString
v) ->
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
l SourceText
s (FastString -> String
forall a. Show a => a -> String
show FastString
v)
markType SrcSpan
l (GHC.HsWildCardTy XWildCardTy GhcPs
_) = do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"_"
markType SrcSpan
_ (GHC.XHsType XXType GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsType for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NewHsTypeX -> String
forall a. Outputable a => a -> String
showGhc NewHsTypeX
XXType GhcPs
x
instance Annotate (GHC.HsSplice GHC.GhcPs) where
markAST :: SrcSpan -> HsSplice GhcPs -> Annotated ()
markAST SrcSpan
l HsSplice GhcPs
c =
case HsSplice GhcPs
c of
GHC.HsQuasiQuote XQuasiQuote GhcPs
_ IdP GhcPs
_ IdP GhcPs
n SrcSpan
_pos FastString
fs -> do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal
(String
"[" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (RdrName -> String
forall a. Outputable a => a -> String
showGhc IdP GhcPs
RdrName
n) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"|" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (FastString -> String
GHC.unpackFS FastString
fs) String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"|]")
GHC.HsTypedSplice XTypedSplice GhcPs
_ SpliceDecoration
hasParens IdP GhcPs
_n b :: Located (HsExpr GhcPs)
b@(GHC.L SrcSpan
_ (GHC.HsVar XVar GhcPs
_ (GHC.L SrcSpan
_ IdP GhcPs
n))) -> do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenPTE
if (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasDollar)
then AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnThIdTySplice (String
"$$" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (OccName -> String
GHC.occNameString (RdrName -> OccName
forall name. HasOccName name => name -> OccName
GHC.occName IdP GhcPs
RdrName
n)))
else Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
GHC.HsTypedSplice XTypedSplice GhcPs
_ SpliceDecoration
hasParens IdP GhcPs
_n Located (HsExpr GhcPs)
b -> do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenPTE
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
GHC.HsUntypedSplice XUntypedSplice GhcPs
_ SpliceDecoration
hasParens IdP GhcPs
_n b :: Located (HsExpr GhcPs)
b@(GHC.L SrcSpan
_ (GHC.HsVar XVar GhcPs
_ (GHC.L SrcSpan
_ IdP GhcPs
n))) -> do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenPE
if (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasDollar)
then AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnThIdSplice (String
"$" String -> String -> String
forall a. [a] -> [a] -> [a]
++ (OccName -> String
GHC.occNameString (RdrName -> OccName
forall name. HasOccName name => name -> OccName
GHC.occName IdP GhcPs
RdrName
n)))
else Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
GHC.HsUntypedSplice XUntypedSplice GhcPs
_ SpliceDecoration
hasParens IdP GhcPs
_n Located (HsExpr GhcPs)
b -> do
case SpliceDecoration
hasParens of
SpliceDecoration
GHC.HasParens -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenPE
SpliceDecoration
GHC.HasDollar -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThIdSplice
SpliceDecoration
GHC.NoParens -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SpliceDecoration
hasParens SpliceDecoration -> SpliceDecoration -> Bool
forall a. Eq a => a -> a -> Bool
== SpliceDecoration
GHC.HasParens) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
GHC.HsSpliced{} -> String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"HsSpliced only exists between renamer and typechecker in GHC"
GHC.HsSplicedT{} -> String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"HsSplicedT only exists between renamer and typechecker in GHC"
(GHC.XSplice XXSplice GhcPs
x) -> String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XSplice for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXSplice GhcPs
x
instance Annotate (GHC.ConDeclField GHC.GhcPs) where
markAST :: SrcSpan -> ConDeclField GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.ConDeclField XConDeclField GhcPs
_ [LFieldOcc GhcPs]
ns LHsType GhcPs
ty Maybe LHsDocString
mdoc) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
[LFieldOcc GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LFieldOcc GhcPs]
ns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
ty
Maybe LHsDocString -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe LHsDocString
mdoc
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.XConDeclField XXConDeclField GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XConDeclField for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXConDeclField GhcPs
x
instance Annotate (GHC.FieldOcc GHC.GhcPs) where
markAST :: SrcSpan -> FieldOcc GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.FieldOcc XCFieldOcc GhcPs
_ Located RdrName
rn) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
rn
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.XFieldOcc XXFieldOcc GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XFieldOcc for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXFieldOcc GhcPs
x
instance Annotate GHC.HsDocString where
markAST :: SrcSpan -> HsDocString -> Annotated ()
markAST SrcSpan
l HsDocString
s = do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (HsDocString -> String
GHC.unpackHDS HsDocString
s)
instance Annotate (GHC.Pat GHC.GhcPs) where
markAST :: SrcSpan -> Pat GhcPs -> Annotated ()
markAST SrcSpan
loc Pat GhcPs
typ = do
SrcSpan -> Pat GhcPs -> Annotated ()
markPat SrcSpan
loc Pat GhcPs
typ
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma Annotated () -> String -> Annotated ()
forall c. c -> String -> c
`debug` (String
"AnnComma in Pat")
where
markPat :: SrcSpan -> Pat GhcPs -> Annotated ()
markPat SrcSpan
l (GHC.WildPat XWildPat GhcPs
_) = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"_"
markPat SrcSpan
l (GHC.VarPat XVarPat GhcPs
_ Located (IdP GhcPs)
n) = do
let pun_RDR :: String
pun_RDR = String
"pun-right-hand-side"
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Located RdrName -> String
forall a. Outputable a => a -> String
showGhc Located (IdP GhcPs)
Located RdrName
n String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
pun_RDR) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ SrcSpan -> RdrName -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l (Located RdrName -> SrcSpanLess (Located RdrName)
forall a. HasSrcSpan a => a -> SrcSpanLess a
GHC.unLoc Located (IdP GhcPs)
Located RdrName
n)
markPat SrcSpan
_ (GHC.LazyPat XLazyPat GhcPs
_ LPat GhcPs
p) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnTilde
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
p
markPat SrcSpan
_ (GHC.AsPat XAsPat GhcPs
_ Located (IdP GhcPs)
ln LPat GhcPs
p) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnAt
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
p
markPat SrcSpan
_ (GHC.ParPat XParPat GhcPs
_ LPat GhcPs
p) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
p
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markPat SrcSpan
_ (GHC.BangPat XBangPat GhcPs
_ LPat GhcPs
p) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBang
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
p
markPat SrcSpan
_ (GHC.ListPat XListPat GhcPs
_ [LPat GhcPs]
ps) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
(Located (Pat GhcPs) -> Annotated ())
-> Int -> [Located (Pat GhcPs)] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LPat GhcPs]
[Located (Pat GhcPs)]
ps
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markPat SrcSpan
_ (GHC.TuplePat XTuplePat GhcPs
_ [LPat GhcPs]
pats Boxity
b) = do
if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
GHC.Boxed then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
else AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
(Located (Pat GhcPs) -> Annotated ())
-> Int -> [Located (Pat GhcPs)] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LPat GhcPs]
[Located (Pat GhcPs)]
pats
if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
GHC.Boxed then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
else AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markPat SrcSpan
_ (GHC.SumPat XSumPat GhcPs
_ LPat GhcPs
pat Int
alt Int
arity) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Int
alt Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
pat
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Int
arity Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
alt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markPat SrcSpan
_ (GHC.ConPatIn Located (IdP GhcPs)
n HsConPatDetails GhcPs
dets) = do
Located RdrName -> HsConPatDetails GhcPs -> Annotated ()
markHsConPatDetails Located (IdP GhcPs)
Located RdrName
n HsConPatDetails GhcPs
dets
markPat SrcSpan
_ GHC.ConPatOut {} =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: ConPatOut Introduced after renaming"
markPat SrcSpan
_ (GHC.ViewPat XViewPat GhcPs
_ Located (HsExpr GhcPs)
e LPat GhcPs
pat) = do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
pat
markPat SrcSpan
l (GHC.SplicePat XSplicePat GhcPs
_ HsSplice GhcPs
s) = do
SrcSpan -> HsSplice GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsSplice GhcPs
s
markPat SrcSpan
l (GHC.LitPat XLitPat GhcPs
_ HsLit GhcPs
lp) = SrcSpan -> HsLit GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsLit GhcPs
lp
markPat SrcSpan
_ (GHC.NPat XNPat GhcPs
_ Located (HsOverLit GhcPs)
ol Maybe (SyntaxExpr GhcPs)
mn SyntaxExpr GhcPs
_) = do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Maybe (SyntaxExpr GhcPs) -> Bool
forall a. Maybe a -> Bool
isJust Maybe (SyntaxExpr GhcPs)
mn) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnMinus
Located (HsOverLit GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsOverLit GhcPs)
ol
markPat SrcSpan
_ (GHC.NPlusKPat XNPlusKPat GhcPs
_ Located (IdP GhcPs)
ln Located (HsOverLit GhcPs)
ol HsOverLit GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnVal String
"+"
Located (HsOverLit GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsOverLit GhcPs)
ol
markPat SrcSpan
_ (GHC.SigPat XSigPat GhcPs
_ LPat GhcPs
pat LHsSigWcType (NoGhcTc GhcPs)
ty) = do
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
pat
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsSigWcType GhcPs -> Annotated ()
markLHsSigWcType LHsSigWcType GhcPs
LHsSigWcType (NoGhcTc GhcPs)
ty
markPat SrcSpan
_ GHC.CoPat {} =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: CoPat introduced after renaming"
markPat SrcSpan
_ (GHC.XPat XXPat GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XPat for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXPat GhcPs
x
hsLit2String :: GHC.HsLit GHC.GhcPs -> String
hsLit2String :: HsLit GhcPs -> String
hsLit2String HsLit GhcPs
lit =
case HsLit GhcPs
lit of
GHC.HsChar XHsChar GhcPs
src Char
v -> SourceText -> Char -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsChar GhcPs
SourceText
src Char
v String
""
GHC.HsCharPrim XHsCharPrim GhcPs
src Char
p -> SourceText -> Char -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsCharPrim GhcPs
SourceText
src Char
p String
"#"
GHC.HsString XHsString GhcPs
src FastString
v -> SourceText -> FastString -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsString GhcPs
SourceText
src FastString
v String
""
GHC.HsStringPrim XHsStringPrim GhcPs
src ByteString
v -> SourceText -> ByteString -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsStringPrim GhcPs
SourceText
src ByteString
v String
""
GHC.HsInt XHsInt GhcPs
_ (GHC.IL SourceText
src Bool
_ Integer
v) -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix SourceText
src Integer
v String
""
GHC.HsIntPrim XHsIntPrim GhcPs
src Integer
v -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsIntPrim GhcPs
SourceText
src Integer
v String
""
GHC.HsWordPrim XHsWordPrim GhcPs
src Integer
v -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsWordPrim GhcPs
SourceText
src Integer
v String
""
GHC.HsInt64Prim XHsInt64Prim GhcPs
src Integer
v -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsInt64Prim GhcPs
SourceText
src Integer
v String
""
GHC.HsWord64Prim XHsWord64Prim GhcPs
src Integer
v -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsWord64Prim GhcPs
SourceText
src Integer
v String
""
GHC.HsInteger XHsInteger GhcPs
src Integer
v Type
_ -> SourceText -> Integer -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix XHsInteger GhcPs
SourceText
src Integer
v String
""
GHC.HsRat XHsRat GhcPs
_ (GHC.FL SourceText
src Bool
_ Rational
v) Type
_ -> SourceText -> Rational -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix SourceText
src Rational
v String
""
GHC.HsFloatPrim XHsFloatPrim GhcPs
_ (GHC.FL SourceText
src Bool
_ Rational
v) -> SourceText -> Rational -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix SourceText
src Rational
v String
"#"
GHC.HsDoublePrim XHsDoublePrim GhcPs
_ (GHC.FL SourceText
src Bool
_ Rational
v) -> SourceText -> Rational -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix SourceText
src Rational
v String
"##"
(GHC.XLit XXLit GhcPs
x) -> String -> String
forall a. HasCallStack => String -> a
error (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
"got XLit for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXLit GhcPs
x
toSourceTextWithSuffix :: (Show a) => GHC.SourceText -> a -> String -> String
toSourceTextWithSuffix :: SourceText -> a -> String -> String
toSourceTextWithSuffix (SourceText
GHC.NoSourceText) a
alt String
suffix = a -> String
forall a. Show a => a -> String
show a
alt String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
suffix
toSourceTextWithSuffix (GHC.SourceText String
txt) a
_alt String
suffix = String
txt String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
suffix
markHsConPatDetails :: GHC.Located GHC.RdrName -> GHC.HsConPatDetails GHC.GhcPs -> Annotated ()
markHsConPatDetails :: Located RdrName -> HsConPatDetails GhcPs -> Annotated ()
markHsConPatDetails Located RdrName
ln HsConPatDetails GhcPs
dets = do
case HsConPatDetails GhcPs
dets of
GHC.PrefixCon [LPat GhcPs]
args -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
(Located (Pat GhcPs) -> Annotated ())
-> [Located (Pat GhcPs)] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LPat GhcPs]
[Located (Pat GhcPs)]
args
GHC.RecCon (GHC.HsRecFields [LHsRecField GhcPs (LPat GhcPs)]
fs Maybe (Located Int)
dd) -> do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
case Maybe (Located Int)
dd of
Maybe (Located Int)
Nothing -> (LHsRecField GhcPs (Located (Pat GhcPs)) -> Annotated ())
-> Int -> [LHsRecField GhcPs (Located (Pat GhcPs))] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LHsRecField GhcPs (Located (Pat GhcPs)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LHsRecField GhcPs (LPat GhcPs)]
[LHsRecField GhcPs (Located (Pat GhcPs))]
fs
Just Located Int
_ -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LHsRecField GhcPs (Located (Pat GhcPs)) -> Annotated ())
-> [LHsRecField GhcPs (Located (Pat GhcPs))] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsRecField GhcPs (Located (Pat GhcPs)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsRecField GhcPs (LPat GhcPs)]
[LHsRecField GhcPs (Located (Pat GhcPs))]
fs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
GHC.InfixCon LPat GhcPs
a1 LPat GhcPs
a2 -> do
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
a1
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
PrefixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
ln
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
a2
markHsConDeclDetails ::
Bool -> Bool -> [GHC.Located GHC.RdrName] -> GHC.HsConDeclDetails GHC.GhcPs -> Annotated ()
markHsConDeclDetails :: Bool
-> Bool
-> [Located RdrName]
-> HsConDeclDetails GhcPs
-> Annotated ()
markHsConDeclDetails Bool
isDeprecated Bool
inGadt [Located RdrName]
lns HsConDeclDetails GhcPs
dets = do
case HsConDeclDetails GhcPs
dets of
GHC.PrefixCon [LHsType GhcPs]
args ->
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LHsType GhcPs -> Annotated ()) -> [LHsType GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsType GhcPs]
args
GHC.RecCon Located [LConDeclField GhcPs]
fs -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
if Bool
inGadt
then do
if Bool
isDeprecated
then Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InGadt]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located [LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LConDeclField GhcPs]
fs
else Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InGadt,AstContext
InRecCon]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located [LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LConDeclField GhcPs]
fs
else do
if Bool
isDeprecated
then Located [LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LConDeclField GhcPs]
fs
else Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InRecCon]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located [LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LConDeclField GhcPs]
fs
GHC.InfixCon LHsType GhcPs
a1 LHsType GhcPs
a2 -> do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
a1
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (Located RdrName -> Annotated ())
-> [Located RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located RdrName]
lns
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
a2
instance Annotate [GHC.LConDeclField GHC.GhcPs] where
markAST :: SrcSpan -> [LConDeclField GhcPs] -> Annotated ()
markAST SrcSpan
_ [LConDeclField GhcPs]
fs = do
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
[LConDeclField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LConDeclField GhcPs]
fs
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnDotdot
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InRecCon) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InGadt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
instance Annotate (GHC.HsOverLit GHC.GhcPs) where
markAST :: SrcSpan -> HsOverLit GhcPs -> Annotated ()
markAST SrcSpan
l HsOverLit GhcPs
ol =
let str :: SourceText
str = case HsOverLit GhcPs -> OverLitVal
forall p. HsOverLit p -> OverLitVal
GHC.ol_val HsOverLit GhcPs
ol of
GHC.HsIntegral (GHC.IL SourceText
src Bool
_ Integer
_) -> SourceText
src
GHC.HsFractional (GHC.FL SourceText
src Bool
_ Rational
_) -> SourceText
src
GHC.HsIsString SourceText
src FastString
_ -> SourceText
src
in
SrcSpan -> SourceText -> String -> Annotated ()
markExternalSourceText SrcSpan
l SourceText
str String
""
instance (Annotate arg)
=> Annotate (GHC.HsImplicitBndrs GHC.GhcPs (GHC.Located arg)) where
markAST :: SrcSpan -> HsImplicitBndrs GhcPs (Located arg) -> Annotated ()
markAST SrcSpan
_ (GHC.HsIB XHsIB GhcPs (Located arg)
_ Located arg
thing) = do
Located arg -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located arg
thing
markAST SrcSpan
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (Located arg)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsImplicitBndrs for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsImplicitBndrs GhcPs (Located arg)
x
instance (Annotate body) => Annotate (GHC.Stmt GHC.GhcPs (GHC.Located body)) where
markAST :: SrcSpan -> Stmt GhcPs (Located body) -> Annotated ()
markAST SrcSpan
_ (GHC.LastStmt XLastStmt GhcPs GhcPs (Located body)
_ Located body
body Bool
_ SyntaxExpr GhcPs
_)
= Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LeftMost,AstContext
PrefixOp]) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located body -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located body
body
markAST SrcSpan
_ (GHC.BindStmt XBindStmt GhcPs GhcPs (Located body)
_ LPat GhcPs
pat Located body
body SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
pat
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLarrow
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LeftMost,AstContext
PrefixOp]) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located body -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located body
body
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate)
(AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma)
(Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar)
Annotated ()
markTrailingSemi
markAST SrcSpan
_ GHC.ApplicativeStmt{}
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"ApplicativeStmt should not appear in ParsedSource"
markAST SrcSpan
_ (GHC.BodyStmt XBodyStmt GhcPs GhcPs (Located body)
_ Located body
body SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located body -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located body
body
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.LetStmt XLetStmt GhcPs GhcPs (Located body)
_ (GHC.L SrcSpan
_ HsLocalBinds GhcPs
lb)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLet
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
lb
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate)
(AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma)
(Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar)
Annotated ()
markTrailingSemi
markAST SrcSpan
l (GHC.ParStmt XParStmt GhcPs GhcPs (Located body)
_ [ParStmtBlock GhcPs GhcPs]
pbs HsExpr GhcPs
_ SyntaxExpr GhcPs
_) = do
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate)
(
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$
ListContexts
-> (ParStmtBlock GhcPs GhcPs -> Annotated ())
-> [ParStmtBlock GhcPs GhcPs]
-> Annotated ()
forall t.
ListContexts -> (t -> Annotated ()) -> [t] -> Annotated ()
markListWithContextsFunction
(Set AstContext
-> Set AstContext
-> Set AstContext
-> Set AstContext
-> ListContexts
LC (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate)
Set AstContext
forall a. Set a
Set.empty
Set AstContext
forall a. Set a
Set.empty
(AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate)
) (SrcSpan -> ParStmtBlock GhcPs GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l) [ParStmtBlock GhcPs GhcPs]
pbs
)
(
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$
ListContexts
-> (ParStmtBlock GhcPs GhcPs -> Annotated ())
-> [ParStmtBlock GhcPs GhcPs]
-> Annotated ()
forall t.
ListContexts -> (t -> Annotated ()) -> [t] -> Annotated ()
markListWithContextsFunction
(Set AstContext
-> Set AstContext
-> Set AstContext
-> Set AstContext
-> ListContexts
LC Set AstContext
forall a. Set a
Set.empty
([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
AddVbar])
([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
AddVbar])
Set AstContext
forall a. Set a
Set.empty
) (SrcSpan -> ParStmtBlock GhcPs GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l) [ParStmtBlock GhcPs GhcPs]
pbs
)
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.TransStmt XTransStmt GhcPs GhcPs (Located body)
_ TransForm
form [GuardLStmt GhcPs]
stmts [(IdP GhcPs, IdP GhcPs)]
_b Located (HsExpr GhcPs)
using Maybe (Located (HsExpr GhcPs))
by SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_ HsExpr GhcPs
_) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (GuardLStmt GhcPs -> Annotated ())
-> [GuardLStmt GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ GuardLStmt GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [GuardLStmt GhcPs]
stmts
case TransForm
form of
TransForm
GHC.ThenForm -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThen
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
using
case Maybe (Located (HsExpr GhcPs))
by of
Just Located (HsExpr GhcPs)
b -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBy
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Maybe (Located (HsExpr GhcPs))
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
TransForm
GHC.GroupForm -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThen
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnGroup
case Maybe (Located (HsExpr GhcPs))
by of
Just Located (HsExpr GhcPs)
b -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBy Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
b
Maybe (Located (HsExpr GhcPs))
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnUsing
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
using
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.RecStmt XRecStmt GhcPs GhcPs (Located body)
_ [LStmtLR GhcPs GhcPs (Located body)]
stmts [IdP GhcPs]
_ [IdP GhcPs]
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRec
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
[LStmtLR GhcPs GhcPs (Located body)] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LStmtLR GhcPs GhcPs (Located body)]
stmts
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XStmtLR XXStmtLR GhcPs GhcPs (Located body)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XStmtLR for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXStmtLR GhcPs GhcPs (Located body)
x
instance Annotate (GHC.ParStmtBlock GHC.GhcPs GHC.GhcPs) where
markAST :: SrcSpan -> ParStmtBlock GhcPs GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.ParStmtBlock XParStmtBlock GhcPs GhcPs
_ [GuardLStmt GhcPs]
stmts [IdP GhcPs]
_ns SyntaxExpr GhcPs
_) = do
[GuardLStmt GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [GuardLStmt GhcPs]
stmts
markAST SrcSpan
_ (GHC.XParStmtBlock XXParStmtBlock GhcPs GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XParStmtBlock for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXParStmtBlock GhcPs GhcPs
x
instance Annotate (GHC.HsLocalBinds GHC.GhcPs) where
markAST :: SrcSpan -> HsLocalBinds GhcPs -> Annotated ()
markAST SrcSpan
_ HsLocalBinds GhcPs
lb = HsLocalBinds GhcPs -> Annotated ()
markHsLocalBinds HsLocalBinds GhcPs
lb
markHsLocalBinds :: GHC.HsLocalBinds GHC.GhcPs -> Annotated ()
markHsLocalBinds :: HsLocalBinds GhcPs -> Annotated ()
markHsLocalBinds (GHC.HsValBinds XHsValBinds GhcPs GhcPs
_ (GHC.ValBinds XValBinds GhcPs GhcPs
_ LHsBinds GhcPs
binds [GenLocated SrcSpan (Sig GhcPs)]
sigs)) =
[(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsLayout
([GenLocated SrcSpan (HsBind GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation (LHsBinds GhcPs -> [GenLocated SrcSpan (HsBind GhcPs)]
forall a. Bag a -> [a]
GHC.bagToList LHsBinds GhcPs
binds)
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpan (Sig GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [GenLocated SrcSpan (Sig GhcPs)]
sigs
)
markHsLocalBinds (GHC.HsIPBinds XHsIPBinds GhcPs GhcPs
_ (GHC.IPBinds XIPBinds GhcPs
_ [LIPBind GhcPs]
binds)) = [LIPBind GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LIPBind GhcPs]
binds
markHsLocalBinds GHC.EmptyLocalBinds{} = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markHsLocalBinds (GHC.HsValBinds XHsValBinds GhcPs GhcPs
_ (GHC.XValBindsLR XXValBindsLR GhcPs GhcPs
_)) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markHsLocalBinds:got extension"
markHsLocalBinds (GHC.HsIPBinds XHsIPBinds GhcPs GhcPs
_ (GHC.XHsIPBinds XXHsIPBinds GhcPs
_)) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markHsLocalBinds:got extension"
markHsLocalBinds (GHC.XHsLocalBindsLR XXHsLocalBindsLR GhcPs GhcPs
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markHsLocalBinds:got extension"
markMatchGroup :: (Annotate body)
=> GHC.SrcSpan -> GHC.MatchGroup GHC.GhcPs (GHC.Located body)
-> Annotated ()
markMatchGroup :: SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
_ (GHC.MG XMG GhcPs (Located body)
_ (GHC.L SrcSpan
_ [LMatch GhcPs (Located body)]
matches) Origin
_)
= Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AdvanceLine) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LMatch GhcPs (Located body)] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LMatch GhcPs (Located body)]
matches
markMatchGroup SrcSpan
_ (GHC.XMatchGroup XXMatchGroup GhcPs (Located body)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XMatchGroup for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXMatchGroup GhcPs (Located body)
x
instance (Annotate body)
=> Annotate [GHC.Located (GHC.Match GHC.GhcPs (GHC.Located body))] where
markAST :: SrcSpan -> [Located (Match GhcPs (Located body))] -> Annotated ()
markAST SrcSpan
_ [Located (Match GhcPs (Located body))]
ls = (Located (Match GhcPs (Located body)) -> Annotated ())
-> [Located (Match GhcPs (Located body))] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located (Match GhcPs (Located body)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located (Match GhcPs (Located body))]
ls
instance Annotate (GHC.HsExpr GHC.GhcPs) where
markAST :: SrcSpan -> HsExpr GhcPs -> Annotated ()
markAST SrcSpan
loc HsExpr GhcPs
expr = do
SrcSpan -> HsExpr GhcPs -> Annotated ()
markExpr SrcSpan
loc HsExpr GhcPs
expr
Set AstContext -> Annotated () -> Annotated ()
inContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
AddVbar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
where
markExpr :: SrcSpan -> HsExpr GhcPs -> Annotated ()
markExpr SrcSpan
_ (GHC.HsVar XVar GhcPs
_ Located (IdP GhcPs)
n) = AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp)
(Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n)
(Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp)
(Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n)
(Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n)
)
markExpr SrcSpan
l (GHC.HsUnboundVar {}) = do
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
InfixOp])
(do AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBackquote
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnVal String
"_"
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnBackquote)
(SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"_")
markExpr SrcSpan
l (GHC.HsRecFld XRecFld GhcPs
_ AmbiguousFieldOcc GhcPs
f) = SrcSpan -> AmbiguousFieldOcc GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l AmbiguousFieldOcc GhcPs
f
markExpr SrcSpan
l (GHC.HsOverLabel XOverLabel GhcPs
_ Maybe (IdP GhcPs)
_ FastString
fs)
= SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (String
"#" String -> String -> String
forall a. [a] -> [a] -> [a]
++ FastString -> String
GHC.unpackFS FastString
fs)
markExpr SrcSpan
l (GHC.HsIPVar XIPVar GhcPs
_ n :: HsIPName
n@(GHC.HsIPName FastString
_v)) =
SrcSpan -> HsIPName -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsIPName
n
markExpr SrcSpan
l (GHC.HsOverLit XOverLitE GhcPs
_ HsOverLit GhcPs
ov) = SrcSpan -> HsOverLit GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsOverLit GhcPs
ov
markExpr SrcSpan
l (GHC.HsLit XLitE GhcPs
_ HsLit GhcPs
lit) = SrcSpan -> HsLit GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsLit GhcPs
lit
markExpr SrcSpan
_ (GHC.HsLam XLam GhcPs
_ (GHC.MG XMG GhcPs (Located (HsExpr GhcPs))
_ (GHC.L SrcSpan
_ [LMatch GhcPs (Located (HsExpr GhcPs))
match]) Origin
_)) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
LambdaExpr) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
LMatch GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LMatch GhcPs (Located (HsExpr GhcPs))
match
markExpr SrcSpan
_ (GHC.HsLam XLam GhcPs
_ MatchGroup GhcPs (Located (HsExpr GhcPs))
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"HsLam with other than one match"
markExpr SrcSpan
l (GHC.HsLamCase XLamCase GhcPs
_ MatchGroup GhcPs (Located (HsExpr GhcPs))
match) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLam
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCase
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnSemi
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
CaseAlt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
SrcSpan
-> MatchGroup GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall body.
Annotate body =>
SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
l MatchGroup GhcPs (Located (HsExpr GhcPs))
match
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
markExpr SrcSpan
_ (GHC.HsApp XApp GhcPs
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
markExpr SrcSpan
_ (GHC.OpApp XOpApp GhcPs
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 Located (HsExpr GhcPs)
e3) = do
let
isInfix :: Bool
isInfix = case Located (HsExpr GhcPs)
e2 of
GHC.L SrcSpan
_ (GHC.HsVar{}) -> Bool
True
Located (HsExpr GhcPs)
_ -> Bool
False
normal :: Annotated ()
normal =
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
LeftMost)
(Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
LeftMost,AstContext
PrefixOp]) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1)
(Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1)
if Bool
isInfix
then Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
else Annotated ()
normal
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
PrefixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
if Bool
isInfix
then Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e3
else Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e3
markExpr SrcSpan
_ (GHC.NegApp XNegApp GhcPs
_ Located (HsExpr GhcPs)
e SyntaxExpr GhcPs
_) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnMinus
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
markExpr SrcSpan
_ (GHC.HsPar XPar GhcPs
_ Located (HsExpr GhcPs)
e) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markExpr SrcSpan
_ (GHC.SectionL XSectionL GhcPs
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2) = do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
markExpr SrcSpan
_ (GHC.SectionR XSectionR GhcPs
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
markExpr SrcSpan
_ (GHC.ExplicitTuple XExplicitTuple GhcPs
_ [LHsTupArg GhcPs]
args Boxity
b) = do
if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
GHC.Boxed then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
else AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LHsTupArg GhcPs -> Annotated ())
-> Int -> [LHsTupArg GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LHsTupArg GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LHsTupArg GhcPs]
args
if Boxity
b Boxity -> Boxity -> Bool
forall a. Eq a => a -> a -> Bool
== Boxity
GHC.Boxed then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
else AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markExpr SrcSpan
_ (GHC.ExplicitSum XExplicitSum GhcPs
_ Int
alt Int
arity Located (HsExpr GhcPs)
e) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"(#"
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Int
alt Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
Int -> Annotated () -> Annotated ()
forall (m :: * -> *) a. Applicative m => Int -> m a -> m ()
replicateM_ (Int
arity Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
alt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#)"
markExpr SrcSpan
l (GHC.HsCase XCase GhcPs
_ Located (HsExpr GhcPs)
e1 MatchGroup GhcPs (Located (HsExpr GhcPs))
matches) = Annotated () -> Annotated ()
setRigidFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCase
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOf
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
CaseAlt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ SrcSpan
-> MatchGroup GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall body.
Annotate body =>
SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
l MatchGroup GhcPs (Located (HsExpr GhcPs))
matches
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
markExpr SrcSpan
_ (GHC.HsIf XIf GhcPs
_ Maybe (SyntaxExpr GhcPs)
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 Located (HsExpr GhcPs)
e3) = Annotated () -> Annotated ()
setLayoutFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnIf
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> AnnKeywordId -> m ()
markAnnBeforeAnn AnnKeywordId
GHC.AnnSemi AnnKeywordId
GHC.AnnThen
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThen
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
ListStart) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
AnnKeywordId -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> AnnKeywordId -> m ()
markAnnBeforeAnn AnnKeywordId
GHC.AnnSemi AnnKeywordId
GHC.AnnElse
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnElse
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
ListStart) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e3
markExpr SrcSpan
_ (GHC.HsMultiIf XMultiIf GhcPs
_ [LGRHS GhcPs (Located (HsExpr GhcPs))]
rhs) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnIf
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
CaseAlt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
[LGRHS GhcPs (Located (HsExpr GhcPs))] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LGRHS GhcPs (Located (HsExpr GhcPs))]
rhs
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
markExpr SrcSpan
_ (GHC.HsLet XLet GhcPs
_ (GHC.L SrcSpan
_ HsLocalBinds GhcPs
binds) Located (HsExpr GhcPs)
e) = do
Annotated () -> Annotated ()
setLayoutFlag (do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLet
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
binds
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnIn
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e)
markExpr SrcSpan
_ (GHC.HsDo XDo GhcPs
_ HsStmtContext Name
cts (GHC.L SrcSpan
_ [GuardLStmt GhcPs]
es)) = do
case HsStmtContext Name
cts of
HsStmtContext Name
GHC.DoExpr -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDo
HsStmtContext Name
GHC.MDoExpr -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnMdo
HsStmtContext Name
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
let (String
ostr,String
cstr) =
if HsStmtContext Name -> Bool
forall name. HsStmtContext name -> Bool
isListComp HsStmtContext Name
cts
then (String
"[", String
"]")
else (String
"{", String
"}")
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (HsStmtContext Name -> Bool
forall name. HsStmtContext name -> Bool
isListComp HsStmtContext Name
cts) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
ostr
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenS
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
if HsStmtContext Name -> Bool
forall name. HsStmtContext name -> Bool
isListComp HsStmtContext Name
cts
then do
GuardLStmt GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ([GuardLStmt GhcPs] -> GuardLStmt GhcPs
forall a. [a] -> a
last [GuardLStmt GhcPs]
es)
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Annotated () -> Annotated ()
setLayoutFlag ([GuardLStmt GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate ([GuardLStmt GhcPs] -> [GuardLStmt GhcPs]
forall a. [a] -> [a]
init [GuardLStmt GhcPs]
es))
else do
[GuardLStmt GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [GuardLStmt GhcPs]
es
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseS
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (HsStmtContext Name -> Bool
forall name. HsStmtContext name -> Bool
isListComp HsStmtContext Name
cts) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
cstr
markExpr SrcSpan
_ (GHC.ExplicitList XExplicitList GhcPs
_ Maybe (SyntaxExpr GhcPs)
_ [Located (HsExpr GhcPs)]
es) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (Located (HsExpr GhcPs) -> Annotated ())
-> Int -> [Located (HsExpr GhcPs)] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [Located (HsExpr GhcPs)]
es
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markExpr SrcSpan
_ (GHC.RecordCon XRecordCon GhcPs
_ Located (IdP GhcPs)
n (GHC.HsRecFields [LHsRecField GhcPs (Located (HsExpr GhcPs))]
fs Maybe (Located Int)
dd)) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
n
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
case Maybe (Located Int)
dd of
Maybe (Located Int)
Nothing -> [LHsRecField GhcPs (Located (HsExpr GhcPs))] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LHsRecField GhcPs (Located (HsExpr GhcPs))]
fs
Just Located Int
_ -> do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Intercalate) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LHsRecField GhcPs (Located (HsExpr GhcPs)) -> Annotated ())
-> [LHsRecField GhcPs (Located (HsExpr GhcPs))] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsRecField GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsRecField GhcPs (Located (HsExpr GhcPs))]
fs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
markExpr SrcSpan
_ (GHC.RecordUpd XRecordUpd GhcPs
_ Located (HsExpr GhcPs)
e [LHsRecUpdField GhcPs]
fs) = do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
[LHsRecUpdField GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [LHsRecUpdField GhcPs]
fs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
markExpr SrcSpan
_ (GHC.ExprWithTySig XExprWithTySig GhcPs
_ Located (HsExpr GhcPs)
e LHsSigWcType (NoGhcTc GhcPs)
typ) = do
Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsSigWcType GhcPs -> Annotated ()
markLHsSigWcType LHsSigWcType GhcPs
LHsSigWcType (NoGhcTc GhcPs)
typ
markExpr SrcSpan
_ (GHC.ArithSeq XArithSeq GhcPs
_ Maybe (SyntaxExpr GhcPs)
_ ArithSeqInfo GhcPs
seqInfo) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenS
case ArithSeqInfo GhcPs
seqInfo of
GHC.From Located (HsExpr GhcPs)
e -> do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
GHC.FromTo Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 -> do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
GHC.FromThen Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 -> do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
GHC.FromThenTo Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 Located (HsExpr GhcPs)
e3 -> do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e3
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseS
markExpr SrcSpan
_ (GHC.HsSCC XSCC GhcPs
_ SourceText
src StringLiteral
csFStr Located (HsExpr GhcPs)
e) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# SCC"
let txt :: String
txt = SourceText -> String -> String
sourceTextToString (StringLiteral -> SourceText
GHC.sl_st StringLiteral
csFStr) (FastString -> String
GHC.unpackFS (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ StringLiteral -> FastString
GHC.sl_fs StringLiteral
csFStr)
AnnKeywordId -> String -> Annotated ()
markWithStringOptional AnnKeywordId
GHC.AnnVal String
txt
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnValStr String
txt
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
markExpr SrcSpan
_ (GHC.HsCoreAnn XCoreAnn GhcPs
_ SourceText
src StringLiteral
csFStr Located (HsExpr GhcPs)
e) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# CORE"
SourceText -> String -> Annotated ()
markSourceText (StringLiteral -> SourceText
GHC.sl_st StringLiteral
csFStr) (FastString -> String
GHC.unpackFS (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ StringLiteral -> FastString
GHC.sl_fs StringLiteral
csFStr)
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
markExpr SrcSpan
l (GHC.HsBracket XBracket GhcPs
_ (GHC.VarBr XVarBr GhcPs
_ Bool
True IdP GhcPs
v)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnSimpleQuote
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOpDollar) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Located RdrName -> Annotated ()
forall ast.
Annotate ast =>
AnnKeywordId -> Located ast -> Annotated ()
markLocatedFromKw AnnKeywordId
GHC.AnnName (SrcSpan -> RdrName -> Located RdrName
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l IdP GhcPs
RdrName
v)
markExpr SrcSpan
l (GHC.HsBracket XBracket GhcPs
_ (GHC.VarBr XVarBr GhcPs
_ Bool
False IdP GhcPs
v)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThTyQuote
AnnKeywordId -> Located RdrName -> Annotated ()
forall ast.
Annotate ast =>
AnnKeywordId -> Located ast -> Annotated ()
markLocatedFromKw AnnKeywordId
GHC.AnnName (SrcSpan -> RdrName -> Located RdrName
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l IdP GhcPs
RdrName
v)
markExpr SrcSpan
_ (GHC.HsBracket XBracket GhcPs
_ (GHC.DecBrL XDecBrL GhcPs
_ [LHsDecl GhcPs]
ds)) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"[d|"
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
NoAdvanceLine)
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Int -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Int -> Annotated () -> m ()
setContextLevel (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
TopLevel) Int
2 (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [LHsDecl GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LHsDecl GhcPs]
ds
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseQ
markExpr SrcSpan
_ (GHC.HsBracket XBracket GhcPs
_ (GHC.DecBrG XDecBrG GhcPs
_ HsGroup GhcPs
_)) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: DecBrG introduced after renamer"
markExpr SrcSpan
_l (GHC.HsBracket XBracket GhcPs
_ (GHC.ExpBr XExpBr GhcPs
_ Located (HsExpr GhcPs)
e)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenEQ
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenE
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseQ
markExpr SrcSpan
_l (GHC.HsBracket XBracket GhcPs
_ (GHC.TExpBr XTExpBr GhcPs
_ Located (HsExpr GhcPs)
e)) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"[||"
AnnKeywordId -> String -> Annotated ()
markWithStringOptional AnnKeywordId
GHC.AnnOpenE String
"[e||"
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"||]"
markExpr SrcSpan
_ (GHC.HsBracket XBracket GhcPs
_ (GHC.TypBr XTypBr GhcPs
_ LHsType GhcPs
e)) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"[t|"
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseQ
markExpr SrcSpan
_ (GHC.HsBracket XBracket GhcPs
_ (GHC.PatBr XPatBr GhcPs
_ LPat GhcPs
e)) = do
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnOpen String
"[p|"
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseQ
markExpr SrcSpan
_ (GHC.HsRnBracketOut {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: HsRnBracketOut introduced after renamer"
markExpr SrcSpan
_ (GHC.HsTcBracketOut {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: HsTcBracketOut introduced after renamer"
markExpr SrcSpan
l (GHC.HsSpliceE XSpliceE GhcPs
_ HsSplice GhcPs
e) = SrcSpan -> HsSplice GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l HsSplice GhcPs
e
markExpr SrcSpan
_ (GHC.HsProc XProc GhcPs
_ LPat GhcPs
p LHsCmdTop GhcPs
c) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnProc
Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LPat GhcPs
Located (Pat GhcPs)
p
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
LHsCmdTop GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmdTop GhcPs
c
markExpr SrcSpan
_ (GHC.HsStatic XStatic GhcPs
_ Located (HsExpr GhcPs)
e) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnStatic
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
markExpr SrcSpan
_ (GHC.HsTick {}) = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markExpr SrcSpan
_ (GHC.HsBinTick {}) = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markExpr SrcSpan
_ (GHC.HsTickPragma XTickPragma GhcPs
_ SourceText
src (StringLiteral
str,(Int
v1,Int
v2),(Int
v3,Int
v4)) ((SourceText
s1,SourceText
s2),(SourceText
s3,SourceText
s4)) Located (HsExpr GhcPs)
e) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
"{-# GENERATED"
AnnKeywordId -> Int -> String -> Annotated ()
markOffsetWithString AnnKeywordId
GHC.AnnVal Int
0 (StringLiteral -> String
stringLiteralToString StringLiteral
str)
let
markOne :: Int -> a -> SourceText -> Annotated ()
markOne Int
n a
v SourceText
GHC.NoSourceText = AnnKeywordId -> Int -> String -> Annotated ()
markOffsetWithString AnnKeywordId
GHC.AnnVal Int
n (a -> String
forall a. Show a => a -> String
show a
v)
markOne Int
n a
_v (GHC.SourceText String
s) = AnnKeywordId -> Int -> String -> Annotated ()
markOffsetWithString AnnKeywordId
GHC.AnnVal Int
n String
s
Int -> Int -> SourceText -> Annotated ()
forall a. Show a => Int -> a -> SourceText -> Annotated ()
markOne Int
1 Int
v1 SourceText
s1
AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnColon Int
0
Int -> Int -> SourceText -> Annotated ()
forall a. Show a => Int -> a -> SourceText -> Annotated ()
markOne Int
2 Int
v2 SourceText
s2
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnMinus
Int -> Int -> SourceText -> Annotated ()
forall a. Show a => Int -> a -> SourceText -> Annotated ()
markOne Int
3 Int
v3 SourceText
s3
AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnColon Int
1
Int -> Int -> SourceText -> Annotated ()
forall a. Show a => Int -> a -> SourceText -> Annotated ()
markOne Int
4 Int
v4 SourceText
s4
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
markExpr SrcSpan
_ (GHC.HsAppType XAppTypeE GhcPs
_ Located (HsExpr GhcPs)
e LHsWcType (NoGhcTc GhcPs)
ty) = do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
AnnKeywordId -> KeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> KeywordId -> m ()
markInstead AnnKeywordId
GHC.AnnAt KeywordId
AnnTypeApp
LHsWcType GhcPs -> Annotated ()
markLHsWcType LHsWcType GhcPs
LHsWcType (NoGhcTc GhcPs)
ty
markExpr SrcSpan
_ (GHC.HsWrap {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: HsWrap introduced after renaming"
markExpr SrcSpan
_ (GHC.HsConLikeOut{}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: HsConLikeOut introduced after type checking"
markExpr SrcSpan
_ (GHC.HsBracket XBracket GhcPs
_ (GHC.XBracket XXBracket GhcPs
_)) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markExpr got extension"
markExpr SrcSpan
_ (GHC.XExpr XXExpr GhcPs
_) = String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"markExpr got extension"
markLHsWcType :: GHC.LHsWcType GHC.GhcPs -> Annotated ()
markLHsWcType :: LHsWcType GhcPs -> Annotated ()
markLHsWcType (GHC.HsWC XHsWC GhcPs (LHsType GhcPs)
_ LHsType GhcPs
ty) = do
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
ty
markLHsWcType (GHC.XHsWildCardBndrs XXHsWildCardBndrs GhcPs (LHsType GhcPs)
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"markLHsWcType got :" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsWildCardBndrs GhcPs (LHsType GhcPs)
x
instance Annotate (GHC.HsLit GHC.GhcPs) where
markAST :: SrcSpan -> HsLit GhcPs -> Annotated ()
markAST SrcSpan
l HsLit GhcPs
lit = SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal (HsLit GhcPs -> String
hsLit2String HsLit GhcPs
lit)
instance Annotate (GHC.HsRecUpdField GHC.GhcPs) where
markAST :: SrcSpan -> HsRecUpdField GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsRecField Located (AmbiguousFieldOcc GhcPs)
lbl Located (HsExpr GhcPs)
expr Bool
punFlag) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (AmbiguousFieldOcc GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (AmbiguousFieldOcc GhcPs)
lbl
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool
punFlag Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool
False) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
expr
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.AmbiguousFieldOcc GHC.GhcPs) where
markAST :: SrcSpan -> AmbiguousFieldOcc GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.Unambiguous XUnambiguous GhcPs
_ Located RdrName
n) = Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
n
markAST SrcSpan
_ (GHC.Ambiguous XAmbiguous GhcPs
_ Located RdrName
n) = Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located RdrName
n
markAST SrcSpan
_ (GHC.XAmbiguousFieldOcc XXAmbiguousFieldOcc GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XAmbiguousFieldOcc for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXAmbiguousFieldOcc GhcPs
x
instance Annotate [GHC.ExprLStmt GHC.GhcPs] where
markAST :: SrcSpan -> [GuardLStmt GhcPs] -> Annotated ()
markAST SrcSpan
_ [GuardLStmt GhcPs]
ls = (GuardLStmt GhcPs -> Annotated ())
-> [GuardLStmt GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ GuardLStmt GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [GuardLStmt GhcPs]
ls
instance Annotate (GHC.HsTupArg GHC.GhcPs) where
markAST :: SrcSpan -> HsTupArg GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.Present XPresent GhcPs
_ (GHC.L SrcSpan
l HsExpr GhcPs
e)) = do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> HsExpr GhcPs -> Located (HsExpr GhcPs)
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l HsExpr GhcPs
e)
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> KeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> KeywordId -> m ()
markOutside AnnKeywordId
GHC.AnnComma (AnnKeywordId -> KeywordId
G AnnKeywordId
GHC.AnnComma)
markAST SrcSpan
_ (GHC.Missing XMissing GhcPs
_) = do
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
markAST SrcSpan
_ (GHC.XTupArg XXTupArg GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XTupArg got:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXTupArg GhcPs
x
instance Annotate (GHC.HsCmdTop GHC.GhcPs) where
markAST :: SrcSpan -> HsCmdTop GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsCmdTop XCmdTop GhcPs
_ LHsCmd GhcPs
cmd) = LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
cmd
markAST SrcSpan
_ (GHC.XCmdTop XXCmdTop GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XCmdTop for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXCmdTop GhcPs
x
instance Annotate (GHC.HsCmd GHC.GhcPs) where
markAST :: SrcSpan -> HsCmd GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsCmdArrApp XCmdArrApp GhcPs
_ Located (HsExpr GhcPs)
e1 Located (HsExpr GhcPs)
e2 HsArrAppType
o Bool
isRightToLeft) = do
if Bool
isRightToLeft
then do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
case HsArrAppType
o of
HsArrAppType
GHC.HsFirstOrderApp -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.Annlarrowtail
HsArrAppType
GHC.HsHigherOrderApp -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLarrowtail
else do
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
case HsArrAppType
o of
HsArrAppType
GHC.HsFirstOrderApp -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.Annrarrowtail
HsArrAppType
GHC.HsHigherOrderApp -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrowtail
if Bool
isRightToLeft
then Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
else Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
markAST SrcSpan
_ (GHC.HsCmdArrForm XCmdArrForm GhcPs
_ Located (HsExpr GhcPs)
e LexicalFixity
fixity Maybe Fixity
_mf [LHsCmdTop GhcPs]
cs) = do
let isPrefixOp :: Bool
isPrefixOp = case LexicalFixity
fixity of
LexicalFixity
GHC.Infix -> Bool
False
LexicalFixity
GHC.Prefix -> Bool
True
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isPrefixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenB
ListContexts -> [(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsContexts (Set AstContext
-> Set AstContext
-> Set AstContext
-> Set AstContext
-> ListContexts
LC (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp)
(AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp))
([Located (HsExpr GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [Located (HsExpr GhcPs)
e]
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [LHsCmdTop GhcPs] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [LHsCmdTop GhcPs]
cs)
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
isPrefixOp (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseB
markAST SrcSpan
_ (GHC.HsCmdApp XCmdApp GhcPs
_ LHsCmd GhcPs
e1 Located (HsExpr GhcPs)
e2) = do
LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
e1
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e2
markAST SrcSpan
l (GHC.HsCmdLam XCmdLam GhcPs
_ MatchGroup GhcPs (LHsCmd GhcPs)
match) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
LambdaExpr) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do SrcSpan -> MatchGroup GhcPs (LHsCmd GhcPs) -> Annotated ()
forall body.
Annotate body =>
SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
l MatchGroup GhcPs (LHsCmd GhcPs)
match
markAST SrcSpan
_ (GHC.HsCmdPar XCmdPar GhcPs
_ LHsCmd GhcPs
e) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenP
LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
e
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseP
markAST SrcSpan
l (GHC.HsCmdCase XCmdCase GhcPs
_ Located (HsExpr GhcPs)
e1 MatchGroup GhcPs (LHsCmd GhcPs)
matches) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCase
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOf
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
CaseAlt) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
SrcSpan -> MatchGroup GhcPs (LHsCmd GhcPs) -> Annotated ()
forall body.
Annotate body =>
SrcSpan -> MatchGroup GhcPs (Located body) -> Annotated ()
markMatchGroup SrcSpan
l MatchGroup GhcPs (LHsCmd GhcPs)
matches
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
markAST SrcSpan
_ (GHC.HsCmdIf XCmdIf GhcPs
_ Maybe (SyntaxExpr GhcPs)
_ Located (HsExpr GhcPs)
e1 LHsCmd GhcPs
e2 LHsCmd GhcPs
e3) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnIf
Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e1
AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnSemi Int
0
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnThen
LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
e2
AnnKeywordId -> Int -> Annotated ()
markOffset AnnKeywordId
GHC.AnnSemi Int
1
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnElse
LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
e3
markAST SrcSpan
_ (GHC.HsCmdLet XCmdLet GhcPs
_ (GHC.L SrcSpan
_ HsLocalBinds GhcPs
binds) LHsCmd GhcPs
e) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnLet
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
HsLocalBinds GhcPs -> Annotated ()
markLocalBindsWithLayout HsLocalBinds GhcPs
binds
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnIn
LHsCmd GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsCmd GhcPs
e
markAST SrcSpan
_ (GHC.HsCmdDo XCmdDo GhcPs
_ (GHC.L SrcSpan
_ [CmdLStmt GhcPs]
es)) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDo
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
[CmdLStmt GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [CmdLStmt GhcPs]
es
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
markAST SrcSpan
_ (GHC.HsCmdWrap {}) =
String -> Annotated ()
forall (f :: * -> *). Applicative f => String -> f ()
traceM String
"warning: HsCmdWrap introduced after renaming"
markAST SrcSpan
_ (GHC.XCmd XXCmd GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XCmd for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXCmd GhcPs
x
instance Annotate [GHC.Located (GHC.StmtLR GHC.GhcPs GHC.GhcPs (GHC.LHsCmd GHC.GhcPs))] where
markAST :: SrcSpan -> [CmdLStmt GhcPs] -> Annotated ()
markAST SrcSpan
_ [CmdLStmt GhcPs]
ls = (CmdLStmt GhcPs -> Annotated ())
-> [CmdLStmt GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ CmdLStmt GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [CmdLStmt GhcPs]
ls
instance Annotate (GHC.TyClDecl GHC.GhcPs) where
markAST :: SrcSpan -> TyClDecl GhcPs -> Annotated ()
markAST SrcSpan
l (GHC.FamDecl XFamDecl GhcPs
_ FamilyDecl GhcPs
famdecl) = SrcSpan -> FamilyDecl GhcPs -> Annotated ()
forall ast. Annotate ast => SrcSpan -> ast -> Annotated ()
markAST SrcSpan
l FamilyDecl GhcPs
famdecl Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.SynDecl XSynDecl GhcPs
_ Located (IdP GhcPs)
ln (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
tyvars) LexicalFixity
fixity LHsType GhcPs
typ) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> [LHsTyVarBndr GhcPs]
-> Annotated ()
forall ast a.
(Data (SrcSpanLess ast), Annotate a, Annotate ast,
HasSrcSpan ast) =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> [ast] -> Annotated ()
markTyClass Maybe [LHsTyVarBndr GhcPs]
forall a. Maybe a
Nothing LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln [LHsTyVarBndr GhcPs]
tyvars
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.DataDecl XDataDecl GhcPs
_ Located (IdP GhcPs)
ln (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
tyVars) LexicalFixity
fixity
(GHC.HsDataDefn XCHsDataDefn GhcPs
_ NewOrData
nd LHsContext GhcPs
ctx Maybe (Located CType)
mctyp Maybe (LHsType GhcPs)
mk [LConDecl GhcPs]
cons HsDeriving GhcPs
derivs)) = do
if NewOrData
nd NewOrData -> NewOrData -> Bool
forall a. Eq a => a -> a -> Bool
== NewOrData
GHC.DataType
then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnData
else AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnNewtype
Maybe (Located CType) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located CType)
mctyp
LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
ctx
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> [LHsTyVarBndr GhcPs]
-> Annotated ()
forall ast a.
(Data (SrcSpanLess ast), Annotate a, Annotate ast,
HasSrcSpan ast) =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> [ast] -> Annotated ()
markTyClass Maybe [LHsTyVarBndr GhcPs]
forall a. Maybe a
Nothing LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln [LHsTyVarBndr GhcPs]
tyVars
case Maybe (LHsType GhcPs)
mk of
Maybe (LHsType GhcPs)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just LHsType GhcPs
k -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
k
if [LConDecl GhcPs] -> Bool
forall name. [LConDecl name] -> Bool
isGadt [LConDecl GhcPs]
cons
then AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
else Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([LConDecl GhcPs] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LConDecl GhcPs]
cons) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
Annotated () -> Annotated ()
setLayoutFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
NoPrecedingSpace)
(Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ ListContexts -> [LConDecl GhcPs] -> Annotated ()
forall ast.
Annotate ast =>
ListContexts -> [Located ast] -> Annotated ()
markListWithContexts' ListContexts
listContexts [LConDecl GhcPs]
cons
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Deriving,AstContext
NoDarrow]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ HsDeriving GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated HsDeriving GhcPs
derivs
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.ClassDecl XClassDecl GhcPs
_ LHsContext GhcPs
ctx Located (IdP GhcPs)
ln (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
tyVars) LexicalFixity
fixity [LHsFunDep GhcPs]
fds
[GenLocated SrcSpan (Sig GhcPs)]
sigs LHsBinds GhcPs
meths [LFamilyDecl GhcPs]
ats [LTyFamInstDecl GhcPs]
atdefs [GenLocated SrcSpan DocDecl]
docs) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnClass
LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
ctx
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> [LHsTyVarBndr GhcPs]
-> Annotated ()
forall ast a.
(Data (SrcSpanLess ast), Annotate a, Annotate ast,
HasSrcSpan ast) =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> [ast] -> Annotated ()
markTyClass Maybe [LHsTyVarBndr GhcPs]
forall a. Maybe a
Nothing LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln [LHsTyVarBndr GhcPs]
tyVars
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([Located (FunDep (Located RdrName))] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LHsFunDep GhcPs]
[Located (FunDep (Located RdrName))]
fds) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
(Located (FunDep (Located RdrName)) -> Annotated ())
-> Int -> [Located (FunDep (Located RdrName))] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel Located (FunDep (Located RdrName)) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LHsFunDep GhcPs]
[Located (FunDep (Located RdrName))]
fds
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markInside AnnKeywordId
GHC.AnnSemi
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InClassDecl) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$
[(SrcSpan, Annotated ())] -> Annotated ()
applyListAnnotationsLayout
([GenLocated SrcSpan (Sig GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [GenLocated SrcSpan (Sig GhcPs)]
sigs
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpan (HsBind GhcPs)] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation (LHsBinds GhcPs -> [GenLocated SrcSpan (HsBind GhcPs)]
forall a. Bag a -> [a]
GHC.bagToList LHsBinds GhcPs
meths)
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [LFamilyDecl GhcPs] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [LFamilyDecl GhcPs]
ats
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [LTyFamInstDecl GhcPs] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [LTyFamInstDecl GhcPs]
atdefs
[(SrcSpan, Annotated ())]
-> [(SrcSpan, Annotated ())] -> [(SrcSpan, Annotated ())]
forall a. [a] -> [a] -> [a]
++ [GenLocated SrcSpan DocDecl] -> [(SrcSpan, Annotated ())]
forall a. Annotate a => [Located a] -> [(SrcSpan, Annotated ())]
prepareListAnnotation [GenLocated SrcSpan DocDecl]
docs
)
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.SynDecl XSynDecl GhcPs
_ Located (IdP GhcPs)
_ (GHC.XLHsQTyVars XXLHsQTyVars GhcPs
_) LexicalFixity
_ LHsType GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyClDecl"
markAST SrcSpan
_ (GHC.DataDecl XDataDecl GhcPs
_ Located (IdP GhcPs)
_ (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
_) LexicalFixity
_ (GHC.XHsDataDefn XXHsDataDefn GhcPs
_))
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyClDecl"
markAST SrcSpan
_ (GHC.DataDecl XDataDecl GhcPs
_ Located (IdP GhcPs)
_ (GHC.XLHsQTyVars XXLHsQTyVars GhcPs
_) LexicalFixity
_ HsDataDefn GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyClDecl"
markAST SrcSpan
_ (GHC.ClassDecl XClassDecl GhcPs
_ LHsContext GhcPs
_ Located (IdP GhcPs)
_ (GHC.XLHsQTyVars XXLHsQTyVars GhcPs
_) LexicalFixity
_ [LHsFunDep GhcPs]
_ [GenLocated SrcSpan (Sig GhcPs)]
_ LHsBinds GhcPs
_ [LFamilyDecl GhcPs]
_ [LTyFamInstDecl GhcPs]
_ [GenLocated SrcSpan DocDecl]
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyClDecl"
markAST SrcSpan
_ (GHC.XTyClDecl XXTyClDecl GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"extension hit for TyClDecl"
markTypeApp :: GHC.SrcSpan -> Annotated ()
markTypeApp :: SrcSpan -> Annotated ()
markTypeApp SrcSpan
loc = do
let l :: SrcSpan
l = SrcSpan -> SrcSpan
GHC.srcSpanFirstCharacter SrcSpan
loc
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"@"
markTyClassArgs :: (Annotate a)
=> Maybe [GHC.LHsTyVarBndr GhcPs] -> GHC.LexicalFixity
-> GHC.Located a -> [GHC.LHsTypeArg GhcPs] -> Annotated ()
markTyClassArgs :: Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> HsTyPats GhcPs -> Annotated ()
markTyClassArgs Maybe [LHsTyVarBndr GhcPs]
mbndrs LexicalFixity
fixity Located a
ln HsTyPats GhcPs
tyVars = do
let
cvt :: HsArg ast ast -> Annotated ()
cvt (GHC.HsValArg ast
val) = ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ast
val
cvt (GHC.HsTypeArg SrcSpan
loc ast
typ) = do
SrcSpan -> Annotated ()
markTypeApp SrcSpan
loc
ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated ast
typ
cvt (GHC.HsArgPar SrcSpan
_ss) = Annotated ()
forall a. HasCallStack => a
undefined
(HsArg (LHsType GhcPs) (LHsType GhcPs) -> Annotated ())
-> Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located a
-> HsTyPats GhcPs
-> Annotated ()
forall a b.
Annotate a =>
(b -> Annotated ())
-> Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located a
-> [b]
-> Annotated ()
markTyClassWorker HsArg (LHsType GhcPs) (LHsType GhcPs) -> Annotated ()
forall ast ast.
(Annotate ast, Annotate ast, HasSrcSpan ast, HasSrcSpan ast,
Data (SrcSpanLess ast), Data (SrcSpanLess ast)) =>
HsArg ast ast -> Annotated ()
cvt Maybe [LHsTyVarBndr GhcPs]
mbndrs LexicalFixity
fixity Located a
ln HsTyPats GhcPs
tyVars
markTyClass :: (Data (GHC.SrcSpanLess ast), Annotate a, Annotate ast,GHC.HasSrcSpan ast)
=> Maybe [GHC.LHsTyVarBndr GhcPs] -> GHC.LexicalFixity
-> GHC.Located a -> [ast] -> Annotated ()
markTyClass :: Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> [ast] -> Annotated ()
markTyClass = (ast -> Annotated ())
-> Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located a
-> [ast]
-> Annotated ()
forall a b.
Annotate a =>
(b -> Annotated ())
-> Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located a
-> [b]
-> Annotated ()
markTyClassWorker ast -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated
markTyClassWorker :: (Annotate a)
=> (b -> Annotated ()) -> Maybe [GHC.LHsTyVarBndr GhcPs] -> GHC.LexicalFixity
-> GHC.Located a -> [b] -> Annotated ()
markTyClassWorker :: (b -> Annotated ())
-> Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located a
-> [b]
-> Annotated ()
markTyClassWorker b -> Annotated ()
markFn Maybe [LHsTyVarBndr GhcPs]
mbndrs LexicalFixity
fixity Located a
ln [b]
tyVars = do
let processBinders :: Annotated ()
processBinders =
case Maybe [LHsTyVarBndr GhcPs]
mbndrs of
Maybe [LHsTyVarBndr GhcPs]
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just [LHsTyVarBndr GhcPs]
bndrs -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LHsTyVarBndr GhcPs -> Annotated ())
-> [LHsTyVarBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsTyVarBndr GhcPs]
bndrs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
[AnnKeywordId] -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
[AnnKeywordId] -> m ()
annotationsToComments [AnnKeywordId
GHC.AnnOpenP,AnnKeywordId
GHC.AnnCloseP]
let markParens :: AnnKeywordId -> Annotated ()
markParens = if LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
GHC.Infix Bool -> Bool -> Bool
&& [b] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [b]
tyVars Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
2
then AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany
else AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional
if LexicalFixity
fixity LexicalFixity -> LexicalFixity -> Bool
forall a. Eq a => a -> a -> Bool
== LexicalFixity
GHC.Prefix
then do
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
GHC.AnnOpenP
Annotated ()
processBinders
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located a -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located a
ln
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (b -> Annotated ()) -> [b] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ b -> Annotated ()
markFn ([b] -> Annotated ()) -> [b] -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Int -> [b] -> [b]
forall a. Int -> [a] -> [a]
take Int
2 [b]
tyVars
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ([b] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [b]
tyVars Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
2) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
markParens AnnKeywordId
GHC.AnnCloseP
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (b -> Annotated ()) -> [b] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ b -> Annotated ()
markFn ([b] -> Annotated ()) -> [b] -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Int -> [b] -> [b]
forall a. Int -> [a] -> [a]
drop Int
2 [b]
tyVars
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
GHC.AnnCloseP
else do
case [b]
tyVars of
(b
x:b
y:[b]
xs) -> do
AnnKeywordId -> Annotated ()
markParens AnnKeywordId
GHC.AnnOpenP
Annotated ()
processBinders
b -> Annotated ()
markFn b
x
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
InfixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located a -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located a
ln
b -> Annotated ()
markFn b
y
AnnKeywordId -> Annotated ()
markParens AnnKeywordId
GHC.AnnCloseP
(b -> Annotated ()) -> [b] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ b -> Annotated ()
markFn [b]
xs
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
GHC.AnnCloseP
[b]
_ -> String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"markTyClass: Infix op without operands"
instance Annotate [GHC.LHsDerivingClause GHC.GhcPs] where
markAST :: SrcSpan -> [LHsDerivingClause GhcPs] -> Annotated ()
markAST SrcSpan
_ [LHsDerivingClause GhcPs]
ds = (LHsDerivingClause GhcPs -> Annotated ())
-> [LHsDerivingClause GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsDerivingClause GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsDerivingClause GhcPs]
ds
instance Annotate (GHC.HsDerivingClause GHC.GhcPs) where
markAST :: SrcSpan -> HsDerivingClause GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.HsDerivingClause XCHsDerivingClause GhcPs
_ Maybe (LDerivStrategy GhcPs)
mstrategy Located [LHsSigType GhcPs]
typs) = do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDeriving
case Maybe (LDerivStrategy GhcPs)
mstrategy of
Maybe (LDerivStrategy GhcPs)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (GHC.L SrcSpan
_ (GHC.ViaStrategy{})) -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just LDerivStrategy GhcPs
s -> LDerivStrategy GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LDerivStrategy GhcPs
s
Located [LHsSigType GhcPs] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located [LHsSigType GhcPs]
typs
case Maybe (LDerivStrategy GhcPs)
mstrategy of
Just s :: LDerivStrategy GhcPs
s@(GHC.L SrcSpan
_ (GHC.ViaStrategy{})) -> LDerivStrategy GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LDerivStrategy GhcPs
s
Maybe (LDerivStrategy GhcPs)
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markAST SrcSpan
_ (GHC.XHsDerivingClause XXHsDerivingClause GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsDerivingClause for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsDerivingClause GhcPs
x
instance Annotate (GHC.FamilyDecl GHC.GhcPs) where
markAST :: SrcSpan -> FamilyDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.FamilyDecl XCFamilyDecl GhcPs
_ FamilyInfo GhcPs
info Located (IdP GhcPs)
ln (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
tyvars) LexicalFixity
fixity LFamilyResultSig GhcPs
rsig Maybe (LInjectivityAnn GhcPs)
minj) = do
case FamilyInfo GhcPs
info of
FamilyInfo GhcPs
GHC.DataFamily -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnData
FamilyInfo GhcPs
_ -> AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnType
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnFamily
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity
-> Located RdrName
-> [LHsTyVarBndr GhcPs]
-> Annotated ()
forall ast a.
(Data (SrcSpanLess ast), Annotate a, Annotate ast,
HasSrcSpan ast) =>
Maybe [LHsTyVarBndr GhcPs]
-> LexicalFixity -> Located a -> [ast] -> Annotated ()
markTyClass Maybe [LHsTyVarBndr GhcPs]
forall a. Maybe a
Nothing LexicalFixity
fixity Located (IdP GhcPs)
Located RdrName
ln [LHsTyVarBndr GhcPs]
tyvars
case LFamilyResultSig GhcPs -> SrcSpanLess (LFamilyResultSig GhcPs)
forall a. HasSrcSpan a => a -> SrcSpanLess a
GHC.unLoc LFamilyResultSig GhcPs
rsig of
GHC.NoSig _ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
GHC.KindSig _ _ -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
LFamilyResultSig GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LFamilyResultSig GhcPs
rsig
GHC.TyVarSig _ _ -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
LFamilyResultSig GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LFamilyResultSig GhcPs
rsig
(GHC.XFamilyResultSig x) -> String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"FamilyDecl:got XFamilyResultSig for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXFamilyResultSig GhcPs
x
case Maybe (LInjectivityAnn GhcPs)
minj of
Maybe (LInjectivityAnn GhcPs)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just LInjectivityAnn GhcPs
inj -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
LInjectivityAnn GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LInjectivityAnn GhcPs
inj
case FamilyInfo GhcPs
info of
GHC.ClosedTypeFamily (Just [LTyFamInstEqn GhcPs]
eqns) -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnOpenC
[LTyFamInstEqn GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LTyFamInstEqn GhcPs]
eqns
AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnCloseC
GHC.ClosedTypeFamily Maybe [LTyFamInstEqn GhcPs]
Nothing -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnWhere
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnOpenC
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDotdot
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnCloseC
FamilyInfo GhcPs
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.FamilyDecl XCFamilyDecl GhcPs
_ FamilyInfo GhcPs
_ Located (IdP GhcPs)
_ (GHC.XLHsQTyVars XXLHsQTyVars GhcPs
_) LexicalFixity
_ LFamilyResultSig GhcPs
_ Maybe (LInjectivityAnn GhcPs)
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"got extension for FamilyDecl"
markAST SrcSpan
_ (GHC.XFamilyDecl XXFamilyDecl GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"got extension for FamilyDecl"
instance Annotate (GHC.FamilyResultSig GHC.GhcPs) where
markAST :: SrcSpan -> FamilyResultSig GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.NoSig XNoSig GhcPs
_) = () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
markAST SrcSpan
_ (GHC.KindSig XCKindSig GhcPs
_ LHsType GhcPs
k) = LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
k
markAST SrcSpan
_ (GHC.TyVarSig XTyVarSig GhcPs
_ LHsTyVarBndr GhcPs
ltv) = LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsTyVarBndr GhcPs
ltv
markAST SrcSpan
_ (GHC.XFamilyResultSig XXFamilyResultSig GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XFamilyResultSig for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXFamilyResultSig GhcPs
x
instance Annotate (GHC.InjectivityAnn GHC.GhcPs) where
markAST :: SrcSpan -> InjectivityAnn GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.InjectivityAnn Located (IdP GhcPs)
ln [Located (IdP GhcPs)]
lns) = do
Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
(Located RdrName -> Annotated ())
-> [Located RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located (IdP GhcPs)]
[Located RdrName]
lns
instance Annotate (GHC.TyFamInstEqn GHC.GhcPs) where
markAST :: SrcSpan
-> HsImplicitBndrs GhcPs (FamEqn GhcPs (LHsType GhcPs))
-> Annotated ()
markAST SrcSpan
_ (GHC.HsIB XHsIB GhcPs (FamEqn GhcPs (LHsType GhcPs))
_ FamEqn GhcPs (LHsType GhcPs)
eqn) = do
FamEqn GhcPs (LHsType GhcPs) -> Annotated ()
markFamEqn FamEqn GhcPs (LHsType GhcPs)
eqn
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.XHsImplicitBndrs XXHsImplicitBndrs GhcPs (FamEqn GhcPs (LHsType GhcPs))
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsImplicitBndrs for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsImplicitBndrs GhcPs (FamEqn GhcPs (LHsType GhcPs))
x
instance Annotate GHC.DocDecl where
markAST :: SrcSpan -> DocDecl -> Annotated ()
markAST SrcSpan
l DocDecl
v =
let str :: String
str =
case DocDecl
v of
(GHC.DocCommentNext HsDocString
ds) -> HsDocString -> String
GHC.unpackHDS HsDocString
ds
(GHC.DocCommentPrev HsDocString
ds) -> HsDocString -> String
GHC.unpackHDS HsDocString
ds
(GHC.DocCommentNamed String
_s HsDocString
ds) -> HsDocString -> String
GHC.unpackHDS HsDocString
ds
(GHC.DocGroup Int
_i HsDocString
ds) -> HsDocString -> String
GHC.unpackHDS HsDocString
ds
in
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
str Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Annotated ()
markTrailingSemi
markDataDefn :: GHC.SrcSpan -> GHC.HsDataDefn GHC.GhcPs -> Annotated ()
markDataDefn :: SrcSpan -> HsDataDefn GhcPs -> Annotated ()
markDataDefn SrcSpan
_ (GHC.HsDataDefn XCHsDataDefn GhcPs
_ NewOrData
_ LHsContext GhcPs
ctx Maybe (Located CType)
typ Maybe (LHsType GhcPs)
_mk [LConDecl GhcPs]
cons HsDeriving GhcPs
derivs) = do
LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
ctx
Maybe (Located CType) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (Located CType)
typ
if [LConDecl GhcPs] -> Bool
forall name. [LConDecl name] -> Bool
isGadt [LConDecl GhcPs]
cons
then [LConDecl GhcPs] -> Annotated ()
forall ast. Annotate ast => [Located ast] -> Annotated ()
markListWithLayout [LConDecl GhcPs]
cons
else (LConDecl GhcPs -> Annotated ())
-> Int -> [LConDecl GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LConDecl GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LConDecl GhcPs]
cons
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Deriving) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ HsDeriving GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated HsDeriving GhcPs
derivs
markDataDefn SrcSpan
_ (GHC.XHsDataDefn XXHsDataDefn GhcPs
x) = String -> Annotated ()
forall a. HasCallStack => String -> a
error (String -> Annotated ()) -> String -> Annotated ()
forall a b. (a -> b) -> a -> b
$ String
"got XHsDataDefn for:" String -> String -> String
forall a. [a] -> [a] -> [a]
++ NoExtCon -> String
forall a. Outputable a => a -> String
showGhc NoExtCon
XXHsDataDefn GhcPs
x
instance Annotate [GHC.LHsType GHC.GhcPs] where
markAST :: SrcSpan -> [LHsType GhcPs] -> Annotated ()
markAST SrcSpan
l [LHsType GhcPs]
ts = do
let
parenIfNeeded' :: AnnKeywordId -> Annotated ()
parenIfNeeded' AnnKeywordId
pa =
case [LHsType GhcPs]
ts of
[] -> if SrcSpan
l SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
GHC.noSrcSpan
then AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
pa
else AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany AnnKeywordId
pa
[GHC.L SrcSpan
_ GHC.HsForAllTy{}] -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany AnnKeywordId
pa
[GHC.L SrcSpan
_ GHC.HsQualTy{}] -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany AnnKeywordId
pa
[LHsType GhcPs
_] -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
pa
[LHsType GhcPs]
_ -> AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany AnnKeywordId
pa
parenIfNeeded'' :: AnnKeywordId -> Annotated ()
parenIfNeeded'' AnnKeywordId
pa =
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
Parens)
(AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markMany AnnKeywordId
pa)
(AnnKeywordId -> Annotated ()
parenIfNeeded' AnnKeywordId
pa)
parenIfNeeded :: AnnKeywordId -> Annotated ()
parenIfNeeded AnnKeywordId
pa =
case [LHsType GhcPs]
ts of
[GHC.L SrcSpan
_ GHC.HsParTy{}] -> AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
pa
[LHsType GhcPs]
_ -> AnnKeywordId -> Annotated ()
parenIfNeeded'' AnnKeywordId
pa
AnnKeywordId -> Annotated ()
parenIfNeeded AnnKeywordId
GHC.AnnOpenP
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ (LHsType GhcPs -> Annotated ())
-> Int -> [LHsType GhcPs] -> Annotated ()
forall t. (t -> Annotated ()) -> Int -> [t] -> Annotated ()
markListIntercalateWithFunLevel LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Int
2 [LHsType GhcPs]
ts
AnnKeywordId -> Annotated ()
parenIfNeeded AnnKeywordId
GHC.AnnCloseP
Set AstContext -> Annotated () -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
Set AstContext -> Annotated () -> Annotated () -> m ()
ifInContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
NoDarrow)
(() -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())
(if [LHsType GhcPs] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LHsType GhcPs]
ts Bool -> Bool -> Bool
&& (SrcSpan
l SrcSpan -> SrcSpan -> Bool
forall a. Eq a => a -> a -> Bool
== SrcSpan
GHC.noSrcSpan)
then AnnKeywordId -> Annotated ()
markOptional AnnKeywordId
GHC.AnnDarrow
else AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDarrow)
instance Annotate (GHC.ConDecl GHC.GhcPs) where
markAST :: SrcSpan -> ConDecl GhcPs -> Annotated ()
markAST SrcSpan
_ (GHC.ConDeclH98 XConDeclH98 GhcPs
_ Located (IdP GhcPs)
ln Located Bool
_fa [LHsTyVarBndr GhcPs]
mqtvs Maybe (LHsContext GhcPs)
mctx
HsConDeclDetails GhcPs
dets Maybe LHsDocString
_) = do
case [LHsTyVarBndr GhcPs]
mqtvs of
[] -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
[LHsTyVarBndr GhcPs]
bndrs -> do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LHsTyVarBndr GhcPs -> Annotated ())
-> [LHsTyVarBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsTyVarBndr GhcPs]
bndrs
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
case Maybe (LHsContext GhcPs)
mctx of
Just LHsContext GhcPs
ctx -> do
Set AstContext -> Annotated () -> Annotated ()
setContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
NoDarrow]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LHsContext GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsContext GhcPs
ctx
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDarrow
Maybe (LHsContext GhcPs)
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
case HsConDeclDetails GhcPs
dets of
GHC.InfixCon LHsType GhcPs
_ LHsType GhcPs
_ -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
HsConDeclDetails GhcPs
_ -> Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (IdP GhcPs)
Located RdrName
ln
Bool
-> Bool
-> [Located RdrName]
-> HsConDeclDetails GhcPs
-> Annotated ()
markHsConDeclDetails Bool
False Bool
False [Located (IdP GhcPs)
Located RdrName
ln] HsConDeclDetails GhcPs
dets
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnVbar
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.ConDeclGADT XConDeclGADT GhcPs
_ [Located (IdP GhcPs)]
lns (GHC.L SrcSpan
l Bool
forall) (GHC.HsQTvs XHsQTvs GhcPs
_ [LHsTyVarBndr GhcPs]
qvars) Maybe (LHsContext GhcPs)
mbCxt HsConDeclDetails GhcPs
args LHsType GhcPs
typ Maybe LHsDocString
_) = do
Set AstContext -> Annotated () -> Annotated ()
setContext (AstContext -> Set AstContext
forall a. a -> Set a
Set.singleton AstContext
PrefixOp) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ [Located RdrName] -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
[ast] -> Annotated ()
markListIntercalate [Located (IdP GhcPs)]
[Located RdrName]
lns
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDcolon
[AnnKeywordId] -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
[AnnKeywordId] -> m ()
annotationsToComments [AnnKeywordId
GHC.AnnOpenP]
GenLocated SrcSpan ResTyGADTHook -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated (SrcSpan -> ResTyGADTHook -> GenLocated SrcSpan ResTyGADTHook
forall l e. l -> e -> GenLocated l e
GHC.L SrcSpan
l (Bool -> [LHsTyVarBndr GhcPs] -> ResTyGADTHook
ResTyGADTHook Bool
forall [LHsTyVarBndr GhcPs]
qvars))
Maybe (LHsContext GhcPs) -> Annotated ()
forall ast. Annotate ast => Maybe (Located ast) -> Annotated ()
markMaybe Maybe (LHsContext GhcPs)
mbCxt
Bool
-> Bool
-> [Located RdrName]
-> HsConDeclDetails GhcPs
-> Annotated ()
markHsConDeclDetails Bool
False Bool
True [Located (IdP GhcPs)]
[Located RdrName]
lns HsConDeclDetails GhcPs
args
LHsType GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LHsType GhcPs
typ
AnnKeywordId -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AnnKeywordId -> m ()
markManyOptional AnnKeywordId
GHC.AnnCloseP
Annotated ()
markTrailingSemi
markAST SrcSpan
_ (GHC.ConDeclGADT XConDeclGADT GhcPs
_ [Located (IdP GhcPs)]
_ (GHC.L SrcSpan
_ Bool
_) (GHC.XLHsQTyVars XXLHsQTyVars GhcPs
_) Maybe (LHsContext GhcPs)
_ HsConDeclDetails GhcPs
_ LHsType GhcPs
_ Maybe LHsDocString
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension point in ConDecl"
markAST SrcSpan
_ (GHC.XConDecl XXConDecl GhcPs
_)
= String -> Annotated ()
forall a. HasCallStack => String -> a
error String
"hit extension point in ConDecl"
data ResTyGADTHook = ResTyGADTHook Bool [GHC.LHsTyVarBndr GHC.GhcPs]
deriving (Typeable)
deriving instance Data (ResTyGADTHook)
instance GHC.Outputable ResTyGADTHook where
ppr :: ResTyGADTHook -> SDoc
ppr (ResTyGADTHook Bool
b [LHsTyVarBndr GhcPs]
bs) = String -> SDoc
GHC.text String
"ResTyGADTHook" SDoc -> SDoc -> SDoc
GHC.<+> Bool -> SDoc
forall a. Outputable a => a -> SDoc
GHC.ppr Bool
b SDoc -> SDoc -> SDoc
GHC.<+> [LHsTyVarBndr GhcPs] -> SDoc
forall a. Outputable a => a -> SDoc
GHC.ppr [LHsTyVarBndr GhcPs]
bs
data WildCardAnon = WildCardAnon deriving (Int -> WildCardAnon -> String -> String
[WildCardAnon] -> String -> String
WildCardAnon -> String
(Int -> WildCardAnon -> String -> String)
-> (WildCardAnon -> String)
-> ([WildCardAnon] -> String -> String)
-> Show WildCardAnon
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [WildCardAnon] -> String -> String
$cshowList :: [WildCardAnon] -> String -> String
show :: WildCardAnon -> String
$cshow :: WildCardAnon -> String
showsPrec :: Int -> WildCardAnon -> String -> String
$cshowsPrec :: Int -> WildCardAnon -> String -> String
Show,Typeable WildCardAnon
DataType
Constr
Typeable WildCardAnon
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WildCardAnon -> c WildCardAnon)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WildCardAnon)
-> (WildCardAnon -> Constr)
-> (WildCardAnon -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WildCardAnon))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WildCardAnon))
-> ((forall b. Data b => b -> b) -> WildCardAnon -> WildCardAnon)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r)
-> (forall u. (forall d. Data d => d -> u) -> WildCardAnon -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> WildCardAnon -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon)
-> Data WildCardAnon
WildCardAnon -> DataType
WildCardAnon -> Constr
(forall b. Data b => b -> b) -> WildCardAnon -> WildCardAnon
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WildCardAnon -> c WildCardAnon
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WildCardAnon
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> WildCardAnon -> u
forall u. (forall d. Data d => d -> u) -> WildCardAnon -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WildCardAnon
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WildCardAnon -> c WildCardAnon
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WildCardAnon)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WildCardAnon)
$cWildCardAnon :: Constr
$tWildCardAnon :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
gmapMp :: (forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
gmapM :: (forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> WildCardAnon -> m WildCardAnon
gmapQi :: Int -> (forall d. Data d => d -> u) -> WildCardAnon -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> WildCardAnon -> u
gmapQ :: (forall d. Data d => d -> u) -> WildCardAnon -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> WildCardAnon -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> WildCardAnon -> r
gmapT :: (forall b. Data b => b -> b) -> WildCardAnon -> WildCardAnon
$cgmapT :: (forall b. Data b => b -> b) -> WildCardAnon -> WildCardAnon
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WildCardAnon)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c WildCardAnon)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c WildCardAnon)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c WildCardAnon)
dataTypeOf :: WildCardAnon -> DataType
$cdataTypeOf :: WildCardAnon -> DataType
toConstr :: WildCardAnon -> Constr
$ctoConstr :: WildCardAnon -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WildCardAnon
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c WildCardAnon
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WildCardAnon -> c WildCardAnon
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> WildCardAnon -> c WildCardAnon
$cp1Data :: Typeable WildCardAnon
Data,Typeable)
instance Annotate WildCardAnon where
markAST :: SrcSpan -> WildCardAnon -> Annotated ()
markAST SrcSpan
l WildCardAnon
WildCardAnon = do
SrcSpan -> AnnKeywordId -> String -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
SrcSpan -> AnnKeywordId -> String -> m ()
markExternal SrcSpan
l AnnKeywordId
GHC.AnnVal String
"_"
instance Annotate ResTyGADTHook where
markAST :: SrcSpan -> ResTyGADTHook -> Annotated ()
markAST SrcSpan
_ (ResTyGADTHook Bool
forall [LHsTyVarBndr GhcPs]
bndrs) = do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([LHsTyVarBndr GhcPs] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [LHsTyVarBndr GhcPs]
bndrs) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
forall (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnForall
(LHsTyVarBndr GhcPs -> Annotated ())
-> [LHsTyVarBndr GhcPs] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ LHsTyVarBndr GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [LHsTyVarBndr GhcPs]
bndrs
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
forall (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnDot
instance Annotate (GHC.HsRecField GHC.GhcPs (GHC.Located (GHC.Pat GHC.GhcPs))) where
markAST :: SrcSpan -> HsRecField GhcPs (Located (Pat GhcPs)) -> Annotated ()
markAST SrcSpan
_ (GHC.HsRecField LFieldOcc GhcPs
n Located (Pat GhcPs)
e Bool
punFlag) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LFieldOcc GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LFieldOcc GhcPs
n
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
punFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (Pat GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (Pat GhcPs)
e
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.HsRecField GHC.GhcPs (GHC.LHsExpr GHC.GhcPs)) where
markAST :: SrcSpan
-> HsRecField GhcPs (Located (HsExpr GhcPs)) -> Annotated ()
markAST SrcSpan
_ (GHC.HsRecField LFieldOcc GhcPs
n Located (HsExpr GhcPs)
e Bool
punFlag) = do
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ LFieldOcc GhcPs -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated LFieldOcc GhcPs
n
Bool -> Annotated () -> Annotated ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
punFlag (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ do
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnEqual
AstContext -> Annotated () -> Annotated ()
forall (m :: * -> *).
MonadFree AnnotationF m =>
AstContext -> Annotated () -> m ()
unsetContext AstContext
Intercalate (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ Located (HsExpr GhcPs) -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated Located (HsExpr GhcPs)
e
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate (GHC.FunDep (GHC.Located GHC.RdrName)) where
markAST :: SrcSpan -> FunDep (Located RdrName) -> Annotated ()
markAST SrcSpan
_ ([Located RdrName]
ls,[Located RdrName]
rs) = do
(Located RdrName -> Annotated ())
-> [Located RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located RdrName]
ls
AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnRarrow
(Located RdrName -> Annotated ())
-> [Located RdrName] -> Annotated ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Located RdrName -> Annotated ()
forall ast.
(Data (SrcSpanLess ast), Annotate ast, HasSrcSpan ast) =>
ast -> Annotated ()
markLocated [Located RdrName]
rs
Set AstContext -> Annotated () -> Annotated ()
inContext ([AstContext] -> Set AstContext
forall a. Ord a => [a] -> Set a
Set.fromList [AstContext
Intercalate]) (Annotated () -> Annotated ()) -> Annotated () -> Annotated ()
forall a b. (a -> b) -> a -> b
$ AnnKeywordId -> Annotated ()
mark AnnKeywordId
GHC.AnnComma
instance Annotate GHC.CType where
markAST :: SrcSpan -> CType -> Annotated ()
markAST SrcSpan
_ (GHC.CType SourceText
src Maybe Header
mh (SourceText, FastString)
f) = do
SourceText -> String -> Annotated ()
markAnnOpen SourceText
src String
""
case Maybe Header
mh of
Maybe Header
Nothing -> () -> Annotated ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just (GHC.Header SourceText
srcH FastString
_h) ->
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnHeader (SourceText -> String -> String -> String
forall a. Show a => SourceText -> a -> String -> String
toSourceTextWithSuffix SourceText
srcH String
"" String
"")
SourceText -> String -> Annotated ()
markSourceText ((SourceText, FastString) -> SourceText
forall a b. (a, b) -> a
fst (SourceText, FastString)
f) (FastString -> String
GHC.unpackFS (FastString -> String) -> FastString -> String
forall a b. (a -> b) -> a -> b
$ (SourceText, FastString) -> FastString
forall a b. (a, b) -> b
snd (SourceText, FastString)
f)
AnnKeywordId -> String -> Annotated ()
markWithString AnnKeywordId
GHC.AnnClose String
"#-}"
stringLiteralToString :: GHC.StringLiteral -> String
stringLiteralToString :: StringLiteral -> String
stringLiteralToString (GHC.StringLiteral SourceText
st FastString
fs) =
case SourceText
st of
SourceText
GHC.NoSourceText -> FastString -> String
GHC.unpackFS FastString
fs
GHC.SourceText String
src -> String
src