Commit f46bfeb8 authored by Alan Zimmerman's avatar Alan Zimmerman
Browse files

API Annotations: make all ModuleName Located

Summary:
This also changes the backpack Renaming type to use a Maybe for the
renameTo field, to more accurately reflect the parsed source.

Updates haddock submodule to match AST changes

Test Plan: ./validate

Reviewers: ezyang, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, mpickering

Differential Revision: https://phabricator.haskell.org/D2670
parent ec22bacd
......@@ -73,5 +73,6 @@ data IncludeDecl n = IncludeDecl {
-- | Rename a module from one name to another. The identity renaming
-- means that the module should be brought into scope.
data Renaming = Renaming { renameFrom :: ModuleName, renameTo :: ModuleName }
data Renaming = Renaming { renameFrom :: Located ModuleName
, renameTo :: Maybe (Located ModuleName) }
type LRenaming = Located Renaming
......@@ -213,9 +213,12 @@ hsunitDeps :: HsUnit HsComponentId -> [(UnitId, ModRenaming)]
hsunitDeps unit = concatMap get_dep (hsunitBody unit)
where
get_dep (L _ (IncludeD (IncludeDecl (L _ hsuid) mb_lrn))) = [(convertHsUnitId hsuid, go mb_lrn)]
where go Nothing = ModRenaming True []
go (Just lrns) = ModRenaming False (map convRn lrns)
where convRn (L _ (Renaming from to)) = (from, to)
where
go Nothing = ModRenaming True []
go (Just lrns) = ModRenaming False (map convRn lrns)
where
convRn (L _ (Renaming (L _ from) Nothing)) = (from, from)
convRn (L _ (Renaming (L _ from) (Just (L _ to)))) = (from, to)
get_dep _ = []
buildUnit :: SessionType -> ComponentId -> [(ModuleName, Module)] -> LHsUnit HsComponentId -> BkpM ()
......
......@@ -53,7 +53,7 @@ data ImportDecl name
ideclSafe :: Bool, -- ^ True => safe import
ideclQualified :: Bool, -- ^ True => qualified
ideclImplicit :: Bool, -- ^ True => implicit import (of Prelude)
ideclAs :: Maybe ModuleName, -- ^ as Module
ideclAs :: Maybe (Located ModuleName), -- ^ as Module
ideclHiding :: Maybe (Bool, Located [LIE name])
-- ^ (True => hiding, names)
}
......
......@@ -575,8 +575,8 @@ rns :: { OrdList LRenaming }
| rn { unitOL $1 }
rn :: { LRenaming }
: modid 'as' modid { sLL $1 $> $ Renaming (unLoc $1) (unLoc $3) }
| modid { sL1 $1 $ Renaming (unLoc $1) (unLoc $1) }
: modid 'as' modid { sLL $1 $> $ Renaming $1 (Just $3) }
| modid { sL1 $1 $ Renaming $1 Nothing }
unitbody :: { OrdList (LHsUnitDecl PackageName) }
: '{' unitdecls '}' { $2 }
......@@ -847,9 +847,9 @@ optqualified :: { ([AddAnn],Bool) }
: 'qualified' { ([mj AnnQualified $1],True) }
| {- empty -} { ([],False) }
maybeas :: { ([AddAnn],Located (Maybe ModuleName)) }
: 'as' modid { ([mj AnnAs $1,mj AnnVal $2]
,sLL $1 $> (Just (unLoc $2))) }
maybeas :: { ([AddAnn],Located (Maybe (Located ModuleName))) }
: 'as' modid { ([mj AnnAs $1]
,sLL $1 $> (Just $2)) }
| {- empty -} { ([],noLoc Nothing) }
maybeimpspec :: { Located (Maybe (Bool, Located [LIE RdrName])) }
......
......@@ -266,7 +266,7 @@ rnImportDecl this_mod
++ "Safe, Trustworthy or Unsafe"))
let
qual_mod_name = as_mod `orElse` imp_mod_name
qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name
imp_spec = ImpDeclSpec { is_mod = imp_mod_name, is_qual = qual_only,
is_dloc = loc, is_as = qual_mod_name }
......
......@@ -749,7 +749,7 @@ getInfoForPrompt = do
rev_imports = reverse imports -- rightmost are the most recent
myIdeclName d | Just m <- ideclAs d = m
myIdeclName d | Just m <- ideclAs d = unLoc m
| otherwise = unLoc (ideclName d)
modules_names =
......
......@@ -12,7 +12,6 @@
((Test10312.hs:9:1-30,AnnImport), [Test10312.hs:9:1-6]),
((Test10312.hs:9:1-30,AnnQualified), [Test10312.hs:9:8-16]),
((Test10312.hs:9:1-30,AnnSemi), [Test10312.hs:10:1]),
((Test10312.hs:9:1-30,AnnVal), [Test10312.hs:9:30]),
((Test10312.hs:10:1-27,AnnImport), [Test10312.hs:10:1-6]),
((Test10312.hs:10:1-27,AnnSemi), [Test10312.hs:11:1]),
((Test10312.hs:10:17-27,AnnCloseP), [Test10312.hs:10:27]),
......
......@@ -19,8 +19,6 @@
(AK AnnotationLet.hs:5:1-32 AnnSemi = [AnnotationLet.hs:6:1])
(AK AnnotationLet.hs:5:1-32 AnnVal = [AnnotationLet.hs:5:31-32])
(AK AnnotationLet.hs:(7,1)-(11,12) AnnEqual = [AnnotationLet.hs:7:5])
(AK AnnotationLet.hs:(7,1)-(11,12) AnnFunId = [AnnotationLet.hs:7:1-3])
......
......@@ -14,7 +14,6 @@
((AnnotationTuple.hs:6:1-32,AnnImport), [AnnotationTuple.hs:6:1-6]),
((AnnotationTuple.hs:6:1-32,AnnQualified), [AnnotationTuple.hs:6:8-16]),
((AnnotationTuple.hs:6:1-32,AnnSemi), [AnnotationTuple.hs:7:1]),
((AnnotationTuple.hs:6:1-32,AnnVal), [AnnotationTuple.hs:6:31-32]),
((AnnotationTuple.hs:(8,1)-(11,14),AnnEqual), [AnnotationTuple.hs:8:5]),
((AnnotationTuple.hs:(8,1)-(11,14),AnnFunId), [AnnotationTuple.hs:8:1-3]),
((AnnotationTuple.hs:(8,1)-(11,14),AnnSemi), [AnnotationTuple.hs:13:1]),
......
{ListComprehensions.hs:1:1, ListComprehensions.hs:6:8-25,
ListComprehensions.hs:10:1-15, ListComprehensions.hs:10:8-15,
ListComprehensions.hs:11:1-30, ListComprehensions.hs:11:18-25,
ListComprehensions.hs:12:1-27, ListComprehensions.hs:12:8-15,
ListComprehensions.hs:12:17-27, ListComprehensions.hs:12:18-26,
ListComprehensions.hs:13:1-25, ListComprehensions.hs:13:8-16,
ListComprehensions.hs:13:18-25, ListComprehensions.hs:13:19-24,
ListComprehensions.hs:17:1-16, ListComprehensions.hs:17:1-25,
ListComprehensions.hs:17:21-25, ListComprehensions.hs:17:22-24,
ListComprehensions.hs:18:1-16,
ListComprehensions.hs:11:30, ListComprehensions.hs:12:1-27,
ListComprehensions.hs:12:8-15, ListComprehensions.hs:12:17-27,
ListComprehensions.hs:12:18-26, ListComprehensions.hs:13:1-25,
ListComprehensions.hs:13:8-16, ListComprehensions.hs:13:18-25,
ListComprehensions.hs:13:19-24, ListComprehensions.hs:17:1-16,
ListComprehensions.hs:17:1-25, ListComprehensions.hs:17:21-25,
ListComprehensions.hs:17:22-24, ListComprehensions.hs:18:1-16,
ListComprehensions.hs:(18,1)-(22,20),
ListComprehensions.hs:(18,18)-(22,20),
ListComprehensions.hs:(18,20)-(22,20), ListComprehensions.hs:18:22,
......@@ -55,8 +55,6 @@
(AK ListComprehensions.hs:11:1-30 AnnSemi = [ListComprehensions.hs:12:1])
(AK ListComprehensions.hs:11:1-30 AnnVal = [ListComprehensions.hs:11:30])
(AK ListComprehensions.hs:12:1-27 AnnImport = [ListComprehensions.hs:12:1-6])
(AK ListComprehensions.hs:12:1-27 AnnSemi = [ListComprehensions.hs:13:1])
......
......@@ -30,8 +30,6 @@
(AK AnnotationTuple.hs:6:1-32 AnnSemi = [AnnotationTuple.hs:7:1])
(AK AnnotationTuple.hs:6:1-32 AnnVal = [AnnotationTuple.hs:6:31-32])
(AK AnnotationTuple.hs:(8,1)-(11,14) AnnEqual = [AnnotationTuple.hs:8:5])
(AK AnnotationTuple.hs:(8,1)-(11,14) AnnFunId = [AnnotationTuple.hs:8:1-3])
......
Subproject commit a5a51f99f42c7ee5e3bb4aeddf601b5f20a88134
Subproject commit f4e355f7023057924161160ce75aeaaa3a8d9914
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment