{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE RecordWildCards #-}

-- | Comment handling around an AST node
module HIndent.Pretty.NodeComments
  ( CommentExtraction(..)
  , emptyNodeComments
  ) where

import Data.Void
import GHC.Core.Coercion
import GHC.Data.BooleanFormula
import GHC.Hs
import GHC.Stack
import GHC.Types.Basic
import GHC.Types.Fixity
import GHC.Types.ForeignCall
import GHC.Types.Name
import GHC.Types.Name.Reader
import GHC.Types.SourceText
import GHC.Types.SrcLoc
import GHC.Unit
import HIndent.Pretty.Pragma
import HIndent.Pretty.SigBindFamily
import HIndent.Pretty.Types

-- | An interface to extract comments from an AST node.
class CommentExtraction a where
  nodeComments :: a -> NodeComments

instance CommentExtraction HsModule where
  nodeComments :: HsModule -> NodeComments
nodeComments = EpAnn AnnsModule -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments (EpAnn AnnsModule -> NodeComments)
-> (HsModule -> EpAnn AnnsModule) -> HsModule -> NodeComments
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EpAnn AnnsModule -> EpAnn AnnsModule
forall {ann}. EpAnn ann -> EpAnn ann
filterOutEofAndPragmasFromAnn (EpAnn AnnsModule -> EpAnn AnnsModule)
-> (HsModule -> EpAnn AnnsModule) -> HsModule -> EpAnn AnnsModule
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsModule -> EpAnn AnnsModule
hsmodAnn
    where
      filterOutEofAndPragmasFromAnn :: EpAnn ann -> EpAnn ann
filterOutEofAndPragmasFromAnn EpAnn {ann
EpAnnComments
Anchor
entry :: Anchor
anns :: ann
comments :: EpAnnComments
entry :: forall ann. EpAnn ann -> Anchor
anns :: forall ann. EpAnn ann -> ann
comments :: forall ann. EpAnn ann -> EpAnnComments
..} =
        EpAnn {comments :: EpAnnComments
comments = EpAnnComments -> EpAnnComments
filterOutEofAndPragmasFromComments EpAnnComments
comments, ann
Anchor
entry :: Anchor
anns :: ann
entry :: Anchor
anns :: ann
..}
      filterOutEofAndPragmasFromAnn EpAnn ann
EpAnnNotUsed = EpAnn ann
forall ann. EpAnn ann
EpAnnNotUsed
      filterOutEofAndPragmasFromComments :: EpAnnComments -> EpAnnComments
filterOutEofAndPragmasFromComments EpAnnComments
comments =
        EpaCommentsBalanced
          { priorComments :: [LEpaComment]
priorComments = [LEpaComment] -> [LEpaComment]
forall {l}. [GenLocated l EpaComment] -> [GenLocated l EpaComment]
filterOutEofAndPragmas ([LEpaComment] -> [LEpaComment]) -> [LEpaComment] -> [LEpaComment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
priorComments EpAnnComments
comments
          , followingComments :: [LEpaComment]
followingComments =
              [LEpaComment] -> [LEpaComment]
forall {l}. [GenLocated l EpaComment] -> [GenLocated l EpaComment]
filterOutEofAndPragmas ([LEpaComment] -> [LEpaComment]) -> [LEpaComment] -> [LEpaComment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
comments
          }
      filterOutEofAndPragmas :: [GenLocated l EpaComment] -> [GenLocated l EpaComment]
filterOutEofAndPragmas = (GenLocated l EpaComment -> Bool)
-> [GenLocated l EpaComment] -> [GenLocated l EpaComment]
forall a. (a -> Bool) -> [a] -> [a]
filter GenLocated l EpaComment -> Bool
forall {l}. GenLocated l EpaComment -> Bool
isNeitherEofNorPragmaComment
      isNeitherEofNorPragmaComment :: GenLocated l EpaComment -> Bool
isNeitherEofNorPragmaComment (L l
_ (EpaComment EpaCommentTok
EpaEofComment RealSrcSpan
_)) = Bool
False
      isNeitherEofNorPragmaComment (L l
_ (EpaComment EpaCommentTok
tok RealSrcSpan
_)) = Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ EpaCommentTok -> Bool
isPragma EpaCommentTok
tok

instance CommentExtraction l => CommentExtraction (GenLocated l e) where
  nodeComments :: GenLocated l e -> NodeComments
nodeComments (L l
l e
_) = l -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments l
l

instance CommentExtraction (HsDecl GhcPs) where
  nodeComments :: HsDecl GhcPs -> NodeComments
nodeComments TyClD {} = NodeComments
emptyNodeComments
  nodeComments InstD {} = NodeComments
emptyNodeComments
  nodeComments DerivD {} = NodeComments
emptyNodeComments
  nodeComments ValD {} = NodeComments
emptyNodeComments
  nodeComments SigD {} = NodeComments
emptyNodeComments
  nodeComments KindSigD {} = NodeComments
emptyNodeComments
  nodeComments DefD {} = NodeComments
emptyNodeComments
  nodeComments ForD {} = NodeComments
emptyNodeComments
  nodeComments WarningD {} = NodeComments
emptyNodeComments
  nodeComments AnnD {} = NodeComments
emptyNodeComments
  nodeComments RuleD {} = NodeComments
emptyNodeComments
  nodeComments SpliceD {} = NodeComments
emptyNodeComments
  nodeComments DocD {} =
    [Char] -> NodeComments
forall a. HasCallStack => [Char] -> a
error [Char]
"Document comments should be treated as normal ones."
  nodeComments RoleAnnotD {} = NodeComments
emptyNodeComments

instance CommentExtraction (TyClDecl GhcPs) where
  nodeComments :: TyClDecl GhcPs -> NodeComments
nodeComments FamDecl {} = NodeComments
emptyNodeComments
  nodeComments SynDecl {XSynDecl GhcPs
LIdP GhcPs
LHsType GhcPs
LexicalFixity
LHsQTyVars GhcPs
tcdSExt :: XSynDecl GhcPs
tcdLName :: LIdP GhcPs
tcdTyVars :: LHsQTyVars GhcPs
tcdFixity :: LexicalFixity
tcdRhs :: LHsType GhcPs
tcdSExt :: forall pass. TyClDecl pass -> XSynDecl pass
tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdRhs :: forall pass. TyClDecl pass -> LHsType pass
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSynDecl GhcPs
EpAnn [AddEpAnn]
tcdSExt
  nodeComments DataDecl {XDataDecl GhcPs
LIdP GhcPs
LexicalFixity
LHsQTyVars GhcPs
HsDataDefn GhcPs
tcdLName :: forall pass. TyClDecl pass -> LIdP pass
tcdTyVars :: forall pass. TyClDecl pass -> LHsQTyVars pass
tcdFixity :: forall pass. TyClDecl pass -> LexicalFixity
tcdDExt :: XDataDecl GhcPs
tcdLName :: LIdP GhcPs
tcdTyVars :: LHsQTyVars GhcPs
tcdFixity :: LexicalFixity
tcdDataDefn :: HsDataDefn GhcPs
tcdDExt :: forall pass. TyClDecl pass -> XDataDecl pass
tcdDataDefn :: forall pass. TyClDecl pass -> HsDataDefn pass
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XDataDecl GhcPs
EpAnn [AddEpAnn]
tcdDExt
  nodeComments ClassDecl {tcdCExt :: forall pass. TyClDecl pass -> XClassDecl pass
tcdCExt = (EpAnn [AddEpAnn]
x, AnnSortKey
_, LayoutInfo
_)} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpAnn [AddEpAnn]
x

instance CommentExtraction (InstDecl GhcPs) where
  nodeComments :: InstDecl GhcPs -> NodeComments
nodeComments = InstDecl GhcPs -> NodeComments
nodeCommentsInstDecl

nodeCommentsInstDecl :: InstDecl GhcPs -> NodeComments
nodeCommentsInstDecl :: InstDecl GhcPs -> NodeComments
nodeCommentsInstDecl ClsInstD {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsInstDecl DataFamInstD {} = NodeComments
emptyNodeComments
#else
nodeCommentsInstDecl DataFamInstD {..} = nodeComments dfid_ext
#endif
nodeCommentsInstDecl TyFamInstD {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsBind GhcPs) where
  nodeComments :: HsBind GhcPs -> NodeComments
nodeComments = HsBind GhcPs -> NodeComments
nodeCommentsHsBind

nodeCommentsHsBind :: HsBind GhcPs -> NodeComments
nodeCommentsHsBind :: HsBind GhcPs -> NodeComments
nodeCommentsHsBind FunBind {[CoreTickish]
XFunBind GhcPs GhcPs
LIdP GhcPs
MatchGroup GhcPs (LHsExpr GhcPs)
fun_ext :: XFunBind GhcPs GhcPs
fun_id :: LIdP GhcPs
fun_matches :: MatchGroup GhcPs (LHsExpr GhcPs)
fun_tick :: [CoreTickish]
fun_ext :: forall idL idR. HsBindLR idL idR -> XFunBind idL idR
fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_tick :: forall idL idR. HsBindLR idL idR -> [CoreTickish]
..} = GenLocated SrcSpanAnnN RdrName -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments GenLocated SrcSpanAnnN RdrName
LIdP GhcPs
fun_id
nodeCommentsHsBind PatBind {([CoreTickish], [[CoreTickish]])
XPatBind GhcPs GhcPs
LPat GhcPs
GRHSs GhcPs (LHsExpr GhcPs)
pat_ext :: XPatBind GhcPs GhcPs
pat_lhs :: LPat GhcPs
pat_rhs :: GRHSs GhcPs (LHsExpr GhcPs)
pat_ticks :: ([CoreTickish], [[CoreTickish]])
pat_ext :: forall idL idR. HsBindLR idL idR -> XPatBind idL idR
pat_lhs :: forall idL idR. HsBindLR idL idR -> LPat idL
pat_rhs :: forall idL idR. HsBindLR idL idR -> GRHSs idR (LHsExpr idR)
pat_ticks :: forall idL idR.
HsBindLR idL idR -> ([CoreTickish], [[CoreTickish]])
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPatBind GhcPs GhcPs
EpAnn [AddEpAnn]
pat_ext
nodeCommentsHsBind VarBind {} = NodeComments
emptyNodeComments
#if !MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsBind AbsBinds {} = emptyNodeComments
#endif
nodeCommentsHsBind PatSynBind {} = NodeComments
emptyNodeComments

instance CommentExtraction (Sig GhcPs) where
  nodeComments :: Sig GhcPs -> NodeComments
nodeComments (TypeSig XTypeSig GhcPs
x [LIdP GhcPs]
_ LHsSigWcType GhcPs
_) = EpAnn AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTypeSig GhcPs
EpAnn AnnSig
x
  nodeComments (PatSynSig XPatSynSig GhcPs
x [LIdP GhcPs]
_ LHsSigType GhcPs
_) = EpAnn AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPatSynSig GhcPs
EpAnn AnnSig
x
  nodeComments (ClassOpSig XClassOpSig GhcPs
x Bool
_ [LIdP GhcPs]
_ LHsSigType GhcPs
_) = EpAnn AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XClassOpSig GhcPs
EpAnn AnnSig
x
  nodeComments IdSig {} = NodeComments
emptyNodeComments
  nodeComments (FixSig XFixSig GhcPs
x FixitySig GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XFixSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (InlineSig XInlineSig GhcPs
x LIdP GhcPs
_ InlinePragma
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XInlineSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (SpecSig XSpecSig GhcPs
x LIdP GhcPs
_ [LHsSigType GhcPs]
_ InlinePragma
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSpecSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (SpecInstSig XSpecInstSig GhcPs
x SourceText
_ LHsSigType GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSpecInstSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (MinimalSig XMinimalSig GhcPs
x SourceText
_ LBooleanFormula (LIdP GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XMinimalSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (SCCFunSig XSCCFunSig GhcPs
x SourceText
_ LIdP GhcPs
_ Maybe (XRec GhcPs StringLiteral)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSCCFunSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (CompleteMatchSig XCompleteMatchSig GhcPs
x SourceText
_ XRec GhcPs [LIdP GhcPs]
_ Maybe (LIdP GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCompleteMatchSig GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction DeclSig where
  nodeComments :: DeclSig -> NodeComments
nodeComments (DeclSig Sig GhcPs
x) = Sig GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Sig GhcPs
x

instance CommentExtraction (HsDataDefn GhcPs) where
  nodeComments :: HsDataDefn GhcPs -> NodeComments
nodeComments HsDataDefn {} = NodeComments
emptyNodeComments

instance CommentExtraction (ClsInstDecl GhcPs) where
  nodeComments :: ClsInstDecl GhcPs -> NodeComments
nodeComments ClsInstDecl {cid_ext :: forall pass. ClsInstDecl pass -> XCClsInstDecl pass
cid_ext = (EpAnn [AddEpAnn]
x, AnnSortKey
_)} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpAnn [AddEpAnn]
x

instance CommentExtraction (MatchGroup GhcPs a) where
  nodeComments :: MatchGroup GhcPs a -> NodeComments
nodeComments MG {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsExpr GhcPs) where
  nodeComments :: HsExpr GhcPs -> NodeComments
nodeComments = HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr

instance CommentExtraction LambdaCase where
  nodeComments :: LambdaCase -> NodeComments
nodeComments (LambdaCase MatchGroup GhcPs (LHsExpr GhcPs)
x CaseOrCases
_) = MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
MatchGroup GhcPs (LHsExpr GhcPs)
x

nodeCommentsHsExpr :: HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr :: HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr HsVar {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (HsUnboundVar XUnboundVar GhcPs
x OccName
_) = EpAnn EpAnnUnboundVar -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XUnboundVar GhcPs
EpAnn EpAnnUnboundVar
x
#if !MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr HsConLikeOut {} = emptyNodeComments
nodeCommentsHsExpr HsRecFld {} = emptyNodeComments
#endif
nodeCommentsHsExpr (HsOverLabel XOverLabel GhcPs
x FastString
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XOverLabel GhcPs
EpAnnCO
x
nodeCommentsHsExpr (HsIPVar XIPVar GhcPs
x HsIPName
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIPVar GhcPs
EpAnnCO
x
nodeCommentsHsExpr (HsOverLit XOverLitE GhcPs
x HsOverLit GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XOverLitE GhcPs
EpAnnCO
x
nodeCommentsHsExpr (HsLit XLitE GhcPs
x HsLit GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLitE GhcPs
EpAnnCO
x
nodeCommentsHsExpr HsLam {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr (HsLamCase XLamCase GhcPs
x LamCaseVariant
_ MatchGroup GhcPs (LHsExpr GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLamCase GhcPs
EpAnn [AddEpAnn]
x
#else
nodeCommentsHsExpr (HsLamCase x _) = nodeComments x
#endif
nodeCommentsHsExpr (HsApp XApp GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XApp GhcPs
EpAnnCO
x
nodeCommentsHsExpr HsAppType {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (OpApp XOpApp GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_ LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XOpApp GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsHsExpr (NegApp XNegApp GhcPs
x LHsExpr GhcPs
_ SyntaxExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XNegApp GhcPs
EpAnn [AddEpAnn]
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr (HsPar XPar GhcPs
x LHsToken "(" GhcPs
_ LHsExpr GhcPs
_ LHsToken ")" GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPar GhcPs
EpAnnCO
x
#else
nodeCommentsHsExpr (HsPar x _) = nodeComments x
#endif
nodeCommentsHsExpr (SectionL XSectionL GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSectionL GhcPs
EpAnnCO
x
nodeCommentsHsExpr (SectionR XSectionR GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSectionR GhcPs
EpAnnCO
x
nodeCommentsHsExpr (ExplicitTuple XExplicitTuple GhcPs
x [HsTupArg GhcPs]
_ Boxity
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitTuple GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsHsExpr (ExplicitSum XExplicitSum GhcPs
x ConTag
_ ConTag
_ LHsExpr GhcPs
_) = EpAnn AnnExplicitSum -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitSum GhcPs
EpAnn AnnExplicitSum
x
nodeCommentsHsExpr (HsCase XCase GhcPs
x LHsExpr GhcPs
_ MatchGroup GhcPs (LHsExpr GhcPs)
_) = EpAnn EpAnnHsCase -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCase GhcPs
EpAnn EpAnnHsCase
x
nodeCommentsHsExpr (HsIf XIf GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_ LHsExpr GhcPs
_) = EpAnn AnnsIf -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIf GhcPs
EpAnn AnnsIf
x
nodeCommentsHsExpr (HsMultiIf XMultiIf GhcPs
x [LGRHS GhcPs (LHsExpr GhcPs)]
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XMultiIf GhcPs
EpAnn [AddEpAnn]
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr (HsLet XLet GhcPs
x LHsToken "let" GhcPs
_ HsLocalBinds GhcPs
_ LHsToken "in" GhcPs
_ LHsExpr GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLet GhcPs
EpAnnCO
x
#else
nodeCommentsHsExpr (HsLet x _ _) = nodeComments x
#endif
nodeCommentsHsExpr (HsDo XDo GhcPs
x HsDoFlavour
_ XRec GhcPs [ExprLStmt GhcPs]
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XDo GhcPs
EpAnn AnnList
x
nodeCommentsHsExpr (ExplicitList XExplicitList GhcPs
x [LHsExpr GhcPs]
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitList GhcPs
EpAnn AnnList
x
nodeCommentsHsExpr RecordCon {XRecordCon GhcPs
XRec GhcPs (ConLikeP GhcPs)
HsRecordBinds GhcPs
rcon_ext :: XRecordCon GhcPs
rcon_con :: XRec GhcPs (ConLikeP GhcPs)
rcon_flds :: HsRecordBinds GhcPs
rcon_ext :: forall p. HsExpr p -> XRecordCon p
rcon_con :: forall p. HsExpr p -> XRec p (ConLikeP p)
rcon_flds :: forall p. HsExpr p -> HsRecordBinds p
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecordCon GhcPs
EpAnn [AddEpAnn]
rcon_ext
nodeCommentsHsExpr RecordUpd {Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
XRecordUpd GhcPs
LHsExpr GhcPs
rupd_ext :: XRecordUpd GhcPs
rupd_expr :: LHsExpr GhcPs
rupd_flds :: Either [LHsRecUpdField GhcPs] [LHsRecUpdProj GhcPs]
rupd_ext :: forall p. HsExpr p -> XRecordUpd p
rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_flds :: forall p. HsExpr p -> Either [LHsRecUpdField p] [LHsRecUpdProj p]
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecordUpd GhcPs
EpAnn [AddEpAnn]
rupd_ext
nodeCommentsHsExpr HsGetField {XGetField GhcPs
LHsExpr GhcPs
XRec GhcPs (DotFieldOcc GhcPs)
gf_ext :: XGetField GhcPs
gf_expr :: LHsExpr GhcPs
gf_field :: XRec GhcPs (DotFieldOcc GhcPs)
gf_ext :: forall p. HsExpr p -> XGetField p
gf_expr :: forall p. HsExpr p -> LHsExpr p
gf_field :: forall p. HsExpr p -> XRec p (DotFieldOcc p)
..} = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XGetField GhcPs
EpAnnCO
gf_ext
nodeCommentsHsExpr HsProjection {NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
XProjection GhcPs
proj_ext :: XProjection GhcPs
proj_flds :: NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
proj_ext :: forall p. HsExpr p -> XProjection p
proj_flds :: forall p. HsExpr p -> NonEmpty (XRec p (DotFieldOcc p))
..} = EpAnn AnnProjection -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XProjection GhcPs
EpAnn AnnProjection
proj_ext
nodeCommentsHsExpr (ExprWithTySig XExprWithTySig GhcPs
x LHsExpr GhcPs
_ LHsSigWcType (NoGhcTc GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExprWithTySig GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsHsExpr (ArithSeq XArithSeq GhcPs
x Maybe (SyntaxExpr GhcPs)
_ ArithSeqInfo GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XArithSeq GhcPs
EpAnn [AddEpAnn]
x
#if !MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr (HsBracket x _) = nodeComments x
nodeCommentsHsExpr HsRnBracketOut {} = notUsedInParsedStage
nodeCommentsHsExpr HsTcBracketOut {} = notUsedInParsedStage
#endif
nodeCommentsHsExpr (HsSpliceE XSpliceE GhcPs
x HsSplice GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSpliceE GhcPs
EpAnnCO
x
nodeCommentsHsExpr (HsProc XProc GhcPs
x LPat GhcPs
_ LHsCmdTop GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XProc GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsHsExpr (HsStatic XStatic GhcPs
x LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XStatic GhcPs
EpAnn [AddEpAnn]
x
#if !MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr HsTick {} = emptyNodeComments
nodeCommentsHsExpr HsBinTick {} = emptyNodeComments
#endif
nodeCommentsHsExpr HsPragE {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsExpr HsRecSel {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (HsTypedBracket XTypedBracket GhcPs
x LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTypedBracket GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsHsExpr (HsUntypedBracket XUntypedBracket GhcPs
x HsQuote GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XUntypedBracket GhcPs
EpAnn [AddEpAnn]
x
#endif
instance CommentExtraction (HsSigType GhcPs) where
  nodeComments :: HsSigType GhcPs -> NodeComments
nodeComments HsSig {} = NodeComments
emptyNodeComments

instance CommentExtraction HsSigType' where
  nodeComments :: HsSigType' -> NodeComments
nodeComments (HsSigType' HsTypeFor
_ HsTypeDir
_ HsSig {}) = NodeComments
emptyNodeComments

instance CommentExtraction (ConDecl GhcPs) where
  nodeComments :: ConDecl GhcPs -> NodeComments
nodeComments ConDeclGADT {[LIdP GhcPs]
Maybe (LHsDoc GhcPs)
Maybe (LHsContext GhcPs)
XConDeclGADT GhcPs
LHsType GhcPs
XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
HsConDeclGADTDetails GhcPs
con_g_ext :: XConDeclGADT GhcPs
con_names :: [LIdP GhcPs]
con_bndrs :: XRec GhcPs (HsOuterSigTyVarBndrs GhcPs)
con_mb_cxt :: Maybe (LHsContext GhcPs)
con_g_args :: HsConDeclGADTDetails GhcPs
con_res_ty :: LHsType GhcPs
con_doc :: Maybe (LHsDoc GhcPs)
con_g_ext :: forall pass. ConDecl pass -> XConDeclGADT pass
con_names :: forall pass. ConDecl pass -> [LIdP pass]
con_bndrs :: forall pass. ConDecl pass -> XRec pass (HsOuterSigTyVarBndrs pass)
con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_g_args :: forall pass. ConDecl pass -> HsConDeclGADTDetails pass
con_res_ty :: forall pass. ConDecl pass -> LHsType pass
con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XConDeclGADT GhcPs
EpAnn [AddEpAnn]
con_g_ext
  nodeComments ConDeclH98 {Bool
[LHsTyVarBndr Specificity GhcPs]
Maybe (LHsDoc GhcPs)
Maybe (LHsContext GhcPs)
XConDeclH98 GhcPs
LIdP GhcPs
HsConDeclH98Details GhcPs
con_mb_cxt :: forall pass. ConDecl pass -> Maybe (LHsContext pass)
con_doc :: forall pass. ConDecl pass -> Maybe (LHsDoc pass)
con_ext :: XConDeclH98 GhcPs
con_name :: LIdP GhcPs
con_forall :: Bool
con_ex_tvs :: [LHsTyVarBndr Specificity GhcPs]
con_mb_cxt :: Maybe (LHsContext GhcPs)
con_args :: HsConDeclH98Details GhcPs
con_doc :: Maybe (LHsDoc GhcPs)
con_ext :: forall pass. ConDecl pass -> XConDeclH98 pass
con_name :: forall pass. ConDecl pass -> LIdP pass
con_forall :: forall pass. ConDecl pass -> Bool
con_ex_tvs :: forall pass. ConDecl pass -> [LHsTyVarBndr Specificity pass]
con_args :: forall pass. ConDecl pass -> HsConDeclH98Details pass
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XConDeclH98 GhcPs
EpAnn [AddEpAnn]
con_ext

instance CommentExtraction (Match GhcPs a) where
  nodeComments :: Match GhcPs a -> NodeComments
nodeComments Match {[LPat GhcPs]
XCMatch GhcPs a
GRHSs GhcPs a
HsMatchContext GhcPs
m_ext :: XCMatch GhcPs a
m_ctxt :: HsMatchContext GhcPs
m_pats :: [LPat GhcPs]
m_grhss :: GRHSs GhcPs a
m_ext :: forall p body. Match p body -> XCMatch p body
m_ctxt :: forall p body. Match p body -> HsMatchContext p
m_pats :: forall p body. Match p body -> [LPat p]
m_grhss :: forall p body. Match p body -> GRHSs p body
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCMatch GhcPs a
EpAnn [AddEpAnn]
m_ext

instance CommentExtraction
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))) where
  nodeComments :: StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
nodeComments LastStmt {} = NodeComments
emptyNodeComments
  nodeComments (BindStmt XBindStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
x LPat GhcPs
_ GenLocated SrcSpanAnnA (HsExpr GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XBindStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn [AddEpAnn]
x
  nodeComments ApplicativeStmt {} = NodeComments
emptyNodeComments
  nodeComments BodyStmt {} = NodeComments
emptyNodeComments
  nodeComments (LetStmt XLetStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
x HsLocalBinds GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLetStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn [AddEpAnn]
x
  nodeComments ParStmt {} = NodeComments
emptyNodeComments
  nodeComments TransStmt {[(IdP GhcPs, IdP GhcPs)]
[ExprLStmt GhcPs]
Maybe (LHsExpr GhcPs)
XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
LHsExpr GhcPs
SyntaxExpr GhcPs
HsExpr GhcPs
TransForm
trS_ext :: XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
trS_form :: TransForm
trS_stmts :: [ExprLStmt GhcPs]
trS_bndrs :: [(IdP GhcPs, IdP GhcPs)]
trS_using :: LHsExpr GhcPs
trS_by :: Maybe (LHsExpr GhcPs)
trS_ret :: SyntaxExpr GhcPs
trS_bind :: SyntaxExpr GhcPs
trS_fmap :: HsExpr GhcPs
trS_ext :: forall idL idR body. StmtLR idL idR body -> XTransStmt idL idR body
trS_form :: forall idL idR body. StmtLR idL idR body -> TransForm
trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_bndrs :: forall idL idR body. StmtLR idL idR body -> [(IdP idR, IdP idR)]
trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_ret :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_bind :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_fmap :: forall idL idR body. StmtLR idL idR body -> HsExpr idR
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn [AddEpAnn]
trS_ext
  nodeComments RecStmt {[IdP GhcPs]
XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
XRec
  GhcPs [LStmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
SyntaxExpr GhcPs
recS_ext :: XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
recS_stmts :: XRec
  GhcPs [LStmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))]
recS_later_ids :: [IdP GhcPs]
recS_rec_ids :: [IdP GhcPs]
recS_bind_fn :: SyntaxExpr GhcPs
recS_ret_fn :: SyntaxExpr GhcPs
recS_mfix_fn :: SyntaxExpr GhcPs
recS_ext :: forall idL idR body. StmtLR idL idR body -> XRecStmt idL idR body
recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_later_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_rec_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_bind_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_ret_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_mfix_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
..} = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
EpAnn AnnList
recS_ext

instance CommentExtraction
           (StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))) where
  nodeComments :: StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
-> NodeComments
nodeComments LastStmt {} = NodeComments
emptyNodeComments
  nodeComments (BindStmt XBindStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
x LPat GhcPs
_ GenLocated SrcSpanAnnA (HsCmd GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XBindStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
EpAnn [AddEpAnn]
x
  nodeComments ApplicativeStmt {} = NodeComments
emptyNodeComments
  nodeComments BodyStmt {} = NodeComments
emptyNodeComments
  nodeComments (LetStmt XLetStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
x HsLocalBinds GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLetStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
EpAnn [AddEpAnn]
x
  nodeComments ParStmt {} = NodeComments
emptyNodeComments
  nodeComments TransStmt {[(IdP GhcPs, IdP GhcPs)]
[ExprLStmt GhcPs]
Maybe (LHsExpr GhcPs)
XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
LHsExpr GhcPs
SyntaxExpr GhcPs
HsExpr GhcPs
TransForm
trS_ext :: forall idL idR body. StmtLR idL idR body -> XTransStmt idL idR body
trS_form :: forall idL idR body. StmtLR idL idR body -> TransForm
trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_bndrs :: forall idL idR body. StmtLR idL idR body -> [(IdP idR, IdP idR)]
trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_ret :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_bind :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_fmap :: forall idL idR body. StmtLR idL idR body -> HsExpr idR
trS_ext :: XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
trS_form :: TransForm
trS_stmts :: [ExprLStmt GhcPs]
trS_bndrs :: [(IdP GhcPs, IdP GhcPs)]
trS_using :: LHsExpr GhcPs
trS_by :: Maybe (LHsExpr GhcPs)
trS_ret :: SyntaxExpr GhcPs
trS_bind :: SyntaxExpr GhcPs
trS_fmap :: HsExpr GhcPs
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTransStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
EpAnn [AddEpAnn]
trS_ext
  nodeComments RecStmt {[IdP GhcPs]
XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
XRec
  GhcPs [LStmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))]
SyntaxExpr GhcPs
recS_ext :: forall idL idR body. StmtLR idL idR body -> XRecStmt idL idR body
recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_later_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_rec_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_bind_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_ret_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_mfix_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_ext :: XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
recS_stmts :: XRec
  GhcPs [LStmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))]
recS_later_ids :: [IdP GhcPs]
recS_rec_ids :: [IdP GhcPs]
recS_bind_fn :: SyntaxExpr GhcPs
recS_ret_fn :: SyntaxExpr GhcPs
recS_mfix_fn :: SyntaxExpr GhcPs
..} = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecStmt GhcPs GhcPs (GenLocated SrcSpanAnnA (HsCmd GhcPs))
EpAnn AnnList
recS_ext

instance CommentExtraction StmtLRInsideVerticalList where
  nodeComments :: StmtLRInsideVerticalList -> NodeComments
nodeComments (StmtLRInsideVerticalList StmtLR GhcPs GhcPs (LHsExpr GhcPs)
x) = StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
StmtLR GhcPs GhcPs (LHsExpr GhcPs)
x

-- | For pattern matching.
instance CommentExtraction
           (HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))) where
  nodeComments :: HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
-> NodeComments
nodeComments HsRecFields {} = NodeComments
emptyNodeComments

-- | For record updates
instance CommentExtraction
           (HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))) where
  nodeComments :: HsRecFields GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
nodeComments HsRecFields {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsType GhcPs) where
  nodeComments :: HsType GhcPs -> NodeComments
nodeComments = HsType' -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments (HsType' -> NodeComments)
-> (HsType GhcPs -> HsType') -> HsType GhcPs -> NodeComments
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HsTypeFor -> HsTypeDir -> HsType GhcPs -> HsType'
HsType' HsTypeFor
HsTypeForNormalDecl HsTypeDir
HsTypeNoDir

instance CommentExtraction HsType' where
  nodeComments :: HsType' -> NodeComments
nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsForAllTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsQualTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsTyVar XTyVar GhcPs
x PromotionFlag
_ LIdP GhcPs
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTyVar GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsAppTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsAppKindTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsFunTy XFunTy GhcPs
x HsArrow GhcPs
_ LHsType GhcPs
_ LHsType GhcPs
_)) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XFunTy GhcPs
EpAnnCO
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsListTy XListTy GhcPs
x LHsType GhcPs
_)) = EpAnn AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XListTy GhcPs
EpAnn AnnParen
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsTupleTy XTupleTy GhcPs
x HsTupleSort
_ [LHsType GhcPs]
_)) = EpAnn AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTupleTy GhcPs
EpAnn AnnParen
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsSumTy XSumTy GhcPs
x [LHsType GhcPs]
_)) = EpAnn AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSumTy GhcPs
EpAnn AnnParen
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsOpTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsParTy XParTy GhcPs
x LHsType GhcPs
_)) = EpAnn AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XParTy GhcPs
EpAnn AnnParen
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsIParamTy XIParamTy GhcPs
x XRec GhcPs HsIPName
_ LHsType GhcPs
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIParamTy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsStarTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsKindSig XKindSig GhcPs
x LHsType GhcPs
_ LHsType GhcPs
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XKindSig GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsSpliceTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsDocTy XDocTy GhcPs
x LHsType GhcPs
_ LHsDoc GhcPs
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XDocTy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsBangTy XBangTy GhcPs
x HsSrcBang
_ LHsType GhcPs
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XBangTy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsRecTy XRecTy GhcPs
x [LConDeclField GhcPs]
_)) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecTy GhcPs
EpAnn AnnList
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsExplicitListTy XExplicitListTy GhcPs
x PromotionFlag
_ [LHsType GhcPs]
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitListTy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ (HsExplicitTupleTy XExplicitTupleTy GhcPs
x [LHsType GhcPs]
_)) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitTupleTy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsTyLit {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ HsWildCardTy {}) = NodeComments
emptyNodeComments
  nodeComments (HsType' HsTypeFor
_ HsTypeDir
_ XHsType {}) = NodeComments
emptyNodeComments

instance CommentExtraction (GRHSs GhcPs a) where
  nodeComments :: GRHSs GhcPs a -> NodeComments
nodeComments GRHSs {[LGRHS GhcPs a]
XCGRHSs GhcPs a
HsLocalBinds GhcPs
grhssExt :: XCGRHSs GhcPs a
grhssGRHSs :: [LGRHS GhcPs a]
grhssLocalBinds :: HsLocalBinds GhcPs
grhssExt :: forall p body. GRHSs p body -> XCGRHSs p body
grhssGRHSs :: forall p body. GRHSs p body -> [LGRHS p body]
grhssLocalBinds :: forall p body. GRHSs p body -> HsLocalBinds p
..} = NodeComments {[LEpaComment]
forall {a}. [a]
commentsBefore :: [LEpaComment]
commentsOnSameLine :: forall {a}. [a]
commentsAfter :: [LEpaComment]
commentsBefore :: [LEpaComment]
commentsOnSameLine :: [LEpaComment]
commentsAfter :: [LEpaComment]
..}
    where
      commentsBefore :: [LEpaComment]
commentsBefore = EpAnnComments -> [LEpaComment]
priorComments XCGRHSs GhcPs a
EpAnnComments
grhssExt
      commentsOnSameLine :: [a]
commentsOnSameLine = []
      commentsAfter :: [LEpaComment]
commentsAfter = EpAnnComments -> [LEpaComment]
getFollowingComments XCGRHSs GhcPs a
EpAnnComments
grhssExt

instance CommentExtraction GRHSsExpr where
  nodeComments :: GRHSsExpr -> NodeComments
nodeComments (GRHSsExpr {GRHSs GhcPs (LHsExpr GhcPs)
GRHSExprType
grhssExprType :: GRHSExprType
grhssExpr :: GRHSs GhcPs (LHsExpr GhcPs)
grhssExprType :: GRHSsExpr -> GRHSExprType
grhssExpr :: GRHSsExpr -> GRHSs GhcPs (LHsExpr GhcPs)
..}) = GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
GRHSs GhcPs (LHsExpr GhcPs)
grhssExpr

instance CommentExtraction (HsMatchContext GhcPs) where
  nodeComments :: HsMatchContext GhcPs -> NodeComments
nodeComments = HsMatchContext GhcPs -> NodeComments
nodeCommentsMatchContext

nodeCommentsMatchContext :: HsMatchContext GhcPs -> NodeComments
nodeCommentsMatchContext :: HsMatchContext GhcPs -> NodeComments
nodeCommentsMatchContext FunRhs {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext LambdaExpr {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext CaseAlt {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext IfAlt {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext ArrowMatchCtxt {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext PatBindRhs {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext PatBindGuards {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext RecUpd {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext StmtCtxt {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext ThPatSplice {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext ThPatQuote {} = NodeComments
emptyNodeComments
nodeCommentsMatchContext PatSyn {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsMatchContext LamCaseAlt {} = NodeComments
emptyNodeComments
#endif
instance CommentExtraction (ParStmtBlock GhcPs GhcPs) where
  nodeComments :: ParStmtBlock GhcPs GhcPs -> NodeComments
nodeComments ParStmtBlock {} = NodeComments
emptyNodeComments

instance CommentExtraction ParStmtBlockInsideVerticalList where
  nodeComments :: ParStmtBlockInsideVerticalList -> NodeComments
nodeComments (ParStmtBlockInsideVerticalList ParStmtBlock GhcPs GhcPs
x) = ParStmtBlock GhcPs GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments ParStmtBlock GhcPs GhcPs
x

instance CommentExtraction RdrName where
  nodeComments :: RdrName -> NodeComments
nodeComments Unqual {} = NodeComments
emptyNodeComments
  nodeComments Qual {} = NodeComments
emptyNodeComments
  nodeComments Orig {} = NodeComments
emptyNodeComments
  nodeComments Exact {} = NodeComments
emptyNodeComments

instance CommentExtraction (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))) where
  nodeComments :: GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> NodeComments
nodeComments = GRHSExpr -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments (GRHSExpr -> NodeComments)
-> (GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> GRHSExpr)
-> GRHS GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GRHSExprType -> GRHS GhcPs (LHsExpr GhcPs) -> GRHSExpr
GRHSExpr GRHSExprType
GRHSExprNormal

instance CommentExtraction GRHSExpr where
  nodeComments :: GRHSExpr -> NodeComments
nodeComments (GRHSExpr {grhsExpr :: GRHSExpr -> GRHS GhcPs (LHsExpr GhcPs)
grhsExpr = (GRHS XCGRHS GhcPs (LHsExpr GhcPs)
x [ExprLStmt GhcPs]
_ LHsExpr GhcPs
_)}) = EpAnn GrhsAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCGRHS GhcPs (LHsExpr GhcPs)
EpAnn GrhsAnn
x

instance CommentExtraction GRHSProc where
  nodeComments :: GRHSProc -> NodeComments
nodeComments (GRHSProc (GRHS XCGRHS GhcPs (LHsCmd GhcPs)
x [ExprLStmt GhcPs]
_ LHsCmd GhcPs
_)) = EpAnn GrhsAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCGRHS GhcPs (LHsCmd GhcPs)
EpAnn GrhsAnn
x

instance CommentExtraction EpaCommentTok where
  nodeComments :: EpaCommentTok -> NodeComments
nodeComments = NodeComments -> EpaCommentTok -> NodeComments
forall a b. a -> b -> a
const NodeComments
emptyNodeComments

instance CommentExtraction (SpliceDecl GhcPs) where
  nodeComments :: SpliceDecl GhcPs -> NodeComments
nodeComments SpliceDecl {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsSplice GhcPs) where
  nodeComments :: HsSplice GhcPs -> NodeComments
nodeComments (HsTypedSplice XTypedSplice GhcPs
x SpliceDecoration
_ IdP GhcPs
_ LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTypedSplice GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (HsUntypedSplice XUntypedSplice GhcPs
x SpliceDecoration
_ IdP GhcPs
_ LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XUntypedSplice GhcPs
EpAnn [AddEpAnn]
x
  nodeComments HsQuasiQuote {} = NodeComments
emptyNodeComments
  nodeComments HsSpliced {} = NodeComments
emptyNodeComments

instance CommentExtraction (Pat GhcPs) where
  nodeComments :: Pat GhcPs -> NodeComments
nodeComments = Pat GhcPs -> NodeComments
nodeCommentsPat

instance CommentExtraction PatInsidePatDecl where
  nodeComments :: PatInsidePatDecl -> NodeComments
nodeComments (PatInsidePatDecl Pat GhcPs
x) = Pat GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Pat GhcPs
x

nodeCommentsPat :: Pat GhcPs -> NodeComments
nodeCommentsPat :: Pat GhcPs -> NodeComments
nodeCommentsPat WildPat {} = NodeComments
emptyNodeComments
nodeCommentsPat VarPat {} = NodeComments
emptyNodeComments
nodeCommentsPat (LazyPat XLazyPat GhcPs
x LPat GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XLazyPat GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsPat (AsPat XAsPat GhcPs
x LIdP GhcPs
_ LPat GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XAsPat GhcPs
EpAnn [AddEpAnn]
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsPat (ParPat XParPat GhcPs
x LHsToken "(" GhcPs
_ LPat GhcPs
_ LHsToken ")" GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XParPat GhcPs
EpAnnCO
x
#else
nodeCommentsPat (ParPat x _) = nodeComments x
#endif
nodeCommentsPat (BangPat XBangPat GhcPs
x LPat GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XBangPat GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsPat (ListPat XListPat GhcPs
x [LPat GhcPs]
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XListPat GhcPs
EpAnn AnnList
x
nodeCommentsPat (TuplePat XTuplePat GhcPs
x [LPat GhcPs]
_ Boxity
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTuplePat GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsPat (SumPat XSumPat GhcPs
x LPat GhcPs
_ ConTag
_ ConTag
_) = EpAnn EpAnnSumPat -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSumPat GhcPs
EpAnn EpAnnSumPat
x
nodeCommentsPat ConPat {XConPat GhcPs
XRec GhcPs (ConLikeP GhcPs)
HsConPatDetails GhcPs
pat_con_ext :: XConPat GhcPs
pat_con :: XRec GhcPs (ConLikeP GhcPs)
pat_args :: HsConPatDetails GhcPs
pat_con_ext :: forall p. Pat p -> XConPat p
pat_con :: forall p. Pat p -> XRec p (ConLikeP p)
pat_args :: forall p. Pat p -> HsConPatDetails p
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XConPat GhcPs
EpAnn [AddEpAnn]
pat_con_ext
nodeCommentsPat (ViewPat XViewPat GhcPs
x LHsExpr GhcPs
_ LPat GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XViewPat GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsPat SplicePat {} = NodeComments
emptyNodeComments
nodeCommentsPat LitPat {} = NodeComments
emptyNodeComments
nodeCommentsPat (NPat XNPat GhcPs
x XRec GhcPs (HsOverLit GhcPs)
_ Maybe (SyntaxExpr GhcPs)
_ SyntaxExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XNPat GhcPs
EpAnn [AddEpAnn]
x
nodeCommentsPat (NPlusKPat XNPlusKPat GhcPs
x LIdP GhcPs
_ XRec GhcPs (HsOverLit GhcPs)
_ HsOverLit GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = EpAnn EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XNPlusKPat GhcPs
EpAnn EpaLocation
x
nodeCommentsPat (SigPat XSigPat GhcPs
x LPat GhcPs
_ HsPatSigType (NoGhcTc GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSigPat GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction RecConPat where
  nodeComments :: RecConPat -> NodeComments
nodeComments (RecConPat HsRecFields GhcPs (LPat GhcPs)
x) = HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
-> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
HsRecFields GhcPs (LPat GhcPs)
x
#if !MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction (HsBracket GhcPs) where
  nodeComments ExpBr {} = emptyNodeComments
  nodeComments PatBr {} = emptyNodeComments
  nodeComments DecBrL {} = emptyNodeComments
  nodeComments DecBrG {} = emptyNodeComments
  nodeComments TypBr {} = emptyNodeComments
  nodeComments VarBr {} = emptyNodeComments
  nodeComments TExpBr {} = emptyNodeComments
#endif
instance CommentExtraction SigBindFamily where
  nodeComments :: SigBindFamily -> NodeComments
nodeComments (Sig Sig GhcPs
x) = Sig GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Sig GhcPs
x
  nodeComments (Bind HsBind GhcPs
x) = HsBind GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsBind GhcPs
x
  nodeComments (TypeFamily FamilyDecl GhcPs
x) = FamilyDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments FamilyDecl GhcPs
x
  nodeComments (TyFamInst TyFamInstDecl GhcPs
x) = TyFamInstDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments TyFamInstDecl GhcPs
x
  nodeComments (DataFamInst DataFamInstDecl GhcPs
x) = DataFamInstDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments DataFamInstDecl GhcPs
x

instance CommentExtraction EpaComment where
  nodeComments :: EpaComment -> NodeComments
nodeComments EpaComment {} = NodeComments
emptyNodeComments

instance CommentExtraction Anchor where
  nodeComments :: Anchor -> NodeComments
nodeComments Anchor {} = NodeComments
emptyNodeComments

instance CommentExtraction (SrcAnn a) where
  nodeComments :: SrcAnn a -> NodeComments
nodeComments (SrcSpanAnn EpAnn a
ep SrcSpan
_) = EpAnn a -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpAnn a
ep

instance CommentExtraction SrcSpan where
  nodeComments :: SrcSpan -> NodeComments
nodeComments RealSrcSpan {} = NodeComments
emptyNodeComments
  nodeComments UnhelpfulSpan {} = NodeComments
emptyNodeComments

instance CommentExtraction (EpAnn a) where
  nodeComments :: EpAnn a -> NodeComments
nodeComments (EpAnn Anchor
ann a
_ EpAnnComments
cs) = NodeComments {[LEpaComment]
commentsBefore :: [LEpaComment]
commentsOnSameLine :: [LEpaComment]
commentsAfter :: [LEpaComment]
commentsBefore :: [LEpaComment]
commentsOnSameLine :: [LEpaComment]
commentsAfter :: [LEpaComment]
..}
    where
      commentsBefore :: [LEpaComment]
commentsBefore = EpAnnComments -> [LEpaComment]
priorComments EpAnnComments
cs
      commentsOnSameLine :: [LEpaComment]
commentsOnSameLine = (LEpaComment -> Bool) -> [LEpaComment] -> [LEpaComment]
forall a. (a -> Bool) -> [a] -> [a]
filter LEpaComment -> Bool
forall {e}. GenLocated Anchor e -> Bool
isCommentOnSameLine ([LEpaComment] -> [LEpaComment]) -> [LEpaComment] -> [LEpaComment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs
      commentsAfter :: [LEpaComment]
commentsAfter =
        (LEpaComment -> Bool) -> [LEpaComment] -> [LEpaComment]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (LEpaComment -> Bool) -> LEpaComment -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LEpaComment -> Bool
forall {e}. GenLocated Anchor e -> Bool
isCommentOnSameLine) ([LEpaComment] -> [LEpaComment]) -> [LEpaComment] -> [LEpaComment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs
      isCommentOnSameLine :: GenLocated Anchor e -> Bool
isCommentOnSameLine (L Anchor
comAnn e
_) =
        RealSrcSpan -> ConTag
srcSpanEndLine (Anchor -> RealSrcSpan
anchor Anchor
ann) ConTag -> ConTag -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> ConTag
srcSpanStartLine (Anchor -> RealSrcSpan
anchor Anchor
comAnn)
  nodeComments EpAnn a
EpAnnNotUsed = NodeComments
emptyNodeComments

instance CommentExtraction (HsLocalBindsLR GhcPs GhcPs) where
  nodeComments :: HsLocalBinds GhcPs -> NodeComments
nodeComments (HsValBinds XHsValBinds GhcPs GhcPs
x HsValBindsLR GhcPs GhcPs
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsValBinds GhcPs GhcPs
EpAnn AnnList
x
  nodeComments (HsIPBinds XHsIPBinds GhcPs GhcPs
x HsIPBinds GhcPs
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsIPBinds GhcPs GhcPs
EpAnn AnnList
x
  nodeComments EmptyLocalBinds {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsValBindsLR GhcPs GhcPs) where
  nodeComments :: HsValBindsLR GhcPs GhcPs -> NodeComments
nodeComments ValBinds {} = NodeComments
emptyNodeComments
  nodeComments XValBindsLR {} = NodeComments
forall a. HasCallStack => a
notUsedInParsedStage

instance CommentExtraction (HsTupArg GhcPs) where
  nodeComments :: HsTupArg GhcPs -> NodeComments
nodeComments (Present XPresent GhcPs
x LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPresent GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (Missing XMissing GhcPs
x) = EpAnn EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XMissing GhcPs
EpAnn EpaLocation
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction RecConField where
  nodeComments :: RecConField -> NodeComments
nodeComments (RecConField HsFieldBind (LFieldOcc GhcPs) (LPat GhcPs)
x) = HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
-> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
HsFieldBind (LFieldOcc GhcPs) (LPat GhcPs)
x
#else
-- | For pattern matching against a record.
instance CommentExtraction
           (HsRecField' (FieldOcc GhcPs) (GenLocated SrcSpanAnnA (Pat GhcPs))) where
  nodeComments HsRecField {..} = nodeComments hsRecFieldAnn

-- | For record updates.
instance CommentExtraction
           (HsRecField' (FieldOcc GhcPs) (GenLocated SrcSpanAnnA (HsExpr GhcPs))) where
  nodeComments HsRecField {..} = nodeComments hsRecFieldAnn
#endif
#if MIN_VERSION_ghc_lib_parser(9,4,1)
-- | For pattern matchings against records.
instance CommentExtraction
           (HsFieldBind
              (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
              (GenLocated SrcSpanAnnA (Pat GhcPs))) where
  nodeComments :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
-> NodeComments
nodeComments HsFieldBind {Bool
GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
GenLocated SrcSpanAnnA (Pat GhcPs)
XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
hfbAnn :: XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
hfbLHS :: GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
hfbRHS :: GenLocated SrcSpanAnnA (Pat GhcPs)
hfbPun :: Bool
hfbAnn :: forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
hfbLHS :: forall lhs rhs. HsFieldBind lhs rhs -> lhs
hfbRHS :: forall lhs rhs. HsFieldBind lhs rhs -> rhs
hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
hfbAnn

-- | For record updates.
instance CommentExtraction
           (HsFieldBind
              (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
              (GenLocated SrcSpanAnnA (HsExpr GhcPs))) where
  nodeComments :: HsFieldBind
  (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (HsExpr GhcPs))
-> NodeComments
nodeComments HsFieldBind {Bool
GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
GenLocated SrcSpanAnnA (HsExpr GhcPs)
XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
hfbAnn :: forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
hfbLHS :: forall lhs rhs. HsFieldBind lhs rhs -> lhs
hfbRHS :: forall lhs rhs. HsFieldBind lhs rhs -> rhs
hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
hfbAnn :: XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
hfbLHS :: GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs)
hfbRHS :: GenLocated SrcSpanAnnA (HsExpr GhcPs)
hfbPun :: Bool
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsFieldBind (GenLocated (SrcAnn NoEpAnns) (FieldOcc GhcPs))
EpAnn [AddEpAnn]
hfbAnn
#else
instance CommentExtraction RecConField where
  nodeComments (RecConField x) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction (FieldOcc GhcPs) where
  nodeComments :: FieldOcc GhcPs -> NodeComments
nodeComments FieldOcc {} = NodeComments
emptyNodeComments
#else
instance CommentExtraction (FieldOcc GhcPs) where
  nodeComments FieldOcc {} = emptyNodeComments
#endif
-- HsConDeclH98Details
instance CommentExtraction
           (HsConDetails
              Void
              (HsScaled GhcPs (GenLocated SrcSpanAnnA (BangType GhcPs)))
              (GenLocated
                 SrcSpanAnnL
                 [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])) where
  nodeComments :: HsConDetails
  Void
  (HsScaled GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs)))
  (GenLocated
     SrcSpanAnnL [GenLocated SrcSpanAnnA (ConDeclField GhcPs)])
-> NodeComments
nodeComments PrefixCon {} = NodeComments
emptyNodeComments
  nodeComments RecCon {} = NodeComments
emptyNodeComments
  nodeComments InfixCon {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsScaled GhcPs a) where
  nodeComments :: HsScaled GhcPs a -> NodeComments
nodeComments HsScaled {} = NodeComments
emptyNodeComments

instance CommentExtraction (ConDeclField GhcPs) where
  nodeComments :: ConDeclField GhcPs -> NodeComments
nodeComments ConDeclField {[LFieldOcc GhcPs]
Maybe (LHsDoc GhcPs)
XConDeclField GhcPs
LHsType GhcPs
cd_fld_ext :: XConDeclField GhcPs
cd_fld_names :: [LFieldOcc GhcPs]
cd_fld_type :: LHsType GhcPs
cd_fld_doc :: Maybe (LHsDoc GhcPs)
cd_fld_ext :: forall pass. ConDeclField pass -> XConDeclField pass
cd_fld_names :: forall pass. ConDeclField pass -> [LFieldOcc pass]
cd_fld_type :: forall pass. ConDeclField pass -> LBangType pass
cd_fld_doc :: forall pass. ConDeclField pass -> Maybe (LHsDoc pass)
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XConDeclField GhcPs
EpAnn [AddEpAnn]
cd_fld_ext

instance CommentExtraction InfixExpr where
  nodeComments :: InfixExpr -> NodeComments
nodeComments (InfixExpr LHsExpr GhcPs
x) = GenLocated SrcSpanAnnA (HsExpr GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments GenLocated SrcSpanAnnA (HsExpr GhcPs)
LHsExpr GhcPs
x

instance CommentExtraction InfixApp where
  nodeComments :: InfixApp -> NodeComments
nodeComments InfixApp {} = NodeComments
emptyNodeComments

instance CommentExtraction (BooleanFormula a) where
  nodeComments :: BooleanFormula a -> NodeComments
nodeComments Var {} = NodeComments
emptyNodeComments
  nodeComments And {} = NodeComments
emptyNodeComments
  nodeComments Or {} = NodeComments
emptyNodeComments
  nodeComments Parens {} = NodeComments
emptyNodeComments

instance CommentExtraction (FieldLabelStrings GhcPs) where
  nodeComments :: FieldLabelStrings GhcPs -> NodeComments
nodeComments FieldLabelStrings {} = NodeComments
emptyNodeComments

instance CommentExtraction (AmbiguousFieldOcc GhcPs) where
  nodeComments :: AmbiguousFieldOcc GhcPs -> NodeComments
nodeComments Unambiguous {} = NodeComments
emptyNodeComments
  nodeComments Ambiguous {} = NodeComments
emptyNodeComments

instance CommentExtraction (ImportDecl GhcPs) where
  nodeComments :: ImportDecl GhcPs -> NodeComments
nodeComments ImportDecl {Bool
Maybe (Bool, XRec GhcPs [LIE GhcPs])
Maybe (XRec GhcPs ModuleName)
IsBootInterface
SourceText
XCImportDecl GhcPs
XRec GhcPs ModuleName
ImportDeclPkgQual GhcPs
ImportDeclQualifiedStyle
ideclExt :: XCImportDecl GhcPs
ideclSourceSrc :: SourceText
ideclName :: XRec GhcPs ModuleName
ideclPkgQual :: ImportDeclPkgQual GhcPs
ideclSource :: IsBootInterface
ideclSafe :: Bool
ideclQualified :: ImportDeclQualifiedStyle
ideclImplicit :: Bool
ideclAs :: Maybe (XRec GhcPs ModuleName)
ideclHiding :: Maybe (Bool, XRec GhcPs [LIE GhcPs])
ideclExt :: forall pass. ImportDecl pass -> XCImportDecl pass
ideclSourceSrc :: forall pass. ImportDecl pass -> SourceText
ideclName :: forall pass. ImportDecl pass -> XRec pass ModuleName
ideclPkgQual :: forall pass. ImportDecl pass -> ImportDeclPkgQual pass
ideclSource :: forall pass. ImportDecl pass -> IsBootInterface
ideclSafe :: forall pass. ImportDecl pass -> Bool
ideclQualified :: forall pass. ImportDecl pass -> ImportDeclQualifiedStyle
ideclImplicit :: forall pass. ImportDecl pass -> Bool
ideclAs :: forall pass. ImportDecl pass -> Maybe (XRec pass ModuleName)
ideclHiding :: forall pass. ImportDecl pass -> Maybe (Bool, XRec pass [LIE pass])
..} = EpAnn EpAnnImportDecl -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCImportDecl GhcPs
EpAnn EpAnnImportDecl
ideclExt

instance CommentExtraction (HsDerivingClause GhcPs) where
  nodeComments :: HsDerivingClause GhcPs -> NodeComments
nodeComments HsDerivingClause {Maybe (LDerivStrategy GhcPs)
XCHsDerivingClause GhcPs
LDerivClauseTys GhcPs
deriv_clause_ext :: XCHsDerivingClause GhcPs
deriv_clause_strategy :: Maybe (LDerivStrategy GhcPs)
deriv_clause_tys :: LDerivClauseTys GhcPs
deriv_clause_ext :: forall pass. HsDerivingClause pass -> XCHsDerivingClause pass
deriv_clause_strategy :: forall pass. HsDerivingClause pass -> Maybe (LDerivStrategy pass)
deriv_clause_tys :: forall pass. HsDerivingClause pass -> LDerivClauseTys pass
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCHsDerivingClause GhcPs
EpAnn [AddEpAnn]
deriv_clause_ext

instance CommentExtraction (DerivClauseTys GhcPs) where
  nodeComments :: DerivClauseTys GhcPs -> NodeComments
nodeComments DctSingle {} = NodeComments
emptyNodeComments
  nodeComments DctMulti {} = NodeComments
emptyNodeComments

instance CommentExtraction OverlapMode where
  nodeComments :: OverlapMode -> NodeComments
nodeComments NoOverlap {} = NodeComments
emptyNodeComments
  nodeComments Overlappable {} = NodeComments
emptyNodeComments
  nodeComments Overlapping {} = NodeComments
emptyNodeComments
  nodeComments Overlaps {} = NodeComments
emptyNodeComments
  nodeComments Incoherent {} = NodeComments
emptyNodeComments

instance CommentExtraction StringLiteral where
  nodeComments :: StringLiteral -> NodeComments
nodeComments StringLiteral {} = NodeComments
emptyNodeComments

-- | This instance is for type family declarations inside a class declaration.
instance CommentExtraction (FamilyDecl GhcPs) where
  nodeComments :: FamilyDecl GhcPs -> NodeComments
nodeComments FamilyDecl {Maybe (LInjectivityAnn GhcPs)
TopLevelFlag
XCFamilyDecl GhcPs
LIdP GhcPs
LFamilyResultSig GhcPs
LexicalFixity
LHsQTyVars GhcPs
FamilyInfo GhcPs
fdExt :: XCFamilyDecl GhcPs
fdInfo :: FamilyInfo GhcPs
fdTopLevel :: TopLevelFlag
fdLName :: LIdP GhcPs
fdTyVars :: LHsQTyVars GhcPs
fdFixity :: LexicalFixity
fdResultSig :: LFamilyResultSig GhcPs
fdInjectivityAnn :: Maybe (LInjectivityAnn GhcPs)
fdExt :: forall pass. FamilyDecl pass -> XCFamilyDecl pass
fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdTopLevel :: forall pass. FamilyDecl pass -> TopLevelFlag
fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdFixity :: forall pass. FamilyDecl pass -> LexicalFixity
fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCFamilyDecl GhcPs
EpAnn [AddEpAnn]
fdExt

instance CommentExtraction (FamilyResultSig GhcPs) where
  nodeComments :: FamilyResultSig GhcPs -> NodeComments
nodeComments NoSig {} = NodeComments
emptyNodeComments
  nodeComments KindSig {} = NodeComments
emptyNodeComments
  nodeComments TyVarSig {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsTyVarBndr a GhcPs) where
  nodeComments :: HsTyVarBndr a GhcPs -> NodeComments
nodeComments (UserTyVar XUserTyVar GhcPs
x a
_ LIdP GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XUserTyVar GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (KindedTyVar XKindedTyVar GhcPs
x a
_ LIdP GhcPs
_ LHsType GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XKindedTyVar GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction (InjectivityAnn GhcPs) where
  nodeComments :: InjectivityAnn GhcPs -> NodeComments
nodeComments (InjectivityAnn XCInjectivityAnn GhcPs
x LIdP GhcPs
_ [LIdP GhcPs]
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCInjectivityAnn GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction (ArithSeqInfo GhcPs) where
  nodeComments :: ArithSeqInfo GhcPs -> NodeComments
nodeComments From {} = NodeComments
emptyNodeComments
  nodeComments FromThen {} = NodeComments
emptyNodeComments
  nodeComments FromTo {} = NodeComments
emptyNodeComments
  nodeComments FromThenTo {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsForAllTelescope GhcPs) where
  nodeComments :: HsForAllTelescope GhcPs -> NodeComments
nodeComments HsForAllVis {[LHsTyVarBndr () GhcPs]
XHsForAllVis GhcPs
hsf_xvis :: XHsForAllVis GhcPs
hsf_vis_bndrs :: [LHsTyVarBndr () GhcPs]
hsf_xvis :: forall pass. HsForAllTelescope pass -> XHsForAllVis pass
hsf_vis_bndrs :: forall pass. HsForAllTelescope pass -> [LHsTyVarBndr () pass]
..} = EpAnnForallTy -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsForAllVis GhcPs
EpAnnForallTy
hsf_xvis
  nodeComments HsForAllInvis {[LHsTyVarBndr Specificity GhcPs]
XHsForAllInvis GhcPs
hsf_xinvis :: XHsForAllInvis GhcPs
hsf_invis_bndrs :: [LHsTyVarBndr Specificity GhcPs]
hsf_xinvis :: forall pass. HsForAllTelescope pass -> XHsForAllInvis pass
hsf_invis_bndrs :: forall pass.
HsForAllTelescope pass -> [LHsTyVarBndr Specificity pass]
..} = EpAnnForallTy -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsForAllInvis GhcPs
EpAnnForallTy
hsf_xinvis

instance CommentExtraction InfixOp where
  nodeComments :: InfixOp -> NodeComments
nodeComments (InfixOp RdrName
x) = RdrName -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments RdrName
x

instance CommentExtraction PrefixOp where
  nodeComments :: PrefixOp -> NodeComments
nodeComments (PrefixOp RdrName
x) = RdrName -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments RdrName
x

instance CommentExtraction Context where
  nodeComments :: Context -> NodeComments
nodeComments Context {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction HorizontalContext where
  nodeComments :: HorizontalContext -> NodeComments
nodeComments HorizontalContext {} = NodeComments
emptyNodeComments

instance CommentExtraction VerticalContext where
  nodeComments :: VerticalContext -> NodeComments
nodeComments VerticalContext {} = NodeComments
emptyNodeComments
#else
instance CommentExtraction HorizontalContext where
  nodeComments HorizontalContext {} = emptyNodeComments

instance CommentExtraction VerticalContext where
  nodeComments VerticalContext {} = emptyNodeComments
#endif
-- Wrap a value of this type with 'ModulenameWithPrefix' to print it with
-- the "module " prefix.
instance CommentExtraction ModuleName where
  nodeComments :: ModuleName -> NodeComments
nodeComments = NodeComments -> ModuleName -> NodeComments
forall a b. a -> b -> a
const NodeComments
emptyNodeComments

instance CommentExtraction ModuleNameWithPrefix where
  nodeComments :: ModuleNameWithPrefix -> NodeComments
nodeComments ModuleNameWithPrefix {} = NodeComments
emptyNodeComments

instance CommentExtraction (IE GhcPs) where
  nodeComments :: IE GhcPs -> NodeComments
nodeComments IEVar {} = NodeComments
emptyNodeComments
  nodeComments (IEThingAbs XIEThingAbs GhcPs
x LIEWrappedName (IdP GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIEThingAbs GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (IEThingAll XIEThingAll GhcPs
x LIEWrappedName (IdP GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIEThingAll GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (IEThingWith XIEThingWith GhcPs
x LIEWrappedName (IdP GhcPs)
_ IEWildcard
_ [LIEWrappedName (IdP GhcPs)]
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIEThingWith GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (IEModuleContents XIEModuleContents GhcPs
x XRec GhcPs ModuleName
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIEModuleContents GhcPs
EpAnn [AddEpAnn]
x
  nodeComments IEGroup {} = NodeComments
emptyNodeComments
  nodeComments IEDoc {} = NodeComments
emptyNodeComments
  nodeComments IEDocNamed {} = NodeComments
emptyNodeComments

instance CommentExtraction
           (FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))) where
  nodeComments :: FamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> NodeComments
nodeComments FamEqn {HsTyPats GhcPs
GenLocated SrcSpanAnnA (HsType GhcPs)
XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
LIdP GhcPs
LexicalFixity
HsOuterFamEqnTyVarBndrs GhcPs
feqn_ext :: XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
feqn_tycon :: LIdP GhcPs
feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_pats :: HsTyPats GhcPs
feqn_fixity :: LexicalFixity
feqn_rhs :: GenLocated SrcSpanAnnA (HsType GhcPs)
feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCFamEqn GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
EpAnn [AddEpAnn]
feqn_ext

instance CommentExtraction FamEqn' where
  nodeComments :: FamEqn' -> NodeComments
nodeComments FamEqn' {FamEqn GhcPs (HsDataDefn GhcPs)
DataFamInstDeclFor
famEqnFor :: DataFamInstDeclFor
famEqn :: FamEqn GhcPs (HsDataDefn GhcPs)
famEqnFor :: FamEqn' -> DataFamInstDeclFor
famEqn :: FamEqn' -> FamEqn GhcPs (HsDataDefn GhcPs)
..} = FamEqn GhcPs (HsDataDefn GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments FamEqn GhcPs (HsDataDefn GhcPs)
famEqn

-- | Pretty-print a data instance.
instance CommentExtraction (FamEqn GhcPs (HsDataDefn GhcPs)) where
  nodeComments :: FamEqn GhcPs (HsDataDefn GhcPs) -> NodeComments
nodeComments FamEqn {HsTyPats GhcPs
XCFamEqn GhcPs (HsDataDefn GhcPs)
LIdP GhcPs
LexicalFixity
HsOuterFamEqnTyVarBndrs GhcPs
HsDataDefn GhcPs
feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsTyPats pass
feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_ext :: XCFamEqn GhcPs (HsDataDefn GhcPs)
feqn_tycon :: LIdP GhcPs
feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_pats :: HsTyPats GhcPs
feqn_fixity :: LexicalFixity
feqn_rhs :: HsDataDefn GhcPs
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCFamEqn GhcPs (HsDataDefn GhcPs)
EpAnn [AddEpAnn]
feqn_ext

-- | HsArg (LHsType GhcPs) (LHsType GhcPs)
instance CommentExtraction
           (HsArg
              (GenLocated SrcSpanAnnA (HsType GhcPs))
              (GenLocated SrcSpanAnnA (HsType GhcPs))) where
  nodeComments :: HsArg
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
-> NodeComments
nodeComments HsValArg {} = NodeComments
emptyNodeComments
  nodeComments HsTypeArg {} = NodeComments
emptyNodeComments
  nodeComments HsArgPar {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction (HsQuote GhcPs) where
  nodeComments :: HsQuote GhcPs -> NodeComments
nodeComments ExpBr {} = NodeComments
emptyNodeComments
  nodeComments PatBr {} = NodeComments
emptyNodeComments
  nodeComments DecBrL {} = NodeComments
emptyNodeComments
  nodeComments DecBrG {} = NodeComments
emptyNodeComments
  nodeComments TypBr {} = NodeComments
emptyNodeComments
  nodeComments VarBr {} = NodeComments
emptyNodeComments
#endif
instance CommentExtraction (WarnDecls GhcPs) where
  nodeComments :: WarnDecls GhcPs -> NodeComments
nodeComments Warnings {[LWarnDecl GhcPs]
SourceText
XWarnings GhcPs
wd_ext :: XWarnings GhcPs
wd_src :: SourceText
wd_warnings :: [LWarnDecl GhcPs]
wd_ext :: forall pass. WarnDecls pass -> XWarnings pass
wd_src :: forall pass. WarnDecls pass -> SourceText
wd_warnings :: forall pass. WarnDecls pass -> [LWarnDecl pass]
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XWarnings GhcPs
EpAnn [AddEpAnn]
wd_ext

instance CommentExtraction (WarnDecl GhcPs) where
  nodeComments :: WarnDecl GhcPs -> NodeComments
nodeComments (Warning XWarning GhcPs
x [LIdP GhcPs]
_ WarningTxt GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XWarning GhcPs
EpAnn [AddEpAnn]
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction (WithHsDocIdentifiers StringLiteral GhcPs) where
  nodeComments :: WithHsDocIdentifiers StringLiteral GhcPs -> NodeComments
nodeComments WithHsDocIdentifiers {} = NodeComments
emptyNodeComments
#endif
-- | 'Pretty' for 'LIEWrappedName (IdP GhcPs)'
instance CommentExtraction (IEWrappedName RdrName) where
  nodeComments :: IEWrappedName RdrName -> NodeComments
nodeComments IEName {} = NodeComments
emptyNodeComments
  nodeComments IEPattern {} = NodeComments
emptyNodeComments
  nodeComments IEType {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
instance CommentExtraction (DotFieldOcc GhcPs) where
  nodeComments :: DotFieldOcc GhcPs -> NodeComments
nodeComments DotFieldOcc {XCDotFieldOcc GhcPs
XRec GhcPs FastString
dfoExt :: XCDotFieldOcc GhcPs
dfoLabel :: XRec GhcPs FastString
dfoExt :: forall p. DotFieldOcc p -> XCDotFieldOcc p
dfoLabel :: forall p. DotFieldOcc p -> XRec p FastString
..} = EpAnn AnnFieldLabel -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCDotFieldOcc GhcPs
EpAnn AnnFieldLabel
dfoExt
#else
instance CommentExtraction (HsFieldLabel GhcPs) where
  nodeComments HsFieldLabel {..} = nodeComments hflExt
#endif
instance CommentExtraction (RuleDecls GhcPs) where
  nodeComments :: RuleDecls GhcPs -> NodeComments
nodeComments HsRules {[LRuleDecl GhcPs]
SourceText
XCRuleDecls GhcPs
rds_ext :: XCRuleDecls GhcPs
rds_src :: SourceText
rds_rules :: [LRuleDecl GhcPs]
rds_ext :: forall pass. RuleDecls pass -> XCRuleDecls pass
rds_src :: forall pass. RuleDecls pass -> SourceText
rds_rules :: forall pass. RuleDecls pass -> [LRuleDecl pass]
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCRuleDecls GhcPs
EpAnn [AddEpAnn]
rds_ext

instance CommentExtraction (RuleDecl GhcPs) where
  nodeComments :: RuleDecl GhcPs -> NodeComments
nodeComments HsRule {[LRuleBndr GhcPs]
Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
Activation
XHsRule GhcPs
XRec GhcPs (SourceText, FastString)
LHsExpr GhcPs
rd_ext :: XHsRule GhcPs
rd_name :: XRec GhcPs (SourceText, FastString)
rd_act :: Activation
rd_tyvs :: Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
rd_tmvs :: [LRuleBndr GhcPs]
rd_lhs :: LHsExpr GhcPs
rd_rhs :: LHsExpr GhcPs
rd_ext :: forall pass. RuleDecl pass -> XHsRule pass
rd_name :: forall pass. RuleDecl pass -> XRec pass (SourceText, FastString)
rd_act :: forall pass. RuleDecl pass -> Activation
rd_tyvs :: forall pass.
RuleDecl pass -> Maybe [LHsTyVarBndr () (NoGhcTc pass)]
rd_tmvs :: forall pass. RuleDecl pass -> [LRuleBndr pass]
rd_lhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
rd_rhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
..} = EpAnn HsRuleAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsRule GhcPs
EpAnn HsRuleAnn
rd_ext

instance CommentExtraction OccName where
  nodeComments :: OccName -> NodeComments
nodeComments = NodeComments -> OccName -> NodeComments
forall a b. a -> b -> a
const NodeComments
emptyNodeComments

instance CommentExtraction (DerivDecl GhcPs) where
  nodeComments :: DerivDecl GhcPs -> NodeComments
nodeComments DerivDecl {Maybe (XRec GhcPs OverlapMode)
Maybe (LDerivStrategy GhcPs)
XCDerivDecl GhcPs
LHsSigWcType GhcPs
deriv_ext :: XCDerivDecl GhcPs
deriv_type :: LHsSigWcType GhcPs
deriv_strategy :: Maybe (LDerivStrategy GhcPs)
deriv_overlap_mode :: Maybe (XRec GhcPs OverlapMode)
deriv_ext :: forall pass. DerivDecl pass -> XCDerivDecl pass
deriv_type :: forall pass. DerivDecl pass -> LHsSigWcType pass
deriv_strategy :: forall pass. DerivDecl pass -> Maybe (LDerivStrategy pass)
deriv_overlap_mode :: forall pass. DerivDecl pass -> Maybe (XRec pass OverlapMode)
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCDerivDecl GhcPs
EpAnn [AddEpAnn]
deriv_ext

-- | 'Pretty' for 'LHsSigWcType GhcPs'.
instance CommentExtraction
           (HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))) where
  nodeComments :: HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsSigType GhcPs))
-> NodeComments
nodeComments HsWC {} = NodeComments
emptyNodeComments

-- | 'Pretty' for 'LHsWcType'
instance CommentExtraction
           (HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))) where
  nodeComments :: HsWildCardBndrs GhcPs (GenLocated SrcSpanAnnA (HsType GhcPs))
-> NodeComments
nodeComments HsWC {} = NodeComments
emptyNodeComments

instance CommentExtraction (StandaloneKindSig GhcPs) where
  nodeComments :: StandaloneKindSig GhcPs -> NodeComments
nodeComments (StandaloneKindSig XStandaloneKindSig GhcPs
x LIdP GhcPs
_ LHsSigType GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XStandaloneKindSig GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction (DefaultDecl GhcPs) where
  nodeComments :: DefaultDecl GhcPs -> NodeComments
nodeComments (DefaultDecl XCDefaultDecl GhcPs
x [LHsType GhcPs]
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCDefaultDecl GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction (ForeignDecl GhcPs) where
  nodeComments :: ForeignDecl GhcPs -> NodeComments
nodeComments ForeignImport {XForeignImport GhcPs
LIdP GhcPs
LHsSigType GhcPs
ForeignImport
fd_i_ext :: XForeignImport GhcPs
fd_name :: LIdP GhcPs
fd_sig_ty :: LHsSigType GhcPs
fd_fi :: ForeignImport
fd_i_ext :: forall pass. ForeignDecl pass -> XForeignImport pass
fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_fi :: forall pass. ForeignDecl pass -> ForeignImport
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XForeignImport GhcPs
EpAnn [AddEpAnn]
fd_i_ext
  nodeComments ForeignExport {XForeignExport GhcPs
LIdP GhcPs
LHsSigType GhcPs
ForeignExport
fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_e_ext :: XForeignExport GhcPs
fd_name :: LIdP GhcPs
fd_sig_ty :: LHsSigType GhcPs
fd_fe :: ForeignExport
fd_e_ext :: forall pass. ForeignDecl pass -> XForeignExport pass
fd_fe :: forall pass. ForeignDecl pass -> ForeignExport
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XForeignExport GhcPs
EpAnn [AddEpAnn]
fd_e_ext

instance CommentExtraction ForeignImport where
  nodeComments :: ForeignImport -> NodeComments
nodeComments CImport {} = NodeComments
emptyNodeComments

instance CommentExtraction ForeignExport where
  nodeComments :: ForeignExport -> NodeComments
nodeComments CExport {} = NodeComments
emptyNodeComments

instance CommentExtraction CExportSpec where
  nodeComments :: CExportSpec -> NodeComments
nodeComments CExportStatic {} = NodeComments
emptyNodeComments

instance CommentExtraction Safety where
  nodeComments :: Safety -> NodeComments
nodeComments Safety
PlaySafe = NodeComments
emptyNodeComments
  nodeComments Safety
PlayInterruptible = NodeComments
emptyNodeComments
  nodeComments Safety
PlayRisky = NodeComments
emptyNodeComments

instance CommentExtraction (AnnDecl GhcPs) where
  nodeComments :: AnnDecl GhcPs -> NodeComments
nodeComments (HsAnnotation XHsAnnotation GhcPs
x SourceText
_ AnnProvenance GhcPs
_ LHsExpr GhcPs
_) = EpAnn AnnPragma -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsAnnotation GhcPs
EpAnn AnnPragma
x

instance CommentExtraction (RoleAnnotDecl GhcPs) where
  nodeComments :: RoleAnnotDecl GhcPs -> NodeComments
nodeComments (RoleAnnotDecl XCRoleAnnotDecl GhcPs
x LIdP GhcPs
_ [XRec GhcPs (Maybe Role)]
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCRoleAnnotDecl GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction Role where
  nodeComments :: Role -> NodeComments
nodeComments Role
Nominal = NodeComments
emptyNodeComments
  nodeComments Role
Representational = NodeComments
emptyNodeComments
  nodeComments Role
Phantom = NodeComments
emptyNodeComments

instance CommentExtraction (TyFamInstDecl GhcPs) where
  nodeComments :: TyFamInstDecl GhcPs -> NodeComments
nodeComments TyFamInstDecl {XCTyFamInstDecl GhcPs
TyFamInstEqn GhcPs
tfid_xtn :: XCTyFamInstDecl GhcPs
tfid_eqn :: TyFamInstEqn GhcPs
tfid_xtn :: forall pass. TyFamInstDecl pass -> XCTyFamInstDecl pass
tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCTyFamInstDecl GhcPs
EpAnn [AddEpAnn]
tfid_xtn

instance CommentExtraction TopLevelTyFamInstDecl where
  nodeComments :: TopLevelTyFamInstDecl -> NodeComments
nodeComments (TopLevelTyFamInstDecl TyFamInstDecl GhcPs
x) = TyFamInstDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments TyFamInstDecl GhcPs
x

instance CommentExtraction (DataFamInstDecl GhcPs) where
  nodeComments :: DataFamInstDecl GhcPs -> NodeComments
nodeComments DataFamInstDecl {} = NodeComments
emptyNodeComments

instance CommentExtraction DataFamInstDecl' where
  nodeComments :: DataFamInstDecl' -> NodeComments
nodeComments DataFamInstDecl' {DataFamInstDecl GhcPs
DataFamInstDeclFor
dataFamInstDeclFor :: DataFamInstDeclFor
dataFamInstDecl :: DataFamInstDecl GhcPs
dataFamInstDeclFor :: DataFamInstDecl' -> DataFamInstDeclFor
dataFamInstDecl :: DataFamInstDecl' -> DataFamInstDecl GhcPs
..} = DataFamInstDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments DataFamInstDecl GhcPs
dataFamInstDecl

instance CommentExtraction (PatSynBind GhcPs GhcPs) where
  nodeComments :: PatSynBind GhcPs GhcPs -> NodeComments
nodeComments PSB {XPSB GhcPs GhcPs
LIdP GhcPs
LPat GhcPs
HsPatSynDetails GhcPs
HsPatSynDir GhcPs
psb_ext :: XPSB GhcPs GhcPs
psb_id :: LIdP GhcPs
psb_args :: HsPatSynDetails GhcPs
psb_def :: LPat GhcPs
psb_dir :: HsPatSynDir GhcPs
psb_ext :: forall idL idR. PatSynBind idL idR -> XPSB idL idR
psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
..} = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPSB GhcPs GhcPs
EpAnn [AddEpAnn]
psb_ext

-- | 'Pretty' for 'HsPatSynDetails'.
instance CommentExtraction
           (HsConDetails
              Void
              (GenLocated SrcSpanAnnN RdrName)
              [RecordPatSynField GhcPs]) where
  nodeComments :: HsConDetails
  Void (GenLocated SrcSpanAnnN RdrName) [RecordPatSynField GhcPs]
-> NodeComments
nodeComments PrefixCon {} = NodeComments
emptyNodeComments
  nodeComments RecCon {} = NodeComments
emptyNodeComments
  nodeComments InfixCon {} = NodeComments
emptyNodeComments

instance CommentExtraction (FixitySig GhcPs) where
  nodeComments :: FixitySig GhcPs -> NodeComments
nodeComments FixitySig {} = NodeComments
emptyNodeComments

instance CommentExtraction Fixity where
  nodeComments :: Fixity -> NodeComments
nodeComments Fixity {} = NodeComments
emptyNodeComments

instance CommentExtraction FixityDirection where
  nodeComments :: FixityDirection -> NodeComments
nodeComments InfixL {} = NodeComments
emptyNodeComments
  nodeComments InfixR {} = NodeComments
emptyNodeComments
  nodeComments InfixN {} = NodeComments
emptyNodeComments

instance CommentExtraction InlinePragma where
  nodeComments :: InlinePragma -> NodeComments
nodeComments InlinePragma {} = NodeComments
emptyNodeComments

instance CommentExtraction InlineSpec where
  nodeComments :: InlineSpec -> NodeComments
nodeComments = InlineSpec -> NodeComments
nodeCommentsInlineSpec

nodeCommentsInlineSpec :: InlineSpec -> NodeComments
nodeCommentsInlineSpec :: InlineSpec -> NodeComments
nodeCommentsInlineSpec Inline {} = NodeComments
emptyNodeComments
nodeCommentsInlineSpec Inlinable {} = NodeComments
emptyNodeComments
nodeCommentsInlineSpec NoInline {} = NodeComments
emptyNodeComments
nodeCommentsInlineSpec NoUserInlinePrag {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsInlineSpec Opaque {} = NodeComments
emptyNodeComments
#endif
instance CommentExtraction (HsPatSynDir GhcPs) where
  nodeComments :: HsPatSynDir GhcPs -> NodeComments
nodeComments HsPatSynDir GhcPs
Unidirectional = NodeComments
emptyNodeComments
  nodeComments HsPatSynDir GhcPs
ImplicitBidirectional = NodeComments
emptyNodeComments
  nodeComments ExplicitBidirectional {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsOverLit GhcPs) where
  nodeComments :: HsOverLit GhcPs -> NodeComments
nodeComments OverLit {} = NodeComments
emptyNodeComments

instance CommentExtraction OverLitVal where
  nodeComments :: OverLitVal -> NodeComments
nodeComments HsIntegral {} = NodeComments
emptyNodeComments
  nodeComments HsFractional {} = NodeComments
emptyNodeComments
  nodeComments HsIsString {} = NodeComments
emptyNodeComments

instance CommentExtraction IntegralLit where
  nodeComments :: IntegralLit -> NodeComments
nodeComments IL {} = NodeComments
emptyNodeComments

instance CommentExtraction FractionalLit where
  nodeComments :: FractionalLit -> NodeComments
nodeComments FL {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsLit GhcPs) where
  nodeComments :: HsLit GhcPs -> NodeComments
nodeComments HsChar {} = NodeComments
emptyNodeComments
  nodeComments HsCharPrim {} = NodeComments
emptyNodeComments
  nodeComments HsString {} = NodeComments
emptyNodeComments
  nodeComments HsStringPrim {} = NodeComments
emptyNodeComments
  nodeComments HsInt {} = NodeComments
emptyNodeComments
  nodeComments HsIntPrim {} = NodeComments
emptyNodeComments
  nodeComments HsWordPrim {} = NodeComments
emptyNodeComments
  nodeComments HsInt64Prim {} = NodeComments
emptyNodeComments
  nodeComments HsWord64Prim {} = NodeComments
emptyNodeComments
  nodeComments HsInteger {} = NodeComments
emptyNodeComments
  nodeComments HsRat {} = NodeComments
emptyNodeComments
  nodeComments HsFloatPrim {} = NodeComments
emptyNodeComments
  nodeComments HsDoublePrim {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsPragE GhcPs) where
  nodeComments :: HsPragE GhcPs -> NodeComments
nodeComments (HsPragSCC XSCC GhcPs
x SourceText
_ StringLiteral
_) = EpAnn AnnPragma -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSCC GhcPs
EpAnn AnnPragma
x

instance CommentExtraction HsIPName where
  nodeComments :: HsIPName -> NodeComments
nodeComments HsIPName {} = NodeComments
emptyNodeComments

instance CommentExtraction HsTyLit where
  nodeComments :: HsTyLit -> NodeComments
nodeComments HsNumTy {} = NodeComments
emptyNodeComments
  nodeComments HsStrTy {} = NodeComments
emptyNodeComments
  nodeComments HsCharTy {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsPatSigType GhcPs) where
  nodeComments :: HsPatSigType GhcPs -> NodeComments
nodeComments HsPS {XHsPS GhcPs
LHsType GhcPs
hsps_ext :: XHsPS GhcPs
hsps_body :: LHsType GhcPs
hsps_ext :: forall pass. HsPatSigType pass -> XHsPS pass
hsps_body :: forall pass. HsPatSigType pass -> LHsType pass
..} = EpAnn EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsPS GhcPs
EpAnn EpaLocation
hsps_ext

instance CommentExtraction (HsIPBinds GhcPs) where
  nodeComments :: HsIPBinds GhcPs -> NodeComments
nodeComments IPBinds {} = NodeComments
emptyNodeComments

instance CommentExtraction (IPBind GhcPs) where
  nodeComments :: IPBind GhcPs -> NodeComments
nodeComments (IPBind XCIPBind GhcPs
x XRec GhcPs HsIPName
_ LHsExpr GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCIPBind GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction (DerivStrategy GhcPs) where
  nodeComments :: DerivStrategy GhcPs -> NodeComments
nodeComments (StockStrategy XStockStrategy GhcPs
x) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XStockStrategy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (AnyclassStrategy XAnyClassStrategy GhcPs
x) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XAnyClassStrategy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (NewtypeStrategy XNewtypeStrategy GhcPs
x) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XNewtypeStrategy GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (ViaStrategy XViaStrategy GhcPs
x) = XViaStrategyPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XViaStrategy GhcPs
XViaStrategyPs
x

instance CommentExtraction XViaStrategyPs where
  nodeComments :: XViaStrategyPs -> NodeComments
nodeComments (XViaStrategyPs EpAnn [AddEpAnn]
x LHsSigType GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpAnn [AddEpAnn]
x

instance CommentExtraction (RecordPatSynField GhcPs) where
  nodeComments :: RecordPatSynField GhcPs -> NodeComments
nodeComments RecordPatSynField {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsCmdTop GhcPs) where
  nodeComments :: HsCmdTop GhcPs -> NodeComments
nodeComments HsCmdTop {} = NodeComments
emptyNodeComments

instance CommentExtraction (HsCmd GhcPs) where
  nodeComments :: HsCmd GhcPs -> NodeComments
nodeComments = HsCmd GhcPs -> NodeComments
nodeCommentsHsCmd

nodeCommentsHsCmd :: HsCmd GhcPs -> NodeComments
nodeCommentsHsCmd :: HsCmd GhcPs -> NodeComments
nodeCommentsHsCmd (HsCmdArrApp XCmdArrApp GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_ HsArrAppType
_ Bool
_) = EpAnn AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdArrApp GhcPs
EpAnn AddEpAnn
x
nodeCommentsHsCmd (HsCmdArrForm XCmdArrForm GhcPs
x LHsExpr GhcPs
_ LexicalFixity
_ Maybe Fixity
_ [LHsCmdTop GhcPs]
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdArrForm GhcPs
EpAnn AnnList
x
nodeCommentsHsCmd (HsCmdApp XCmdApp GhcPs
x LHsCmd GhcPs
_ LHsExpr GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdApp GhcPs
EpAnnCO
x
nodeCommentsHsCmd HsCmdLam {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsCmd (HsCmdPar XCmdPar GhcPs
x LHsToken "(" GhcPs
_ LHsCmd GhcPs
_ LHsToken ")" GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdPar GhcPs
EpAnnCO
x
#else
nodeCommentsHsCmd (HsCmdPar x _) = nodeComments x
#endif
nodeCommentsHsCmd (HsCmdCase XCmdCase GhcPs
x LHsExpr GhcPs
_ MatchGroup GhcPs (LHsCmd GhcPs)
_) = EpAnn EpAnnHsCase -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdCase GhcPs
EpAnn EpAnnHsCase
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsCmd (HsCmdLamCase XCmdLamCase GhcPs
x LamCaseVariant
_ MatchGroup GhcPs (LHsCmd GhcPs)
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdLamCase GhcPs
EpAnn [AddEpAnn]
x
#else
nodeCommentsHsCmd (HsCmdLamCase x _) = nodeComments x
#endif
nodeCommentsHsCmd (HsCmdIf XCmdIf GhcPs
x SyntaxExpr GhcPs
_ LHsExpr GhcPs
_ LHsCmd GhcPs
_ LHsCmd GhcPs
_) = EpAnn AnnsIf -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdIf GhcPs
EpAnn AnnsIf
x
#if MIN_VERSION_ghc_lib_parser(9,4,1)
nodeCommentsHsCmd (HsCmdLet XCmdLet GhcPs
x LHsToken "let" GhcPs
_ HsLocalBinds GhcPs
_ LHsToken "in" GhcPs
_ LHsCmd GhcPs
_) = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdLet GhcPs
EpAnnCO
x
#else
nodeCommentsHsCmd (HsCmdLet x _ _) = nodeComments x
#endif
nodeCommentsHsCmd (HsCmdDo XCmdDo GhcPs
x XRec GhcPs [CmdLStmt GhcPs]
_) = EpAnn AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdDo GhcPs
EpAnn AnnList
x

instance CommentExtraction ListComprehension where
  nodeComments :: ListComprehension -> NodeComments
nodeComments ListComprehension {} = NodeComments
emptyNodeComments

instance CommentExtraction DoExpression where
  nodeComments :: DoExpression -> NodeComments
nodeComments DoExpression {} = NodeComments
emptyNodeComments

instance CommentExtraction LetIn where
  nodeComments :: LetIn -> NodeComments
nodeComments LetIn {} = NodeComments
emptyNodeComments

instance CommentExtraction (RuleBndr GhcPs) where
  nodeComments :: RuleBndr GhcPs -> NodeComments
nodeComments (RuleBndr XCRuleBndr GhcPs
x LIdP GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCRuleBndr GhcPs
EpAnn [AddEpAnn]
x
  nodeComments (RuleBndrSig XRuleBndrSig GhcPs
x LIdP GhcPs
_ HsPatSigType GhcPs
_) = EpAnn [AddEpAnn] -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRuleBndrSig GhcPs
EpAnn [AddEpAnn]
x

instance CommentExtraction CCallConv where
  nodeComments :: CCallConv -> NodeComments
nodeComments = NodeComments -> CCallConv -> NodeComments
forall a b. a -> b -> a
const NodeComments
emptyNodeComments

instance CommentExtraction ModuleDeprecatedPragma where
  nodeComments :: ModuleDeprecatedPragma -> NodeComments
nodeComments ModuleDeprecatedPragma {} = NodeComments
emptyNodeComments

instance CommentExtraction HsSrcBang where
  nodeComments :: HsSrcBang -> NodeComments
nodeComments HsSrcBang {} = NodeComments
emptyNodeComments

instance CommentExtraction SrcUnpackedness where
  nodeComments :: SrcUnpackedness -> NodeComments
nodeComments SrcUnpackedness
SrcUnpack = NodeComments
emptyNodeComments
  nodeComments SrcUnpackedness
SrcNoUnpack = NodeComments
emptyNodeComments
  nodeComments SrcUnpackedness
NoSrcUnpack = NodeComments
emptyNodeComments

instance CommentExtraction SrcStrictness where
  nodeComments :: SrcStrictness -> NodeComments
nodeComments SrcStrictness
SrcLazy = NodeComments
emptyNodeComments
  nodeComments SrcStrictness
SrcStrict = NodeComments
emptyNodeComments
  nodeComments SrcStrictness
NoSrcStrict = NodeComments
emptyNodeComments

instance CommentExtraction (HsOuterSigTyVarBndrs GhcPs) where
  nodeComments :: HsOuterSigTyVarBndrs GhcPs -> NodeComments
nodeComments HsOuterImplicit {} = NodeComments
emptyNodeComments
  nodeComments HsOuterExplicit {[LHsTyVarBndr Specificity (NoGhcTc GhcPs)]
XHsOuterExplicit GhcPs Specificity
hso_xexplicit :: XHsOuterExplicit GhcPs Specificity
hso_bndrs :: [LHsTyVarBndr Specificity (NoGhcTc GhcPs)]
hso_xexplicit :: forall flag pass.
HsOuterTyVarBndrs flag pass -> XHsOuterExplicit pass flag
hso_bndrs :: forall flag pass.
HsOuterTyVarBndrs flag pass -> [LHsTyVarBndr flag (NoGhcTc pass)]
..} = EpAnnForallTy -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsOuterExplicit GhcPs Specificity
EpAnnForallTy
hso_xexplicit

-- | Marks an AST node as never appearing in the AST.
--
-- Some AST node types are only used in the renaming or type-checking phase.
notUsedInParsedStage :: HasCallStack => a
notUsedInParsedStage :: forall a. HasCallStack => a
notUsedInParsedStage =
  [Char] -> a
forall a. HasCallStack => [Char] -> a
error
    [Char]
"This AST should never appears in an AST. It only appears in the renaming or type checked stages."

-- | A 'NodeComment' with no comments.
emptyNodeComments :: NodeComments
emptyNodeComments :: NodeComments
emptyNodeComments = [LEpaComment] -> [LEpaComment] -> [LEpaComment] -> NodeComments
NodeComments [] [] []