summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2021-03-25 20:06:28 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-31 11:13:28 -0400
commit2fcebb72d97edd1e630002bef89bc6982529e36f (patch)
treef99af71a7e68e8a42b3223c069990554a5795786 /utils
parentdbadd672ba7da67533c34d8594ac7f91dde0f415 (diff)
downloadhaskell-2fcebb72d97edd1e630002bef89bc6982529e36f.tar.gz
EPA : Rename AddApiAnn to AddEpAnn
As port of the process of migrating naming from API Annotations to exact print annotations (EPA) Follow-up from !2418, see #19579
Diffstat (limited to 'utils')
-rw-r--r--utils/check-exact/ExactPrint.hs58
-rw-r--r--utils/check-exact/Main.hs12
-rw-r--r--utils/check-exact/Transform.hs12
-rw-r--r--utils/check-exact/Types.hs18
-rw-r--r--utils/check-exact/Utils.hs4
5 files changed, 43 insertions, 61 deletions
diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs
index 80ef0eb19c..9d911e34fe 100644
--- a/utils/check-exact/ExactPrint.hs
+++ b/utils/check-exact/ExactPrint.hs
@@ -293,11 +293,11 @@ addComments csNew = do
-- |In order to interleave annotations into the stream, we turn them into
-- comments.
-annotationsToComments :: [AddApiAnn] -> [AnnKeywordId] -> EPP ()
+annotationsToComments :: [AddEpAnn] -> [AnnKeywordId] -> EPP ()
annotationsToComments ans kws = do
let
getSpans _ [] = []
- getSpans k1 (AddApiAnn k2 ss:as)
+ getSpans k1 (AddEpAnn k2 ss:as)
| k1 == k2 = ss : getSpans k1 as
| otherwise = getSpans k1 as
doOne :: AnnKeywordId -> EPP [Comment]
@@ -382,7 +382,7 @@ instance ExactPrint HsModule where
debugM $ "HsModule.AnnWhere coming"
setLayoutTopLevelP $ markApiAnn' an am_main AnnWhere
- setLayoutTopLevelP $ mapM_ markAddApiAnn (al_open $ am_decls $ anns an)
+ setLayoutTopLevelP $ mapM_ markAddEpAnn (al_open $ am_decls $ anns an)
-- markOptional GHC.AnnOpenC -- Possible '{'
-- markManyOptional GHC.AnnSemi -- possible leading semis
@@ -395,7 +395,7 @@ instance ExactPrint HsModule where
-- setLayoutTopLevelP $ markAnnotated decls
markTopLevelList decls
- setLayoutTopLevelP $ mapM_ markAddApiAnn (al_close $ am_decls $ anns an)
+ setLayoutTopLevelP $ mapM_ markAddEpAnn (al_close $ am_decls $ anns an)
-- markOptional GHC.AnnCloseC -- Possible '}'
-- markEOF
@@ -473,36 +473,36 @@ markExternalSourceText l (SourceText txt) _ = printStringAtKw' (realSrcSpan l) t
-- ---------------------------------------------------------------------
-markAddApiAnn :: AddApiAnn -> EPP ()
-markAddApiAnn a@(AddApiAnn kw _) = mark [a] kw
+markAddEpAnn :: AddEpAnn -> EPP ()
+markAddEpAnn a@(AddEpAnn kw _) = mark [a] kw
-markLocatedMAA :: ApiAnn' a -> (a -> Maybe AddApiAnn) -> EPP ()
+markLocatedMAA :: ApiAnn' a -> (a -> Maybe AddEpAnn) -> EPP ()
markLocatedMAA ApiAnnNotUsed _ = return ()
markLocatedMAA (ApiAnn _ a _) f =
case f a of
Nothing -> return ()
- Just aa -> markAddApiAnn aa
+ Just aa -> markAddEpAnn aa
-markLocatedAA :: ApiAnn' a -> (a -> AddApiAnn) -> EPP ()
+markLocatedAA :: ApiAnn' a -> (a -> AddEpAnn) -> EPP ()
markLocatedAA ApiAnnNotUsed _ = return ()
markLocatedAA (ApiAnn _ a _) f = markKw (f a)
-markLocatedAAL :: ApiAnn' a -> (a -> [AddApiAnn]) -> AnnKeywordId -> EPP ()
+markLocatedAAL :: ApiAnn' a -> (a -> [AddEpAnn]) -> AnnKeywordId -> EPP ()
markLocatedAAL ApiAnnNotUsed _ _ = return ()
markLocatedAAL (ApiAnn _ a _) f kw = go (f a)
where
go [] = return ()
- go (aa@(AddApiAnn kw' _):as)
+ go (aa@(AddEpAnn kw' _):as)
| kw' == kw = mark [aa] kw
| otherwise = go as
-markLocatedAALS :: ApiAnn' a -> (a -> [AddApiAnn]) -> AnnKeywordId -> Maybe String -> EPP ()
+markLocatedAALS :: ApiAnn' a -> (a -> [AddEpAnn]) -> AnnKeywordId -> Maybe String -> EPP ()
markLocatedAALS an f kw Nothing = markLocatedAAL an f kw
markLocatedAALS ApiAnnNotUsed _ _ _ = return ()
markLocatedAALS (ApiAnn _ a _) f kw (Just str) = go (f a)
where
go [] = return ()
- go (AddApiAnn kw' r:as)
+ go (AddEpAnn kw' r:as)
| kw' == kw = printStringAtAA r str
| otherwise = go as
@@ -567,21 +567,21 @@ markApiAnn :: ApiAnn -> AnnKeywordId -> EPP ()
markApiAnn ApiAnnNotUsed _ = return ()
markApiAnn (ApiAnn _ a _) kw = mark a kw
-markApiAnn' :: ApiAnn' ann -> (ann -> [AddApiAnn]) -> AnnKeywordId -> EPP ()
+markApiAnn' :: ApiAnn' ann -> (ann -> [AddEpAnn]) -> AnnKeywordId -> EPP ()
markApiAnn' ApiAnnNotUsed _ _ = return ()
markApiAnn' (ApiAnn _ a _) f kw = mark (f a) kw
-markApiAnnAll :: ApiAnn' ann -> (ann -> [AddApiAnn]) -> AnnKeywordId -> EPP ()
+markApiAnnAll :: ApiAnn' ann -> (ann -> [AddEpAnn]) -> AnnKeywordId -> EPP ()
markApiAnnAll ApiAnnNotUsed _ _ = return ()
markApiAnnAll (ApiAnn _ a _) f kw = mapM_ markKw (sort anns)
where
- anns = filter (\(AddApiAnn ka _) -> ka == kw) (f a)
+ anns = filter (\(AddEpAnn ka _) -> ka == kw) (f a)
-mark :: [AddApiAnn] -> AnnKeywordId -> EPP ()
+mark :: [AddEpAnn] -> AnnKeywordId -> EPP ()
mark anns kw = do
- case find (\(AddApiAnn k _) -> k == kw) anns of
+ case find (\(AddEpAnn k _) -> k == kw) anns of
Just aa -> markKw aa
- Nothing -> case find (\(AddApiAnn k _) -> k == (unicodeAnn kw)) anns of
+ Nothing -> case find (\(AddEpAnn k _) -> k == (unicodeAnn kw)) anns of
Just aau -> markKw aau
Nothing -> return ()
@@ -594,8 +594,8 @@ markKwT (AddRarrowAnnU ss) = markKwA AnnRarrowU ss
-- markKwT (AddLollyAnn ss) = markKwA AnnLolly ss
-- markKwT (AddLollyAnnU ss) = markKwA AnnLollyU ss
-markKw :: AddApiAnn -> EPP ()
-markKw (AddApiAnn kw ss) = markKwA kw ss
+markKw :: AddEpAnn -> EPP ()
+markKw (AddEpAnn kw ss) = markKwA kw ss
-- | This should be the main driver of the process, managing comments
markKwA :: AnnKeywordId -> AnnAnchor -> EPP ()
@@ -1005,7 +1005,7 @@ instance ExactPrint (RuleDecl GhcPs) where
-- inContext (Set.singleton Intercalate) $ mark GHC.AnnSemi
-- markTrailingSemi
-markActivation :: ApiAnn' a -> (a -> [AddApiAnn]) -> Activation -> Annotated ()
+markActivation :: ApiAnn' a -> (a -> [AddEpAnn]) -> Activation -> Annotated ()
markActivation an fn act = do
case act of
ActiveBefore src phase -> do
@@ -3164,19 +3164,19 @@ instance ExactPrint (LocatedN RdrName) where
markTrailing t
NameAnnCommas a o cs c t -> do
let (kwo,kwc) = adornments a
- markKw (AddApiAnn kwo o)
- forM_ cs (\loc -> markKw (AddApiAnn AnnComma loc))
- markKw (AddApiAnn kwc c)
+ markKw (AddEpAnn kwo o)
+ forM_ cs (\loc -> markKw (AddEpAnn AnnComma loc))
+ markKw (AddEpAnn kwc c)
markTrailing t
NameAnnOnly a o c t -> do
markName a o Nothing c
markTrailing t
NameAnnRArrow nl t -> do
- markKw (AddApiAnn AnnRarrow nl)
+ markKw (AddEpAnn AnnRarrow nl)
markTrailing t
NameAnnQuote q name t -> do
debugM $ "NameAnnQuote"
- markKw (AddApiAnn AnnSimpleQuote q)
+ markKw (AddEpAnn AnnSimpleQuote q)
markAnnotated (L name n)
markTrailing t
NameAnnTrailing t -> do
@@ -3187,11 +3187,11 @@ markName :: NameAdornment
-> AnnAnchor -> Maybe (AnnAnchor,RdrName) -> AnnAnchor -> EPP ()
markName adorn open mname close = do
let (kwo,kwc) = adornments adorn
- markKw (AddApiAnn kwo open)
+ markKw (AddEpAnn kwo open)
case mname of
Nothing -> return ()
Just (name, a) -> printStringAtAA name (showPprUnsafe a)
- markKw (AddApiAnn kwc close)
+ markKw (AddEpAnn kwc close)
adornments :: NameAdornment -> (AnnKeywordId, AnnKeywordId)
adornments NameParens = (AnnOpenP, AnnCloseP)
diff --git a/utils/check-exact/Main.hs b/utils/check-exact/Main.hs
index 1a3a5f2bf6..d5bc59662d 100644
--- a/utils/check-exact/Main.hs
+++ b/utils/check-exact/Main.hs
@@ -878,9 +878,9 @@ addHiding1 _libdir (L l p) = do
v2 = L ( noAnnSrcSpanDP0 l2) (IEVar noExtField (L (noAnnSrcSpanDP0 l2) (IEName n2)))
impHiding = L (SrcSpanAnn (ApiAnn (Anchor (realSrcSpan l0) m0)
(AnnList Nothing
- (Just (AddApiAnn AnnOpenP d1))
- (Just (AddApiAnn AnnCloseP d0))
- [(AddApiAnn AnnHiding d1)]
+ (Just (AddEpAnn AnnOpenP d1))
+ (Just (AddEpAnn AnnCloseP d0))
+ [(AddEpAnn AnnHiding d1)]
[])
noCom) l0) [v1,v2]
imp1' = imp1 { ideclHiding = Just (True,impHiding)}
@@ -903,9 +903,9 @@ addHiding2 _libdir (L l p) = do
Just (_,L lh ns) = ideclHiding imp1
lh' = (SrcSpanAnn (ApiAnn (Anchor (realSrcSpan (locA lh)) m0)
(AnnList Nothing
- (Just (AddApiAnn AnnOpenP d1))
- (Just (AddApiAnn AnnCloseP d0))
- [(AddApiAnn AnnHiding d1)]
+ (Just (AddEpAnn AnnOpenP d1))
+ (Just (AddEpAnn AnnCloseP d0))
+ [(AddEpAnn AnnHiding d1)]
[])
noCom) (locA lh))
n1 = L (noAnnSrcSpanDP0 l1) (mkVarUnqual (mkFastString "n1"))
diff --git a/utils/check-exact/Transform.hs b/utils/check-exact/Transform.hs
index ea0b38870f..71e27428f2 100644
--- a/utils/check-exact/Transform.hs
+++ b/utils/check-exact/Transform.hs
@@ -291,14 +291,14 @@ captureTypeSigSpacing (L l (SigD x (TypeSig (ApiAnn anc (AnnSig dc rs') cs) ns (
where
-- we want DPs for the distance from the end of the ns to the
-- AnnDColon, and to the start of the ty
- AddApiAnn kw dca = dc
+ AddEpAnn kw dca = dc
rd = case last ns of
L (SrcSpanAnn ApiAnnNotUsed ll) _ -> realSrcSpan ll
L (SrcSpanAnn (ApiAnn anc' _ _) _) _ -> anchor anc' -- TODO MovedAnchor?
-- DP (line, col) = ss2delta (ss2pos $ anchor $ getLoc lc) r
dc' = case dca of
- AR r -> AddApiAnn kw (AD $ ss2delta (ss2posEnd rd) r)
- AD _ -> AddApiAnn kw dca
+ AR r -> AddEpAnn kw (AD $ ss2delta (ss2posEnd rd) r)
+ AD _ -> AddEpAnn kw dca
-- ---------------------------------
@@ -1414,7 +1414,7 @@ oldWhereAnnotation :: (Monad m)
oldWhereAnnotation ApiAnnNotUsed ww _oldSpan = do
newSpan <- uniqueSrcSpanT
let w = case ww of
- WithWhere -> [AddApiAnn AnnWhere (AD (DP 0 0))]
+ WithWhere -> [AddEpAnn AnnWhere (AD (DP 0 0))]
WithoutWhere -> []
let anc2' = Anchor (rs newSpan) (MovedAnchor (DP 0 1))
(anc, anc2) <- do
@@ -1429,7 +1429,7 @@ oldWhereAnnotation (ApiAnn anc an cs) ww _oldSpan = do
-- TODO: when we set DP (0,0) for the HsValBinds ApiAnnAnchor, change the AnnList anchor to have the correct DP too
let (AnnList ancl o c _r t) = an
let w = case ww of
- WithWhere -> [AddApiAnn AnnWhere (AD (DP 0 0))]
+ WithWhere -> [AddEpAnn AnnWhere (AD (DP 0 0))]
WithoutWhere -> []
(anc', ancl') <- do
case ww of
@@ -1446,7 +1446,7 @@ newWhereAnnotation ww = do
let anc = Anchor (rs newSpan) (MovedAnchor (DP 1 2))
let anc2 = Anchor (rs newSpan) (MovedAnchor (DP 1 4))
let w = case ww of
- WithWhere -> [AddApiAnn AnnWhere (AD (DP 0 0))]
+ WithWhere -> [AddEpAnn AnnWhere (AD (DP 0 0))]
WithoutWhere -> []
let an = ApiAnn anc
(AnnList (Just anc2) Nothing Nothing w [])
diff --git a/utils/check-exact/Types.hs b/utils/check-exact/Types.hs
index 46ce9b4291..6bae34631a 100644
--- a/utils/check-exact/Types.hs
+++ b/utils/check-exact/Types.hs
@@ -12,30 +12,13 @@ module Types
where
import GHC hiding (AnnComment)
--- import GHC.Hs.Extension
--- import GHC.Parser.Lexer (AddApiAnn(..))
--- import GHC.Types.Basic hiding (EP)
--- import GHC.Types.Name.Reader
--- import GHC.Types.SrcLoc
import GHC.Utils.Outputable hiding ( (<>) )
--- import GHC.Driver.Session
import GHC.Driver.Ppr
--- import Control.Monad.Identity
--- import Control.Monad.RWS
import Data.Data (Data, toConstr,cast)
--- import Data.Foldable
--- import Data.List (sortBy, elemIndex)
--- import Data.Maybe (fromMaybe)
--- import Data.Ord (comparing)
import qualified Data.Map as Map
import qualified Data.Set as Set
--- import qualified GHC
--- import Lookup
-
--- ---------------------------------------------------------------------
-
-- ---------------------------------------------------------------------
-- | This structure holds a complete set of annotations for an AST
type Anns = Map.Map AnnKey Annotation
@@ -48,7 +31,6 @@ emptyAnns = Map.empty
-- These are used to maintain context in the AP and EP monads
data AnnKey = AnnKey RealSrcSpan AnnConName
deriving (Eq, Data, Ord)
--- deriving instance Ord SrcSpan
-- More compact Show instance
instance Show AnnKey where
diff --git a/utils/check-exact/Utils.hs b/utils/check-exact/Utils.hs
index 9a5864b696..a6e026d189 100644
--- a/utils/check-exact/Utils.hs
+++ b/utils/check-exact/Utils.hs
@@ -145,8 +145,8 @@ undelta (l,c) (DP dl dc) (LayoutStartCol co) = (fl,fc)
fc = if dl == 0 then c + dc
else co + dc
-undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddApiAnn
-undeltaSpan anchor kw dp = AddApiAnn kw (AR sp)
+undeltaSpan :: RealSrcSpan -> AnnKeywordId -> DeltaPos -> AddEpAnn
+undeltaSpan anchor kw dp = AddEpAnn kw (AR sp)
where
(l,c) = undelta (ss2pos anchor) dp (LayoutStartCol 0)
len = length (keywordToString (G kw))