@@ -57,7 +57,9 @@ import Language.LSP.Server
57
57
import Language.LSP.Types
58
58
import Language.LSP.Types.Capabilities
59
59
import qualified Language.LSP.Types.Lens as J
60
+ #if __GLASGOW_HASKELL__ >= 902
60
61
import qualified GHC.Types.Error as Error
62
+ #endif
61
63
62
64
descriptor :: PluginId -> PluginDescriptor IdeState
63
65
descriptor plId =
@@ -122,13 +124,13 @@ expandTHSplice _eStyle ideState params@ExpandSpliceParams {..} = do
122
124
withTypeChecked fp TcModuleResult {.. } = do
123
125
(ps, _hscEnv, dflags) <- setupHscEnv ideState fp tmrParsed
124
126
let Splices {.. } = tmrTopLevelSplices
125
- let
127
+ let exprSuperSpans =
128
+ listToMaybe $ findSubSpansDesc srcSpan exprSplices
126
129
_patSuperSpans =
130
+ #if __GLASGOW_HASKELL__ == 808
131
+ fmap (second dL) $
132
+ #endif
127
133
listToMaybe $ findSubSpansDesc srcSpan patSplices
128
-
129
- exprSuperSpans =
130
- listToMaybe $ findSubSpansDesc srcSpan exprSplices
131
-
132
134
typeSuperSpans =
133
135
listToMaybe $ findSubSpansDesc srcSpan typeSplices
134
136
declSuperSpans =
@@ -269,8 +271,7 @@ findSubSpansDesc :: SrcSpan -> [(LHsExpr GhcTc, a)] -> [(SrcSpan, a)]
269
271
findSubSpansDesc srcSpan =
270
272
sortOn (Down . SubSpan . fst )
271
273
. mapMaybe
272
- ( \ (lcted, e) -> do
273
- let spn = getLocA lcted
274
+ ( \ (getLocA -> spn, e) -> do
274
275
guard (spn `isSubspanOf` srcSpan)
275
276
pure (spn, e)
276
277
)
@@ -353,9 +354,12 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e
353
354
)
354
355
Just <$> either (pure . L _spn) (unRenamedE dflags) eExpr
355
356
_ -> pure Nothing
356
- let
357
- warns = Error. getWarningMessages msgs
358
- errs = Error. getErrorMessages msgs
357
+ let (warns, errs) =
358
+ #if __GLASGOW_HASKELL__ >= 902
359
+ (Error. getWarningMessages msgs, Error. getErrorMessages msgs)
360
+ #else
361
+ msgs
362
+ #endif
359
363
pure $ (warns,) <$> fromMaybe (Left $ show errs) eresl
360
364
361
365
unless
@@ -379,10 +383,17 @@ unRenamedE ::
379
383
TransformT m (LocatedAn l (ast GhcPs ))
380
384
unRenamedE dflags expr = do
381
385
uniq <- show <$> uniqueSrcSpanT
382
- either (fail . show ) pure $
386
+ r <- either (fail . show ) pure $
383
387
parseAST @ _ @ (ast GhcPs ) dflags uniq $
384
388
showSDoc dflags $ ppr expr
385
389
390
+ #if __GLASGOW_HASKELL__ >= 902
391
+ pure r
392
+ #else
393
+ let (_anns, expr') = r
394
+ pure expr'
395
+ #endif
396
+
386
397
data SearchResult r =
387
398
Continue | Stop | Here r
388
399
deriving (Read , Show , Eq , Ord , Data , Typeable )
@@ -432,7 +443,12 @@ codeAction state plId (CodeActionParams _ _ docId ran _) = liftIO $
432
443
_ -> Continue
433
444
_ -> Stop
434
445
)
435
- `extQ` (\ loced@ (L _ pat :: LPat GhcPs ) ->
446
+ `extQ` (
447
+ #if __GLASGOW_HASKELL__ == 808
448
+ \ dL @ (Pat GhcPs ) -> loced@ (L _ pat :: Located (Pat GhcPs )) ->
449
+ #else
450
+ \ loced@ (L _ pat :: LPat GhcPs ) ->
451
+ #endif
436
452
let thisSpan = getLocA loced
437
453
in case thisSpan of
438
454
RealSrcSpan spLoc _
0 commit comments