aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-06-02 19:02:14 +1000
committerYuchen Pei <hi@ypei.me>2022-06-02 19:02:14 +1000
commit8a5101dc657a2c9f720fc5da4ec59fd02a59e64d (patch)
tree928ea41c90c8ac8e5aac7b1f8d8d4cc83c3f4298
parentca6f5d8bfaaae477a5e6130ea91eec1f6567785e (diff)
renamed source
-rw-r--r--src/HaskellCodeExplorer/AST/RenamedSource.hs84
1 files changed, 26 insertions, 58 deletions
diff --git a/src/HaskellCodeExplorer/AST/RenamedSource.hs b/src/HaskellCodeExplorer/AST/RenamedSource.hs
index 44e0190..cb0f132 100644
--- a/src/HaskellCodeExplorer/AST/RenamedSource.hs
+++ b/src/HaskellCodeExplorer/AST/RenamedSource.hs
@@ -10,8 +10,10 @@ module HaskellCodeExplorer.AST.RenamedSource
, namesFromRenamedSource
) where
-import BasicTypes (TupleSort(..))
-import BooleanFormula (BooleanFormula(..))
+-- import BasicTypes (TupleSort(..))
+import GHC.Types.Basic (TupleSort(..))
+-- import BooleanFormula (BooleanFormula(..))
+import GHC.Data.BooleanFormula (BooleanFormula(..))
import Data.Generics (Data, everything, extQ, mkQ)
import Data.Maybe (Maybe(..), mapMaybe)
import qualified Data.Text as T (Text)
@@ -28,6 +30,7 @@ import GHC
, FixitySig(..)
, ForeignDecl(..)
, GenLocated(..)
+ , getLocA
, HsBindLR(..)
, HsExpr(..)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,1,0)
@@ -65,6 +68,7 @@ import GHC
, Name
, Pat(..)
, PatSynBind(..)
+ , reLocN
, Sig(..)
, TyClDecl(..)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@@ -79,17 +83,21 @@ import GHC
, unLoc
)
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
-import HsExtension (GhcRn)
+-- import HsExtension (GhcRn)
+import GHC.Hs.Extension (GhcRn)
#endif
import HaskellCodeExplorer.GhcUtils (hsPatSynDetails, ieLocNames, ghcDL)
import Prelude hiding (span)
-import TysWiredIn
+-- import TysWiredIn
+import GHC.Builtin.Types
( nilDataConName
, tupleTyConName
- , typeNatKind
+-- , typeNatKind
+ , naturalTy
, typeSymbolKind
)
-import SrcLoc
+-- import SrcLoc
+import GHC.Types.SrcLoc
( mkRealSrcSpan
, mkRealSrcLoc
, realSrcSpanEnd
@@ -139,19 +147,11 @@ namesFromRenamedSource =
roleAnnotationNames `extQ`
injectivityAnnotationNames)
-#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
fieldOccName :: Bool -> FieldOcc GhcRn -> NameOccurrence
-#else
-fieldOccName :: Bool -> FieldOcc Name -> NameOccurrence
-#endif
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
fieldOccName _ (XFieldOcc _) = undefined
-fieldOccName isBinder (FieldOcc name (L span _)) =
-#else
-fieldOccName isBinder (FieldOcc (L span _) name) =
-#endif
+fieldOccName isBinder (FieldOcc name located) =
NameOccurrence
- { locatedName = L span (Just name)
+ { locatedName = L (getLocA located) (Just name)
, description = "FieldOcc"
, isBinder = isBinder
}
@@ -215,12 +215,12 @@ hsExprNames (L _span (HsVar _ name)) =
hsExprNames (L _span (HsVar name)) =
#endif
[ NameOccurrence
- { locatedName = Just <$> name
+ { locatedName = Just <$> reLocN name
, description = "HsVar"
, isBinder = False
}
]
-hsExprNames (L span (ExplicitList _ _ exprs))
+hsExprNames (L span (ExplicitList _ exprs))
| null exprs =
[ NameOccurrence
{ locatedName = L span $ Just nilDataConName
@@ -268,7 +268,7 @@ hsExprNames (L span (HsRnBracketOut _ (VarBr _ quote name) _)) =
hsExprNames (L span (HsRnBracketOut (VarBr quote name) _)) =
#endif
case span of
- RealSrcSpan realSpan ->
+ RealSrcSpan realSpan _ ->
let start = realSrcSpanStart realSpan
end = realSrcSpanEnd realSpan
offset =
@@ -362,45 +362,29 @@ importNames =
ieLocNames
-#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
patNames :: LPat GhcRn -> [NameOccurrence]
-#else
-patNames :: LPat Name -> [NameOccurrence]
-#endif
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (ghcDL -> (L _span (VarPat _ name))) =
-#else
-patNames (L _span (VarPat name)) =
-#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "VarPat"
, isBinder = True
}
]
-patNames (ghcDL -> (L _span (ConPatIn name _))) =
+patNames (ghcDL -> (L _span (ConPat _ name _))) =
[ NameOccurrence
{ locatedName = Just <$> name
, description = "ConPatIn"
, isBinder = False
}
]
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (ghcDL -> (L _span (AsPat _ name _))) =
-#else
-patNames (L _span (AsPat name _)) =
-#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "AsPat"
, isBinder = True
}
]
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
patNames (ghcDL -> (L _span (NPlusKPat _ name _ _ _ _))) =
-#else
-patNames (L _span (NPlusKPat name _ _ _ _ _)) =
-#endif
[ NameOccurrence
{ locatedName = Just <$> name
, description = "NPlusKPat"
@@ -538,7 +522,7 @@ hsTypeNames (L span (HsTyLit lit)) =
#endif
let kind =
case lit of
- HsNumTy _ _ -> typeNatKind
+ HsNumTy _ _ -> naturalTy
HsStrTy _ _ -> typeSymbolKind
in [ TyLitOccurrence
{ locatedName = L span Nothing
@@ -566,8 +550,6 @@ hsTypeNames (L span (HsTupleTy tupleSort types))
let sort =
case tupleSort of
HsUnboxedTuple -> UnboxedTuple
- HsBoxedTuple -> BoxedTuple
- HsConstraintTuple -> ConstraintTuple
HsBoxedOrConstraintTuple -> BoxedTuple
in [ NameOccurrence
{ locatedName = L span (Just $ tupleTyConName sort 0)
@@ -582,36 +564,22 @@ hsTypeNames (L span (HsTupleTy tupleSort types))
hsTypeNames _ = []
-#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
-hsTyVarBndrNames :: HsTyVarBndr GhcRn -> [NameOccurrence]
-#else
-hsTyVarBndrNames :: HsTyVarBndr Name -> [NameOccurrence]
-#endif
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
-hsTyVarBndrNames (UserTyVar _ n) =
-#else
-hsTyVarBndrNames (UserTyVar n) =
-#endif
+hsTyVarBndrNames :: HsTyVarBndr flag GhcRn -> [NameOccurrence]
+hsTyVarBndrNames (UserTyVar _ _ n) =
[ NameOccurrence
{ locatedName = Just <$> n
, description = "UserTyVar"
, isBinder = True
}
]
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
-hsTyVarBndrNames (KindedTyVar _ n _) =
-#else
-hsTyVarBndrNames (KindedTyVar n _) =
-#endif
+hsTyVarBndrNames (KindedTyVar _ _ n _) =
[ NameOccurrence
{ locatedName = Just <$> n
, description = "KindedTyVar"
, isBinder = True
}
]
-#if MIN_VERSION_GLASGOW_HASKELL(8,6,1,0)
hsTyVarBndrNames _ = []
-#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
@@ -669,7 +637,7 @@ familyDeclNames _ = []
#endif
#if MIN_VERSION_GLASGOW_HASKELL(8,4,3,0)
-familyEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (LHsType GhcRn) -> [NameOccurrence]
+familyEqNames :: FamEqn GhcRn (LHsType GhcRn) -> [NameOccurrence]
familyEqNames FamEqn {feqn_tycon = tyCon} =
[ NameOccurrence
{ locatedName = Just <$> tyCon
@@ -681,7 +649,7 @@ familyEqNames FamEqn {feqn_tycon = tyCon} =
familyEqNames _ = []
#endif
-dataEqNames :: FamEqn GhcRn (HsTyPats GhcRn) (HsDataDefn GhcRn) -> [NameOccurrence]
+dataEqNames :: FamEqn GhcRn (HsDataDefn GhcRn) -> [NameOccurrence]
dataEqNames FamEqn {feqn_tycon = tyCon} =
[ NameOccurrence
{ locatedName = Just <$> tyCon