@@ -23,8 +23,7 @@ import qualified Data.Text as T
23
23
import Development.IDE.Core.RuleTypes (GhcSessionDeps (GhcSessionDeps ),
24
24
TcModuleResult (tmrModule ),
25
25
TypeCheck (TypeCheck ))
26
- import Development.IDE.Core.Shake (IdeAction , IdeState (.. ),
27
- runIdeAction , useWithStaleFast )
26
+ import Development.IDE.Core.Shake (use , IdeState (.. ))
28
27
import Development.IDE.GHC.Compat
29
28
import Development.IDE.GHC.Error (realSpan , realSrcSpanToRange )
30
29
import Development.IDE.GHC.Util (HscEnvEq , hscEnv , prettyPrint )
@@ -37,6 +36,8 @@ import RnNames (findImportUsage,
37
36
getMinimalImports )
38
37
import TcRnMonad (initTcWithGbl )
39
38
import TcRnTypes (TcGblEnv (tcg_used_gres ))
39
+ import Development.IDE.Core.Service (runAction )
40
+ import Development.Shake (Action )
40
41
41
42
importCommandId :: CommandId
42
43
importCommandId = " ImportLensCommand"
@@ -85,14 +86,10 @@ provider _lspFuncs -- LSP functions, not used
85
86
-- haskell-lsp provides conversion functions
86
87
| Just nfp <- uriToNormalizedFilePath $ toNormalizedUri _uri
87
88
= 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
94
91
-- We also need a GHC session with all the dependencies
95
- hsc <- runIde state $ useWithStaleFast GhcSessionDeps nfp
92
+ hsc <- runIde state $ use GhcSessionDeps nfp
96
93
-- Use the GHC api to extract the "minimal" imports
97
94
(imports, mbMinImports) <- extractMinimalImports hsc tmr
98
95
@@ -112,10 +109,10 @@ provider _lspFuncs -- LSP functions, not used
112
109
113
110
-- | Use the ghc api to extract a minimal, explicit set of imports for this module
114
111
extractMinimalImports
115
- :: Maybe (HscEnvEq , a )
116
- -> Maybe (TcModuleResult , b )
112
+ :: Maybe (HscEnvEq )
113
+ -> Maybe (TcModuleResult )
117
114
-> IO ([LImportDecl GhcRn ], Maybe [LImportDecl GhcRn ])
118
- extractMinimalImports (Just (hsc, _ )) (Just (tmrModule -> TypecheckedModule {.. }, _ )) = do
115
+ extractMinimalImports (Just (hsc)) (Just (tmrModule -> TypecheckedModule {.. })) = do
119
116
-- extract the original imports and the typechecking environment
120
117
let (tcEnv,_) = tm_internals_
121
118
Just (_, imports, _, _) = tm_renamed_source
@@ -168,5 +165,5 @@ generateLens pId uri minImports (L src imp)
168
165
= return Nothing
169
166
170
167
-- | 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