@@ -22,7 +22,11 @@ import Development.IDE
2222import Development.IDE.Core.PositionMapping
2323import Development.IDE.GHC.Compat hiding (getContext )
2424import GHC.Generics (Generic )
25+
26+ #if MIN_VERSION_ghc(9,9,0)
2527import GHC.Hs (HasLoc )
28+ #endif
29+
2630
2731-- | A context of a declaration in the program e.g. is the declaration a
2832-- type declaration or a value declaration. Used for determining which code
@@ -118,8 +122,13 @@ getContextMap pm =
118122 HsModule {hsmodImports, hsmodDecls} =
119123 unLoc (pm_parsed_source pm)
120124
125+ #if MIN_VERSION_ghc(9,9,0)
121126rangeOf :: HasLoc a => a -> Maybe Range
122127rangeOf = srcSpanToRange . locA
128+ #else
129+ rangeOf :: GenLocated (SrcSpanAnn' a ) e -> Maybe Range
130+ rangeOf = srcSpanToRange . getLocA
131+ #endif
123132
124133getImportContext :: LImportDecl GhcPs -> Range -> ContextResult
125134getImportContext imports query =
@@ -197,7 +206,12 @@ sigQ = contextual TypeContext True
197206bindQ :: Range -> LHsBind GhcPs -> (ContextResult , Bool )
198207bindQ = contextual ValueContext False
199208
209+
210+ #if MIN_VERSION_ghc(9,9,0)
200211contextual :: HasLoc a => Context -> Bool -> Range -> a -> (ContextResult , Bool )
212+ #else
213+ contextual :: Context -> Bool -> Range -> GenLocated (SrcSpanAnn' a ) e -> (ContextResult , Bool )
214+ #endif
201215contextual context shouldStop query s =
202216 let range = rangeOf s
203217 in case range of
0 commit comments