@@ -66,6 +66,7 @@ import Development.IDE.GHC.Compat (GenLocated (L), GhcPs,
66
66
isQual_maybe , locA ,
67
67
mi_fixities ,
68
68
moduleNameString ,
69
+ ms_hspp_opts ,
69
70
nameModule_maybe ,
70
71
nameRdrName , noLocA ,
71
72
occNameFS , occNameString ,
@@ -74,13 +75,13 @@ import Development.IDE.GHC.Compat (GenLocated (L), GhcPs,
74
75
pattern RealSrcSpan ,
75
76
pm_parsed_source ,
76
77
rdrNameOcc , rds_rules ,
77
- srcSpanFile , unLocA )
78
+ srcSpanFile , topDir ,
79
+ unLocA )
78
80
import Development.IDE.GHC.Compat.Util hiding (catch , try )
79
81
import qualified GHC (Module ,
80
82
ParsedModule (.. ),
81
83
moduleName , parseModule )
82
84
import GHC.Generics (Generic )
83
- import GHC.Paths (libdir )
84
85
import Ide.PluginUtils
85
86
import Ide.Types
86
87
import Language.LSP.Server (LspM ,
@@ -330,6 +331,7 @@ suggestRuleRewrites originatingFile pos ms_mod (L _ HsRules {rds_rules}) =
330
331
CodeActionRefactor ,
331
332
RunRetrieParams {.. }
332
333
)
334
+ suggestRuleRewrites _ _ _ _ = []
333
335
334
336
qualify :: GHC. Module -> String -> String
335
337
qualify ms_mod x = T. unpack (printOutputable ms_mod) <> " ." <> x
@@ -361,15 +363,19 @@ callRetrie ::
361
363
IO ([CallRetrieError ], WorkspaceEdit )
362
364
callRetrie state session rewrites origin restrictToOriginatingFile = do
363
365
knownFiles <- toKnownFiles . unhashed <$> readTVarIO (knownTargetsVar $ shakeExtras state)
366
+ #if MIN_VERSION_ghc(9,2,0)
367
+ -- retrie needs the libdir for `parseRewriteSpecs`
368
+ libdir <- topDir . ms_hspp_opts . msrModSummary <$> useOrFail " Retrie.GetModSummary" (CallRetrieInternalError " file not found" ) GetModSummary origin
369
+ #endif
364
370
let reuseParsedModule f = do
365
- pm <- useOrFail " GetParsedModule" NoParse GetParsedModule f
371
+ pm <- useOrFail " Retrie. GetParsedModule" NoParse GetParsedModule f
366
372
(fixities, pm') <- fixFixities f (fixAnns pm)
367
373
return (fixities, pm')
368
374
getCPPmodule t = do
369
375
nt <- toNormalizedFilePath' <$> makeAbsolute t
370
376
let getParsedModule f contents = do
371
377
modSummary <- msrModSummary <$>
372
- useOrFail " GetModSummary" (CallRetrieInternalError " file not found" ) GetModSummary nt
378
+ useOrFail " Retrie. GetModSummary" (CallRetrieInternalError " file not found" ) GetModSummary nt
373
379
let ms' =
374
380
modSummary
375
381
{ ms_hspp_buf =
@@ -427,7 +433,7 @@ callRetrie state session rewrites origin restrictToOriginatingFile = do
427
433
(\ specs -> apply specs >> addImports annotatedImports)
428
434
<$> parseRewriteSpecs
429
435
#if MIN_VERSION_ghc(9,2,0)
430
- libdir -- TODO: does this actualy get the proper libdir?
436
+ libdir
431
437
#endif
432
438
(\ _f -> return $ NoCPP originParsedModule)
433
439
originFixities
0 commit comments