diff options
author | romes <rodrigo.m.mesquita@gmail.com> | 2022-05-17 16:06:52 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-03 14:11:31 -0400 |
commit | f9f8099598fd169fa2f17305fc660e5c473f8836 (patch) | |
tree | 5acdb9a38b78dc17ffa0abb63d87555e214d98af /utils | |
parent | 3a8970ac0c69335a1d229f9c9a71e6e333e99bfb (diff) | |
download | haskell-f9f8099598fd169fa2f17305fc660e5c473f8836.tar.gz |
TTG: Move ImpExp client-independent bits to L.H.S.ImpExp
Move the GHC-independent definitions from GHC.Hs.ImpExp to
Language.Haskell.Syntax.ImpExp with the required TTG extension fields
such as to keep the AST independent from GHC.
This is progress towards having the haskell-syntax package, as described
in #21592
Bumps haddock submodule
Diffstat (limited to 'utils')
-rw-r--r-- | utils/check-exact/ExactPrint.hs | 18 | ||||
-rw-r--r-- | utils/check-exact/Main.hs | 14 | ||||
-rw-r--r-- | utils/check-exact/Parsers.hs | 6 | ||||
-rw-r--r-- | utils/check-exact/Transform.hs | 8 | ||||
-rw-r--r-- | utils/check-exact/Utils.hs | 4 | ||||
-rw-r--r-- | utils/check-ppr/Main.hs | 4 | ||||
m--------- | utils/haddock | 0 |
7 files changed, 27 insertions, 27 deletions
diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index 9d5f932f1e..1255d492e0 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/utils/check-exact/ExactPrint.hs @@ -398,11 +398,11 @@ instance (ExactPrint a) => ExactPrint (Maybe a) where -- --------------------------------------------------------------------- -- | 'Located (HsModule GhcPs)' corresponds to 'ParsedSource' -instance ExactPrint HsModule where - getAnnotationEntry hsmod = fromAnn (hsmodAnn hsmod) +instance ExactPrint (HsModule GhcPs) where + getAnnotationEntry hsmod = fromAnn (hsmodAnn $ hsmodExt hsmod) - exact hsmod@(HsModule EpAnnNotUsed _ _ _ _ _ _ _) = withPpr hsmod - exact (HsModule an _lo mmn mexports imports decls mdeprec mbDoc) = do + exact hsmod@(HsModule (XModulePs EpAnnNotUsed _ _ _) _ _ _ _) = withPpr hsmod + exact (HsModule (XModulePs an _lo mdeprec mbDoc) mmn mexports imports decls) = do markAnnotated mbDoc @@ -760,9 +760,9 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where -- --------------------------------------------------------------------- instance ExactPrint (ImportDecl GhcPs) where - getAnnotationEntry idecl = fromAnn (ideclExt idecl) - exact x@(ImportDecl EpAnnNotUsed _ _ _ _ _ _ _ _ _) = withPpr x - exact (ImportDecl ann@(EpAnn _ an _) msrc modname mpkg _src safeflag qualFlag _impl mAs hiding) = do + getAnnotationEntry idecl = fromAnn (ideclAnn $ ideclExt idecl) + exact x@(ImportDecl{ ideclExt = XImportDeclPass{ ideclAnn = EpAnnNotUsed } }) = withPpr x + exact (ImportDecl (XImportDeclPass ann@(EpAnn _ an _) msrc _impl) modname mpkg _src safeflag qualFlag mAs hiding) = do markAnnKw ann importDeclAnnImport AnnImport @@ -3515,10 +3515,10 @@ instance ExactPrint (IE GhcPs) where -- --------------------------------------------------------------------- -instance ExactPrint (IEWrappedName RdrName) where +instance ExactPrint (IEWrappedName GhcPs) where getAnnotationEntry = const NoEntryVal - exact (IEName n) = markAnnotated n + exact (IEName _ n) = markAnnotated n exact (IEPattern r n) = do printStringAtAA r "pattern" markAnnotated n diff --git a/utils/check-exact/Main.hs b/utils/check-exact/Main.hs index f017233da5..8e79de24b3 100644 --- a/utils/check-exact/Main.hs +++ b/utils/check-exact/Main.hs @@ -883,8 +883,8 @@ addHiding1 _libdir (L l p) = do [L li imp1,imp2] = hsmodImports p n1 = L (noAnnSrcSpanDP0 l1) (mkVarUnqual (mkFastString "n1")) n2 = L (noAnnSrcSpanDP0 l2) (mkVarUnqual (mkFastString "n2")) - v1 = L (addComma $ noAnnSrcSpanDP0 l1) (IEVar noExtField (L (noAnnSrcSpanDP0 l1) (IEName n1))) - v2 = L ( noAnnSrcSpanDP0 l2) (IEVar noExtField (L (noAnnSrcSpanDP0 l2) (IEName n2))) + v1 = L (addComma $ noAnnSrcSpanDP0 l1) (IEVar noExtField (L (noAnnSrcSpanDP0 l1) (IEName noExtField n1))) + v2 = L ( noAnnSrcSpanDP0 l2) (IEVar noExtField (L (noAnnSrcSpanDP0 l2) (IEName noExtField n2))) impHiding = L (SrcSpanAnn (EpAnn (Anchor (realSrcSpan l0) m0) (AnnList Nothing (Just (AddEpAnn AnnOpenP d1)) @@ -892,7 +892,7 @@ addHiding1 _libdir (L l p) = do [(AddEpAnn AnnHiding d1)] []) emptyComments) l0) [v1,v2] - imp1' = imp1 { ideclHiding = Just (True,impHiding)} + imp1' = imp1 { ideclImportList = Just (EverythingBut,impHiding)} p' = p { hsmodImports = [L li imp1',imp2]} return (L l p') @@ -909,7 +909,7 @@ addHiding2 _libdir (L l p) = do l2 <- uniqueSrcSpanT let [L li imp1] = hsmodImports p - Just (_,L lh ns) = ideclHiding imp1 + Just (_,L lh ns) = ideclImportList imp1 lh' = (SrcSpanAnn (EpAnn (Anchor (realSrcSpan (locA lh)) m0) (AnnList Nothing (Just (AddEpAnn AnnOpenP d1)) @@ -919,11 +919,11 @@ addHiding2 _libdir (L l p) = do emptyComments) (locA lh)) n1 = L (noAnnSrcSpanDP0 l1) (mkVarUnqual (mkFastString "n1")) n2 = L (noAnnSrcSpanDP0 l2) (mkVarUnqual (mkFastString "n2")) - v1 = L (addComma $ noAnnSrcSpanDP0 l1) (IEVar noExtField (L (noAnnSrcSpanDP0 l1) (IEName n1))) - v2 = L ( noAnnSrcSpanDP0 l2) (IEVar noExtField (L (noAnnSrcSpanDP0 l2) (IEName n2))) + v1 = L (addComma $ noAnnSrcSpanDP0 l1) (IEVar noExtField (L (noAnnSrcSpanDP0 l1) (IEName noExtField n1))) + v2 = L ( noAnnSrcSpanDP0 l2) (IEVar noExtField (L (noAnnSrcSpanDP0 l2) (IEName noExtField n2))) L ln n = last ns n' = L (addComma ln) n - imp1' = imp1 { ideclHiding = Just (True,L lh' (init ns ++ [n',v1,v2]))} + imp1' = imp1 { ideclImportList = Just (EverythingBut, L lh' (init ns ++ [n',v1,v2]))} p' = p { hsmodImports = [L li imp1']} return (L l p') diff --git a/utils/check-exact/Parsers.hs b/utils/check-exact/Parsers.hs index b592a4cee4..e631d43314 100644 --- a/utils/check-exact/Parsers.hs +++ b/utils/check-exact/Parsers.hs @@ -119,7 +119,7 @@ withDynFlags libdir action = ghcWrapper libdir $ do -- --------------------------------------------------------------------- -parseFile :: GHC.DynFlags -> FilePath -> String -> GHC.ParseResult (GHC.Located GHC.HsModule) +parseFile :: GHC.DynFlags -> FilePath -> String -> GHC.ParseResult (GHC.Located (GHC.HsModule GHC.GhcPs)) parseFile = runParser GHC.parseModule -- --------------------------------------------------------------------- @@ -275,10 +275,10 @@ postParseTransform parseRes = fmap mkAnns parseRes fixModuleTrailingComments :: GHC.ParsedSource -> GHC.ParsedSource fixModuleTrailingComments (GHC.L l p) = GHC.L l p' where - an' = case GHC.hsmodAnn p of + an' = case GHC.hsmodAnn $ GHC.hsmodExt p of (GHC.EpAnn a an ocs) -> GHC.EpAnn a an (rebalance (GHC.am_decls an) ocs) unused -> unused - p' = p { GHC.hsmodAnn = an' } + p' = p { GHC.hsmodExt = (GHC.hsmodExt p){ GHC.hsmodAnn = an' } } -- p' = error $ "fixModuleTrailingComments: an'=" ++ showAst an' rebalance :: GHC.AnnList -> GHC.EpAnnComments -> GHC.EpAnnComments diff --git a/utils/check-exact/Transform.hs b/utils/check-exact/Transform.hs index fec7a32068..08b335291c 100644 --- a/utils/check-exact/Transform.hs +++ b/utils/check-exact/Transform.hs @@ -979,7 +979,7 @@ moveTrailingComments first second = do -- --------------------------------------------------------------------- anchorEof :: ParsedSource -> ParsedSource -anchorEof (L l m@(HsModule an _lo _mn _exps _imps _decls _ _)) = L l (m { hsmodAnn = an' }) +anchorEof (L l m@(HsModule (XModulePs an _lo _ _) _mn _exps _imps _decls)) = L l (m { hsmodExt = (hsmodExt m){ hsmodAnn = an' } }) where an' = addCommentOrigDeltasAnn an @@ -1128,12 +1128,12 @@ class (Data t) => HasDecls t where -- --------------------------------------------------------------------- instance HasDecls ParsedSource where - hsDecls (L _ (HsModule _ _lo _mn _exps _imps decls _ _)) = return decls - replaceDecls (L l (HsModule a lo mname exps imps _decls deps haddocks)) decls + hsDecls (L _ (HsModule (XModulePs _ _lo _ _) _mn _exps _imps decls)) = return decls + replaceDecls (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps _decls)) decls = do logTr "replaceDecls LHsModule" -- modifyAnnsT (captureOrder m decls) - return (L l (HsModule a lo mname exps imps decls deps haddocks)) + return (L l (HsModule (XModulePs a lo deps haddocks) mname exps imps decls)) -- --------------------------------------------------------------------- diff --git a/utils/check-exact/Utils.hs b/utils/check-exact/Utils.hs index 4f94222370..3f16407175 100644 --- a/utils/check-exact/Utils.hs +++ b/utils/check-exact/Utils.hs @@ -229,10 +229,10 @@ insertCppComments :: ParsedSource -> [LEpaComment] -> ParsedSource insertCppComments (L l p) cs = L l p' where ncs = EpaComments cs - an' = case GHC.hsmodAnn p of + an' = case GHC.hsmodAnn $ GHC.hsmodExt p of (EpAnn a an ocs) -> EpAnn a an (ocs <> ncs) unused -> unused - p' = p { GHC.hsmodAnn = an' } + p' = p { GHC.hsmodExt = (GHC.hsmodExt p) { GHC.hsmodAnn = an' } } -- --------------------------------------------------------------------- diff --git a/utils/check-ppr/Main.hs b/utils/check-ppr/Main.hs index 47b3fe3bbf..9758889052 100644 --- a/utils/check-ppr/Main.hs +++ b/utils/check-ppr/Main.hs @@ -90,8 +90,8 @@ parseOneFile libdir fileName = do Left _err -> error "parseOneFile" Right ms -> parseModule ms -getPragmas :: Located HsModule -> String -getPragmas (L _ (HsModule { hsmodAnn = anns'})) = pragmaStr +getPragmas :: Located (HsModule GhcPs) -> String +getPragmas (L _ (HsModule { hsmodExt = XModulePs { hsmodAnn = anns' } })) = pragmaStr where tokComment (L _ (EpaComment (EpaBlockComment s) _)) = s tokComment (L _ (EpaComment (EpaLineComment s) _)) = s diff --git a/utils/haddock b/utils/haddock -Subproject 89afef9daeb6da6624d42d32813d86c1f9b9f0c +Subproject 8976930748c4c9ba19cede2f0f29037d1cbce5e |