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

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

import Data.Maybe
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 HIndent.Ast.NodeComments
import HIndent.Pretty.SigBindFamily
import HIndent.Pretty.Types
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
import GHC.Core.DataCon
#else
import GHC.Unit
#endif
-- | An interface to extract comments from an AST node.
class CommentExtraction a where
  nodeComments :: a -> NodeComments

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 (MatchGroup GhcPs a) where
  nodeComments :: MatchGroup GhcPs a -> NodeComments
nodeComments MG {} = NodeComments
emptyNodeComments

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 (LHsExpr GhcPs)
MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
x

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

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

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 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 (LHsExpr GhcPs)
StmtLR GhcPs GhcPs (GenLocated SrcSpanAnnA (HsExpr 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' where
  nodeComments :: HsType' -> NodeComments
nodeComments HsType' {HsType GhcPs
HsTypeDir
HsTypeFor
hsTypeFor :: HsTypeFor
hsTypeDir :: HsTypeDir
hsType :: HsType GhcPs
hsType :: HsType' -> HsType GhcPs
hsTypeDir :: HsType' -> HsTypeDir
hsTypeFor :: HsType' -> HsTypeFor
..} = HsType GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsType GhcPs
hsType

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
grhssLocalBinds :: forall p body. GRHSs p body -> HsLocalBinds p
grhssGRHSs :: forall p body. GRHSs p body -> [LGRHS p body]
grhssExt :: forall p body. GRHSs p body -> XCGRHSs p body
..} = NodeComments {[LEpaComment]
forall {a}. [a]
commentsBefore :: [LEpaComment]
commentsOnSameLine :: forall {a}. [a]
commentsAfter :: [LEpaComment]
commentsAfter :: [LEpaComment]
commentsOnSameLine :: [LEpaComment]
commentsBefore :: [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)
grhssExpr :: GRHSsExpr -> GRHSs GhcPs (LHsExpr GhcPs)
grhssExprType :: GRHSsExpr -> GRHSExprType
..}) = GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments GRHSs GhcPs (LHsExpr GhcPs)
GRHSs GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs))
grhssExpr

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 [GuardLStmt 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 [GuardLStmt 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 PatInsidePatDecl where
  nodeComments :: PatInsidePatDecl -> NodeComments
nodeComments (PatInsidePatDecl Pat GhcPs
x) = Pat GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Pat GhcPs
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 (LPat GhcPs)
HsRecFields GhcPs (GenLocated SrcSpanAnnA (Pat GhcPs))
x

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 HsBindLR GhcPs GhcPs
x) = HsBindLR GhcPs GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsBindLR GhcPs 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 SrcSpan where
  nodeComments :: SrcSpan -> NodeComments
nodeComments RealSrcSpan {} = NodeComments
emptyNodeComments
  nodeComments UnhelpfulSpan {} = 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 (FieldOcc GhcPs) where
  nodeComments :: FieldOcc GhcPs -> NodeComments
nodeComments FieldOcc {} = NodeComments
emptyNodeComments

-- 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
     (EpAnn AnnList) [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 InfixExpr where
  nodeComments :: InfixExpr -> NodeComments
nodeComments (InfixExpr LHsExpr GhcPs
x) = GenLocated SrcSpanAnnA (HsExpr GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments LHsExpr GhcPs
GenLocated SrcSpanAnnA (HsExpr 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 (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
Maybe (XRec GhcPs ModuleName)
ImportDeclPkgQual GhcPs
XCImportDecl GhcPs
XRec GhcPs ModuleName
IsBootInterface
ImportDeclQualifiedStyle
ideclExt :: XCImportDecl GhcPs
ideclName :: XRec GhcPs ModuleName
ideclPkgQual :: ImportDeclPkgQual GhcPs
ideclSource :: IsBootInterface
ideclSafe :: Bool
ideclQualified :: ImportDeclQualifiedStyle
ideclAs :: Maybe (XRec GhcPs ModuleName)
ideclImportList :: Maybe (ImportListInterpretation, XRec GhcPs [LIE GhcPs])
ideclImportList :: forall pass.
ImportDecl pass
-> Maybe (ImportListInterpretation, XRec pass [LIE pass])
ideclAs :: forall pass. ImportDecl pass -> Maybe (XRec pass ModuleName)
ideclQualified :: forall pass. ImportDecl pass -> ImportDeclQualifiedStyle
ideclSafe :: forall pass. ImportDecl pass -> Bool
ideclSource :: forall pass. ImportDecl pass -> IsBootInterface
ideclPkgQual :: forall pass. ImportDecl pass -> ImportDeclPkgQual pass
ideclName :: forall pass. ImportDecl pass -> XRec pass ModuleName
ideclExt :: forall pass. ImportDecl pass -> XCImportDecl pass
..} = XImportDeclPass -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCImportDecl GhcPs
XImportDeclPass
ideclExt

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

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

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_vis_bndrs :: forall pass. HsForAllTelescope pass -> [LHsTyVarBndr () pass]
hsf_xvis :: forall pass. HsForAllTelescope pass -> XHsForAllVis 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_invis_bndrs :: forall pass.
HsForAllTelescope pass -> [LHsTyVarBndr Specificity pass]
hsf_xinvis :: forall pass. HsForAllTelescope pass -> XHsForAllInvis 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

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

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

-- 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 FamEqn' where
  nodeComments :: FamEqn' -> NodeComments
nodeComments FamEqn' {FamEqn GhcPs (HsDataDefn GhcPs)
DataFamInstDeclFor
famEqnFor :: DataFamInstDeclFor
famEqn :: FamEqn GhcPs (HsDataDefn GhcPs)
famEqn :: FamEqn' -> FamEqn GhcPs (HsDataDefn GhcPs)
famEqnFor :: FamEqn' -> DataFamInstDeclFor
..} = FamEqn GhcPs (HsDataDefn GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments FamEqn GhcPs (HsDataDefn GhcPs)
famEqn

instance CommentExtraction (IEWrappedName a) where
  nodeComments :: IEWrappedName a -> NodeComments
nodeComments IEName {} = NodeComments
emptyNodeComments
  nodeComments IEPattern {} = NodeComments
emptyNodeComments
  nodeComments IEType {} = NodeComments
emptyNodeComments

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

-- | '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 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 Role where
  nodeComments :: Role -> NodeComments
nodeComments Role
Nominal = NodeComments
emptyNodeComments
  nodeComments Role
Representational = NodeComments
emptyNodeComments
  nodeComments Role
Phantom = NodeComments
emptyNodeComments

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
dataFamInstDecl :: DataFamInstDecl' -> DataFamInstDecl GhcPs
dataFamInstDeclFor :: DataFamInstDecl' -> DataFamInstDeclFor
..} = DataFamInstDecl GhcPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments DataFamInstDecl GhcPs
dataFamInstDecl

-- | '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 (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 HsIPName where
  nodeComments :: HsIPName -> NodeComments
nodeComments HsIPName {} = 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_body :: forall pass. HsPatSigType pass -> LHsType pass
hsps_ext :: forall pass. HsPatSigType pass -> XHsPS pass
..} = EpAnnCO -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsPS GhcPs
EpAnnCO
hsps_ext

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

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 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 CCallConv where
  nodeComments :: CCallConv -> NodeComments
nodeComments = NodeComments -> CCallConv -> NodeComments
forall a b. a -> b -> a
const 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_bndrs :: forall flag pass.
HsOuterTyVarBndrs flag pass -> [LHsTyVarBndr flag (NoGhcTc pass)]
hso_xexplicit :: forall flag pass.
HsOuterTyVarBndrs flag pass -> XHsOuterExplicit pass flag
..} = EpAnnForallTy -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XHsOuterExplicit GhcPs Specificity
EpAnnForallTy
hso_xexplicit

instance CommentExtraction AddEpAnn where
  nodeComments :: AddEpAnn -> NodeComments
nodeComments (AddEpAnn AnnKeywordId
_ EpaLocation
x) = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
x

instance CommentExtraction EpaLocation where
  nodeComments :: EpaLocation -> NodeComments
nodeComments EpaSpan {} = NodeComments
emptyNodeComments
  nodeComments (EpaDelta DeltaPos
_ [LEpaComment]
x) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (LEpaComment -> NodeComments) -> [LEpaComment] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LEpaComment -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [LEpaComment]
x

instance CommentExtraction AnnPragma where
  nodeComments :: AnnPragma -> NodeComments
nodeComments AnnPragma {[AddEpAnn]
AddEpAnn
apr_open :: AddEpAnn
apr_close :: AddEpAnn
apr_rest :: [AddEpAnn]
apr_rest :: AnnPragma -> [AddEpAnn]
apr_close :: AnnPragma -> AddEpAnn
apr_open :: AnnPragma -> AddEpAnn
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments ([AddEpAnn] -> [NodeComments]) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ AddEpAnn
apr_open AddEpAnn -> [AddEpAnn] -> [AddEpAnn]
forall a. a -> [a] -> [a]
: AddEpAnn
apr_close AddEpAnn -> [AddEpAnn] -> [AddEpAnn]
forall a. a -> [a] -> [a]
: [AddEpAnn]
apr_rest

instance CommentExtraction HsRuleAnn where
  nodeComments :: HsRuleAnn -> NodeComments
nodeComments HsRuleAnn {[AddEpAnn]
Maybe (AddEpAnn, AddEpAnn)
ra_tyanns :: Maybe (AddEpAnn, AddEpAnn)
ra_tmanns :: Maybe (AddEpAnn, AddEpAnn)
ra_rest :: [AddEpAnn]
ra_rest :: HsRuleAnn -> [AddEpAnn]
ra_tmanns :: HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
ra_tyanns :: HsRuleAnn -> Maybe (AddEpAnn, AddEpAnn)
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ Maybe (AddEpAnn, AddEpAnn) -> NodeComments
forall {a}. CommentExtraction a => Maybe (a, a) -> NodeComments
f Maybe (AddEpAnn, AddEpAnn)
ra_tyanns NodeComments -> [NodeComments] -> [NodeComments]
forall a. a -> [a] -> [a]
: Maybe (AddEpAnn, AddEpAnn) -> NodeComments
forall {a}. CommentExtraction a => Maybe (a, a) -> NodeComments
f Maybe (AddEpAnn, AddEpAnn)
ra_tmanns NodeComments -> [NodeComments] -> [NodeComments]
forall a. a -> [a] -> [a]
: (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
ra_rest
    where
      f :: Maybe (a, a) -> NodeComments
f (Just (a
x, a
y)) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (a -> NodeComments) -> [a] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [a
x, a
y]
      f Maybe (a, a)
Nothing = NodeComments
emptyNodeComments

instance CommentExtraction AnnFieldLabel where
  nodeComments :: AnnFieldLabel -> NodeComments
nodeComments AnnFieldLabel {afDot :: AnnFieldLabel -> Maybe EpaLocation
afDot = Just EpaLocation
x} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
x
  nodeComments AnnFieldLabel {afDot :: AnnFieldLabel -> Maybe EpaLocation
afDot = Maybe EpaLocation
Nothing} = NodeComments
emptyNodeComments

instance CommentExtraction EpAnnSumPat where
  nodeComments :: EpAnnSumPat -> NodeComments
nodeComments EpAnnSumPat {[EpaLocation]
[AddEpAnn]
sumPatParens :: [AddEpAnn]
sumPatVbarsBefore :: [EpaLocation]
sumPatVbarsAfter :: [EpaLocation]
sumPatVbarsAfter :: EpAnnSumPat -> [EpaLocation]
sumPatVbarsBefore :: EpAnnSumPat -> [EpaLocation]
sumPatParens :: EpAnnSumPat -> [AddEpAnn]
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat
      ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
sumPatParens
          [NodeComments] -> [NodeComments] -> [NodeComments]
forall a. Semigroup a => a -> a -> a
<> (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [EpaLocation]
sumPatVbarsBefore
          [NodeComments] -> [NodeComments] -> [NodeComments]
forall a. Semigroup a => a -> a -> a
<> (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [EpaLocation]
sumPatVbarsAfter

instance CommentExtraction AnnProjection where
  nodeComments :: AnnProjection -> NodeComments
nodeComments AnnProjection {EpaLocation
apOpen :: EpaLocation
apClose :: EpaLocation
apClose :: AnnProjection -> EpaLocation
apOpen :: AnnProjection -> EpaLocation
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [EpaLocation
apOpen, EpaLocation
apClose]

instance CommentExtraction AnnsIf where
  nodeComments :: AnnsIf -> NodeComments
nodeComments AnnsIf {Maybe EpaLocation
EpaLocation
aiIf :: EpaLocation
aiThen :: EpaLocation
aiElse :: EpaLocation
aiThenSemi :: Maybe EpaLocation
aiElseSemi :: Maybe EpaLocation
aiElseSemi :: AnnsIf -> Maybe EpaLocation
aiThenSemi :: AnnsIf -> Maybe EpaLocation
aiElse :: AnnsIf -> EpaLocation
aiThen :: AnnsIf -> EpaLocation
aiIf :: AnnsIf -> EpaLocation
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat
      ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments
      ([EpaLocation] -> [NodeComments])
-> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ EpaLocation
aiIf
          EpaLocation -> [EpaLocation] -> [EpaLocation]
forall a. a -> [a] -> [a]
: EpaLocation
aiThen
          EpaLocation -> [EpaLocation] -> [EpaLocation]
forall a. a -> [a] -> [a]
: EpaLocation
aiElse
          EpaLocation -> [EpaLocation] -> [EpaLocation]
forall a. a -> [a] -> [a]
: (Maybe EpaLocation -> [EpaLocation]
forall a. Maybe a -> [a]
maybeToList Maybe EpaLocation
aiThenSemi [EpaLocation] -> [EpaLocation] -> [EpaLocation]
forall a. Semigroup a => a -> a -> a
<> Maybe EpaLocation -> [EpaLocation]
forall a. Maybe a -> [a]
maybeToList Maybe EpaLocation
aiElseSemi)

instance CommentExtraction EpAnnHsCase where
  nodeComments :: EpAnnHsCase -> NodeComments
nodeComments EpAnnHsCase {[AddEpAnn]
EpaLocation
hsCaseAnnCase :: EpaLocation
hsCaseAnnOf :: EpaLocation
hsCaseAnnsRest :: [AddEpAnn]
hsCaseAnnsRest :: EpAnnHsCase -> [AddEpAnn]
hsCaseAnnOf :: EpAnnHsCase -> EpaLocation
hsCaseAnnCase :: EpAnnHsCase -> EpaLocation
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat
      ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
hsCaseAnnCase
          NodeComments -> [NodeComments] -> [NodeComments]
forall a. a -> [a] -> [a]
: EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
hsCaseAnnOf
          NodeComments -> [NodeComments] -> [NodeComments]
forall a. a -> [a] -> [a]
: (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
hsCaseAnnsRest

instance CommentExtraction AnnExplicitSum where
  nodeComments :: AnnExplicitSum -> NodeComments
nodeComments AnnExplicitSum {[EpaLocation]
EpaLocation
aesOpen :: EpaLocation
aesBarsBefore :: [EpaLocation]
aesBarsAfter :: [EpaLocation]
aesClose :: EpaLocation
aesClose :: AnnExplicitSum -> EpaLocation
aesBarsAfter :: AnnExplicitSum -> [EpaLocation]
aesBarsBefore :: AnnExplicitSum -> [EpaLocation]
aesOpen :: AnnExplicitSum -> EpaLocation
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat
      ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments
      ([EpaLocation] -> [NodeComments])
-> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ EpaLocation
aesOpen EpaLocation -> [EpaLocation] -> [EpaLocation]
forall a. a -> [a] -> [a]
: [EpaLocation]
aesBarsBefore [EpaLocation] -> [EpaLocation] -> [EpaLocation]
forall a. Semigroup a => a -> a -> a
<> [EpaLocation]
aesBarsAfter [EpaLocation] -> [EpaLocation] -> [EpaLocation]
forall a. Semigroup a => a -> a -> a
<> [EpaLocation
aesClose]

instance CommentExtraction EpAnnUnboundVar where
  nodeComments :: EpAnnUnboundVar -> NodeComments
nodeComments EpAnnUnboundVar {(EpaLocation, EpaLocation)
EpaLocation
hsUnboundBackquotes :: (EpaLocation, EpaLocation)
hsUnboundHole :: EpaLocation
hsUnboundHole :: EpAnnUnboundVar -> EpaLocation
hsUnboundBackquotes :: EpAnnUnboundVar -> (EpaLocation, EpaLocation)
..} =
    [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat
      ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
          EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments
          [(EpaLocation, EpaLocation) -> EpaLocation
forall a b. (a, b) -> a
fst (EpaLocation, EpaLocation)
hsUnboundBackquotes, (EpaLocation, EpaLocation) -> EpaLocation
forall a b. (a, b) -> b
snd (EpaLocation, EpaLocation)
hsUnboundBackquotes, EpaLocation
hsUnboundHole]

instance CommentExtraction AnnSig where
  nodeComments :: AnnSig -> NodeComments
nodeComments AnnSig {[AddEpAnn]
AddEpAnn
asDcolon :: AddEpAnn
asRest :: [AddEpAnn]
asRest :: AnnSig -> [AddEpAnn]
asDcolon :: AnnSig -> AddEpAnn
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments ([AddEpAnn] -> [NodeComments]) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ AddEpAnn
asDcolon AddEpAnn -> [AddEpAnn] -> [AddEpAnn]
forall a. a -> [a] -> [a]
: [AddEpAnn]
asRest

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

nodeCommentsHsBind :: HsBind GhcPs -> NodeComments
nodeCommentsHsBind :: HsBindLR GhcPs GhcPs -> NodeComments
nodeCommentsHsBind FunBind {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_matches :: forall idL idR. HsBindLR idL idR -> MatchGroup idR (LHsExpr idR)
fun_id :: forall idL idR. HsBindLR idL idR -> LIdP idL
fun_ext :: forall idL idR. HsBindLR idL idR -> XFunBind idL idR
..} = GenLocated SrcSpanAnnN RdrName -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments LIdP GhcPs
GenLocated SrcSpanAnnN RdrName
fun_id
#if MIN_VERSION_ghc_lib_parser(9, 10, 0)
nodeCommentsHsBind PatBind {} = NodeComments
emptyNodeComments
#else
nodeCommentsHsBind PatBind {..} = nodeComments pat_ext
#endif
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 = Sig GhcPs -> NodeComments
nodeCommentsSig

nodeCommentsSig :: Sig GhcPs -> NodeComments
nodeCommentsSig :: Sig GhcPs -> NodeComments
nodeCommentsSig (TypeSig XTypeSig GhcPs
x [LIdP GhcPs]
_ LHsSigWcType GhcPs
_) = AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTypeSig GhcPs
AnnSig
x
nodeCommentsSig (PatSynSig XPatSynSig GhcPs
x [LIdP GhcPs]
_ LHsSigType GhcPs
_) = AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XPatSynSig GhcPs
AnnSig
x
nodeCommentsSig (ClassOpSig XClassOpSig GhcPs
x Bool
_ [LIdP GhcPs]
_ LHsSigType GhcPs
_) = AnnSig -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XClassOpSig GhcPs
AnnSig
x
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsSig (FixSig XFixSig GhcPs
x FixitySig GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XFixSig GhcPs
x
nodeCommentsSig (InlineSig XInlineSig GhcPs
x LIdP GhcPs
_ InlinePragma
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XInlineSig GhcPs
x
nodeCommentsSig (SpecSig XSpecSig GhcPs
x LIdP GhcPs
_ [LHsSigType GhcPs]
_ InlinePragma
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XSpecSig GhcPs
x
nodeCommentsSig (SpecInstSig ([AddEpAnn]
x, SourceText
_) LHsSigType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
nodeCommentsSig (MinimalSig ([AddEpAnn]
x, SourceText
_) LBooleanFormula (LIdP GhcPs)
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
nodeCommentsSig (SCCFunSig ([AddEpAnn]
x, SourceText
_) LIdP GhcPs
_ Maybe (XRec GhcPs StringLiteral)
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
nodeCommentsSig (CompleteMatchSig ([AddEpAnn]
x, SourceText
_) [LIdP GhcPs]
_ Maybe (LIdP GhcPs)
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
#elif MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsSig (FixSig x _) = nodeComments x
nodeCommentsSig (InlineSig x _ _) = nodeComments x
nodeCommentsSig (SpecSig x _ _ _) = nodeComments x
nodeCommentsSig (SpecInstSig (x, _) _) = nodeComments x
nodeCommentsSig (MinimalSig (x, _) _) = nodeComments x
nodeCommentsSig (SCCFunSig (x, _) _ _) = nodeComments x
nodeCommentsSig (CompleteMatchSig (x, _) _ _) = nodeComments x
#else
nodeCommentsSig (FixSig x _) = nodeComments x
nodeCommentsSig (InlineSig x _ _) = nodeComments x
nodeCommentsSig (SpecSig x _ _ _) = nodeComments x
nodeCommentsSig IdSig {} = emptyNodeComments
nodeCommentsSig (SpecInstSig x _ _) = nodeComments x
nodeCommentsSig (MinimalSig x _ _) = nodeComments x
nodeCommentsSig (SCCFunSig x _ _ _) = nodeComments x
nodeCommentsSig (CompleteMatchSig x _ _ _) = nodeComments x
#endif
instance CommentExtraction (HsExpr GhcPs) where
  nodeComments :: HsExpr GhcPs -> NodeComments
nodeComments = HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr

nodeCommentsHsExpr :: HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr :: HsExpr GhcPs -> NodeComments
nodeCommentsHsExpr HsVar {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsLam {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsAppType {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (ExplicitSum XExplicitSum GhcPs
x ConTag
_ ConTag
_ LHsExpr GhcPs
_) = AnnExplicitSum -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitSum GhcPs
AnnExplicitSum
x
nodeCommentsHsExpr (HsCase XCase GhcPs
x LHsExpr GhcPs
_ MatchGroup GhcPs (LHsExpr GhcPs)
_) = EpAnnHsCase -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCase GhcPs
EpAnnHsCase
x
nodeCommentsHsExpr (HsIf XIf GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_ LHsExpr GhcPs
_) = AnnsIf -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XIf GhcPs
AnnsIf
x
nodeCommentsHsExpr (HsDo XDo GhcPs
x HsDoFlavour
_ XRec GhcPs [GuardLStmt GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XDo GhcPs
AnnList
x
nodeCommentsHsExpr (ExplicitList XExplicitList GhcPs
x [LHsExpr GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XExplicitList GhcPs
AnnList
x
nodeCommentsHsExpr HsProjection {NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
XProjection GhcPs
proj_ext :: XProjection GhcPs
proj_flds :: NonEmpty (XRec GhcPs (DotFieldOcc GhcPs))
proj_flds :: forall p. HsExpr p -> NonEmpty (XRec p (DotFieldOcc p))
proj_ext :: forall p. HsExpr p -> XProjection p
..} = AnnProjection -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XProjection GhcPs
AnnProjection
proj_ext
nodeCommentsHsExpr HsPragE {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsExpr (HsTypedBracket XTypedBracket GhcPs
x LHsExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XTypedBracket GhcPs
x
nodeCommentsHsExpr (HsUntypedBracket XUntypedBracket GhcPs
x HsQuote GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XUntypedBracket GhcPs
x
nodeCommentsHsExpr HsLet {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsPar {} = NodeComments
emptyNodeComments
#elif MIN_VERSION_ghc_lib_parser(9, 4, 1)
nodeCommentsHsExpr HsRecSel {} = emptyNodeComments
nodeCommentsHsExpr (HsTypedBracket x _) = nodeComments x
nodeCommentsHsExpr (HsUntypedBracket x _) = nodeComments x
nodeCommentsHsExpr (HsLet x _ _ _ _) = nodeComments x
nodeCommentsHsExpr (HsPar x _ _ _) = nodeComments x
nodeCommentsHsExpr (HsLamCase x _ _) = nodeComments x
#else
nodeCommentsHsExpr HsTick {} = emptyNodeComments
nodeCommentsHsExpr HsBinTick {} = emptyNodeComments
nodeCommentsHsExpr (HsBracket x _) = nodeComments x
nodeCommentsHsExpr HsRnBracketOut {} = notUsedInParsedStage
nodeCommentsHsExpr HsTcBracketOut {} = notUsedInParsedStage
nodeCommentsHsExpr (HsLet x _ _) = nodeComments x
nodeCommentsHsExpr (HsPar x _) = nodeComments x
nodeCommentsHsExpr (HsLamCase x _) = nodeComments x
nodeCommentsHsExpr HsConLikeOut {} = emptyNodeComments
nodeCommentsHsExpr HsRecFld {} = emptyNodeComments
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsExpr (HsTypedSplice XTypedSplice GhcPs
x LHsExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XTypedSplice GhcPs
x
nodeCommentsHsExpr HsUntypedSplice {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsOverLabel {} = NodeComments
emptyNodeComments
#elif MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsHsExpr (HsTypedSplice (x, y) _) = nodeComments x <> nodeComments y
nodeCommentsHsExpr (HsUntypedSplice x _) = nodeComments x
nodeCommentsHsExpr (HsOverLabel x _ _) = nodeComments x
#else
nodeCommentsHsExpr (HsSpliceE x _) = nodeComments x
nodeCommentsHsExpr (HsOverLabel x _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsExpr (HsStatic XStatic GhcPs
x LHsExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XStatic GhcPs
x
nodeCommentsHsExpr (HsProc XProc GhcPs
x LPat GhcPs
_ LHsCmdTop GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XProc GhcPs
x
nodeCommentsHsExpr (ArithSeq XArithSeq GhcPs
x Maybe (SyntaxExpr GhcPs)
_ ArithSeqInfo GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XArithSeq GhcPs
x
nodeCommentsHsExpr (ExprWithTySig XExprWithTySig GhcPs
x LHsExpr GhcPs
_ LHsSigWcType (NoGhcTc GhcPs)
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XExprWithTySig GhcPs
x
nodeCommentsHsExpr HsGetField {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr RecordUpd {XRecordUpd GhcPs
LHsExpr GhcPs
LHsRecUpdFields GhcPs
rupd_ext :: XRecordUpd GhcPs
rupd_expr :: LHsExpr GhcPs
rupd_flds :: LHsRecUpdFields GhcPs
rupd_flds :: forall p. HsExpr p -> LHsRecUpdFields p
rupd_expr :: forall p. HsExpr p -> LHsExpr p
rupd_ext :: forall p. HsExpr p -> XRecordUpd p
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XRecordUpd GhcPs
rupd_ext
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_flds :: forall p. HsExpr p -> HsRecordBinds p
rcon_con :: forall p. HsExpr p -> XRec p (ConLikeP p)
rcon_ext :: forall p. HsExpr p -> XRecordCon p
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XRecordCon GhcPs
rcon_ext
nodeCommentsHsExpr (HsMultiIf XMultiIf GhcPs
x [LGRHS GhcPs (LHsExpr GhcPs)]
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XMultiIf GhcPs
x
nodeCommentsHsExpr (ExplicitTuple XExplicitTuple GhcPs
x [HsTupArg GhcPs]
_ Boxity
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XExplicitTuple GhcPs
x
nodeCommentsHsExpr SectionR {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr SectionL {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (NegApp XNegApp GhcPs
x LHsExpr GhcPs
_ SyntaxExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XNegApp GhcPs
x
nodeCommentsHsExpr (OpApp XOpApp GhcPs
x LHsExpr GhcPs
_ LHsExpr GhcPs
_ LHsExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XOpApp GhcPs
x
nodeCommentsHsExpr HsApp {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsLit {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsOverLit {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr HsIPVar {} = NodeComments
emptyNodeComments
nodeCommentsHsExpr (HsUnboundVar XUnboundVar GhcPs
x RdrName
_) = NodeComments -> Maybe NodeComments -> NodeComments
forall a. a -> Maybe a -> a
fromMaybe NodeComments
forall a. Monoid a => a
mempty (Maybe NodeComments -> NodeComments)
-> Maybe NodeComments -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpAnnUnboundVar -> NodeComments)
-> Maybe EpAnnUnboundVar -> Maybe NodeComments
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpAnnUnboundVar -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe EpAnnUnboundVar
XUnboundVar GhcPs
x
#else
nodeCommentsHsExpr (HsStatic x _) = nodeComments x
nodeCommentsHsExpr (HsProc x _ _) = nodeComments x
nodeCommentsHsExpr (ArithSeq x _ _) = nodeComments x
nodeCommentsHsExpr (ExprWithTySig x _ _) = nodeComments x
nodeCommentsHsExpr HsGetField {..} = nodeComments gf_ext
nodeCommentsHsExpr RecordUpd {..} = nodeComments rupd_ext
nodeCommentsHsExpr RecordCon {..} = nodeComments rcon_ext
nodeCommentsHsExpr (HsMultiIf x _) = nodeComments x
nodeCommentsHsExpr (ExplicitTuple x _ _) = nodeComments x
nodeCommentsHsExpr (SectionR x _ _) = nodeComments x
nodeCommentsHsExpr (SectionL x _ _) = nodeComments x
nodeCommentsHsExpr (NegApp x _ _) = nodeComments x
nodeCommentsHsExpr (OpApp x _ _ _) = nodeComments x
nodeCommentsHsExpr (HsApp x _ _) = nodeComments x
nodeCommentsHsExpr (HsLit x _) = nodeComments x
nodeCommentsHsExpr (HsOverLit x _) = nodeComments x
nodeCommentsHsExpr (HsIPVar x _) = nodeComments x
nodeCommentsHsExpr (HsUnboundVar x _) = nodeComments x
#endif
instance CommentExtraction (Match GhcPs a) where
  nodeComments :: Match GhcPs a -> NodeComments
nodeComments = Match GhcPs a -> NodeComments
forall a. Match GhcPs a -> NodeComments
nodeCommentsMatch

nodeCommentsMatch :: Match GhcPs a -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsMatch :: forall a. Match GhcPs a -> NodeComments
nodeCommentsMatch Match {[LPat GhcPs]
XCMatch GhcPs a
GRHSs GhcPs a
HsMatchContext (LIdP (NoGhcTc GhcPs))
m_ext :: XCMatch GhcPs a
m_ctxt :: HsMatchContext (LIdP (NoGhcTc GhcPs))
m_pats :: [LPat GhcPs]
m_grhss :: GRHSs GhcPs a
m_grhss :: forall p body. Match p body -> GRHSs p body
m_pats :: forall p body. Match p body -> [LPat p]
m_ctxt :: forall p body. Match p body -> HsMatchContext (LIdP (NoGhcTc p))
m_ext :: forall p body. Match p body -> XCMatch p body
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCMatch GhcPs a
m_ext
#else
nodeCommentsMatch Match {..} = nodeComments m_ext
#endif
instance CommentExtraction (StmtLR GhcPs GhcPs a) where
  nodeComments :: StmtLR GhcPs GhcPs a -> NodeComments
nodeComments = StmtLR GhcPs GhcPs a -> NodeComments
forall a. StmtLR GhcPs GhcPs a -> NodeComments
nodeCommentsStmtLR

nodeCommentsStmtLR :: StmtLR GhcPs GhcPs a -> NodeComments
nodeCommentsStmtLR :: forall a. StmtLR GhcPs GhcPs a -> NodeComments
nodeCommentsStmtLR LastStmt {} = NodeComments
emptyNodeComments
nodeCommentsStmtLR ApplicativeStmt {} = NodeComments
emptyNodeComments
nodeCommentsStmtLR BodyStmt {} = NodeComments
emptyNodeComments
nodeCommentsStmtLR ParStmt {} = NodeComments
emptyNodeComments
nodeCommentsStmtLR RecStmt {[IdP GhcPs]
XRecStmt GhcPs GhcPs a
XRec GhcPs [LStmtLR GhcPs GhcPs a]
SyntaxExpr GhcPs
recS_ext :: XRecStmt GhcPs GhcPs a
recS_stmts :: XRec GhcPs [LStmtLR GhcPs GhcPs a]
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_mfix_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_bind_fn :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
recS_rec_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_later_ids :: forall idL idR body. StmtLR idL idR body -> [IdP idR]
recS_stmts :: forall idL idR body.
StmtLR idL idR body -> XRec idR [LStmtLR idL idR body]
recS_ext :: forall idL idR body. StmtLR idL idR body -> XRecStmt idL idR body
..} = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecStmt GhcPs GhcPs a
AnnList
recS_ext
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsStmtLR (BindStmt XBindStmt GhcPs GhcPs a
x LPat GhcPs
_ a
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XBindStmt GhcPs GhcPs a
x
nodeCommentsStmtLR (LetStmt XLetStmt GhcPs GhcPs a
x HsLocalBinds GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XLetStmt GhcPs GhcPs a
x
nodeCommentsStmtLR TransStmt {[(IdP GhcPs, IdP GhcPs)]
[GuardLStmt GhcPs]
Maybe (LHsExpr GhcPs)
XTransStmt GhcPs GhcPs a
LHsExpr GhcPs
SyntaxExpr GhcPs
HsExpr GhcPs
TransForm
trS_ext :: XTransStmt GhcPs GhcPs a
trS_form :: TransForm
trS_stmts :: [GuardLStmt 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_fmap :: forall idL idR body. StmtLR idL idR body -> HsExpr idR
trS_bind :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_ret :: forall idL idR body. StmtLR idL idR body -> SyntaxExpr idR
trS_by :: forall idL idR body. StmtLR idL idR body -> Maybe (LHsExpr idR)
trS_using :: forall idL idR body. StmtLR idL idR body -> LHsExpr idR
trS_bndrs :: forall idL idR body. StmtLR idL idR body -> [(IdP idR, IdP idR)]
trS_stmts :: forall idL idR body. StmtLR idL idR body -> [ExprLStmt idL]
trS_form :: forall idL idR body. StmtLR idL idR body -> TransForm
trS_ext :: forall idL idR body. StmtLR idL idR body -> XTransStmt idL idR body
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XTransStmt GhcPs GhcPs a
trS_ext
#else
nodeCommentsStmtLR (BindStmt x _ _) = nodeComments x
nodeCommentsStmtLR (LetStmt x _) = nodeComments x
nodeCommentsStmtLR TransStmt {..} = nodeComments trS_ext
#endif
instance CommentExtraction (HsType GhcPs) where
  nodeComments :: HsType GhcPs -> NodeComments
nodeComments = HsType GhcPs -> NodeComments
nodeCommentsHsType

nodeCommentsHsType :: HsType GhcPs -> NodeComments
nodeCommentsHsType :: HsType GhcPs -> NodeComments
nodeCommentsHsType HsForAllTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType HsQualTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType HsAppTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType HsAppKindTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType (HsListTy XListTy GhcPs
x LHsType GhcPs
_) = AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XListTy GhcPs
AnnParen
x
nodeCommentsHsType (HsTupleTy XTupleTy GhcPs
x HsTupleSort
_ [LHsType GhcPs]
_) = AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XTupleTy GhcPs
AnnParen
x
nodeCommentsHsType (HsSumTy XSumTy GhcPs
x [LHsType GhcPs]
_) = AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSumTy GhcPs
AnnParen
x
nodeCommentsHsType HsOpTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType (HsParTy XParTy GhcPs
x LHsType GhcPs
_) = AnnParen -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XParTy GhcPs
AnnParen
x
nodeCommentsHsType HsStarTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType HsSpliceTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType (HsRecTy XRecTy GhcPs
x [LConDeclField GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XRecTy GhcPs
AnnList
x
nodeCommentsHsType HsTyLit {} = NodeComments
emptyNodeComments
nodeCommentsHsType HsWildCardTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType XHsType {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsType (HsTyVar XTyVar GhcPs
x PromotionFlag
_ LIdP GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XTyVar GhcPs
x
nodeCommentsHsType HsFunTy {} = NodeComments
emptyNodeComments
nodeCommentsHsType (HsIParamTy XIParamTy GhcPs
x XRec GhcPs HsIPName
_ LHsType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XIParamTy GhcPs
x
nodeCommentsHsType (HsKindSig XKindSig GhcPs
x LHsType GhcPs
_ LHsType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XKindSig GhcPs
x
nodeCommentsHsType (HsDocTy XDocTy GhcPs
x LHsType GhcPs
_ LHsDoc GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XDocTy GhcPs
x
nodeCommentsHsType (HsBangTy XBangTy GhcPs
x HsSrcBang
_ LHsType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XBangTy GhcPs
x
nodeCommentsHsType (HsExplicitListTy XExplicitListTy GhcPs
x PromotionFlag
_ [LHsType GhcPs]
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XExplicitListTy GhcPs
x
nodeCommentsHsType (HsExplicitTupleTy XExplicitTupleTy GhcPs
x [LHsType GhcPs]
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XExplicitTupleTy GhcPs
x
#else
nodeCommentsHsType (HsTyVar x _ _) = nodeComments x
nodeCommentsHsType (HsFunTy x _ _ _) = nodeComments x
nodeCommentsHsType (HsIParamTy x _ _) = nodeComments x
nodeCommentsHsType (HsKindSig x _ _) = nodeComments x
nodeCommentsHsType (HsDocTy x _ _) = nodeComments x
nodeCommentsHsType (HsBangTy x _ _) = nodeComments x
nodeCommentsHsType (HsExplicitListTy x _ _) = nodeComments x
nodeCommentsHsType (HsExplicitTupleTy x _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
instance CommentExtraction (HsMatchContext (GenLocated SrcSpanAnnN RdrName)) where
  nodeComments :: HsMatchContext (GenLocated SrcSpanAnnN RdrName) -> NodeComments
nodeComments = HsMatchContext (GenLocated SrcSpanAnnN RdrName) -> NodeComments
nodeCommentsMatchContext
#else
instance CommentExtraction (HsMatchContext GhcPs) where
  nodeComments = nodeCommentsMatchContext
#endif

#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsMatchContext ::
     HsMatchContext (GenLocated SrcSpanAnnN RdrName) -> NodeComments
#else
nodeCommentsMatchContext :: HsMatchContext GhcPs -> NodeComments
#endif
nodeCommentsMatchContext :: HsMatchContext (GenLocated SrcSpanAnnN RdrName) -> NodeComments
nodeCommentsMatchContext FunRhs {} = 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, 10, 1)
nodeCommentsMatchContext LambdaExpr {} = emptyNodeComments
#endif
#if MIN_VERSION_ghc_lib_parser(9, 4, 1) && !MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsMatchContext LamCaseAlt {} = emptyNodeComments
#endif
instance CommentExtraction (Pat GhcPs) where
  nodeComments :: Pat GhcPs -> NodeComments
nodeComments = Pat GhcPs -> NodeComments
nodeCommentsPat

nodeCommentsPat :: Pat GhcPs -> NodeComments
nodeCommentsPat :: Pat GhcPs -> NodeComments
nodeCommentsPat WildPat {} = NodeComments
emptyNodeComments
nodeCommentsPat VarPat {} = NodeComments
emptyNodeComments
nodeCommentsPat (ListPat XListPat GhcPs
x [LPat GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XListPat GhcPs
AnnList
x
nodeCommentsPat (SumPat XSumPat GhcPs
x LPat GhcPs
_ ConTag
_ ConTag
_) = EpAnnSumPat -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XSumPat GhcPs
EpAnnSumPat
x
nodeCommentsPat SplicePat {} = NodeComments
emptyNodeComments
nodeCommentsPat LitPat {} = NodeComments
emptyNodeComments
nodeCommentsPat (NPlusKPat XNPlusKPat GhcPs
x LIdP GhcPs
_ XRec GhcPs (HsOverLit GhcPs)
_ HsOverLit GhcPs
_ SyntaxExpr GhcPs
_ SyntaxExpr GhcPs
_) = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XNPlusKPat GhcPs
EpaLocation
x
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsPat ParPat {} = NodeComments
emptyNodeComments
#elif MIN_VERSION_ghc_lib_parser(9, 4, 1)
nodeCommentsPat (ParPat x _ _ _) = nodeComments x
#else
nodeCommentsPat (ParPat x _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsPat AsPat {} = NodeComments
emptyNodeComments
#elif MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsPat (AsPat x _ _ _) = nodeComments x
#else
nodeCommentsPat (AsPat x _ _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsPat (LazyPat XLazyPat GhcPs
x LPat GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XLazyPat GhcPs
x
nodeCommentsPat (BangPat XBangPat GhcPs
x LPat GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XBangPat GhcPs
x
nodeCommentsPat (TuplePat XTuplePat GhcPs
x [LPat GhcPs]
_ Boxity
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XTuplePat GhcPs
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_args :: forall p. Pat p -> HsConPatDetails p
pat_con :: forall p. Pat p -> XRec p (ConLikeP p)
pat_con_ext :: forall p. Pat p -> XConPat p
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XConPat GhcPs
pat_con_ext
nodeCommentsPat (ViewPat XViewPat GhcPs
x LHsExpr GhcPs
_ LPat GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XViewPat GhcPs
x
nodeCommentsPat (NPat XNPat GhcPs
x XRec GhcPs (HsOverLit GhcPs)
_ Maybe (SyntaxExpr GhcPs)
_ SyntaxExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XNPat GhcPs
x
nodeCommentsPat (SigPat XSigPat GhcPs
x LPat GhcPs
_ HsPatSigType (NoGhcTc GhcPs)
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XSigPat GhcPs
x
#else
nodeCommentsPat (LazyPat x _) = nodeComments x
nodeCommentsPat (BangPat x _) = nodeComments x
nodeCommentsPat (TuplePat x _ _) = nodeComments x
nodeCommentsPat ConPat {..} = nodeComments pat_con_ext
nodeCommentsPat (ViewPat x _ _) = nodeComments x
nodeCommentsPat (NPat x _ _ _) = nodeComments x
nodeCommentsPat (SigPat x _ _) = nodeComments x
#endif
instance CommentExtraction (HsTupArg GhcPs) where
  nodeComments :: HsTupArg GhcPs -> NodeComments
nodeComments = HsTupArg GhcPs -> NodeComments
nodeCommentsHsTupArg

nodeCommentsHsTupArg :: HsTupArg GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsTupArg :: HsTupArg GhcPs -> NodeComments
nodeCommentsHsTupArg Present {} = NodeComments
emptyNodeComments
#else
nodeCommentsHsTupArg (Present x _) = nodeComments x
#endif
nodeCommentsHsTupArg (Missing XMissing GhcPs
x) = EpAnn Bool -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XMissing GhcPs
EpAnn Bool
x

instance CommentExtraction (ConDeclField GhcPs) where
  nodeComments :: ConDeclField GhcPs -> NodeComments
nodeComments = ConDeclField GhcPs -> NodeComments
nodeCommentsConDeclField

nodeCommentsConDeclField :: ConDeclField GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsConDeclField :: ConDeclField GhcPs -> NodeComments
nodeCommentsConDeclField 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_doc :: forall pass. ConDeclField pass -> Maybe (LHsDoc pass)
cd_fld_type :: forall pass. ConDeclField pass -> LBangType pass
cd_fld_names :: forall pass. ConDeclField pass -> [LFieldOcc pass]
cd_fld_ext :: forall pass. ConDeclField pass -> XConDeclField pass
..} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XConDeclField GhcPs
cd_fld_ext
#else
nodeCommentsConDeclField ConDeclField {..} = nodeComments cd_fld_ext
#endif
instance CommentExtraction (HsDerivingClause GhcPs) where
  nodeComments :: HsDerivingClause GhcPs -> NodeComments
nodeComments = HsDerivingClause GhcPs -> NodeComments
nodeCommentsHsDerivingClause

nodeCommentsHsDerivingClause :: HsDerivingClause GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsDerivingClause :: HsDerivingClause GhcPs -> NodeComments
nodeCommentsHsDerivingClause 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_tys :: forall pass. HsDerivingClause pass -> LDerivClauseTys pass
deriv_clause_strategy :: forall pass. HsDerivingClause pass -> Maybe (LDerivStrategy pass)
deriv_clause_ext :: forall pass. HsDerivingClause pass -> XCHsDerivingClause pass
..} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCHsDerivingClause GhcPs
deriv_clause_ext
#else
nodeCommentsHsDerivingClause HsDerivingClause {..} =
  nodeComments deriv_clause_ext
#endif
-- | This instance is for type family declarations inside a class declaration.
instance CommentExtraction (FamilyDecl GhcPs) where
  nodeComments :: FamilyDecl GhcPs -> NodeComments
nodeComments = FamilyDecl GhcPs -> NodeComments
nodeCommentsFamilyDecl

nodeCommentsFamilyDecl :: FamilyDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsFamilyDecl :: FamilyDecl GhcPs -> NodeComments
nodeCommentsFamilyDecl FamilyDecl {Maybe (LInjectivityAnn GhcPs)
XCFamilyDecl GhcPs
LIdP GhcPs
LFamilyResultSig GhcPs
TopLevelFlag
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)
fdInjectivityAnn :: forall pass. FamilyDecl pass -> Maybe (LInjectivityAnn pass)
fdResultSig :: forall pass. FamilyDecl pass -> LFamilyResultSig pass
fdFixity :: forall pass. FamilyDecl pass -> LexicalFixity
fdTyVars :: forall pass. FamilyDecl pass -> LHsQTyVars pass
fdLName :: forall pass. FamilyDecl pass -> LIdP pass
fdTopLevel :: forall pass. FamilyDecl pass -> TopLevelFlag
fdInfo :: forall pass. FamilyDecl pass -> FamilyInfo pass
fdExt :: forall pass. FamilyDecl pass -> XCFamilyDecl pass
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCFamilyDecl GhcPs
fdExt
#else
nodeCommentsFamilyDecl FamilyDecl {..} = nodeComments fdExt
#endif
instance CommentExtraction (HsTyVarBndr a GhcPs) where
  nodeComments :: HsTyVarBndr a GhcPs -> NodeComments
nodeComments = HsTyVarBndr a GhcPs -> NodeComments
forall a. HsTyVarBndr a GhcPs -> NodeComments
nodeCommentsHsTyVarBndr

nodeCommentsHsTyVarBndr :: HsTyVarBndr a GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsTyVarBndr :: forall a. HsTyVarBndr a GhcPs -> NodeComments
nodeCommentsHsTyVarBndr (UserTyVar XUserTyVar GhcPs
x a
_ LIdP GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XUserTyVar GhcPs
x
nodeCommentsHsTyVarBndr (KindedTyVar XKindedTyVar GhcPs
x a
_ LIdP GhcPs
_ LHsType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XKindedTyVar GhcPs
x
#else
nodeCommentsHsTyVarBndr (UserTyVar x _ _) = nodeComments x
nodeCommentsHsTyVarBndr (KindedTyVar x _ _ _) = nodeComments x
#endif
instance CommentExtraction (IE GhcPs) where
  nodeComments :: IE GhcPs -> NodeComments
nodeComments = IE GhcPs -> NodeComments
nodeCommentsIE

nodeCommentsIE :: IE GhcPs -> NodeComments
nodeCommentsIE :: IE GhcPs -> NodeComments
nodeCommentsIE IEVar {} = NodeComments
emptyNodeComments
nodeCommentsIE IEGroup {} = NodeComments
emptyNodeComments
nodeCommentsIE IEDoc {} = NodeComments
emptyNodeComments
nodeCommentsIE IEDocNamed {} = NodeComments
emptyNodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsIE (IEThingAbs XIEThingAbs GhcPs
_ LIEWrappedName GhcPs
x Maybe (LHsDoc GhcPs)
_) = GenLocated SrcSpanAnnA (IEWrappedName GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
x
nodeCommentsIE (IEThingAll XIEThingAll GhcPs
_ LIEWrappedName GhcPs
x Maybe (LHsDoc GhcPs)
_) = GenLocated SrcSpanAnnA (IEWrappedName GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
x
nodeCommentsIE (IEThingWith XIEThingWith GhcPs
_ LIEWrappedName GhcPs
x IEWildcard
_ [LIEWrappedName GhcPs]
_ Maybe (LHsDoc GhcPs)
_) = GenLocated SrcSpanAnnA (IEWrappedName GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments LIEWrappedName GhcPs
GenLocated SrcSpanAnnA (IEWrappedName GhcPs)
x
nodeCommentsIE (IEModuleContents (Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
x, [AddEpAnn]
y) XRec GhcPs ModuleName
_) =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ Maybe NodeComments -> [NodeComments]
forall a. Maybe a -> [a]
maybeToList ((GenLocated SrcSpanAnnP (WarningTxt GhcPs) -> NodeComments)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
-> Maybe NodeComments
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnP (WarningTxt GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
x) [NodeComments] -> [NodeComments] -> [NodeComments]
forall a. Semigroup a => a -> a -> a
<> (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
y
#elif MIN_VERSION_ghc_lib_parser(9, 8, 1)
nodeCommentsIE (IEThingAbs (_, x) _) = nodeComments x
nodeCommentsIE (IEThingAll (_, x) _) = nodeComments x
nodeCommentsIE (IEThingWith (_, x) _ _ _) = nodeComments x
nodeCommentsIE (IEModuleContents (_, x) _) = nodeComments x
#else
nodeCommentsIE (IEThingAbs x _) = nodeComments x
nodeCommentsIE (IEThingAll x _) = nodeComments x
nodeCommentsIE (IEThingWith x _ _ _) = nodeComments x
nodeCommentsIE (IEModuleContents x _) = nodeComments x
#endif
instance CommentExtraction (FamEqn GhcPs a) where
  nodeComments :: FamEqn GhcPs a -> NodeComments
nodeComments = FamEqn GhcPs a -> NodeComments
forall a. FamEqn GhcPs a -> NodeComments
nodeCommentsFamEqn

nodeCommentsFamEqn :: FamEqn GhcPs a -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsFamEqn :: forall a. FamEqn GhcPs a -> NodeComments
nodeCommentsFamEqn FamEqn {a
HsFamEqnPats GhcPs
XCFamEqn GhcPs a
LIdP GhcPs
LexicalFixity
HsOuterFamEqnTyVarBndrs GhcPs
feqn_ext :: XCFamEqn GhcPs a
feqn_tycon :: LIdP GhcPs
feqn_bndrs :: HsOuterFamEqnTyVarBndrs GhcPs
feqn_pats :: HsFamEqnPats GhcPs
feqn_fixity :: LexicalFixity
feqn_rhs :: a
feqn_rhs :: forall pass rhs. FamEqn pass rhs -> rhs
feqn_fixity :: forall pass rhs. FamEqn pass rhs -> LexicalFixity
feqn_pats :: forall pass rhs. FamEqn pass rhs -> HsFamEqnPats pass
feqn_bndrs :: forall pass rhs. FamEqn pass rhs -> HsOuterFamEqnTyVarBndrs pass
feqn_tycon :: forall pass rhs. FamEqn pass rhs -> LIdP pass
feqn_ext :: forall pass rhs. FamEqn pass rhs -> XCFamEqn pass rhs
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCFamEqn GhcPs a
feqn_ext
#else
nodeCommentsFamEqn FamEqn {..} = nodeComments feqn_ext
#endif
instance CommentExtraction (WarnDecls GhcPs) where
  nodeComments :: WarnDecls GhcPs -> NodeComments
nodeComments = WarnDecls GhcPs -> NodeComments
nodeCommentsWarnDecls

nodeCommentsWarnDecls :: WarnDecls GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsWarnDecls :: WarnDecls GhcPs -> NodeComments
nodeCommentsWarnDecls Warnings {[LWarnDecl GhcPs]
XWarnings GhcPs
wd_ext :: XWarnings GhcPs
wd_warnings :: [LWarnDecl GhcPs]
wd_warnings :: forall pass. WarnDecls pass -> [LWarnDecl pass]
wd_ext :: forall pass. WarnDecls pass -> XWarnings pass
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments ([AddEpAnn] -> [NodeComments]) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ ([AddEpAnn], SourceText) -> [AddEpAnn]
forall a b. (a, b) -> a
fst ([AddEpAnn], SourceText)
XWarnings GhcPs
wd_ext
#elif MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsWarnDecls Warnings {..} = nodeComments $ fst wd_ext
#else
nodeCommentsWarnDecls Warnings {..} = nodeComments wd_ext
#endif
instance CommentExtraction (WarnDecl GhcPs) where
  nodeComments :: WarnDecl GhcPs -> NodeComments
nodeComments = WarnDecl GhcPs -> NodeComments
nodeCommentsWarnDecl

nodeCommentsWarnDecl :: WarnDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsWarnDecl :: WarnDecl GhcPs -> NodeComments
nodeCommentsWarnDecl (Warning (NamespaceSpecifier
_, [AddEpAnn]
x) [LIdP GhcPs]
_ WarningTxt GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
#else
nodeCommentsWarnDecl (Warning x _ _) = nodeComments x
#endif
instance CommentExtraction (RuleDecls GhcPs) where
  nodeComments :: RuleDecls GhcPs -> NodeComments
nodeComments = RuleDecls GhcPs -> NodeComments
nodeCommentsRuleDecls

nodeCommentsRuleDecls :: RuleDecls GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsRuleDecls :: RuleDecls GhcPs -> NodeComments
nodeCommentsRuleDecls HsRules {[LRuleDecl GhcPs]
XCRuleDecls GhcPs
rds_ext :: XCRuleDecls GhcPs
rds_rules :: [LRuleDecl GhcPs]
rds_rules :: forall pass. RuleDecls pass -> [LRuleDecl pass]
rds_ext :: forall pass. RuleDecls pass -> XCRuleDecls pass
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments ([AddEpAnn] -> [NodeComments]) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> a -> b
$ ([AddEpAnn], SourceText) -> [AddEpAnn]
forall a b. (a, b) -> a
fst ([AddEpAnn], SourceText)
XCRuleDecls GhcPs
rds_ext
#elif MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsRuleDecls HsRules {..} = nodeComments $ fst rds_ext
#else
nodeCommentsRuleDecls HsRules {..} = nodeComments rds_ext
#endif
instance CommentExtraction (RuleDecl GhcPs) where
  nodeComments :: RuleDecl GhcPs -> NodeComments
nodeComments = RuleDecl GhcPs -> NodeComments
nodeCommentsRuleDecl

nodeCommentsRuleDecl :: RuleDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsRuleDecl :: RuleDecl GhcPs -> NodeComments
nodeCommentsRuleDecl HsRule {[LRuleBndr GhcPs]
Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
XHsRule GhcPs
XRec GhcPs RuleName
LHsExpr GhcPs
Activation
rd_ext :: XHsRule GhcPs
rd_name :: XRec GhcPs RuleName
rd_act :: Activation
rd_tyvs :: Maybe [LHsTyVarBndr () (NoGhcTc GhcPs)]
rd_tmvs :: [LRuleBndr GhcPs]
rd_lhs :: LHsExpr GhcPs
rd_rhs :: LHsExpr GhcPs
rd_rhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
rd_lhs :: forall pass. RuleDecl pass -> XRec pass (HsExpr pass)
rd_tmvs :: forall pass. RuleDecl pass -> [LRuleBndr pass]
rd_tyvs :: forall pass.
RuleDecl pass -> Maybe [LHsTyVarBndr () (NoGhcTc pass)]
rd_act :: forall pass. RuleDecl pass -> Activation
rd_name :: forall pass. RuleDecl pass -> XRec pass RuleName
rd_ext :: forall pass. RuleDecl pass -> XHsRule pass
..} = HsRuleAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments (HsRuleAnn -> NodeComments) -> HsRuleAnn -> NodeComments
forall a b. (a -> b) -> a -> b
$ (HsRuleAnn, SourceText) -> HsRuleAnn
forall a b. (a, b) -> a
fst (HsRuleAnn, SourceText)
XHsRule GhcPs
rd_ext
#else
nodeCommentsRuleDecl HsRule {..} = nodeComments rd_ext
#endif
instance CommentExtraction (DerivDecl GhcPs) where
  nodeComments :: DerivDecl GhcPs -> NodeComments
nodeComments = DerivDecl GhcPs -> NodeComments
nodeCommentsDerivDecl

nodeCommentsDerivDecl :: DerivDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsDerivDecl :: DerivDecl GhcPs -> NodeComments
nodeCommentsDerivDecl DerivDecl {deriv_ext :: forall pass. DerivDecl pass -> XCDerivDecl pass
deriv_ext = (Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
x, [AddEpAnn]
xs)} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ Maybe NodeComments -> [NodeComments]
forall a. Maybe a -> [a]
maybeToList ((GenLocated SrcSpanAnnP (WarningTxt GhcPs) -> NodeComments)
-> Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
-> Maybe NodeComments
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenLocated SrcSpanAnnP (WarningTxt GhcPs) -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe (GenLocated SrcSpanAnnP (WarningTxt GhcPs))
x) [NodeComments] -> [NodeComments] -> [NodeComments]
forall a. Semigroup a => a -> a -> a
<> (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
xs
#else
nodeCommentsDerivDecl DerivDecl {..} = nodeComments deriv_ext
#endif
instance CommentExtraction (StandaloneKindSig GhcPs) where
  nodeComments :: StandaloneKindSig GhcPs -> NodeComments
nodeComments = StandaloneKindSig GhcPs -> NodeComments
nodeCommentsStandaloneKindSig

nodeCommentsStandaloneKindSig :: StandaloneKindSig GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsStandaloneKindSig :: StandaloneKindSig GhcPs -> NodeComments
nodeCommentsStandaloneKindSig (StandaloneKindSig XStandaloneKindSig GhcPs
x LIdP GhcPs
_ LHsSigType GhcPs
_) =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XStandaloneKindSig GhcPs
x
#else
nodeCommentsStandaloneKindSig (StandaloneKindSig x _ _) = nodeComments x
#endif
instance CommentExtraction (DefaultDecl GhcPs) where
  nodeComments :: DefaultDecl GhcPs -> NodeComments
nodeComments = DefaultDecl GhcPs -> NodeComments
nodeCommentsDefaultDecl

nodeCommentsDefaultDecl :: DefaultDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsDefaultDecl :: DefaultDecl GhcPs -> NodeComments
nodeCommentsDefaultDecl (DefaultDecl XCDefaultDecl GhcPs
x [LHsType GhcPs]
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCDefaultDecl GhcPs
x
#else
nodeCommentsDefaultDecl (DefaultDecl x _) = nodeComments x
#endif
instance CommentExtraction (ForeignDecl GhcPs) where
  nodeComments :: ForeignDecl GhcPs -> NodeComments
nodeComments = ForeignDecl GhcPs -> NodeComments
nodeCommentsForeignDecl

nodeCommentsForeignDecl :: ForeignDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsForeignDecl :: ForeignDecl GhcPs -> NodeComments
nodeCommentsForeignDecl ForeignImport {XForeignImport GhcPs
LIdP GhcPs
LHsSigType GhcPs
ForeignImport GhcPs
fd_i_ext :: XForeignImport GhcPs
fd_name :: LIdP GhcPs
fd_sig_ty :: LHsSigType GhcPs
fd_fi :: ForeignImport GhcPs
fd_fi :: forall pass. ForeignDecl pass -> ForeignImport pass
fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_i_ext :: forall pass. ForeignDecl pass -> XForeignImport pass
..} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XForeignImport GhcPs
fd_i_ext
nodeCommentsForeignDecl ForeignExport {XForeignExport GhcPs
LIdP GhcPs
LHsSigType GhcPs
ForeignExport GhcPs
fd_sig_ty :: forall pass. ForeignDecl pass -> LHsSigType pass
fd_name :: forall pass. ForeignDecl pass -> LIdP pass
fd_e_ext :: XForeignExport GhcPs
fd_name :: LIdP GhcPs
fd_sig_ty :: LHsSigType GhcPs
fd_fe :: ForeignExport GhcPs
fd_fe :: forall pass. ForeignDecl pass -> ForeignExport pass
fd_e_ext :: forall pass. ForeignDecl pass -> XForeignExport pass
..} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XForeignExport GhcPs
fd_e_ext
#else
nodeCommentsForeignDecl ForeignImport {..} = nodeComments fd_i_ext
nodeCommentsForeignDecl ForeignExport {..} = nodeComments fd_e_ext
#endif
instance CommentExtraction (AnnDecl GhcPs) where
  nodeComments :: AnnDecl GhcPs -> NodeComments
nodeComments = AnnDecl GhcPs -> NodeComments
nodeCommentsAnnDecl

nodeCommentsAnnDecl :: AnnDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsAnnDecl :: AnnDecl GhcPs -> NodeComments
nodeCommentsAnnDecl (HsAnnotation (AnnPragma
x, SourceText
_) AnnProvenance GhcPs
_ LHsExpr GhcPs
_) = AnnPragma -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments AnnPragma
x
#else
nodeCommentsAnnDecl (HsAnnotation x _ _ _) = nodeComments x
#endif
instance CommentExtraction (RoleAnnotDecl GhcPs) where
  nodeComments :: RoleAnnotDecl GhcPs -> NodeComments
nodeComments = RoleAnnotDecl GhcPs -> NodeComments
nodeCommentsRoleAnnotDecl

nodeCommentsRoleAnnotDecl :: RoleAnnotDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsRoleAnnotDecl :: RoleAnnotDecl GhcPs -> NodeComments
nodeCommentsRoleAnnotDecl (RoleAnnotDecl XCRoleAnnotDecl GhcPs
x LIdP GhcPs
_ [XRec GhcPs (Maybe Role)]
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCRoleAnnotDecl GhcPs
x
#else
nodeCommentsRoleAnnotDecl (RoleAnnotDecl x _ _) = nodeComments x
#endif
instance CommentExtraction (TyFamInstDecl GhcPs) where
  nodeComments :: TyFamInstDecl GhcPs -> NodeComments
nodeComments = TyFamInstDecl GhcPs -> NodeComments
nodeCommentsTyFamInstDecl

nodeCommentsTyFamInstDecl :: TyFamInstDecl GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsTyFamInstDecl :: TyFamInstDecl GhcPs -> NodeComments
nodeCommentsTyFamInstDecl TyFamInstDecl {XCTyFamInstDecl GhcPs
TyFamInstEqn GhcPs
tfid_xtn :: XCTyFamInstDecl GhcPs
tfid_eqn :: TyFamInstEqn GhcPs
tfid_eqn :: forall pass. TyFamInstDecl pass -> TyFamInstEqn pass
tfid_xtn :: forall pass. TyFamInstDecl pass -> XCTyFamInstDecl pass
..} =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCTyFamInstDecl GhcPs
tfid_xtn
#else
nodeCommentsTyFamInstDecl TyFamInstDecl {..} = nodeComments tfid_xtn
#endif
instance CommentExtraction (PatSynBind GhcPs GhcPs) where
  nodeComments :: PatSynBind GhcPs GhcPs -> NodeComments
nodeComments = PatSynBind GhcPs GhcPs -> NodeComments
nodeCommentsPatSynBind

nodeCommentsPatSynBind :: PatSynBind GhcPs GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsPatSynBind :: PatSynBind GhcPs GhcPs -> NodeComments
nodeCommentsPatSynBind 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_dir :: forall idL idR. PatSynBind idL idR -> HsPatSynDir idR
psb_def :: forall idL idR. PatSynBind idL idR -> LPat idR
psb_args :: forall idL idR. PatSynBind idL idR -> HsPatSynDetails idR
psb_id :: forall idL idR. PatSynBind idL idR -> LIdP idL
psb_ext :: forall idL idR. PatSynBind idL idR -> XPSB idL idR
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XPSB GhcPs GhcPs
psb_ext
#else
nodeCommentsPatSynBind PSB {..} = nodeComments psb_ext
#endif
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 (HsPragE GhcPs) where
  nodeComments :: HsPragE GhcPs -> NodeComments
nodeComments = HsPragE GhcPs -> NodeComments
nodeCommentsHsPragE

nodeCommentsHsPragE :: HsPragE GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
nodeCommentsHsPragE :: HsPragE GhcPs -> NodeComments
nodeCommentsHsPragE (HsPragSCC (AnnPragma
x, SourceText
_) StringLiteral
_) = AnnPragma -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments AnnPragma
x
#else
nodeCommentsHsPragE (HsPragSCC x _ _) = nodeComments x
#endif
instance CommentExtraction (IPBind GhcPs) where
  nodeComments :: IPBind GhcPs -> NodeComments
nodeComments = IPBind GhcPs -> NodeComments
nodeCommentsIPBind

nodeCommentsIPBind :: IPBind GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsIPBind :: IPBind GhcPs -> NodeComments
nodeCommentsIPBind (IPBind XCIPBind GhcPs
x XRec GhcPs HsIPName
_ LHsExpr GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCIPBind GhcPs
x
#else
nodeCommentsIPBind (IPBind x _ _) = nodeComments x
#endif
instance CommentExtraction (DerivStrategy GhcPs) where
  nodeComments :: DerivStrategy GhcPs -> NodeComments
nodeComments = DerivStrategy GhcPs -> NodeComments
nodeCommentsDerivStrategy

nodeCommentsDerivStrategy :: DerivStrategy GhcPs -> NodeComments
nodeCommentsDerivStrategy :: DerivStrategy GhcPs -> NodeComments
nodeCommentsDerivStrategy (ViaStrategy XViaStrategy GhcPs
x) = XViaStrategyPs -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XViaStrategy GhcPs
XViaStrategyPs
x
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsDerivStrategy (StockStrategy XStockStrategy GhcPs
x) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XStockStrategy GhcPs
x
nodeCommentsDerivStrategy (AnyclassStrategy XAnyClassStrategy GhcPs
x) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XAnyClassStrategy GhcPs
x
nodeCommentsDerivStrategy (NewtypeStrategy XNewtypeStrategy GhcPs
x) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XNewtypeStrategy GhcPs
x
#else
nodeCommentsDerivStrategy (StockStrategy x) = nodeComments x
nodeCommentsDerivStrategy (AnyclassStrategy x) = nodeComments x
nodeCommentsDerivStrategy (NewtypeStrategy x) = nodeComments x
#endif
instance CommentExtraction XViaStrategyPs where
  nodeComments :: XViaStrategyPs -> NodeComments
nodeComments = XViaStrategyPs -> NodeComments
nodeCommentsXViaStrategyPs

nodeCommentsXViaStrategyPs :: XViaStrategyPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsXViaStrategyPs :: XViaStrategyPs -> NodeComments
nodeCommentsXViaStrategyPs (XViaStrategyPs [AddEpAnn]
x LHsSigType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
x
#else
nodeCommentsXViaStrategyPs (XViaStrategyPs x _) = nodeComments x
#endif
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
_) = AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdArrApp GhcPs
AddEpAnn
x
nodeCommentsHsCmd (HsCmdArrForm XCmdArrForm GhcPs
x LHsExpr GhcPs
_ LexicalFixity
_ Maybe Fixity
_ [LHsCmdTop GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdArrForm GhcPs
AnnList
x
nodeCommentsHsCmd HsCmdLam {} = NodeComments
emptyNodeComments
nodeCommentsHsCmd (HsCmdCase XCmdCase GhcPs
x LHsExpr GhcPs
_ MatchGroup GhcPs (LHsCmd GhcPs)
_) = EpAnnHsCase -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdCase GhcPs
EpAnnHsCase
x
nodeCommentsHsCmd (HsCmdIf XCmdIf GhcPs
x SyntaxExpr GhcPs
_ LHsExpr GhcPs
_ LHsCmd GhcPs
_ LHsCmd GhcPs
_) = AnnsIf -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdIf GhcPs
AnnsIf
x
nodeCommentsHsCmd (HsCmdDo XCmdDo GhcPs
x XRec GhcPs [CmdLStmt GhcPs]
_) = AnnList -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCmdDo GhcPs
AnnList
x
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsCmd HsCmdApp {} = NodeComments
emptyNodeComments
#else
nodeCommentsHsCmd (HsCmdApp x _ _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsCmd HsCmdPar {} = NodeComments
emptyNodeComments
nodeCommentsHsCmd HsCmdLet {} = NodeComments
emptyNodeComments
#elif MIN_VERSION_ghc_lib_parser(9, 4, 1)
nodeCommentsHsCmd (HsCmdPar x _ _ _) = nodeComments x
nodeCommentsHsCmd (HsCmdLamCase x _ _) = nodeComments x
nodeCommentsHsCmd (HsCmdLet x _ _ _ _) = nodeComments x
#else
nodeCommentsHsCmd (HsCmdPar x _) = nodeComments x
nodeCommentsHsCmd (HsCmdLamCase x _) = nodeComments x
nodeCommentsHsCmd (HsCmdLet x _ _) = nodeComments x
#endif
instance CommentExtraction (RuleBndr GhcPs) where
  nodeComments :: RuleBndr GhcPs -> NodeComments
nodeComments = RuleBndr GhcPs -> NodeComments
nodeCommentsRuleBndr

nodeCommentsRuleBndr :: RuleBndr GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsRuleBndr :: RuleBndr GhcPs -> NodeComments
nodeCommentsRuleBndr (RuleBndr XCRuleBndr GhcPs
x LIdP GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XCRuleBndr GhcPs
x
nodeCommentsRuleBndr (RuleBndrSig XRuleBndrSig GhcPs
x LIdP GhcPs
_ HsPatSigType GhcPs
_) = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XRuleBndrSig GhcPs
x
#else
nodeCommentsRuleBndr (RuleBndr x _) = nodeComments x
nodeCommentsRuleBndr (RuleBndrSig x _ _) = nodeComments x
#endif
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
instance CommentExtraction FieldLabelString where
  nodeComments :: FieldLabelString -> NodeComments
nodeComments = NodeComments -> FieldLabelString -> NodeComments
forall a b. a -> b -> a
const NodeComments
emptyNodeComments

instance CommentExtraction (HsUntypedSplice GhcPs) where
  nodeComments :: HsUntypedSplice GhcPs -> NodeComments
nodeComments = HsUntypedSplice GhcPs -> NodeComments
nodeCommentsHsUntypedSplice

nodeCommentsHsUntypedSplice :: HsUntypedSplice GhcPs -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsUntypedSplice :: HsUntypedSplice GhcPs -> NodeComments
nodeCommentsHsUntypedSplice (HsUntypedSpliceExpr XUntypedSpliceExpr GhcPs
x LHsExpr GhcPs
_) =
  [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XUntypedSpliceExpr GhcPs
x
#else
nodeCommentsHsUntypedSplice (HsUntypedSpliceExpr x _) = nodeComments x
#endif
nodeCommentsHsUntypedSplice HsQuasiQuote {} = NodeComments
emptyNodeComments
#endif
#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

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

instance CommentExtraction (DotFieldOcc GhcPs) where
  nodeComments :: DotFieldOcc GhcPs -> NodeComments
nodeComments DotFieldOcc {XCDotFieldOcc GhcPs
XRec GhcPs FieldLabelString
dfoExt :: XCDotFieldOcc GhcPs
dfoLabel :: XRec GhcPs FieldLabelString
dfoLabel :: forall p. DotFieldOcc p -> XRec p FieldLabelString
dfoExt :: forall p. DotFieldOcc p -> XCDotFieldOcc p
..} = AnnFieldLabel -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments XCDotFieldOcc GhcPs
AnnFieldLabel
dfoExt

instance CommentExtraction (HsFieldBind a b) where
  nodeComments :: HsFieldBind a b -> NodeComments
nodeComments = HsFieldBind a b -> NodeComments
forall a b. HsFieldBind a b -> NodeComments
nodeCommentsHsFieldBind

nodeCommentsHsFieldBind :: HsFieldBind a b -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
nodeCommentsHsFieldBind :: forall a b. HsFieldBind a b -> NodeComments
nodeCommentsHsFieldBind HsFieldBind {a
b
Bool
XHsFieldBind a
hfbAnn :: XHsFieldBind a
hfbLHS :: a
hfbRHS :: b
hfbPun :: Bool
hfbPun :: forall lhs rhs. HsFieldBind lhs rhs -> Bool
hfbRHS :: forall lhs rhs. HsFieldBind lhs rhs -> rhs
hfbLHS :: forall lhs rhs. HsFieldBind lhs rhs -> lhs
hfbAnn :: forall lhs rhs. HsFieldBind lhs rhs -> XHsFieldBind lhs
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
XHsFieldBind a
hfbAnn
#else
nodeCommentsHsFieldBind HsFieldBind {..} = nodeComments hfbAnn
#endif
#else
instance CommentExtraction (HsFieldLabel GhcPs) where
  nodeComments HsFieldLabel {..} = nodeComments hflExt

instance CommentExtraction RecConField where
  nodeComments (RecConField x) = nodeComments x
#endif
#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 SrcSpanAnnA (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
-> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments HsFieldBind (LFieldOcc GhcPs) (LPat GhcPs)
HsFieldBind
  (GenLocated SrcSpanAnnA (FieldOcc GhcPs))
  (GenLocated SrcSpanAnnA (Pat GhcPs))
x
#else
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

instance CommentExtraction (HsRecField' (FieldOcc GhcPs) a) where
  nodeComments HsRecField {..} = nodeComments hsRecFieldAnn
#endif
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
instance CommentExtraction XImportDeclPass where
  nodeComments :: XImportDeclPass -> NodeComments
nodeComments XImportDeclPass {Bool
SourceText
EpAnn EpAnnImportDecl
ideclAnn :: EpAnn EpAnnImportDecl
ideclSourceText :: SourceText
ideclImplicit :: Bool
ideclImplicit :: XImportDeclPass -> Bool
ideclSourceText :: XImportDeclPass -> SourceText
ideclAnn :: XImportDeclPass -> EpAnn EpAnnImportDecl
..} = EpAnn EpAnnImportDecl -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpAnn EpAnnImportDecl
ideclAnn

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

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

instance CommentExtraction (HsTyLit GhcPs) where
  nodeComments :: HsTyLit GhcPs -> NodeComments
nodeComments HsNumTy {} = NodeComments
emptyNodeComments
  nodeComments HsStrTy {} = NodeComments
emptyNodeComments
  nodeComments HsCharTy {} = NodeComments
emptyNodeComments
#else
instance CommentExtraction (HsSplice GhcPs) where
  nodeComments (HsTypedSplice x _ _ _) = nodeComments x
  nodeComments (HsUntypedSplice x _ _ _) = nodeComments x
  nodeComments HsQuasiQuote {} = emptyNodeComments
  nodeComments HsSpliced {} = emptyNodeComments

instance CommentExtraction ForeignImport where
  nodeComments CImport {} = emptyNodeComments

instance CommentExtraction ForeignExport where
  nodeComments CExport {} = emptyNodeComments

instance CommentExtraction HsTyLit where
  nodeComments HsNumTy {} = emptyNodeComments
  nodeComments HsStrTy {} = emptyNodeComments
  nodeComments HsCharTy {} = emptyNodeComments
#endif
#if MIN_VERSION_ghc_lib_parser(9, 8, 1)
instance CommentExtraction
           (HsArg
              GhcPs
              (GenLocated SrcSpanAnnA (HsType GhcPs))
              (GenLocated SrcSpanAnnA (HsType GhcPs))) where
  nodeComments :: HsArg
  GhcPs
  (GenLocated SrcSpanAnnA (HsType GhcPs))
  (GenLocated SrcSpanAnnA (HsType GhcPs))
-> NodeComments
nodeComments HsValArg {} = NodeComments
emptyNodeComments
  nodeComments HsTypeArg {} = NodeComments
emptyNodeComments
  nodeComments HsArgPar {} = NodeComments
emptyNodeComments

instance CommentExtraction (LHsRecUpdFields GhcPs) where
  nodeComments :: LHsRecUpdFields GhcPs -> NodeComments
nodeComments RegularRecUpdFields {} = NodeComments
emptyNodeComments
  nodeComments OverloadedRecUpdFields {} = NodeComments
emptyNodeComments
#else
instance CommentExtraction
           (HsArg
              (GenLocated SrcSpanAnnA (HsType GhcPs))
              (GenLocated SrcSpanAnnA (HsType GhcPs))) where
  nodeComments HsValArg {} = emptyNodeComments
  nodeComments HsTypeArg {} = emptyNodeComments
  nodeComments HsArgPar {} = emptyNodeComments
#endif
#if MIN_VERSION_ghc_lib_parser(9, 10, 1)
instance CommentExtraction (EpAnn a) where
  nodeComments :: EpAnn a -> NodeComments
nodeComments (EpAnn EpaLocation
ann a
_ EpAnnComments
cs) = NodeComments {[LEpaComment]
commentsAfter :: [LEpaComment]
commentsOnSameLine :: [LEpaComment]
commentsBefore :: [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 {a} {e}. GenLocated (EpaLocation' a) 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 {a} {e}. GenLocated (EpaLocation' a) e -> Bool
isCommentOnSameLine) ([LEpaComment] -> [LEpaComment]) -> [LEpaComment] -> [LEpaComment]
forall a b. (a -> b) -> a -> b
$ EpAnnComments -> [LEpaComment]
getFollowingComments EpAnnComments
cs
      isCommentOnSameLine :: GenLocated (EpaLocation' a) e -> Bool
isCommentOnSameLine (L EpaLocation' a
comAnn e
_) =
        RealSrcSpan -> ConTag
srcSpanEndLine (EpaLocation -> RealSrcSpan
forall a. EpaLocation' a -> RealSrcSpan
anchor EpaLocation
ann) ConTag -> ConTag -> Bool
forall a. Eq a => a -> a -> Bool
== RealSrcSpan -> ConTag
srcSpanStartLine (EpaLocation' a -> RealSrcSpan
forall a. EpaLocation' a -> RealSrcSpan
anchor EpaLocation' a
comAnn)

instance CommentExtraction (EpaLocation' NoComments) where
  nodeComments :: EpaLocation' NoComments -> NodeComments
nodeComments EpaSpan {} = NodeComments
emptyNodeComments
  nodeComments EpaDelta {} = NodeComments
emptyNodeComments

instance CommentExtraction AnnList where
  nodeComments :: AnnList -> NodeComments
nodeComments AnnList {[TrailingAnn]
[AddEpAnn]
Maybe EpaLocation
Maybe AddEpAnn
al_anchor :: Maybe EpaLocation
al_open :: Maybe AddEpAnn
al_close :: Maybe AddEpAnn
al_rest :: [AddEpAnn]
al_trailing :: [TrailingAnn]
al_trailing :: AnnList -> [TrailingAnn]
al_rest :: AnnList -> [AddEpAnn]
al_close :: AnnList -> Maybe AddEpAnn
al_open :: AnnList -> Maybe AddEpAnn
al_anchor :: AnnList -> Maybe EpaLocation
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat [NodeComments
a, NodeComments
b, NodeComments
c, NodeComments
d, NodeComments
e]
    where
      a :: NodeComments
a = NodeComments
-> (EpaLocation -> NodeComments)
-> Maybe EpaLocation
-> NodeComments
forall b a. b -> (a -> b) -> Maybe a -> b
maybe NodeComments
forall a. Monoid a => a
mempty EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe EpaLocation
al_anchor
      b :: NodeComments
b = NodeComments
-> (AddEpAnn -> NodeComments) -> Maybe AddEpAnn -> NodeComments
forall b a. b -> (a -> b) -> Maybe a -> b
maybe NodeComments
forall a. Monoid a => a
mempty AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe AddEpAnn
al_open
      c :: NodeComments
c = NodeComments
-> (AddEpAnn -> NodeComments) -> Maybe AddEpAnn -> NodeComments
forall b a. b -> (a -> b) -> Maybe a -> b
maybe NodeComments
forall a. Monoid a => a
mempty AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments Maybe AddEpAnn
al_close
      d :: NodeComments
d = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (AddEpAnn -> NodeComments) -> [AddEpAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap AddEpAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [AddEpAnn]
al_rest
      e :: NodeComments
e = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (TrailingAnn -> NodeComments) -> [TrailingAnn] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TrailingAnn -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [TrailingAnn]
al_trailing

instance CommentExtraction TrailingAnn where
  nodeComments :: TrailingAnn -> NodeComments
nodeComments AddSemiAnn {EpaLocation
ta_location :: EpaLocation
ta_location :: TrailingAnn -> EpaLocation
..} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
ta_location
  nodeComments AddCommaAnn {EpaLocation
ta_location :: TrailingAnn -> EpaLocation
ta_location :: EpaLocation
..} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
ta_location
  nodeComments AddVbarAnn {EpaLocation
ta_location :: TrailingAnn -> EpaLocation
ta_location :: EpaLocation
..} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
ta_location
  nodeComments AddDarrowAnn {EpaLocation
ta_location :: TrailingAnn -> EpaLocation
ta_location :: EpaLocation
..} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
ta_location
  nodeComments AddDarrowUAnn {EpaLocation
ta_location :: TrailingAnn -> EpaLocation
ta_location :: EpaLocation
..} = EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments EpaLocation
ta_location

instance CommentExtraction AnnParen where
  nodeComments :: AnnParen -> NodeComments
nodeComments AnnParen {EpaLocation
ParenType
ap_adornment :: ParenType
ap_open :: EpaLocation
ap_close :: EpaLocation
ap_close :: AnnParen -> EpaLocation
ap_open :: AnnParen -> EpaLocation
ap_adornment :: AnnParen -> ParenType
..} = [NodeComments] -> NodeComments
forall a. Monoid a => [a] -> a
mconcat ([NodeComments] -> NodeComments) -> [NodeComments] -> NodeComments
forall a b. (a -> b) -> a -> b
$ (EpaLocation -> NodeComments) -> [EpaLocation] -> [NodeComments]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EpaLocation -> NodeComments
forall a. CommentExtraction a => a -> NodeComments
nodeComments [EpaLocation
ap_open, EpaLocation
ap_close]
#else
instance CommentExtraction Anchor where
  nodeComments Anchor {} = emptyNodeComments

instance CommentExtraction (SrcAnn a) where
  nodeComments (SrcSpanAnn ep _) = nodeComments ep

instance CommentExtraction (EpAnn a) where
  nodeComments (EpAnn ann _ cs) = NodeComments {..}
    where
      commentsBefore = priorComments cs
      commentsOnSameLine = filter isCommentOnSameLine $ getFollowingComments cs
      commentsAfter =
        filter (not . isCommentOnSameLine) $ getFollowingComments cs
      isCommentOnSameLine (L comAnn _) =
        srcSpanEndLine (anchor ann) == srcSpanStartLine (anchor comAnn)
  nodeComments EpAnnNotUsed = emptyNodeComments
#endif
-- | 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 [] [] []