Skip to content

Commit d8ba345

Browse files
committed
Compatibility ifs
1 parent 4e904c8 commit d8ba345

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

ghcide/src/Development/IDE/Plugin/Completions/Context.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import Development.IDE
2222
import Development.IDE.Core.PositionMapping
2323
import Development.IDE.GHC.Compat hiding (getContext)
2424
import GHC.Generics (Generic)
25+
26+
#if MIN_VERSION_ghc(9,9,0)
2527
import 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)
121126
rangeOf :: HasLoc a => a -> Maybe Range
122127
rangeOf = srcSpanToRange . locA
128+
#else
129+
rangeOf :: GenLocated (SrcSpanAnn' a) e -> Maybe Range
130+
rangeOf = srcSpanToRange . getLocA
131+
#endif
123132

124133
getImportContext :: LImportDecl GhcPs -> Range -> ContextResult
125134
getImportContext imports query =
@@ -197,7 +206,12 @@ sigQ = contextual TypeContext True
197206
bindQ :: Range -> LHsBind GhcPs -> (ContextResult, Bool)
198207
bindQ = contextual ValueContext False
199208

209+
210+
#if MIN_VERSION_ghc(9,9,0)
200211
contextual :: HasLoc a => Context -> Bool -> Range -> a -> (ContextResult, Bool)
212+
#else
213+
contextual :: Context -> Bool -> Range -> GenLocated (SrcSpanAnn' a) e -> (ContextResult, Bool)
214+
#endif
201215
contextual context shouldStop query s =
202216
let range = rangeOf s
203217
in case range of

hls-plugin-api/src/Ide/PluginUtils.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Ide.PluginUtils
77
extendNextLine,
88
extendLineStart,
99
extendToFullLines,
10-
WithDeletions(..),
10+
WithDeletions (..),
1111
getProcessID,
1212
makeDiffTextEdit,
1313
makeDiffTextEditAdditive,
@@ -31,10 +31,12 @@ module Ide.PluginUtils
3131
rangesOverlap,
3232
positionInRange,
3333
usePropertyLsp,
34+
3435
-- * Escape
3536
unescape,
37+
3638
-- * toAbsolute
37-
toAbsolute
39+
toAbsolute,
3840
)
3941
where
4042

@@ -99,7 +101,6 @@ extendLineStart (Range (Position sl _) e) =
99101
extendToFullLines :: Range -> Range
100102
extendToFullLines = extendLineStart . extendNextLine
101103

102-
103104
-- ---------------------------------------------------------------------
104105

105106
data WithDeletions = IncludeDeletions | SkipDeletions
@@ -278,7 +279,6 @@ fullRange s = Range startPos endPos
278279
subRange :: Range -> Range -> Bool
279280
subRange = isSubrangeOf
280281

281-
282282
-- | Check whether the two 'Range's overlap in any way.
283283
--
284284
-- >>> rangesOverlap (mkRange 1 0 1 4) (mkRange 1 2 1 5)
@@ -306,7 +306,6 @@ allLspCmdIds pid commands = concatMap go commands
306306

307307
-- ---------------------------------------------------------------------
308308

309-
310309
type TextParser = P.Parsec Void T.Text
311310

312311
-- | Unescape printable escape sequences within double quotes.

0 commit comments

Comments
 (0)