@@ -23,8 +23,7 @@ import qualified Data.Text as T
2323import Development.IDE.Core.RuleTypes (GhcSessionDeps (GhcSessionDeps ),
2424 TcModuleResult (tmrModule ),
2525 TypeCheck (TypeCheck ))
26- import Development.IDE.Core.Shake (IdeAction , IdeState (.. ),
27- runIdeAction , useWithStaleFast )
26+ import Development.IDE.Core.Shake (use , IdeState (.. ))
2827import Development.IDE.GHC.Compat
2928import Development.IDE.GHC.Error (realSpan , realSrcSpanToRange )
3029import Development.IDE.GHC.Util (HscEnvEq , hscEnv , prettyPrint )
@@ -37,6 +36,8 @@ import RnNames (findImportUsage,
3736 getMinimalImports )
3837import TcRnMonad (initTcWithGbl )
3938import TcRnTypes (TcGblEnv (tcg_used_gres ))
39+ import Development.IDE.Core.Service (runAction )
40+ import Development.Shake (Action )
4041
4142importCommandId :: CommandId
4243importCommandId = " ImportLensCommand"
@@ -85,14 +86,10 @@ provider _lspFuncs -- LSP functions, not used
8586 -- haskell-lsp provides conversion functions
8687 | Just nfp <- uriToNormalizedFilePath $ toNormalizedUri _uri
8788 = do
88- -- Get the typechecking artifacts from the module, even if they are stale.
89- -- This is for responsiveness - we don't want our code lenses to vanish
90- -- just because there is a type error unrelated to the moduel imports.
91- -- However, if the user edits the imports while the module does not typecheck,
92- -- our code lenses will get out of sync
93- tmr <- runIde state $ useWithStaleFast TypeCheck nfp
89+ -- Get the typechecking artifacts from the module
90+ tmr <- runIde state $ use TypeCheck nfp
9491 -- We also need a GHC session with all the dependencies
95- hsc <- runIde state $ useWithStaleFast GhcSessionDeps nfp
92+ hsc <- runIde state $ use GhcSessionDeps nfp
9693 -- Use the GHC api to extract the "minimal" imports
9794 (imports, mbMinImports) <- extractMinimalImports hsc tmr
9895
@@ -112,10 +109,10 @@ provider _lspFuncs -- LSP functions, not used
112109
113110-- | Use the ghc api to extract a minimal, explicit set of imports for this module
114111extractMinimalImports
115- :: Maybe (HscEnvEq , a )
116- -> Maybe (TcModuleResult , b )
112+ :: Maybe (HscEnvEq )
113+ -> Maybe (TcModuleResult )
117114 -> IO ([LImportDecl GhcRn ], Maybe [LImportDecl GhcRn ])
118- extractMinimalImports (Just (hsc, _ )) (Just (tmrModule -> TypecheckedModule {.. }, _ )) = do
115+ extractMinimalImports (Just (hsc)) (Just (tmrModule -> TypecheckedModule {.. })) = do
119116 -- extract the original imports and the typechecking environment
120117 let (tcEnv,_) = tm_internals_
121118 Just (_, imports, _, _) = tm_renamed_source
@@ -168,5 +165,5 @@ generateLens pId uri minImports (L src imp)
168165 = return Nothing
169166
170167-- | A helper to run ide actions
171- runIde :: IdeState -> IdeAction a -> IO a
172- runIde state = runIdeAction " importLens" (shakeExtras state)
168+ runIde :: IdeState -> Action a -> IO a
169+ runIde state = runAction " importLens" state
0 commit comments