@@ -3,6 +3,7 @@
33
44-- ORIGINALLY COPIED FROM https://github.com/commercialhaskell/intero
55
6+{-# LANGUAGE CPP #-}
67{-# LANGUAGE RankNTypes #-}
78
89-- | Get information on modules, identifiers, etc.
@@ -31,6 +32,14 @@ import Development.IDE.Core.Compile
3132import Development.IDE.GHC.Util
3233
3334
35+-- A lot of things gained an extra X argument in GHC 8.6, which we mostly ignore
36+-- this U ignores that arg in 8.6, but is hidden in 8.4
37+#if __GLASGOW_HASKELL__ >= 806
38+#define U _
39+#else
40+#define U
41+#endif
42+
3443-- | Get source span info, used for e.g. AtPoint and Goto Definition.
3544getSrcSpanInfos
3645 :: HscEnv
@@ -75,12 +84,12 @@ getExports m
7584 ]
7685getExports _ = []
7786
78−-- | Variant of GHC’s ieNames that produces LIdP instead of IdP
79−ieLNames :: IE pass -> [LIdP pass]
80−ieLNames (IEVar _ n ) = [ieLWrappedName n]
81−ieLNames (IEThingAbs _ n ) = [ieLWrappedName n]
82−ieLNames (IEThingAll _ n ) = [ieLWrappedName n]
83−ieLNames (IEThingWith _ n _ ns _) = ieLWrappedName n : map ieLWrappedName ns
87+-- | Variant of GHC's ieNames that produces LIdP instead of IdP
88+ieLNames :: IE pass -> [Located (IdP pass)]
89+ieLNames (IEVar U n ) = [ieLWrappedName n]
90+ieLNames (IEThingAbs U n ) = [ieLWrappedName n]
91+ieLNames (IEThingAll U n ) = [ieLWrappedName n]
92+ieLNames (IEThingWith U n _ ns _) = ieLWrappedName n : map ieLWrappedName ns
8493ieLNames _ = []
8594
8695-- | Get the name and type of a binding.
@@ -88,7 +97,7 @@ getTypeLHsBind :: (GhcMonad m)
8897 => TypecheckedModule
8998 -> LHsBind GhcTc
9099 -> m [(SpanSource, SrcSpan, Maybe Type)]
91−getTypeLHsBind _ (L _spn FunBind{fun_id = pid,fun_matches = MG _ _ _typ}) =
100+getTypeLHsBind _ (L _spn FunBind{fun_id = pid,fun_matches = MG{}}) =
92101 return [(Named $ getName (unLoc pid), getLoc pid, Just (varType (unLoc pid)))]
93102getTypeLHsBind _ _ = return []
94103
@@ -107,11 +116,11 @@ getTypeLHsExpr _ e = do
107116 Nothing -> Nothing
108117 where
109118 getSpanSource :: HsExpr GhcTc -> SpanSource
110− getSpanSource (HsVar _ (L _ i)) = Named (getName i)
111− getSpanSource (HsConLikeOut _ (RealDataCon dc)) = Named (dataConName dc)
119+ getSpanSource (HsVar U (L _ i)) = Named (getName i)
120+ getSpanSource (HsConLikeOut U (RealDataCon dc)) = Named (dataConName dc)
112121 getSpanSource RecordCon {rcon_con_name} = Named (getName rcon_con_name)
113− getSpanSource (HsWrap _ _ xpr) = getSpanSource xpr
114− getSpanSource (HsPar _ xpr) = getSpanSource (unLoc xpr)
122+ getSpanSource (HsWrap U _ xpr) = getSpanSource xpr
123+ getSpanSource (HsPar U xpr) = getSpanSource (unLoc xpr)
115124 getSpanSource _ = NoSource
116125
117126-- | Get the name and type of a pattern.
@@ -124,7 +133,7 @@ getTypeLPat _ pat =
124133 return $ Just (src, spn, Just (hsPatType pat))
125134 where
126135 getSpanSource :: Pat GhcTc -> (SpanSource, SrcSpan)
127− getSpanSource (VarPat _ (L spn vid)) = (Named (getName vid), spn)
136+ getSpanSource (VarPat U (L spn vid)) = (Named (getName vid), spn)
128137 getSpanSource (ConPatOut (L spn (RealDataCon dc)) _ _ _ _ _ _) =
129138 (Named (dataConName dc), spn)
130139 getSpanSource _ = (NoSource, noSrcSpan)
@@ -134,7 +143,7 @@ getLHsType
134143 => TypecheckedModule
135144 -> LHsType GhcRn
136145 -> m [(SpanSource, SrcSpan, Maybe Type)]
137−getLHsType _ (L spn (HsTyVar _ _ v)) = pure [(Named $ unLoc v, spn, Nothing)]
146+getLHsType _ (L spn (HsTyVar U _ v)) = pure [(Named $ unLoc v, spn, Nothing)]
138147getLHsType _ _ = pure []
139148
140149importInfo :: [(Located ModuleName, Maybe NormalizedFilePath)]